]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added shortcuts to move line or selection up or down with Ctrl+Up,Down
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 18 May 2017 13:26:02 +0000 (09:26 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 18 May 2017 13:26:02 +0000 (09:26 -0400)
docs/xedit.1
docs/xedit.1.md
inc/shortcuts.h

index 3a3d793c0bfb1c4e8f6cf34c1573d9da318e8900..9fc7b8722244bb6c6cf090686b90ef56da4645ba 100644 (file)
@@ -132,13 +132,21 @@ Move the cursor one character to the right\.
 .
 .TP
 \fBUp\fR
-Move the cursor to theprevious line\.
+Move the cursor to the previous line\.
 .
 .TP
 \fBDown\fR
 Move the cursor to the next line\.
 .
 .TP
+\fBCtrl+Up\fR
+Move the current line or selection up a line\.
+.
+.TP
+\fBCtrl+Down\fR
+Move the current line or selection down a line\.
+.
+.TP
 \fBCtrl+Left\fR
 Move the cursor to the beginning of the word to the left\.
 .
@@ -162,11 +170,11 @@ Redo the previously undone change on the active region\.
 .
 .TP
 \fBCtrl+x\fR
-Cut the selected text to the X11 CLIPBOARD selection\.
+Cut the selected text to the X11 CLIPBOARD selection\. If no text is selected then the current line is cut\.
 .
 .TP
 \fBCtrl+c\fR
-Copy the selected text to the X11 CLIPBOARD selection\.
+Copy the selected text to the X11 CLIPBOARD selection\. If no text is selected then the current line is copied\.
 .
 .TP
 \fBCtrl+v\fR
index 0bc261d5decf29851b2096eace435fffdeb587a1..55dd87c1ac1c1ca4377999b86c53b20451ffcaa4 100644 (file)
@@ -179,10 +179,16 @@ position.
     Move the cursor one character to the right.
 
 * `Up`:
-    Move the cursor to theprevious line.
+    Move the cursor to the previous line.
 
 * `Down`:
     Move the cursor to the next line.
+    
+* `Ctrl+Up`:
+    Move the current line or selection up a line.
+
+* `Ctrl+Down`:
+    Move the current line or selection down a line.
 
 * `Ctrl+Left`:
     Move the cursor to the beginning of the word to the left.
@@ -202,10 +208,12 @@ position.
     Redo the previously undone change on the active region.
 
 * `Ctrl+x`:
-    Cut the selected text to the X11 CLIPBOARD selection.
+    Cut the selected text to the X11 CLIPBOARD selection. If no text is selected
+    then the current line is cut.
 
 * `Ctrl+c`:
-    Copy the selected text to the X11 CLIPBOARD selection.
+    Copy the selected text to the X11 CLIPBOARD selection. If no text is selected
+    then the current line is copied.
 
 * `Ctrl+v`:
     Paste the contents of the X11 CLIPBOARD selection to the active region.
index 0756d7370699dde7d9c59fc3a11470476726195c..9ada8c10469b1ebc0861c23035a73cb41afea587 100644 (file)
@@ -66,6 +66,23 @@ static void cursor_eol(void) {
     view_eol(win_view(FOCUSED), false);
 }
 
+static void move_line_up(void) {
+    if (!view_selsize(win_view(FOCUSED)))
+        select_line();
+    cut();
+    view_byline(win_view(FOCUSED), UP, false);
+    paste();
+}
+
+static void move_line_dn(void) {
+    if (!view_selsize(win_view(FOCUSED)))
+        select_line();
+    cut();
+    cursor_eol();
+    view_byrune(win_view(FOCUSED), RIGHT, false);
+    paste();
+}
+
 static void cursor_home(void) {
     bool extsel = x11_keymodsset(ModShift);
     if (x11_keymodsset(ModCtrl))
@@ -84,12 +101,18 @@ static void cursor_end(void) {
 
 static void cursor_up(void) {
     bool extsel = x11_keymodsset(ModShift);
-    view_byline(win_view(FOCUSED), UP, extsel);
+    if (x11_keymodsset(ModCtrl))
+        move_line_up();
+    else
+        view_byline(win_view(FOCUSED), UP, extsel);
 }
 
 static void cursor_dn(void) {
     bool extsel = x11_keymodsset(ModShift);
-    view_byline(win_view(FOCUSED), DOWN, extsel);
+    if (x11_keymodsset(ModCtrl))
+        move_line_dn();
+    else
+        view_byline(win_view(FOCUSED), DOWN, extsel);
 }
 
 static void cursor_left(void) {