[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] bindings: let <Alt+Home/End> move the cursor to top/bottom o
From: |
Benno Schulenberg |
Subject: |
[PATCH 3/3] bindings: let <Alt+Home/End> move the cursor to top/bottom of viewport |
Date: |
Mon, 25 Mar 2024 11:07:10 +0100 |
For now these are hidden keystrokes -- they are not listed anywhere,
and the functions are not bindable by the user.
---
src/definitions.h | 2 ++
src/global.c | 4 +++-
src/nano.c | 2 ++
src/prototypes.h | 1 +
src/winio.c | 8 +++++++-
5 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/definitions.h b/src/definitions.h
index 86eeae35..ef31f898 100644
--- 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
index 87beeacc..62337df4 100644
--- 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
index 47221064..87806c45 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2429,6 +2429,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
index 0afdadad..2ef73c0a 100644
--- 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
index d0ef2525..2e392566 100644
--- 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;
--
2.42.1