>From 9bae9b7b8c0871e94f240706db03bfdadc4ff953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Mon, 3 Dec 2018 23:45:18 -0200 Subject: [PATCH 2/2] bindings: hard bind toggle and jump to bookmarks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hard bind toggling bookmarks to M-Ins, jump to next bookmark to M-PgDn and jump to previous bookmark to M-PgUp. Signed-off-by: Marco Diego Aurélio Mesquita --- src/global.c | 12 +++++++++++- src/nano.c | 3 +++ src/nano.h | 3 +++ src/proto.h | 2 +- src/winio.c | 25 ++++++++++++++++++++++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/global.c b/src/global.c index a0d088c8..0b001d7b 100644 --- a/src/global.c +++ b/src/global.c @@ -76,7 +76,7 @@ int shiftleft, shiftright, shiftup, shiftdown; int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown; int shiftcontrolhome, shiftcontrolend; int altleft, altright, altup, altdown; -int altdelete; +int altinsert, altdelete, altpageup, altpagedown; int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; #endif @@ -983,6 +983,13 @@ void shortcut_init(void) add_to_funcs(zap_text, MMAIN, N_("Zap Text"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW); + add_to_funcs(do_bookmark, MMAIN, + N_("Bookmark"), WITHORSANS("Toggle bookmark"), TOGETHER, NOVIEW); + add_to_funcs(do_bookmark_next, MMAIN, + N_("Next mark"), WITHORSANS("Go to next bookmark"), TOGETHER, NOVIEW); + add_to_funcs(do_bookmark_previous, MMAIN, + N_("Previous mark"), WITHORSANS("Go to previous bookmark"), BLANKAFTER, NOVIEW); + #ifdef ENABLE_COLOR if (!ISSET(RESTRICTED)) add_to_funcs(do_linter, MMAIN, @@ -1151,7 +1158,10 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-E", 0, do_redo, 0); add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, do_cut_prev_word, 0); add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, do_cut_next_word, 0); + add_to_sclist(MMAIN, "M-Ins", ALT_INSERT, do_bookmark, 0); add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0); + add_to_sclist(MMAIN, "M-PgUp", ALT_PAGEUP, do_bookmark_previous, 0); + add_to_sclist(MMAIN, "M-PgDn", ALT_PAGEDOWN, do_bookmark_next, 0); #endif #ifdef ENABLE_WORDCOMPLETION add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0); diff --git a/src/nano.c b/src/nano.c index 3cb4cb83..2781f0ef 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2597,7 +2597,10 @@ int main(int argc, char **argv) altright = get_keycode("kRIT3", ALT_RIGHT); altup = get_keycode("kUP3", ALT_UP); altdown = get_keycode("kDN3", ALT_DOWN); + altinsert = get_keycode("kIC3", ALT_INSERT); altdelete = get_keycode("kDC3", ALT_DELETE); + altpageup = get_keycode("kPRV3", ALT_PAGEUP); + altpagedown = get_keycode("kNXT3", ALT_PAGEDOWN); shiftaltleft = get_keycode("kLFT4", SHIFT_ALT_LEFT); shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT); diff --git a/src/nano.h b/src/nano.h index 87aca1fe..42f43fdb 100644 --- a/src/nano.h +++ b/src/nano.h @@ -596,7 +596,10 @@ enum #define ALT_RIGHT 0x422 #define ALT_UP 0x423 #define ALT_DOWN 0x424 +#define ALT_INSERT 0x42C #define ALT_DELETE 0x42D +#define ALT_PAGEUP 0x427 +#define ALT_PAGEDOWN 0x428 #define SHIFT_ALT_LEFT 0x431 #define SHIFT_ALT_RIGHT 0x432 #define SHIFT_ALT_UP 0x433 diff --git a/src/proto.h b/src/proto.h index 8de46e90..d54bb366 100644 --- a/src/proto.h +++ b/src/proto.h @@ -67,7 +67,7 @@ extern int shiftcontrolup, shiftcontroldown; extern int shiftcontrolhome, shiftcontrolend; extern int altleft, altright; extern int altup, altdown; -extern int altdelete; +extern int altinsert, altdelete, altpageup, altpagedown; extern int shiftaltleft, shiftaltright; extern int shiftaltup, shiftaltdown; #endif diff --git a/src/winio.c b/src/winio.c index a4a3df77..dca79ed0 100644 --- a/src/winio.c +++ b/src/winio.c @@ -570,8 +570,14 @@ int parse_kbinput(WINDOW *win) return ALT_UP; else if (retval == altdown) return ALT_DOWN; + else if (retval == altinsert) + return ALT_INSERT; else if (retval == altdelete) return ALT_DELETE; + else if (retval == altpageup) + return ALT_PAGEUP; + else if (retval == altpagedown) + return ALT_PAGEDOWN; else if (retval == shiftaltleft) { shift_held = TRUE; return KEY_HOME; @@ -610,8 +616,14 @@ int parse_kbinput(WINDOW *win) } /* Is Alt being held? */ if (modifiers == 0x08) { + if (retval == KEY_IC) + return ALT_INSERT; if (retval == KEY_DC) return ALT_DELETE; + if (retval == KEY_PPAGE) + return ALT_PAGEUP; + if (retval == KEY_NPAGE) + return ALT_PAGEDOWN; if (retval == KEY_UP) return ALT_UP; if (retval == KEY_DOWN) @@ -1101,9 +1113,14 @@ int convert_sequence(const int *seq, size_t length, int *consumed) /* Esc [ 2 ~ == Insert on VT220/VT320/ * Linux console/xterm/Terminal. */ return KEY_IC; - else if (length > 4 && seq[2] == ';' && seq[4] == '~') + else if (length > 4 && seq[2] == ';' && seq[4] == '~') { /* Esc [ 2 ; x ~ == modified Insert on xterm. */ *consumed = 5; + + if (seq[3] == '3') + /* Esc [ 2 ; 3 ~ == Shift-Delete on xterm. */ + return ALT_INSERT; + } break; case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/ * Linux console/xterm/Terminal. */ @@ -1153,6 +1170,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY if (seq[3] == '2') return shiftaltup; + if (seq[3] == '3') + /* Esc [ 5 ; 3 ~ == Alt-PageUp on xterm. */ + return altpageup; #endif } break; @@ -1166,6 +1186,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY if (seq[3] == '2') return shiftaltdown; + if (seq[3] == '3') + /* Esc [ 6 ; 3 ~ == Alt-PageDown on xterm. */ + return altpagedown; #endif } break; -- 2.11.0