From 0910ec32835a3dfa6d9266ae7330a1b7864492d2 Mon Sep 17 00:00:00 2001 From: wrmr Date: Sun, 19 Oct 2025 15:54:45 -0400 Subject: add long help message --- main.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 114 insertions(+), 13 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c803a95..6b5e229 100644 --- a/main.c +++ b/main.c @@ -690,18 +690,108 @@ void gfx_draw_msg(void) { mvaddstr(getmaxy(stdscr) - 1, getmaxx(stdscr) - strlen(msg), msg); } -void gfx_draw_help(Arena *scratch) { +void init_curses(void); +void fini_curses(void); + +const char *help_long = + "KEY BINDINGS\n" + "\n" + " c create post\n" + " e edit post\n" + " r refresh posts list\n" + " i view info of post author\n" + " p edit your profile picture\n" + " v view post in external pager\n" + " q quit cbink\n" + " ? open this help\n" + " Tab toggle profile pictures\n" + " g scroll to top\n" + " G scroll to bottom\n" + " j/Down next post\n" + " k/Up prev post\n" + " PageDown/Space next page\n" + " PageUp/b prev page\n" + " u/Ctrl-u half-page up\n" + " d/Ctrl-d half-page down\n" + "\n" + "CONFIGURATION\n" + "\n" + "~/.cbinkrc is an INI-style config file, with [sections], #comments, and key=value pairs.\n" + "\n" + "The sections are as follows:\n" + "\n" + " [cbink]\n" + "\n" + " help = 1 | 0 enable or disable the short help banner\n" + " pfp = 1 | 0 enable or disable profile pictures\n" + " pronouns = 1 | 0 enable or disable user pronouns in posts\n" + " date = 1 | 0 enable or disable post timestamps\n" + " datefmt = ... configure the timestamp format; see date(1) or strftime(1)\n" + "\n" + " [margin]\n" + "\n" + " left = N margin at left of screen\n" + " right = N margin at right of screen\n" + " top = N margin at top of screen\n" + " bottom = N margin at bottom of screen\n" + " text.x = N horizontal margin around post text\n" + " text.y = N vertical margin around post text\n" + " pfp = N margin between profile picture and post\n" + "\n" + " [color]\n" + "\n" + " All values in the color section have the same format ([ATTR1,...]FG[:BG]) --- a\n" + " foreground color, optionally followed by a colon and a background color, optionally\n" + " with comma-separated attributes.\n" + "\n" + " Foreground and background colors can be default, black, red, green, yellow, blue,\n" + " magenta, cyan, white, and hexadecimal RGB (#RRGGBB) if the terminal supports it.\n" + "\n" + " Attributes can be standout (highlighted), underline, blink, dim, bold, and italic.\n" + "\n" + " Color keys:\n" + "\n" + " default configure what 'default' means in foreground/background\n" + " text normal post text\n" + " mention text in a post that mentions you\n" + " help short help banner at bottom of screen\n" + " user post author username\n" + " pronouns post author pronouns\n" + " date post timestamp\n" + " pfp pfp of other users\n" + " pfp.self your own pfp\n" + " banner banner in user profile\n" + " border border around posts\n" + " msg.ok successful\n" + " msg.warn unsuccessful but correct\n" + " msg.err error occurred\n" + "\n" + "FILES\n" + "\n" + " ~/.cbinkrc\n" + " configuration and styling\n" + "\n" + " ~/.binkbanner\n" + " user profile banner image\n" + "\n" + " ~/.binkpfp\n" + " user profile picture\n" + "\n" + " ~/.pronouns\n" + " user pronouns\n" + "\n" + " ~/.bink\n" + " directory of posts\n" + "\n" + ; + +const char *help_short = "[c]reate [e]dit [r]efresh [q]uit [?]help" + " | scrolling: arrows, j/k, b/space, page up/down, (ctrl-)d/u"; + +void gfx_draw_help_banner(Arena *scratch) { use_color(CPAIR_HELP); - //const char *help_src = "[c]reate [r]efresh [q]uit [?]help | scrolling: arrows, j/k, (ctrl-)d/u, space, page up/down"; - /*const char *help_src = "[c]reate [r]efresh [q]uit [?]help" - " [up/k]prev [down/j]next" - " [space]pagedown [b]pageup" - " [u]halfup [d]halfdown" - ;*/ - const char *help_src = "[c]reate [e]dit [r]efresh [q]uit" - " | scrolling: arrows, j/k, b/space, page up/down, (ctrl-)d/u"; Str wrapped = { 0 }; - str_cat_wrap(&wrapped, str_from_cstr(help_src), getmaxx(stdscr), scratch); + str_cat_wrap(&wrapped, str_from_cstr(help_short), getmaxx(stdscr), scratch); int line_count = 0; for (Str src = wrapped, line = { 0 }; next_line(&src, &line);) line_count++; int y = getmaxy(stdscr) - line_count; @@ -720,7 +810,7 @@ void gfx_draw(Gfx *gfx, int cur, Arena *scratch) { y += gfx_post_height(&gfx->posts[i]) + GFX_POST_SPACING; } if (opt.cbink.help) { - gfx_draw_help(scratch); + gfx_draw_help_banner(scratch); } gfx_draw_msg(); } @@ -840,8 +930,6 @@ char *get_editor(void) { return editor; } -void init_curses(void); -void fini_curses(void); int edit_file(const char *path, Arena *temp) { fini_curses(); int r = system(cstr_fmt(temp, "%s %s", get_editor(), path)); @@ -1182,6 +1270,16 @@ int load_config(Arena *perm, Arena *temp) { /* main */ +void view_long_help(void) { + fini_curses(); + FILE *f = popen("less", "w"); + if (f) { + fputs(help_long, f); + pclose(f); + } + init_curses(); +} + int main(void) { /* init */ @@ -1294,6 +1392,9 @@ resize: gfx_draw_user(posts.data[cur].user, &temp_arena); (void)getch(); break; + case '?': + view_long_help(); + break; } } -- cgit v1.2.3