bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special keycodes, distinct from plain Home and End. Make the users of those emulators (and of the Linux console) glad by making ^Home and ^End do the obvious thing, and the combinations with Shift too.master
parent
005ee8eda6
commit
cb0806b2a0
|
@ -59,9 +59,10 @@ message_type lastmessage = HUSH;
|
|||
filestruct *pletion_line = NULL;
|
||||
/* The line where the last completion was found, if any. */
|
||||
|
||||
int controlleft, controlright, controlup, controldown;
|
||||
int controlleft, controlright, controlup, controldown, controlhome, controlend;
|
||||
#ifndef NANO_TINY
|
||||
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
|
||||
int shiftcontrolhome, shiftcontrolend;
|
||||
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
|
||||
#endif
|
||||
|
||||
|
@ -1078,8 +1079,10 @@ void shortcut_init(void)
|
|||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^Home", CONTROL_HOME, do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
|
||||
|
@ -1239,6 +1242,8 @@ void shortcut_init(void)
|
|||
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, do_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_HOME, do_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
|
||||
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
|
||||
|
|
|
@ -2514,12 +2514,18 @@ int main(int argc, char **argv)
|
|||
controlright = get_keycode("kRIT5", CONTROL_RIGHT);
|
||||
controlup = get_keycode("kUP5", CONTROL_UP);
|
||||
controldown = get_keycode("kDN5", CONTROL_DOWN);
|
||||
/* Ask for the codes for Control+Home/End. */
|
||||
controlhome = get_keycode("kHOM5", CONTROL_HOME);
|
||||
controlend = get_keycode("kEND5", CONTROL_END);
|
||||
#ifndef NANO_TINY
|
||||
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
|
||||
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
|
||||
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
|
||||
shiftcontrolup = get_keycode("kUP6", SHIFT_CONTROL_UP);
|
||||
shiftcontroldown = get_keycode("kDN6", SHIFT_CONTROL_DOWN);
|
||||
/* Ask for the codes for Shift+Control+Home/End. */
|
||||
shiftcontrolhome = get_keycode("kHOM6", SHIFT_CONTROL_HOME);
|
||||
shiftcontrolend = get_keycode("kEND6", SHIFT_CONTROL_END);
|
||||
/* Ask for the codes for Shift+Alt+Left/Right/Up/Down. */
|
||||
shiftaltleft = get_keycode("kLFT4", SHIFT_ALT_LEFT);
|
||||
shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT);
|
||||
|
|
|
@ -553,10 +553,14 @@ enum
|
|||
#define CONTROL_RIGHT 0x402
|
||||
#define CONTROL_UP 0x403
|
||||
#define CONTROL_DOWN 0x404
|
||||
#define CONTROL_HOME 0x411
|
||||
#define CONTROL_END 0x412
|
||||
#define SHIFT_CONTROL_LEFT 0x405
|
||||
#define SHIFT_CONTROL_RIGHT 0x406
|
||||
#define SHIFT_CONTROL_UP 0x407
|
||||
#define SHIFT_CONTROL_DOWN 0x408
|
||||
#define SHIFT_CONTROL_HOME 0x413
|
||||
#define SHIFT_CONTROL_END 0x414
|
||||
#define SHIFT_ALT_LEFT 0x409
|
||||
#define SHIFT_ALT_RIGHT 0x40a
|
||||
#define SHIFT_ALT_UP 0x40b
|
||||
|
|
|
@ -51,11 +51,15 @@ extern int controlleft;
|
|||
extern int controlright;
|
||||
extern int controlup;
|
||||
extern int controldown;
|
||||
extern int controlhome;
|
||||
extern int controlend;
|
||||
#ifndef NANO_TINY
|
||||
extern int shiftcontrolleft;
|
||||
extern int shiftcontrolright;
|
||||
extern int shiftcontrolup;
|
||||
extern int shiftcontroldown;
|
||||
extern int shiftcontrolhome;
|
||||
extern int shiftcontrolend;
|
||||
extern int shiftaltleft;
|
||||
extern int shiftaltright;
|
||||
extern int shiftaltup;
|
||||
|
|
14
src/winio.c
14
src/winio.c
|
@ -505,6 +505,10 @@ int parse_kbinput(WINDOW *win)
|
|||
return CONTROL_UP;
|
||||
else if (retval == controldown)
|
||||
return CONTROL_DOWN;
|
||||
else if (retval == controlhome)
|
||||
return CONTROL_HOME;
|
||||
else if (retval == controlend)
|
||||
return CONTROL_END;
|
||||
#ifndef NANO_TINY
|
||||
else if (retval == shiftcontrolleft) {
|
||||
shift_held = TRUE;
|
||||
|
@ -518,6 +522,12 @@ int parse_kbinput(WINDOW *win)
|
|||
} else if (retval == shiftcontroldown) {
|
||||
shift_held = TRUE;
|
||||
return CONTROL_DOWN;
|
||||
} else if (retval == shiftcontrolhome) {
|
||||
shift_held = TRUE;
|
||||
return CONTROL_HOME;
|
||||
} else if (retval == shiftcontrolend) {
|
||||
shift_held = TRUE;
|
||||
return CONTROL_END;
|
||||
} else if (retval == shiftaltleft) {
|
||||
shift_held = TRUE;
|
||||
return KEY_HOME;
|
||||
|
@ -554,6 +564,10 @@ int parse_kbinput(WINDOW *win)
|
|||
return CONTROL_LEFT;
|
||||
else if (retval == KEY_RIGHT)
|
||||
return CONTROL_RIGHT;
|
||||
else if (retval == KEY_HOME)
|
||||
return CONTROL_HOME;
|
||||
else if (retval == KEY_END)
|
||||
return CONTROL_END;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
/* Are both Shift and Alt being held? */
|
||||
|
|
Loading…
Reference in New Issue