From bea1afc01c287c5b96c7474c6ac223bebc444017 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sun, 5 Aug 2012 14:32:30 +0100 Subject: [PATCH] 6 new shortcuts added New shortcuts added for next/previous tab, move line up/down, new tab and close tab switchTab function now accepts a noFocus param to stop focusing on the document Fix to set the visibility on the content area when starting a new tab, wasn't showing otherwise Functions added for nextTab, previousTab, moveLineUp and moveLineDown (Other 2 functions newTab & closeTab already exist) helpScreen taller to accomodate the 6 new shortcuts --- lib/coder.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index a7d87fe..c720659 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -252,6 +252,36 @@ var ICEcoder = { top.ICEcoder.ctrlKeyDown = false; return false; + // CTRL+right arrow (Next tab) + } else if(key==39 && top.ICEcoder.ctrlKeyDown==true && area!="content") { + top.ICEcoder.nextTab(); + return false; + + // CTRL+left arrow (Previous tab) + } else if(key==37 && top.ICEcoder.ctrlKeyDown==true && area!="content") { + top.ICEcoder.previousTab(); + return false; + + // CTRL+up arrow (Move line up) + } else if(key==38 && top.ICEcoder.ctrlKeyDown==true && area=="content") { + top.ICEcoder.moveLineUp(); + return false; + + // CTRL+down arrow (Move line down) + } else if(key==40 && top.ICEcoder.ctrlKeyDown==true && area=="content") { + top.ICEcoder.moveLineDown(); + return false; + + // CTRL+numeric plus (New tab) + } else if(key==107 && top.ICEcoder.ctrlKeyDown==true) { + top.ICEcoder.newTab(); + return false; + + // CTRL+numeric minus (Close tab) + } else if(key==109 && top.ICEcoder.ctrlKeyDown==true) { + top.ICEcoder.closeTab(top.ICEcoder.selectedTab); + return false; + // CTRL+S (Save), CTRL+Shift+S (Save As) } else if(key==83 && top.ICEcoder.ctrlKeyDown==true) { if(top.ICEcoder.shiftKeyDown==true) { @@ -343,7 +373,7 @@ var ICEcoder = { }, // Change tabs by switching visibility of instances - switchTab: function(newTab) { + switchTab: function(newTab,noFocus) { var cM; // Identify tab that's currently selected & get the instance @@ -362,7 +392,7 @@ var ICEcoder = { cM.getWrapperElement().style.display = "block"; // Focus on & refresh our selected instance - cM.focus(); + if (!noFocus) {cM.focus();} cM.refresh(); // Highlight the selected tab @@ -405,6 +435,7 @@ var ICEcoder = { ICEcoder.cMInstances.push(ICEcoder.nextcMInstance); ICEcoder.selectedTab = ICEcoder.cMInstances.length; + ICEcoder.content.style.visibility='visible'; ICEcoder.content.contentWindow.createNewCMInstance(ICEcoder.nextcMInstance); ICEcoder.thisFileFolderType='file'; @@ -441,6 +472,22 @@ var ICEcoder = { top.ICEcoder.setPreviousFiles(); }, + // Cycle to next tab + nextTab: function() { + var goToTab; + + goToTab = top.ICEcoder.selectedTab+1 <= top.ICEcoder.openFiles.length ? top.ICEcoder.selectedTab+1 : 1; + top.ICEcoder.switchTab(goToTab,'noFocus'); + }, + + // Cycle to next tab + previousTab: function() { + var goToTab; + + goToTab = top.ICEcoder.selectedTab-1 >= 1 ? top.ICEcoder.selectedTab-1 : top.ICEcoder.openFiles.length; + top.ICEcoder.switchTab(goToTab,'noFocus'); + }, + // Create a new tab for a file renameTab: function(tabNum,newName) { var closeTabLink; @@ -865,6 +912,36 @@ var ICEcoder = { elem.style.visibility = doVis=="show" ? 'visible' : 'hidden'; }, + // Move current line upwards + moveLineUp: function() { + var cM, line, ch, prevLine; + + cM = top.ICEcoder.getcMInstance(); + line = cM.getCursor().line; + ch = cM.getCursor().ch; + if (line>0) { + prevLine = cM.getLine(line-1); + cM.setLine(line-1,cM.getLine(line)); + cM.setLine(line,prevLine); + cM.setCursor(line-1,ch); + } + }, + + // Move current line downwards + moveLineDown: function() { + var cM, line, ch, nextLine; + + cM = top.ICEcoder.getcMInstance(); + line = cM.getCursor().line; + ch = cM.getCursor().ch; + if (line