diff options
| author | verdant <im@verdant.ee> | 2026-08-05 18:58:37 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-08-05 18:58:37 +0800 |
| commit | 67ce364fe39d971b5190421f280e6e033f11571d (patch) | |
| tree | 70de996ce07450a374ee13ee3109d88bdaa5dcd8 /src/keys.c | |
| parent | 3722c34e4d0210bb82bb448130ead6ab8b232411 (diff) | |
| download | sf-67ce364fe39d971b5190421f280e6e033f11571d.tar.gz sf-67ce364fe39d971b5190421f280e6e033f11571d.zip | |
Add Emacs and Vim keybindings for navigation
Add basic Control key combinations to handling_keys() for scrolling:
- C-n / C-p for line navigation (Emacs style)
- C-d / C-v for half-page down (Vim/Emacs style)
- C-u / M-v for half-page up (Vim/Emacs style)
Diffstat (limited to 'src/keys.c')
| -rw-r--r-- | src/keys.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -12,9 +12,37 @@ #include "mem.h" #include "wm.h" +bool keymap = false; + void handling_keys(int ch, fm_info *i) { + /* Control(C) or Alt(M) */ + if (ch < 32) { + log_write(LOG_INFO, "ch = %d", ch); + switch (ch) { + case 14: /* C-n, scroll down in Emacs*/ + fm_entries_scroll(i, 1); + break; + case 16: /* C-p scroll up in Emacs */ + fm_entries_scroll(i, -1); + break; + /* Page down */ + case 4: /* C-d, for Vi users' habit */ + case 22: /* C-v, for Emacs users' habit*/ + fm_entries_scroll(i, i->windows[PANE_LEFT]->height / 2); + break; + /* Page up */ + case 21: /* C-u */ + case 27: /* M-v */ + fm_entries_scroll(i, + -(i->windows[PANE_LEFT]->height / 2)); + break; + } + + return; + } + switch (ch) { #ifdef KEY_RESIZE case KEY_RESIZE: |
