]> git.mdlowis.com Git - projs/tide.git/commitdiff
added shortcuts to create new line before or after the current line
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 3 Mar 2017 01:02:16 +0000 (20:02 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 3 Mar 2017 01:02:16 +0000 (20:02 -0500)
xedit.c

diff --git a/xedit.c b/xedit.c
index b012d51730afcde03911411af50092973f1434cc..aeaff7b749fbd1634f14fb36a325bfe471f7eb0a 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -391,6 +391,21 @@ static void new_win(void) {
     cmd_exec("!edit");
 }
 
+static void newline(void) {
+    View* view = win_view(FOCUSED);
+    if (x11_keymodsset(ModShift)) {
+        view_byline(view, UP, false);
+        view_bol(view, false);
+        if (view->selection.end == 0) {
+            view_insert(view, true, '\n');
+            view->selection = (Sel){0,0,0};
+        }
+    } else {
+        view_eol(view, false);
+        view_insert(view, true, '\n');
+    }
+}
+
 /* Main Routine
  *****************************************************************************/
 static Tag Builtins[] = {
@@ -454,6 +469,8 @@ static KeyBinding Bindings[] = {
     { ModCtrl,          'p',        pick_ctag    },
     { ModCtrl,          'g',        goto_ctag    },
     { ModCtrl,          'n',        new_win      },
+    { ModCtrl,          '\n',       newline      },
+    { ModCtrl|ModShift, '\n',       newline      },
     { 0, 0, 0 }
 };