bindings: let <Alt+Home/End> move the cursor to top/bottom of viewport

For now these are hidden keystrokes -- they are not listed anywhere,
and the functions are not bindable by the user.
This commit is contained in:
Benno Schulenberg 2024-03-24 15:07:45 +01:00
parent 5ecefb8766
commit 67d459b262
5 changed files with 15 additions and 2 deletions

View File

@ -195,6 +195,8 @@
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_HOME 0x425
#define ALT_END 0x426
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C

View File

@ -104,7 +104,7 @@ int shiftleft, shiftright, shiftup, shiftdown;
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int altleft, altright, altup, altdown;
int altpageup, altpagedown;
int althome, altend, altpageup, altpagedown;
int altinsert, altdelete;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
@ -1314,6 +1314,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, chop_next_word, 0);
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);
add_to_sclist(MMAIN, "M-Ins", ALT_INSERT, put_or_lift_anchor, 0);
add_to_sclist(MMAIN, "M-Home", ALT_HOME, to_top_row, 0);
add_to_sclist(MMAIN, "M-End", ALT_END, to_bottom_row, 0);
add_to_sclist(MMAIN, "M-PgUp", ALT_PAGEUP, to_prev_anchor, 0);
add_to_sclist(MMAIN, "M-PgDn", ALT_PAGEDOWN, to_next_anchor, 0);
add_to_sclist(MMAIN, "M-\"", 0, put_or_lift_anchor, 0);

View File

@ -2434,6 +2434,8 @@ int main(int argc, char **argv)
altup = get_keycode("kUP3", ALT_UP);
altdown = get_keycode("kDN3", ALT_DOWN);
althome = get_keycode("kHOM3", ALT_HOME);
altend = get_keycode("kEND3", ALT_END);
altpageup = get_keycode("kPRV3", ALT_PAGEUP);
altpagedown = get_keycode("kNXT3", ALT_PAGEDOWN);
altinsert = get_keycode("kIC3", ALT_INSERT);

View File

@ -75,6 +75,7 @@ extern int shiftcontrolup, shiftcontroldown;
extern int shiftcontrolhome, shiftcontrolend;
extern int altleft, altright;
extern int altup, altdown;
extern int althome, altend;
extern int altpageup, altpagedown;
extern int altinsert, altdelete;
extern int shiftaltleft, shiftaltright;

View File

@ -1173,6 +1173,10 @@ int parse_kbinput(WINDOW *frame)
return ALT_UP;
else if (keycode == altdown)
return ALT_DOWN;
else if (keycode == althome)
return ALT_HOME;
else if (keycode == altend)
return ALT_END;
else if (keycode == altpageup)
return ALT_PAGEUP;
else if (keycode == altpagedown)
@ -1216,11 +1220,13 @@ int parse_kbinput(WINDOW *frame)
if (!meta_key)
shift_held = TRUE;
}
/* Is Alt being held? */
/* Is only Alt being held? */
if (modifiers == 0x08) {
switch (keycode) {
case KEY_UP: return ALT_UP;
case KEY_DOWN: return ALT_DOWN;
case KEY_HOME: return ALT_HOME;
case KEY_END: return ALT_END;
case KEY_PPAGE: return ALT_PAGEUP;
case KEY_NPAGE: return ALT_PAGEDOWN;
case KEY_DC: return ALT_DELETE;