mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 05:34:39 +08:00
input: vim-style paging keys in the help screen (UX-5)
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.
This commit is contained in:
parent
c66491d4f8
commit
ae1bc2f166
2 changed files with 24 additions and 0 deletions
20
src/input.c
20
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);
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue