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
This commit is contained in:
Matt Pass
2012-08-05 14:32:30 +01:00
parent 8cbc5d79d4
commit bea1afc01c

View File

@@ -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<cM.lineCount()-1) {
nextLine = cM.getLine(line+1);
cM.setLine(line+1,cM.getLine(line));
cM.setLine(line,nextLine);
cM.setCursor(line+1,ch);
}
},
// Update find & replace options based on user selection
findReplaceOptions: function() {
top.document.getElementById('rText').style.display =
@@ -1504,7 +1581,7 @@ var ICEcoder = {
// Show the help screen
helpScreen: function() {
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/help.php" class="whiteGlow" style="width: 400px; height: 400px"></iframe>';
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/help.php" class="whiteGlow" style="width: 400px; height: 500px"></iframe>';
top.ICEcoder.showHide('show',top.document.getElementById('blackMask'));
},