diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 6e1aaa8..200a76d 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -24,7 +24,6 @@ var ICEcoder = { selectedFiles: [], // Array of selected files findMode: false, // States if we're in find/replace mode lockedNav: true, // Nav is locked or not - htmlTagArray: [], // Array storing the nest of tags mouseDown: false, // If the mouse is down draggingFilesW: false, // If we're dragging the file manager width draggingTab: false, // If we're dragging a tab @@ -61,7 +60,7 @@ var ICEcoder = { // Set our aliases initAliases: function() { - var aliasArray = ["header","files", "fileOptions", "optionsFile", "optionsEdit", "optionsRemote", "optionsHelp", "filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","splitPaneControls","charDisplay","byteDisplay"]; + var aliasArray = ["header","files", "fileOptions", "optionsFile", "optionsEdit", "optionsRemote", "optionsHelp", "filesFrame","editor","tabsBar","findBar","content","footer","nestValid","splitPaneControls","charDisplay","byteDisplay"]; // Create our ID aliases for (var i=0;i=nestPos;i--) { - cursor = cM.getSearchCursor("<"+top.ICEcoder.htmlTagArray[i],searchPos); - cursor.findPrevious(); - searchPos.ch = cursor.from().ch; - searchPos.line = cursor.from().line; - if (i==nestPos) { - cursorTemp = cM.getSearchCursor(">",searchPos); - cursorTemp.findNext(); - cM.setCursor(cursorTemp.from().line, cursorTemp.from().ch+1); - top.ICEcoder.getNestLocation(); - if (ICEcoder.htmlTagArray.length-1 != nestPos) { - i++; - } - } - } - // Once we've found our tag - if (cursor.from()) { - // Set our vars to match the start position - startPos = new Object(); - top.ICEcoder.startPosLine = startPos.line = cursor.from().line; - top.ICEcoder.startPosCh = startPos.ch = cursor.from().ch; - // Now set an end position object that matches this start tag - endPos = new Object(); - endPos.line = top.ICEcoder.content.contentWindow.CodeMirror.fold.xml(cM,startPos) || startPos.line; - endPos.line = endPos.line.to ? endPos.line.to.line : endPos.line; - endPos.ch = cM.getLine(endPos.line).indexOf("")+top.ICEcoder.htmlTagArray[nestPos].length+3; - // Set the selection or escape out of not selecting - !top.ICEcoder.dontSelect ? cM.setSelection(startPos,endPos) : top.ICEcoder.dontSelect = false; - cM.scrollIntoView(startPos); - } - } - }, - // Set our cursor position upon mouse click of the nest position - setPosition: function(nestPos,line,tag) { - var cM, ch, chPos; - - cM = ICEcoder.getcMInstance(); - // Set our ch position just after the tag, and refocus on the editor - ch = cM.getLine(line).indexOf(">",cM.getLine(line).indexOf("<"+tag))+1; - cM.setCursor(line,ch); - top.ICEcoder.focus(); - // Now update nest display to this nest depth & without any HTML tags to kill further interactivity - chPos = 0; - for (var i=0;i<=nestPos;i++) { - chPos = ICEcoder.nestDisplay.innerHTML.indexOf(">",chPos+1); - } - ICEcoder.nestDisplay.innerHTML = ICEcoder.nestDisplay.innerHTML.substr(0,chPos).replace(/<(?:.|\n)*?>/gm, ''); - top.ICEcoder.dontUpdateNest = false; - top.ICEcoder.dontSelect = true; - }, - // Wrap our selected text/cursor with tags tagWrapper: function(tag) { var cM, cMdiff, thisCM, tagStart, tagEnd, startLine, endLine; @@ -1682,57 +1606,6 @@ var ICEcoder = { // INFO & DISPLAY // ============== - // Work out the nesting depth location on demand and update our display if required - getNestLocation: function(updateNestDisplay) { - var cM, cMdiff, thisCM, nestCheck, state, cx, startPos, fileName; - - cM = ICEcoder.getcMInstance(); - cMdiff = ICEcoder.getcMdiffInstance(); - thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM; - - if (thisCM) { - nestCheck = thisCM.getValue(); - - // Get the token state at our cursor - state = thisCM.getTokenAt(thisCM.getCursor()).state; - cx = false; - - // XML - if ("undefined" != typeof state) { - cx = state.context; - } - // HTML - if ("undefined" != typeof state.curState && "undefined" != typeof state.curState.htmlState) { - cx = state.curState.htmlState.context; - } - - // Set up array to store nest data - ICEcoder.htmlTagArray = []; - if (cx) { - for (cx = cx; cx; cx = cx.prev) { - if ("undefined" != typeof cx.tagName) { - ICEcoder.htmlTagArray.unshift(cx.tagName); - } - } - } - ICEcoder.tagString = ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1]; - if (ICEcoder.caretLocType=="JavaScript") { - ICEcoder.tagString = "script"; - } - - // Now we've built up our nest depth array, if we're due to show it in the display - if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) { - // Clear the display - ICEcoder.nestDisplay.innerHTML = ""; - if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) { - fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; - - ICEcoder.getNestLocationSub(nestCheck, fileName); - } - } - } - }, - // Get the caret position getCaretPosition: function() { var cM, cMdiff, thisCM, line, ch, chPos; @@ -1748,7 +1621,6 @@ var ICEcoder = { chPos += thisCM.getLine(i).length+1; } ICEcoder.caretPos=(chPos+ch-1); - ICEcoder.getNestLocation('yes'); }, // Update the code type, line & character display @@ -2033,22 +1905,28 @@ var ICEcoder = { // Turning on/off the Code Assist codeAssistToggle: function() { - var cM; + var cM, cMdiff, fileName, fileExt; - cM = ICEcoder.getcMInstance(); top.ICEcoder.codeAssist = !top.ICEcoder.codeAssist; top.get('codeAssistDisplay').style.backgroundPosition = top.ICEcoder.codeAssist ? "0 0" : "-16px 0"; top.ICEcoder.cssColorPreview(); - top.ICEcoder.focus(); + top.ICEcoder.focus(top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? 'diff' : false); for (i=0;i-1) { + fileName = top.ICEcoder.openFiles[i]; + fileExt = fileName.split("."); + fileExt = fileExt[fileExt.length-1]; + if (fileExt == "js" || fileExt == "json") { cM = top.ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[i]]; + cMdiff = top.ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[i]+'diff']; if (!top.ICEcoder.codeAssist) { cM.clearGutter("CodeMirror-lint-markers"); - cM.setOption("lintWith",false); + cM.setOption("lint",false); + cMdiff.clearGutter("CodeMirror-lint-markers"); + cMdiff.setOption("lint",false); } else { - cM.setOption("lintWith",top.ICEcoder.content.contentWindow.CodeMirror.javascriptValidator); + cM.setOption("lint", true); + cMdiff.setOption("lint", true); } } } @@ -2758,9 +2636,6 @@ var ICEcoder = { top.ICEcoder.savedPoints.splice(closeTabNum-1,1); top.ICEcoder.redoTabHighlight(ICEcoder.selectedTab); - // Update the nesting indicator - top.ICEcoder.getNestLocation('update'); - // Remove any highlighting from the file manager top.ICEcoder.selectDeselectFile('deselect',top.ICEcoder.filesFrame.contentWindow.document.getElementById(closeFileName.replace(/\//g,"|")));