From ae1bc2f1665bd79b50330ff1f6960101a5f2d2a7 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Sun, 17 May 2026 13:49:00 +0800 Subject: [PATCH] input: vim-style paging keys in the help screen (UX-5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NORMAL chat mode has Ctrl+D/U (half page) and Ctrl+F/B (full page) scrolling, which is what vim users reach for. The help screen had none of these — only j/k single-line and g/G top/bottom — so reaching the bottom of a help dump meant mashing j. Now the help screen accepts the same four shortcuts. The page size is computed from client->height (matching what NORMAL mode does), so half/full page scroll size scales with the terminal. Both the EN and ZH help text have been updated to advertise the new shortcuts. --- src/input.c | 20 ++++++++++++++++++++ src/tui.c | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/input.c b/src/input.c index 9bc55f9..d564ba6 100644 --- a/src/input.c +++ b/src/input.c @@ -167,6 +167,12 @@ static bool handle_key(client_t *client, unsigned char key, char *input) { /* Handle help screen */ if (client->show_help) { + /* Page size: roughly the visible help body region. */ + int page = client->height - 2; + if (page < 1) page = 1; + int half = page / 2; + if (half < 1) half = 1; + if (key == 'q' || key == 27) { client->show_help = false; tui_render_screen(client); @@ -184,6 +190,20 @@ static bool handle_key(client_t *client, unsigned char key, char *input) { } else if (key == 'k' && client->help_scroll_pos > 0) { client->help_scroll_pos--; tui_render_help(client); + } else if (key == 4) { /* Ctrl+D: half page down */ + client->help_scroll_pos += half; + tui_render_help(client); + } else if (key == 21) { /* Ctrl+U: half page up */ + client->help_scroll_pos -= half; + if (client->help_scroll_pos < 0) client->help_scroll_pos = 0; + tui_render_help(client); + } else if (key == 6) { /* Ctrl+F: full page down */ + client->help_scroll_pos += page; + tui_render_help(client); + } else if (key == 2) { /* Ctrl+B: full page up */ + client->help_scroll_pos -= page; + if (client->help_scroll_pos < 0) client->help_scroll_pos = 0; + tui_render_help(client); } else if (key == 'g') { client->help_scroll_pos = 0; tui_render_help(client); diff --git a/src/tui.c b/src/tui.c index 9778719..a96371b 100644 --- a/src/tui.c +++ b/src/tui.c @@ -730,6 +730,8 @@ const char* tui_get_help_text(help_lang_t lang) { "HELP SCREEN KEYS:\n" " q, ESC - Close help\n" " j/k - Scroll down/up\n" + " Ctrl+D/U - Scroll half page down/up\n" + " Ctrl+F/B - Scroll full page down/up\n" " g/G - Jump to top/bottom\n" " e/z - Switch English/Chinese\n"; } else { @@ -777,6 +779,8 @@ const char* tui_get_help_text(help_lang_t lang) { "帮助界面按键:\n" " q, ESC - 关闭帮助\n" " j/k - 向下/上滚动\n" + " Ctrl+D/U - 向下/上滚动半页\n" + " Ctrl+F/B - 向下/上滚动整页\n" " g/G - 跳到顶部/底部\n" " e/z - 切换英文/中文\n"; }