mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-23 00:37:14 +01:00
Nest display functions gone & code assist on diff
Lots of items removed as part of dropping this: dontUpdateNest dontSelect htmlTagArray startPosLine startPosCh cursorOrigCh cursorOrigLine nestDisplay tagString highlightBlock() getNestLocation() getNestLocationSub() setPosition() images/nest-tag-bg.gif codeAssistToggle now working on diff pane also
This commit is contained in:
155
lib/ice-coder.js
155
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<aliasArray.length;i++) {
|
||||
@@ -69,11 +68,11 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// On load, set the layout and get the nest location
|
||||
// On load, set the layout and check any nesting is valid
|
||||
init: function() {
|
||||
var screenIcon, sISrc;
|
||||
|
||||
// Set layout & the nest location
|
||||
// Set layout
|
||||
ICEcoder.setLayout();
|
||||
|
||||
// Hide the loading screen & auto open last files?
|
||||
@@ -114,7 +113,6 @@ var ICEcoder = {
|
||||
this.optionsFile.style.width = this.optionsEdit.style.width = this.optionsRemote.style.width = this.optionsHelp.style.width = (this.filesW-60) + "px";
|
||||
this.filesFrame.style.height = (winH-headerH-fileNavH) + "px";
|
||||
this.nestValid.style.left = (this.filesW+10) + "px";
|
||||
this.nestDisplay.style.left = (this.filesW+17) + "px";
|
||||
this.splitPaneControls.style.left = (parseInt((winW-this.filesW)/2,10)-25-4+this.filesW) + "px";
|
||||
top.ICEcoder.setTabWidths();
|
||||
|
||||
@@ -272,7 +270,6 @@ var ICEcoder = {
|
||||
top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab);
|
||||
}
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.dontUpdateNest = false;
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
top.ICEcoder.updateByteDisplay();
|
||||
top.ICEcoder.updateNestingIndicator();
|
||||
@@ -660,79 +657,6 @@ var ICEcoder = {
|
||||
ICEcoder.lineCommentToggleSub(thisCM, cursorPos, linePos, lineContent, lCLen, adjustCursor);
|
||||
},
|
||||
|
||||
// Highlight or hide block upon roll over/out of nest positions
|
||||
highlightBlock: function(nestPos,hide) {
|
||||
var cM, searchPos, cursor, cursorTemp, startPos, endPos;
|
||||
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
// Hiding the block
|
||||
if (hide) {
|
||||
// Set cursor back to orig pos if we haven't clicked, or redo nest display if we have
|
||||
top.ICEcoder.dontUpdateNest
|
||||
? cM.setCursor(top.ICEcoder.cursorOrigLine,top.ICEcoder.cursorOrigCh)
|
||||
: top.ICEcoder.getNestLocation('updateNestDisplay');
|
||||
top.ICEcoder.dontUpdateNest = false;
|
||||
} else {
|
||||
// Showing the block, set orig cursor position
|
||||
top.ICEcoder.cursorOrigCh = cM.getCursor().ch;
|
||||
top.ICEcoder.cursorOrigLine = cM.getCursor().line;
|
||||
top.ICEcoder.dontUpdateNest = true;
|
||||
// Set a cursor position object to begin with
|
||||
searchPos = new Object();
|
||||
searchPos.ch = cM.getCursor().ch;
|
||||
searchPos.line = cM.getCursor().line;
|
||||
// Then find our cursor position for our target nest depth
|
||||
for (var i=top.ICEcoder.htmlTagArray.length-1;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]+">")+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<top.ICEcoder.cMInstances.length;i++) {
|
||||
if (top.ICEcoder.openFiles[i].indexOf(".js")>-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,"|")));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user