diff options
| author | wrmr | 2025-10-18 14:32:38 -0400 |
|---|---|---|
| committer | wrmr | 2025-10-18 14:32:38 -0400 |
| commit | 7e044fb8d9fa9d0ae8835849f123535ae859017f (patch) | |
| tree | b0d36da70b1dfc1867e36f03fdfc7ff478a596b4 | |
| parent | 8d3fc8ee149604f31b15b56fb77e106e4327b7ec (diff) | |
yep
| -rw-r--r-- | main.c | 43 |
1 files changed, 37 insertions, 6 deletions
@@ -73,6 +73,7 @@ X(CPAIR_DEFAULT , COLOR_FG , COLOR_BG, A_NORMAL , "default")\ X(CPAIR_TEXT , COLOR_FG , COLOR_BG, A_NORMAL , "text")\ X(CPAIR_MENTION , COLOR_FG , COLOR_BG, A_REVERSE, "mention")\ + X(CPAIR_HELP , COLOR_FG , COLOR_BG, A_REVERSE, "help")\ X(CPAIR_USER , COLOR_YELLOW , COLOR_BG, A_NORMAL , "user")\ X(CPAIR_PRONOUNS , COLOR_CYAN , COLOR_BG, A_NORMAL , "pronouns")\ X(CPAIR_DATE , COLOR_BLUE , COLOR_BG, A_NORMAL , "date")\ @@ -680,12 +681,48 @@ void gfx_draw_post(GfxPost *post, int y, int x, int width, Arena *scratch) { } } +void gfx_draw_msg(void) { + switch (msg_status) { + case MSG_OK: use_color(CPAIR_MSG_OK); break; + case MSG_WARN: use_color(CPAIR_MSG_WARN); break; + case MSG_ERR: use_color(CPAIR_MSG_ERR); break; + } + mvaddstr(getmaxy(stdscr) - 1, getmaxx(stdscr) - strlen(msg), msg); +} + +void gfx_draw_help(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); + int line_count = 0; + for (Str src = wrapped, line = { 0 }; next_line(&src, &line);) line_count++; + int y = getmaxy(stdscr) - line_count; + for (Str src = wrapped, line = { 0 }; next_line(&src, &line);) { + mvaddnstr(y++, 0, line.s, line.n); + for (int i = getmaxx(stdscr); i > line.n; i--) { + addch(' '); + } + } +} + void gfx_draw(Gfx *gfx, int cur, Arena *scratch) { erase(); for (int i = cur, y = opt.margin.top; i < gfx->len && y < getmaxy(stdscr) - opt.margin.bottom; i++) { gfx_draw_post(&gfx->posts[i], y, post_left_margin(gfx->posts[i].src), gfx_post_width(gfx->posts[i].src), scratch); y += gfx_post_height(&gfx->posts[i]) + GFX_POST_SPACING; } + if (opt.cbink.help) { + gfx_draw_help(scratch); + } + gfx_draw_msg(); } /* maybe should write an ui layer to not have to deal with all the manual layout stuff */ @@ -1178,12 +1215,6 @@ int main(void) { arena_reset(&temp_arena); gfx_draw(&gfx, cur, &temp_arena); - switch (msg_status) { - case MSG_OK: use_color(CPAIR_MSG_OK); break; - case MSG_WARN: use_color(CPAIR_MSG_WARN); break; - case MSG_ERR: use_color(CPAIR_MSG_ERR); break; - } - mvaddstr(getmaxy(stdscr) - 1, getmaxx(stdscr) - strlen(msg), msg); msg[0] = '\0'; int ch = getch(); |
