Permalink
Browse files

duplicateLine & removeLine functions

Functions added to duplicate line and remove line. Triggered from CTRL+
+ and CTRL+ - shortcuts whilst in editor area.
  • Loading branch information...
1 parent bf40cb2 commit 6161518d8bb135d0916fc2fb986a56b54453ed21 @mattpass committed Mar 16, 2013
Showing with 28 additions and 2 deletions.
  1. +28 −2 lib/ice-coder.js
View
@@ -393,6 +393,28 @@ var ICEcoder = {
cM.setLine(line,cM.getLine(line)+"<br>");
},
+ // Duplicate line
+ duplicateLine: function(line) {
+ var cM, ch;
+
+ cM = ICEcoder.getcMInstance();
+ if (!line) {line = cM.getCursor().line};
+ ch = cM.getCursor().ch;
+ cM.setLine(line,cM.getLine(line)+"\n"+cM.getLine(line));
+ cM.setCursor(line+1,ch);
+ },
+
+ // Remove line
+ removeLine: function(line) {
+ var cM, ch;
+
+ cM = ICEcoder.getcMInstance();
+ if (!line) {line = cM.getCursor().line};
+ ch = cM.getCursor().ch;
+ cM.removeLine(line);
+ cM.setCursor(line-1,ch);
+ },
+
// ==============
// FILES
// ==============
@@ -1982,12 +2004,16 @@ var ICEcoder = {
// CTRL+numeric plus (New tab)
} else if(key==107 && top.ICEcoder.ctrlKeyDown==true) {
- top.ICEcoder.newTab();
+ area=="content"
+ ? top.ICEcoder.duplicateLine()
+ : top.ICEcoder.newTab();
return false;
// CTRL+numeric minus (Close tab)
} else if(key==109 && top.ICEcoder.ctrlKeyDown==true) {
- top.ICEcoder.closeTab(top.ICEcoder.selectedTab);
+ area=="content"
+ ? top.ICEcoder.removeLine()
+ : top.ICEcoder.closeTab(top.ICEcoder.selectedTab);
return false;
// CTRL+S (Save), CTRL+Shift+S (Save As)

0 comments on commit 6161518

Please sign in to comment.