commit c6be26e477ec817b6c8e56297729595524b7b9c3 from: Omar Polo date: Wed Jul 21 15:47:46 2021 UTC pretty print help lines commit - 1f496e7b32b9d7c16904e37cc30e9429556945f3 commit + c6be26e477ec817b6c8e56297729595524b7b9c3 blob - 41d778cbe0b60fa78a0cddd9953bbeaf9eeb519b blob + c30b7e3163325c8d1e15b7970ec6b6d4fe2b128c --- ChangeLog +++ ChangeLog @@ -1,4 +1,6 @@ 2021-07-21 Omar Polo + + * ui.c (print_vline_descr): pretty print help lines * defaults.c (load_default_keys): bind other-window to C-x o blob - 4292085f16a406089816b95288f1602ac2f30fdf blob + 5cc7dcd9be593acbe18b86fdf7ce51ef6f83cb95 --- defaults.c +++ defaults.c @@ -51,6 +51,8 @@ struct lineprefix line_prefixes[] = { [LINE_COMPL] = {"", ""}, [LINE_COMPL_CURRENT] = {"", ""}, + + [LINE_HELP] = {"", ""}, }; struct line_face line_faces[] = { @@ -122,6 +124,13 @@ struct line_face line_faces[] = { .trail_pair = PCOMPL_CURR_TRAIL, .attr = A_REVERSE, .trail_attr = A_REVERSE, + }, + + /* help */ + [LINE_HELP] = { + .prfx_pair = PHELP_PRFX, + .pair = PHELP, + .trail_pair = PHELP_TRAIL, }, }; @@ -174,7 +183,10 @@ struct mapping { /* minibuffer */ {"compl", LINE_COMPL}, - {"compl.current", LINE_COMPL_CURRENT} + {"compl.current", LINE_COMPL_CURRENT}, + + /* help */ + {"help", LINE_HELP}, }; static struct mapping * blob - feff40f2d0a90f9370a0a962f0aebd390490ef54 blob + e7c87832db63b1d9e09565308a05e89b040bc161 --- help.c +++ help.c @@ -39,11 +39,10 @@ emit_help_item(char *prfx, void *fn) if ((l = calloc(1, sizeof(*l))) == NULL) abort(); - l->type = LINE_TEXT; - l->alt = NULL; + l->type = LINE_HELP; + l->line = strdup(prfx); + l->alt = (char*)cmd->cmd; - asprintf(&l->line, "%s %s", prfx, cmd->cmd); - if (TAILQ_EMPTY(&helpwin.page.head)) TAILQ_INSERT_HEAD(&helpwin.page.head, l, lines); else blob - f5e9f458306a7c724e0d03e581549a55a1a16801 blob + 7df00153aef20574474487911253c30fa648bdf9 --- telescope.h +++ telescope.h @@ -84,6 +84,9 @@ enum line_type { /* minibuffer */ LINE_COMPL, LINE_COMPL_CURRENT, + + /* help */ + LINE_HELP, }; /* for lines: mark as hidden */ blob - ac941eeb88699330a5d78d5271177dba3336ad4c blob + 9abd944ed9c1c3f0bc2c5bbdd1d71d207ffc1d35 --- ui.c +++ ui.c @@ -399,7 +399,8 @@ print_vline_descr(int width, WINDOW *window, struct vl int x, y, goal; if (vl->parent->type != LINE_COMPL && - vl->parent->type != LINE_COMPL_CURRENT) + vl->parent->type != LINE_COMPL_CURRENT && + vl->parent->type != LINE_HELP) return; if (vl->parent->alt == NULL) @@ -408,7 +409,11 @@ print_vline_descr(int width, WINDOW *window, struct vl (void)y; getyx(window, y, x); - goal = width/2; + if (vl->parent->type == LINE_HELP) + goal = 8; + else + goal = width/2; + if (goal <= x) wprintw(window, " "); for (; goal > x; ++x) blob - db3789d6001bd4fab4e04a800b1e045e5b9748ad blob + 9e4beea54dee556d8373c629423cee16e377e2ea --- ui.h +++ ui.h @@ -80,6 +80,10 @@ enum pairs { PCOMPL_CURR, PCOMPL_CURR_TRAIL, + PHELP_PRFX, + PHELP, + PHELP_TRAIL, + PMODELINE, PMINIBUF, blob - 1d4731e413b208c4a3095363a3d08fa437ae13c4 blob + 87393e3d4ab3e7bfe8fc9c291eea287064fbb55e --- wrap.c +++ wrap.c @@ -57,7 +57,8 @@ empty_linelist(struct buffer *buffer) free(l->line); if (l->type != LINE_COMPL && - l->type != LINE_COMPL_CURRENT) + l->type != LINE_COMPL_CURRENT && + l->type != LINE_HELP) free(l->alt); free(l); @@ -279,6 +280,7 @@ wrap_page(struct buffer *buffer, int width) break; case LINE_COMPL: case LINE_COMPL_CURRENT: + case LINE_HELP: wrap_one(buffer, prfx, l, width); break; }