nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 67d459b2629ffe0f3535438b5b057a4fcd5f8fb7
parent 5ecefb876653872b73de904edcb23515d947cb90
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 24 Mar 2024 15:07:45 +0100

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.

Diffstat:
Msrc/definitions.h | 2++
Msrc/global.c | 4+++-
Msrc/nano.c | 2++
Msrc/prototypes.h | 1+
Msrc/winio.c | 8+++++++-
5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h @@ -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 diff --git a/src/global.c b/src/global.c @@ -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); diff --git a/src/nano.c b/src/nano.c @@ -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); diff --git a/src/prototypes.h b/src/prototypes.h @@ -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; diff --git a/src/winio.c b/src/winio.c @@ -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;