diff --git a/lib/coder.js b/lib/coder.js
index ec8bd88..3db024c 100644
--- a/lib/coder.js
+++ b/lib/coder.js
@@ -246,11 +246,16 @@ var ICEcoder = {
top.ICEcoder.ctrlKeyDown = false;
return false;
- // ESC (Comment/Uncomment line)
+ // ESC in content area (Comment/Uncomment line)
} else if(key==27 && area == "content") {
top.ICEcoder.lineCommentToggle();
return false;
+ // ESC not in content area (Cancel all actions)
+ } else if(key==27 && area != "content") {
+ top.ICEcoder.cancelAllActions();
+ return false;
+
// Any other key
} else {
return key;
@@ -348,6 +353,7 @@ var ICEcoder = {
i==selectedTab ? ICEcoder.changedContent[selectedTab-1]==1 ? bgVPos = -33 : bgVPos = -22 : bgVPos = bgVPos;
document.getElementById('tab'+i).style.backgroundPosition = "0px "+bgVPos+"px";
}
+ ICEcoder.changedContent[selectedTab-1]==1 ? top.ICEcoder.fMIconVis('fMSave',1) : top.ICEcoder.fMIconVis('fMSave',0.3);
},
// Starts a new file by setting a few vars & creating a new cM instance
@@ -520,6 +526,7 @@ var ICEcoder = {
// hide the content area if we have no tabs open
if (ICEcoder.openFiles.length==0) {
top.document.getElementById('content').style.visibility = "hidden";
+ top.ICEcoder.fMIconVis('fMView',0.3);
} else {
// Switch the mode & the tab
ICEcoder.switchMode();
@@ -594,7 +601,7 @@ var ICEcoder = {
ICEcoder.selectDeselectFile('deselect',resetFile);
}
}
- // Set our arrray to contain 0 items
+ // Set our array to contain 0 items
top.ICEcoder.selectedFiles.length = 0;
}
} else {
@@ -642,6 +649,13 @@ var ICEcoder = {
document.findAndReplace.target[2].innerHTML = "selected files";
document.findAndReplace.target[3].innerHTML = "selected filenames";
}
+
+ // Finally, show or grey out the relevant file manager icons
+ top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMOpen',1) : top.ICEcoder.fMIconVis('fMOpen',0.3);
+ top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? top.ICEcoder.fMIconVis('fMNewFile',1) : top.ICEcoder.fMIconVis('fMNewFile',0.3);
+ top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? top.ICEcoder.fMIconVis('fMNewFolder',1) : top.ICEcoder.fMIconVis('fMNewFolder',0.3);
+ top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMDelete',1) : top.ICEcoder.fMIconVis('fMDelete',0.3);
+ top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMRename',1) : top.ICEcoder.fMIconVis('fMRename',0.3);
},
// Select or deselect file
@@ -709,6 +723,7 @@ var ICEcoder = {
} else {
top.ICEcoder.createNewTab();
}
+ top.ICEcoder.fMIconVis('fMView',1);
}
}
},
@@ -1178,5 +1193,108 @@ var ICEcoder = {
top.document.getElementById('header').appendChild(newBlock);
cM.addWidget(cM.getCursor(), top.document.getElementById('cssColor'), true);
}
+ },
+
+ // Carry out actions when clicking icons above file manager
+ fMIcon: function(action) {
+
+ if (action=="save" && ICEcoder.openFiles.length>0) {
+ top.ICEcoder.saveFile();
+ }
+
+ if (ICEcoder.selectedFiles.length==1) {
+ top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.ICEcoder.selectedFiles[0].replace('|','/');
+
+ if (action=="open" && ICEcoder.selectedFiles[0].indexOf(".")>0) {
+ top.ICEcoder.thisFileFolderType='file';
+ top.ICEcoder.openFile();
+ }
+ if (action=="newFile") {top.ICEcoder.newFile();}
+ if (action=="newFolder") {top.ICEcoder.newFolder();}
+ if (action=="delete") {top.ICEcoder.deleteFile(top.ICEcoder.rightClickedFile);}
+ if (action=="rename") {top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile);}
+ }
+
+ if (action=="view" && ICEcoder.openFiles.length>0) {
+ window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]);
+ }
+ },
+
+ // Change opacity of the file manager icons on demand
+ fMIconVis: function(icon, vis) {
+ if (top.document.getElementById(icon)) {
+ top.document.getElementById(icon).style.opacity = vis;
+ }
+ },
+
+ // Cancel all actions on pressing Esc in non content areas
+ cancelAllActions: function() {
+ // Stop whatever the parent may be loading, plus clear any file manager tasks other than the current one
+ window.stop();
+ if (ICEcoder.serverQueueItems.length>0) {
+ ICEcoder.serverQueueItems.splice(1,ICEcoder.serverQueueItems.length);
+ }
+ top.document.getElementById('loadingMask').style.visibility = "hidden";
+ top.ICEcoder.serverMessage('Cancelled tasks');
+ setTimeout(function() {top.ICEcoder.serverMessage();},2000);
+ },
+
+ // Fold or show code by clicking line nos in the gutter
+ foldCode: function(instance,lineNo,mouseEvt) {
+ var cM, string, origLine, origChar, collapseTag, nestDepth, cursor, lastLine;
+
+ cM = top.ICEcoder.getcMInstance();
+
+ setTimeout(function() {
+ // If the next line is hidden, unhide lines until we reach a line that isn't hidden
+ if (cM.lineInfo(lineNo+1).handle.hidden) {
+ for (var i=lineNo;i<=1000000;i++) {
+ cM.lineInfo(i+1).handle.hidden ? cM.showLine(i+1) : i=1000000;
+ if (!cM.lineInfo(i+1).handle.hidden) {
+ cM.clearMarker(i);
+ }
+ }
+ // Clear the gutter marker
+ cM.clearMarker(lineNo);
+ } else {
+ // Get the line of text, plus set our original (current) line & char position
+ string = cM.getLine(lineNo);
+ origLine = cM.getCursor().line;
+ origChar = cM.getCursor().ch;
+
+ // Then shoft the cursor to just after the first > char
+ cM.setCursor(lineNo,string.indexOf(">")+1);
+
+ setTimeout(function() {
+ // Get the tag we're collapsing on and it's nest depth
+ collapseTag = top.ICEcoder.htmlTagArray[top.ICEcoder.htmlTagArray.length-1];
+ nestDepth = top.ICEcoder.htmlTagArray.length;
+
+ setTimeout(function() {
+ // If we don't have the end tag on the same line
+ if (string.indexOf(""+collapseTag+">",string.indexOf("<"+collapseTag+">"))==-1) {
+ // Find each matching end tag in turn and if it's the same nest depth, we have the correct one
+ cursor = cM.getSearchCursor(""+collapseTag+">",cM.getCursor());
+ for (var i=0;i<=1000000;i++) {
+ lastLine = cursor.findNext();
+ lastLine = cursor.to().line;
+ cM.setCursor(cursor.to().line,cursor.to().ch);
+ if (top.ICEcoder.htmlTagArray.length==nestDepth-1) {
+ i=1000000;
+ }
+ }
+ // Now we can hide lines in that range
+ for (i=lineNo+1;i+ %N%")
+ cM.setCursor(origLine,origChar);
+ },1);
+
+ },1);
+ };
+ },1);
}
};
\ No newline at end of file