From f666b55a5ff8155963d821ea36814383e2d7977a Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 18 May 2017 09:26:02 -0400 Subject: [PATCH] Added shortcuts to move line or selection up or down with Ctrl+Up,Down --- docs/xedit.1 | 14 +++++++++++--- docs/xedit.1.md | 14 +++++++++++--- inc/shortcuts.h | 27 +++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/docs/xedit.1 b/docs/xedit.1 index 3a3d793..9fc7b87 100644 --- a/docs/xedit.1 +++ b/docs/xedit.1 @@ -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 diff --git a/docs/xedit.1.md b/docs/xedit.1.md index 0bc261d..55dd87c 100644 --- a/docs/xedit.1.md +++ b/docs/xedit.1.md @@ -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. diff --git a/inc/shortcuts.h b/inc/shortcuts.h index 0756d73..9ada8c1 100644 --- a/inc/shortcuts.h +++ b/inc/shortcuts.h @@ -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) { -- 2.54.0