Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 80d578c37ee779e92207c81616262b3f3c7c1bd4 Author: rani <clagv.randomgames@gmail.com> Date: Fri Jan 09 21:18:14 2026 +0000 Add: vim/emacs navigation keys diff --git a/include/ui.h b/include/ui.h index c097623..0f8214b 100644 --- a/include/ui.h +++ b/include/ui.h @@ -79 +731 @@    #include "dir.h"   +#define CTRL(k) ((k) & 0x1F) +  #define KEY_DEL 127  #define KEY_ESC 27   +#define UP_KEYS \ + case KEY_UP: \ + case CTRL('P'): \ + case 'k' + +#define DOWN_KEYS \ + case KEY_DOWN: \ + case CTRL('N'): \ + case 'j' + +#define LEFT_KEYS \ + case KEY_LEFT: \ + case CTRL('B'): \ + case 'h' + +#define RIGHT_KEYS \ + case KEY_RIGHT: \ + case CTRL('F'): \ + case 'l' +  enum ui_color {   COLOR_FILE = 1,   COLOR_DIR, diff --git a/src/main.c b/src/main.c index 7dbd870..abce483 100644 --- a/src/main.c +++ b/src/main.c @@ -3515 +3515 @@ int main(int argc, char ** argv) {   else cur_de = &entries[cursor];     switch (getch()) { - case KEY_UP: + UP_KEYS:   if (cursor > 0) cursor--;   ui_status_info("");   break; - case KEY_DOWN: + DOWN_KEYS:   if (cursor < dirlen - 1) cursor++;   ui_status_info("");   break; - case KEY_LEFT: { + LEFT_KEYS: {   // the string from dir_basename(cwd) may be a static field   // so it might not be safe to use it after changing cwd   const char * truebasename = dir_basename(cwd); @@ -717 +717 @@ int main(int argc, char ** argv) {   free(basename);   break;   } - case KEY_RIGHT: { + RIGHT_KEYS: {   ui_status_info("");   if (!cur_de) break;   if (cur_de->type == DE_DIR || (cur_de->type == DE_LINK @@ -1147 +1147 @@ int main(int argc, char ** argv) {   ui_status_info("");   break;   } - case 'l': + case 'o':   // cycle through long mode options   if (config.longmode) {   if (config.longinline) config.longinline = false; diff --git a/src/ui.c b/src/ui.c index eea5aef..75c7f09 100644 --- a/src/ui.c +++ b/src/ui.c @@ -597 +597 @@ void ui_init(void) {   setlocale(LC_CTYPE, "");     initscr(); - cbreak(); + raw();   keypad(stdscr, TRUE);   curs_set(0);   noecho(); @@ -51610 +51610 @@ const char * ui_prompt(const char * prompt, prompt_opts_t opts) {   ret = NULL;   done = true;   } else switch (c) { - case KEY_LEFT: + LEFT_KEYS:   if (cursor > 0) cursor--;   break; - case KEY_RIGHT: + RIGHT_KEYS:   if (cursor < n_opts - 1) cursor++;   break;   case '\n':