From d323b08b6df6b3695a6492c6d13ef8387c5747d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Thu, 12 Jul 2018 18:47:46 -0300 Subject: [PATCH] Erase next word if ctrl is held when pressing delete. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Diego Aurélio Mesquita --- src/global.c | 4 +++- src/nano.c | 1 + src/nano.h | 1 + src/proto.h | 1 + src/winio.c | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/global.c b/src/global.c index 089d530..35f9b4f 100644 --- a/src/global.c +++ b/src/global.c @@ -68,7 +68,8 @@ bool also_the_last = FALSE; int didfind = 0; /* Whether the last search found something. */ -int controlleft, controlright, controlup, controldown, controlhome, controlend; +int controlleft, controlright, controlup, controldown; +int controlhome, controlend, controldel; #ifndef NANO_TINY int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown; int shiftcontrolhome, shiftcontrolend; @@ -1169,6 +1170,7 @@ void shortcut_init(void) #endif add_to_sclist(MMOST, "^B", 0, do_left, 0); add_to_sclist(MMOST, "^F", 0, do_right, 0); + add_to_sclist(MMAIN, "^Del", CONTROL_DEL, do_cut_next_word, 0); #ifdef ENABLE_UTF8 if (using_utf8()) { add_to_sclist(MMOST, "\xE2\x97\x80", KEY_LEFT, do_left, 0); diff --git a/src/nano.c b/src/nano.c index 51bb2fe..af22601 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2582,6 +2582,7 @@ int main(int argc, char **argv) /* Ask for the codes for Control+Home/End. */ controlhome = get_keycode("kHOM5", CONTROL_HOME); controlend = get_keycode("kEND5", CONTROL_END); + controldel = get_keycode("kDC5", CONTROL_DEL); #ifndef NANO_TINY /* Ask for the codes for Shift+Control+Left/Right/Up/Down. */ shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT); diff --git a/src/nano.h b/src/nano.h index e05ae52..1547d8e 100644 --- a/src/nano.h +++ b/src/nano.h @@ -585,6 +585,7 @@ enum #define CONTROL_DOWN 0x404 #define CONTROL_HOME 0x405 #define CONTROL_END 0x406 +#define CONTROL_DEL 0x407 #define SHIFT_CONTROL_LEFT 0x411 #define SHIFT_CONTROL_RIGHT 0x412 #define SHIFT_CONTROL_UP 0x413 diff --git a/src/proto.h b/src/proto.h index b2edf4d..10cc358 100644 --- a/src/proto.h +++ b/src/proto.h @@ -61,6 +61,7 @@ extern int controlup; extern int controldown; extern int controlhome; extern int controlend; +extern int controldel; #ifndef NANO_TINY extern int shiftcontrolleft; extern int shiftcontrolright; diff --git a/src/winio.c b/src/winio.c index 1457d8c..d37c5f8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -538,6 +538,8 @@ int parse_kbinput(WINDOW *win) return CONTROL_HOME; else if (retval == controlend) return CONTROL_END; + else if (retval == controldel) + return CONTROL_DEL; #ifndef NANO_TINY else if (retval == shiftcontrolleft) { shift_held = TRUE; -- 2.7.4