commit 2a97bab5af5aba7ba6889e14c0fd47fe8110d85a
parent 155496adf93b918311950e3c70aa1d5d54565f5e
Author: sin <sin@2f30.org>
Date: Mon, 9 Apr 2018 13:32:25 +0100
Change emacs keybinds for jumping to first/last entry
Signed-off-by: sin <sin@2f30.org>
Diffstat:
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -49,11 +49,11 @@ struct key bindings[] = {
{ CONTROL('U'), SEL_PGUP },
/* Home */
{ KEY_HOME, SEL_HOME },
- { CONTROL('A'), SEL_HOME },
+ { META('<'), SEL_HOME },
{ '^', SEL_HOME },
/* End */
{ KEY_END, SEL_END },
- { CONTROL('E'), SEL_END },
+ { META('>'), SEL_END },
{ '$', SEL_END },
/* Change dir */
{ 'c', SEL_CD },
diff --git a/noice.1 b/noice.1
@@ -1,4 +1,4 @@
-.Dd March 5, 2018
+.Dd April 9, 2018
.Dt NOICE 1
.Os
.Sh NAME
@@ -39,9 +39,9 @@ Move to next entry.
Scroll up half a page.
.It Ic [Pgdown] or C-d
Scroll down half a page.
-.It Ic [Home], ^ or C-a
+.It Ic [Home], ^ or M-<
Move to the first entry.
-.It Ic [End], $ or C-e
+.It Ic [End], $ or M->
Move to the last entry.
.It Ic l, [Right], [Return] or C-m
Open file or enter directory.
diff --git a/noice.c b/noice.c
@@ -38,6 +38,7 @@
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define ISODD(x) ((x) & 1)
#define CONTROL(c) ((c) ^ 0x40)
+#define META(c) ((c) ^ 0x80)
struct assoc {
char *regex; /* Regex to match on filename */
@@ -335,18 +336,28 @@ printprompt(char *str)
printw(str);
}
-/* Returns SEL_* if key is bound and 0 otherwise.
- * Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}) */
-int
-nextsel(char **run, char **env)
+int xgetch(void)
{
- int c, i;
+ int c;
c = getch();
if (c == -1)
idle++;
else
idle = 0;
+ return c;
+}
+
+/* Returns SEL_* if key is bound and 0 otherwise.
+ * Also modifies the run and env pointers (used on SEL_{RUN,RUNARG}) */
+int
+nextsel(char **run, char **env)
+{
+ int c, i;
+
+ c = xgetch();
+ if (c == 033)
+ c = META(xgetch());
for (i = 0; i < LEN(bindings); i++)
if (c == bindings[i].sym) {