Skip to content
Myr

config: add --mesg, --mesg-mode and --message-color command line options

Before adoption: this commit came in with the history the project adopted, so no landing records it.

and the corresponding config options: * mesg * mesg-mode * colors.message --mesg can be used to display an informational message above the prompt. The default is to wrap long messages, but this can be changed to instead automatically expand the window with --mesg-mode=wrap|expand. The color of the message text can be changed with --message-color. This feature is likely most useful in dmenu mode, but it isn't limited to it. I.e. it can be used in application mode too. Closes #454

authored by SlayerOfTheBad · committed by Daniel Eklöf · parent 72f6b2f · Browse files · 11 files+341 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+341 added−6 removed

  • other:+341 added−6 removed

11 files+341 added−6 removed

modified:completions/fish/fuzzel.fish+3 added
44 unmodified lines
45complete -c fuzzel -x -s y -l vertical-pad -d "vertical padding, in pixels (8)"46complete -c fuzzel -x -s P -l inner-pad -d "vertical padding between prompt and matches, in pixels (0)"47complete -c fuzzel -x -s b -l background -d "background color (fdf6e3ff)"48complete -c fuzzel -x -s t -l text-color -d "text color (657b83ff)"49complete -c fuzzel -x -l message-color -d "color of the message text (657b83ff)"50complete -c fuzzel -x -l prompt-color -d "color of the prompt text (586e75ff)"51complete -c fuzzel -x -l placeholder-color -d "color of the placeholder text (93a1a1ff)"52complete -c fuzzel -x -l input-color -d "color of the input string (657b83ff)"53complete -c fuzzel -x -s m -l match-color -d "color of matched substring (cb4b16ff)"
31 unmodified lines
85complete -c fuzzel -x -l accept-nth -d "output the N:th column (tab separated by default) of each input line (dmenu only)"86complete -c fuzzel -x -l match-nth -d "match against the N:th column (tab separated by default) of each input line (dmenu only)"87complete -c fuzzel -x -l nth-delimiter -d "field delimiter for --with-nth and --accept-nth"88complete -c fuzzel -x -l only-match -d "do not allow custom entries, only return a selected item"89complete -c fuzzel -x -l mesg -d "string to use as informational message above the prompt"90complete -c fuzzel -x -l mesg-mode -a "wrap expand" -d "how to deal with message lines longer than the ui (wrap)"91complete -c fuzzel -s R -l no-run-if-empty -d "exit immediately without showing the UI if stdin is empty (dmenu mode only)"92complete -c fuzzel -x -s d -l log-level -a "info warning error none" -d "log-level (warning)"93complete -c fuzzel -x -s l -l log-colorize -a "always never auto" -d "enable or disable colorization of log output on stderr"94complete -c fuzzel -s S -l log-no-syslog -d "disable syslog logging"
4 unmodified lines
modified:completions/zsh/_fuzzel+3 added
36 unmodified lines
37 '(-y --vertical-pad)'{-y,--vertical-pad}'[vertical padding, in pixels (8)]:()' \38 '(-P --inner-pad)'{-P,--inner-pad}'[vertical padding between prompt and matches, in pixels (0)]:()' \39 '(-b --background)'{-b,--background}'[background color (fdf6e3ff)]:background:()' \40 '(-t --text-color)'{-t,--text-color}'[text color (657b83ff)]:text-color:()' \41 '--message-color[color of the message text (657b83ff)]:message-color:()' \42 '--prompt-color[color of the prompt text (586e75ff)]:prompt-color:()' \43 '--placeholder-color[color of the placeholder text (93a1a1ff)]:()' \44 '--input-color[color of the input string (657b83ff)]:input-color:()' \45 '(-m --match-color)'{-m,--match-color}'[color of matched substring (cb4b16ff)]:match-color:()' \
30 unmodified lines
76 '--accept-nth[output the N:th column (tab separated by default) of each input line (dmenu mode only)]:accept-nth:()' \77 '--match-nth[match against the N:th column (tab separated by default) of each input line (dmenu only)]:match-nth:()' \78 '--nth-delimiter[field delimiter for --with-nth and --accept-nth]:nth-delim:()' \79 '--only-match[do not allow custom entries, only return a selected item]:only-match:()' \80 '--mesg[string to use as informational message above the prompt]:()' \81 '--mesg-mode[how to deal with message lines longer than the ui (wrap)]:match_mode:(wrap expand)' \82 '(-R --no-run-if-empty)'{-R,--no-run-if-empty}'[exit immediately without showing the UI if stdin is empty (dmenu mode only)]' \83 '--log-level[log level (warning)]:loglevel:(info warning error none)' \84 '--log-colorize[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \85 '--log-no-syslog[disable syslog logging]' \
23 unmodified lines
modified:doc/fuzzel.1.scd+12 added
140 unmodified lines
141142*--placeholder*=_TEXT_143 Text to display as placeholder in the input box. Default: empty.144145*--mesg*=_STRING_146 Message to display above the prompt. Can contain some informational147 message, or can be used for having your prompt be above the input148 instead of in front. Supports newlines.149150*--mesg-mode*=_wrap_|_expand_151 How to handle lines in *--mesg* when they are longer than *--width*.152 See *fuzzel.ini*(5) for details. The default is *wrap*.153154*--search*=_TEXT_155 Initial search/filter string. This option pre-fills the input box156 with the specified string, letting you pre-filter the result.157
123 unmodified lines
281282*-t*,*--text-color*=_HEX_283 Text color. See *COLORS*. Default: _657b83ff_.284285*--message-color*=_HEX_286 Message color. See *COLORS*. Default: _657b83ff_.287288*--prompt-color*=_HEX_289 Text (foreground) color of prompt character(s). See290 *COLORS*. Default: _586e75ff_.291
379 unmodified lines
modified:doc/fuzzel.ini.5.scd+21 added-1 removed
141 unmodified lines
142*prompt*143 String to use as input prompt. Note that trailing spaces are144 trimmed, unless the string is quoted. Default: _"> "_.145146*mesg*147 Message to display above the prompt. Can contain some informational148 message, or can be used for having your prompt be above the input149 instead of in front. Supports newlines.150 For details on how long lines are treated, see *mesg-mode*.151152*mesg-mode*153 One of *wrap*, and *expand*.154155 *wrap*: any line that is longer than *width* is wrapped to the156 following line. Wraps on space boundaries if available, trimming157 leading spaces caused by truncation. If no space is available,158 the line is broken up after *width* characters.159160 *expand*: If the longest line in *mesg* is longer than *width*,161 make the dialogue box wider to accommodate *mesg*.162163*icon-theme*164 Icon theme. Note that the name is case sensitive. Default:165 _default_.166
298 unmodified lines
465*text*466 Text (foreground) color of unselected entries. Default:467 _657b83ff_.468469*message*470 Text (foreground) color of the message string. Default:471 _657b83ff_.472473*prompt*474 Text (foreground) color of prompt character(s). Default:475 _586e75ff_.476
51 unmodified lines
528 Boolean. If enabled, fuzzel will not run at all (i.e. it will not529 open a window, and will not print anything on stdout) if there's530 nothing on stdin. Default: _no_.531511532# SECTION: key-bindings533534This section lets you override the default key bindings.535
210 unmodified lines
modified:CHANGELOG.md+5 added
43 unmodified lines
44* `--only-match` command line option, preventing the user from45 executing "custom" input in dmenu mode ([#651][651]).46* `--nth-delimiter=CHR` option added support for custom delimiter in 1.1347 but is just now documented in the changelog.48* The ability to set a custom "message" above the prompt, controlled49 with the new command line options `--mesg`, `--mesg-mode` and50 `--message-color` (and the corresponding config options `mesg`,51 `mesg-mode` and `colors.message`) ([#454][454]).5253[650]: https://codeberg.org/dnkl/fuzzel/issues/65054[589]: https://codeberg.org/dnkl/fuzzel/issues/58955[651]: https://codeberg.org/dnkl/fuzzel/issues/65156[454]: https://codeberg.org/dnkl/fuzzel/issues/4545758### Changed5960* When typing, the selected entry now always reverts to the first
1085 unmodified lines
modified:config.c+20 added
795 unmodified lines
796797 else if (strcmp(key, "placeholder") == 0)798 return value_to_wchars(ctx, &conf->placeholder);799800 else if (strcmp(key, "message") == 0)801 return value_to_wchars(ctx, &conf->message);802803 else if (strcmp(key, "message-mode") == 0) {804 _Static_assert(sizeof(conf->message_mode) == sizeof(int),805 "enum is not 32-bit");806807 return value_to_enum(808 ctx,809 (const char *[]){"wrap", "expand", NULL},810 (int *)&conf->message_mode);811 }812813 else if (strcmp(key, "icon-theme") == 0)814 return value_to_str(ctx, &conf->icon_theme);815816 else if (strcmp(key, "icons-enabled") == 0)
253 unmodified lines
10701071 else if (strcmp(key, "text") == 0)1072 return value_to_color(ctx, true, &conf->colors.text);10731074 else if (strcmp(key, "message") == 0)1075 return value_to_color(ctx, true, &conf->colors.message);10761077 else if (strcmp(key, "prompt") == 0)1078 return value_to_color(ctx, true, &conf->colors.prompt);10791080 else if (strcmp(key, "placeholder") == 0)
562 unmodified lines
1643 .namespace = xstrdup("launcher"),1644 .prompt = xc32dup(U"> "),1645 .placeholder = xc32dup(U""),1646 .search_text = xc32dup(U""),1647 .message = NULL,1648 .message_mode = MESSAGE_MODE_WRAP,1649 .match_fields = MATCH_FILENAME | MATCH_NAME | MATCH_GENERIC,1650 .password_mode = {1651 .character = U'\0',1652 .enabled = false,
46 unmodified lines
1699 .colors = {1700 .background = conf_hex_to_rgba(0xfdf6e3ff),1701 .border = conf_hex_to_rgba(0x002b36ff),1702 .text = conf_hex_to_rgba(0x657b83ff),1703 .message = conf_hex_to_rgba(0x657b83ff),1704 .prompt = conf_hex_to_rgba(0x586e75ff),1705 .input = conf_hex_to_rgba(0x657b83ff),1706 .match = conf_hex_to_rgba(0xcb4b16ff),1707 .selection = conf_hex_to_rgba(0xeee8d5ff),
85 unmodified lines
1793 free(conf->output);1794 free(conf->prompt);1795 free(conf->placeholder);1796 free(conf->search_text);1797 free(conf->message);1798 free(conf->terminal);1799 free(conf->launch_prefix);1800 free(conf->font);1801 free(conf->icon_theme);
17 unmodified lines
modified:config.h+9 added
33 unmodified lines
34 MATCH_MODE_FZF,35 MATCH_MODE_FUZZY,36};3738enum message_mode {39 MESSAGE_MODE_WRAP,40 MESSAGE_MODE_EXPAND,41};424344enum match_fields {45 MATCH_NAME = 0x01,46 MATCH_FILENAME = 0x02,47 MATCH_GENERIC = 0x04,
70 unmodified lines
118 char *output;119 char32_t *prompt;120 char32_t *placeholder;121 char32_t *search_text;122 char32_t *message;123 enum message_mode message_mode;124 bool prompt_only;125 enum match_fields match_fields;126127 char *namespace;
73 unmodified lines
201 struct {202 struct rgba background;203 struct rgba border;204 struct rgba text;205 struct rgba message;206 struct rgba prompt;207 struct rgba input;208 struct rgba match;209 struct rgba selection;
39 unmodified lines
modified:main.c+62 added
362 unmodified lines
363 " wait for STDIN, and implies --lines=0\n"364 " --placeholder=TEXT placeholder text in input box\n"365 " --search=TEXT initial search/filter string\n"366 " --password=[CHARACTER] render all input as CHARACTER ('*' by default)\n"367 " --mesg show informational message above the prompt\n"368 " --mesg-mode=wrap|expand how to deal with message lines longer than\n"369 " the ui (wrap)\n"370 " -T,--terminal terminal command to use when launching\n"371 " 'terminal' programs, e.g. \"xterm -e\".\n"372 " Not used in dmenu mode (not set)\n"373 " -a,--anchor window anchor (center)\n"
20 unmodified lines
394 " -b,--background-color=HEX background color (fdf6e3ff)\n"395 " -t,--text-color=HEX text color of matched entries (657b83ff)\n"396 " --prompt-color=HEX text color of the prompt (586e75ff)\n"397 " --placeholder-color=HEX text color of the placeholder text (93a1a1)\n"398 " --message-color=HEX text color of the message (657b83ff)\n"399 " --input-color=HEX text color of the input string (657b83ff)\n"400 " -m,--match-color=HEX color of matched substring (cb4b16ff)\n"401 " -s,--selection-color=HEX background color of selected item (eee8d5ff)\n"402 " -S,--selection-text-color=HEX text color of selected item (586e75ff)\n"
60 unmodified lines
463 " --print-timing-info print timing information, to help debug\n"464 " performance issues\n"465 " --no-mouse disable mouse input\n"466 " -v,--version show the version number and quit\n");467468 printf("\n");469 printf("All colors are RGBA - i.e. 8-digit hex values, without prefix.\n");470}471
392 unmodified lines
864 #define OPT_NO_MOUSE 307865 #define OPT_DMENU_NTH_DELIM 308866 #define OPT_DMENU_MATCH_NTH 309867 #define OPT_DMENU_ONLY_MATCH 310868 #define OPT_DMENU_MESSAGE 311869 #define OPT_DMENU_MESSAGE_MODE 312870 #define OPT_MESSAGE_COLOR 313871872 static const struct option longopts[] = {873 {"config", required_argument, 0, OPT_CONFIG},874 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},
23 unmodified lines
898 {"vertical-pad", required_argument, 0, 'y'},899 {"inner-pad", required_argument, 0, 'P'},900 {"background-color", required_argument, 0, 'b'},901 {"text-color", required_argument, 0, 't'},902 {"message-color", required_argument, 0, OPT_MESSAGE_COLOR},903 {"prompt-color", required_argument, 0, OPT_PROMPT_COLOR},904 {"placeholder-color", required_argument, 0, OPT_PLACEHOLDER_COLOR},905 {"input-color", required_argument, 0, OPT_INPUT_COLOR},906 {"match-color", required_argument, 0, 'm'},
42 unmodified lines
949 {"with-nth", required_argument, 0, OPT_DMENU_WITH_NTH},950 {"accept-nth", required_argument, 0, OPT_DMENU_ACCEPT_NTH},951 {"match-nth", required_argument, 0, OPT_DMENU_MATCH_NTH},952 {"only-match", no_argument, 0, OPT_DMENU_ONLY_MATCH},953 {"mesg", required_argument, 0, OPT_DMENU_MESSAGE},954 {"mesg-mode", required_argument, 0, OPT_DMENU_MESSAGE_MODE},955956 /* Misc */957 {"log-level", required_argument, 0, OPT_LOG_LEVEL},958 {"log-colorize", optional_argument, 0, OPT_LOG_COLORIZE},
32 unmodified lines
991 bool pad_y_set:1;992 bool pad_inner_set:1;993 bool background_color_set:1;994 bool text_color_set:1;995 bool message_color_set:1;996 bool prompt_color_set:1;997 bool input_color_set:1;998 bool match_color_set:1;999 bool selection_color_set:1;
20 unmodified lines
1020 bool dmenu_with_nth_set:1;1021 bool dmenu_accept_nth_set:1;1022 bool dmenu_match_nth_set:1;1023 bool dmenu_only_match_set:1;1024 bool mesg_mode_set:1;1025 bool layer_set:1;1026 bool keyboard_focus_set:1;1027 bool no_exit_on_keyboard_focus_loss_set:1;1028 bool render_workers_set:1;
377 unmodified lines
1406 cmdline_overrides.text_color_set = true;1407 break;1408 }14091410 case OPT_MESSAGE_COLOR: {1411 const char *clr_start = optarg;1412 if (clr_start[0] == '#')1413 clr_start++;14141415 errno = 0;1416 char *end = NULL;1417 uint32_t message_color = strtoul(clr_start, &end, 16);1418 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1419 fprintf(stderr, "message-color: %s: invalid color\n", optarg);1420 return EXIT_FAILURE;1421 }1422 cmdline_overrides.conf.colors.message = conf_hex_to_rgba(message_color);1423 cmdline_overrides.message_color_set = true;1424 break;1425 }14261427 case OPT_PROMPT_COLOR: {1428 const char *clr_start = optarg;1429 if (clr_start[0] == '#')1430 clr_start++;
402 unmodified lines
1833 cmdline_overrides.conf.dmenu.only_match = true;1834 cmdline_overrides.dmenu_only_match_set = true;1835 break;18361837 case OPT_DMENU_MESSAGE:1838 free(cmdline_overrides.conf.message);1839 cmdline_overrides.conf.message = ambstoc32(optarg);18401841 if (cmdline_overrides.conf.message == NULL) {1842 fprintf(stderr, "%s: invalid dmenu message\n", optarg);1843 return EXIT_FAILURE;1844 }18451846 break;18471848 case OPT_DMENU_MESSAGE_MODE:1849 if (strcmp(optarg, "wrap") == 0)1850 cmdline_overrides.conf.message_mode = MESSAGE_MODE_WRAP;1851 else if (strcmp(optarg, "expand") == 0)1852 cmdline_overrides.conf.message_mode = MESSAGE_MODE_EXPAND;1853 else {1854 fprintf(stderr, "%s: invalid mesg-mode. Must be 'wrap' or 'expand'\n", optarg);1855 return EXIT_FAILURE;1856 }18571858 cmdline_overrides.mesg_mode_set = true;1859 break;18601861 case OPT_LOG_LEVEL: {1862 int lvl = log_level_from_string(optarg);1863 if (lvl < 0) {1864 fprintf(
249 unmodified lines
2114 if (cmdline_overrides.background_color_set)2115 conf.colors.background = cmdline_overrides.conf.colors.background;2116 if (cmdline_overrides.text_color_set)2117 conf.colors.text = cmdline_overrides.conf.colors.text;2118 if (cmdline_overrides.message_color_set)2119 conf.colors.message = cmdline_overrides.conf.colors.message;2120 if (cmdline_overrides.prompt_color_set)2121 conf.colors.prompt = cmdline_overrides.conf.colors.prompt;2122 if (cmdline_overrides.placeholder_color_set)2123 conf.colors.placeholder = cmdline_overrides.conf.colors.placeholder;
62 unmodified lines
2186 conf.dmenu.match_nth_format = cmdline_overrides.conf.dmenu.match_nth_format;2187 }2188 if (cmdline_overrides.dmenu_only_match_set)2189 conf.dmenu.only_match = cmdline_overrides.conf.dmenu.only_match;2190 if (cmdline_overrides.conf.message != NULL) {2191 free(conf.message);2192 conf.message = cmdline_overrides.conf.message;2193 }2194 if (cmdline_overrides.mesg_mode_set)2195 conf.message_mode = cmdline_overrides.conf.message_mode;2196 if (cmdline_overrides.conf.list_executables_in_path)2197 conf.list_executables_in_path = cmdline_overrides.conf.list_executables_in_path;2198 if (cmdline_overrides.render_workers_set)2199 conf.render_worker_count = cmdline_overrides.conf.render_worker_count;
255 unmodified lines
modified:render.c+203 added-5 removed
63 unmodified lines
64 enum fcft_subpixel subpixel;6566 /* Cached fcft text runs */67 struct fcft_text_run *prompt_text_run;68 struct fcft_text_run *message_text_run;69 struct fcft_text_run *placeholder_text_run;7071 /* Cached selection corners */72 pixman_image_t *selection_corners;
5 unmodified lines
78 bool gamma_correct;79 pixman_color_t pix_background_color;80 pixman_color_t pix_border_color;81 pixman_color_t pix_text_color;82 pixman_color_t pix_message_color;83 pixman_color_t pix_prompt_color;84 pixman_color_t pix_input_color;85 pixman_color_t pix_match_color;86 pixman_color_t pix_selection_color;
9 unmodified lines
96 unsigned border_radius;97 unsigned selection_border_radius;98 unsigned row_height;99 unsigned icon_height;100 unsigned message_height;101102 unsigned input_glyph_offset; /* At which glyph to start rendering input */103104 struct {
447 unmodified lines
552 pos += kern + glyph->advance.x;553 }554}555556static void557current_line_boundaries(char32_t* remaining_message, const struct config *conf,558 char32_t** current_line_end, char32_t** next_line_start)559{560 char32_t* next_linebreak = c32chr(remaining_message, U'\n');561 // Unless word wrapping, the current line boundaries are the whole line562 // If the line is shorter than the configured width, we can also immediately return563 if (conf->message_mode != MESSAGE_MODE_WRAP564 || (next_linebreak != NULL && next_linebreak - remaining_message <= conf->chars)565 || (next_linebreak == NULL && c32len(remaining_message) <= conf->chars)566 ) {567 if (next_linebreak) {568 *current_line_end = next_linebreak-1;569 // Do not skip leading spaces after a linebreak,570 // as intentional spaces likely exist for formatting purposes.571 *next_line_start = next_linebreak+1;572 } else {573 *current_line_end = remaining_message + c32len(remaining_message) - 1;574 *next_line_start = NULL;575 }576 goto strip_trailing_spaces;577 }578579 // Wrapping logic580 char32_t* last_space = NULL;581 *current_line_end = remaining_message;582 while (*current_line_end - remaining_message < conf->chars) {583 if (**current_line_end == U' ') {584 last_space = *current_line_end;585 }586 (*current_line_end)++;587 }588589 // If there is no space in the line, all we can really do (without590 // changing the string) is stop at the end character and move to591 // the next line.592 // Might be nice to have a configurable "wrapping character" option593 // later.594 // current_line_end is already conf->chars characters after remaining_message595 // here due to the space-searching loop596 if (last_space == NULL) {597 // Bumped one beyond conf->chars before the loop ends598 (*current_line_end)--;599 *next_line_start = *current_line_end + 1;600 // Consistency. Should never happen here, but good to check.601 goto strip_leading_spaces;602 }603604605 // If there is a space in the line, break on it.606 *current_line_end = last_space-1;607 *next_line_start = last_space+1;608609strip_leading_spaces:610 while (*next_line_start != NULL && c32len(*next_line_start) > 0 && **next_line_start == U' ')611 (*next_line_start)++;612 if (c32len(*next_line_start) == 0)613 *next_line_start = NULL;614615strip_trailing_spaces:616 while (617 *current_line_end != NULL618 && *current_line_end > remaining_message619 && **current_line_end == U' ')620 {621 (*current_line_end)--;622 }623624}625626void627render_message(struct render *render, struct buffer *buf)628{629 if (!render->conf->message) return;630631 struct fcft_font *font = render->font;632 assert(font != NULL);633634 const char32_t *message = render->conf->message;635 size_t message_len = c32len(message);636637 const enum fcft_subpixel subpixel =638 (render->conf->colors.background.a == 1. &&639 render->conf->colors.message.a == 1.)640 ? render->subpixel : FCFT_SUBPIXEL_NONE;641642643 int x = render->border_size + render->x_margin;644 int y = render->border_size + render->y_margin + render_baseline(render);645646 /* Erase background */647 pixman_color_t bg = render->pix_background_color;648 //pixman_color_t bg = (pixman_color_t){0xffff, 0, 0, 0xffff};649 pixman_image_fill_rectangles(650 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,651 &(pixman_rectangle16_t){652 render->border_size + render->x_margin - render->x_margin / 3,653 render->border_size + render->y_margin,654 buf->width - 2 * (render->border_size + render->x_margin - render->x_margin / 3),655 render->message_height});656657 struct fcft_text_run *message_run = render->message_text_run;658659 if (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING && message_run == NULL) {660 message_run = fcft_rasterize_text_run_utf32(661 font, message_len, message, subpixel);662 }663664 char32_t* current_pos = render->conf->message;665 char32_t* current_line_end = NULL;666 char32_t* next_line_start = NULL;667 while (current_pos != NULL) {668 current_line_boundaries(current_pos, render->conf,669 &current_line_end, &next_line_start);670671 if (message_run != NULL) {672 for (; current_pos <= current_line_end; current_pos++) {673 int i = current_pos - render->conf->message;674 const struct fcft_glyph *glyph = message_run->glyphs[i];675676 render_glyph(buf->pix[0], glyph, x, y, &render->pix_message_color);677 x += glyph->advance.x;678 }679 } else {680 char32_t prev = 0;681 for (; current_pos <= current_line_end; current_pos++) {682 int i = current_pos - render->conf->message;683 const char32_t wc = message[i];684 if (wc == U'\n') {685 x = render->border_size + render->x_margin;686 y += render->row_height;687 continue;688 }689690 const struct fcft_glyph *glyph = fcft_rasterize_char_utf32(font, wc, subpixel);691692 if (glyph == NULL) {693 prev = wc;694 continue;695 }696697 long x_kern;698 fcft_kerning(font, prev, wc, &x_kern, NULL);699700 x += x_kern;701702 render_glyph(703 buf->pix[0], glyph, x, y, &render->pix_message_color);704 x += glyph->advance.x;705 x += pt_or_px_as_pixels(render, &render->conf->letter_spacing);706707 prev = wc;708 }709 }710711 current_pos = next_line_start;712 x = render->border_size + render->x_margin;713 y += render->row_height;714 }715716717 if (render->message_text_run == NULL)718 render->message_text_run = message_run;719 else if (message_run != render->message_text_run)720 fcft_text_run_destroy(message_run);721}722723void724render_prompt(struct render *render, struct buffer *buf,725 const struct prompt *prompt, const struct matches *matches)726{727 struct fcft_font *font = render->font;
35 unmodified lines
763 text_len = c32len(ptext);764 }765766 int x = render->border_size + render->x_margin;597 int y = render->border_size + render->y_margin + render_baseline(render);767 int y = render->border_size + render->y_margin + render_baseline(render) + render->message_height;768769 /* Erase background */770 pixman_color_t bg = render->pix_background_color;771 //pixman_color_t bg = (pixman_color_t){0xffff, 0, 0, 0xffff};772 pixman_image_fill_rectangles(773 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,774 &(pixman_rectangle16_t){775 render->border_size + render->x_margin - render->x_margin / 3,606 render->border_size + render->y_margin,776 render->border_size + render->y_margin + render->message_height,777 buf->width - 2 * (render->border_size + render->x_margin - render->x_margin / 3),778 render->row_height});779780#if 0
786 unmodified lines
1567{1568 return (render->border_size +1569 render->y_margin +1570 (render->conf->hide_prompt ? 0 : render->row_height) +1401 (render->conf->hide_prompt ? 0 : render->inner_pad));1571 (render->conf->hide_prompt ? 0 : render->inner_pad) +1572 render->message_height);1573}15741575static void1576render_match_entry_background(const struct render *render,
368 unmodified lines
1945 render->gamma_correct = gamma_correct;1946 render->pix_background_color = rgba2pixman(gamma_correct, conf->colors.background);1947 render->pix_border_color = rgba2pixman(gamma_correct, conf->colors.border);1948 render->pix_text_color = rgba2pixman(gamma_correct, conf->colors.text);1949 render->pix_message_color = rgba2pixman(gamma_correct, conf->colors.message);1950 render->pix_prompt_color = rgba2pixman(gamma_correct, conf->colors.prompt);1951 render->pix_input_color = rgba2pixman(gamma_correct, conf->colors.input);1952 render->pix_match_color = rgba2pixman(gamma_correct, conf->colors.match);1953 render->pix_selection_color = rgba2pixman(gamma_correct, conf->colors.selection);
36 unmodified lines
1990 : max(font->height, font->ascent + font->descent);19911992 const unsigned icon_height = max(0, row_height - font->descent);19931994 unsigned message_lines = 0;1995 unsigned longest_message_line = 0;1996 if (render->conf->message != NULL) {1997 char32_t* current_pos = render->conf->message;1998 char32_t* current_line_end = NULL;1999 char32_t* next_line_start = NULL;2000 while (current_pos != NULL) {2001 message_lines++;2002 current_line_boundaries(current_pos, render->conf,2003 &current_line_end, &next_line_start);20042005 if (render->conf->message_mode == MESSAGE_MODE_EXPAND2006 && current_line_end + 1 - current_pos > longest_message_line)2007 {2008 longest_message_line = current_line_end + 1 - current_pos;2009 }2010 current_pos = next_line_start;2011 }2012 }20132014 const unsigned height =2015 border_size + /* Top border */2016 y_margin +2017 (render->conf->hide_prompt ? 0 : row_height) + /* The prompt (hidden if hide_prompt) */2018 (render->conf->hide_prompt ? 0 : inner_pad) + /* Padding between prompt and matches (only if prompt shown) */2019 render->conf->lines * row_height + /* Matches */2020 message_lines * row_height + /* Message */2021 y_margin +2022 border_size; /* Bottom border */20232024 const unsigned width =
1 unmodified line
2026 x_margin +2027 (max((W->advance.x + pt_or_px_as_pixels(2028 render, &render->conf->letter_spacing)),2029 0)1837 * render->conf->chars) +2030 * max(render->conf->chars, longest_message_line)) +2031 x_margin +2032 border_size;20332034 LOG_DBG("x-margin: %d, y-margin: %d, border-size: %d, border-radius: %d, "
8 unmodified lines
2043 render->border_radius = border_radius;2044 render->selection_border_radius = selection_border_radius;2045 render->row_height = row_height;2046 render->icon_height = icon_height;2047 render->message_height = message_lines * render->row_height;20482049 if (new_width != NULL)2050 *new_width = width;2051 if (new_height != NULL)
72 unmodified lines
2124 assert(tll_length(render->workers.queue) == 0);2125 tll_free(render->workers.queue);21262127 fcft_text_run_destroy(render->prompt_text_run);2128 fcft_text_run_destroy(render->message_text_run);2129 fcft_text_run_destroy(render->placeholder_text_run);21302131 if (render->selection_corners != NULL)2132 pixman_image_unref(render->selection_corners);
10 unmodified lines
2143 const int y_margin = render->y_margin;2144 const int inner_pad = render->inner_pad;2145 const int border_size = render->border_size;2146 const int row_height = render->row_height;2147 const int message_height = render->message_height;21482149 const int min_x = render->border_size + render->x_margin - render->x_margin / 3;2150 const int max_x = width - (min_x);21511956 const int first_row = 1 * border_size + y_margin +2152 const int first_row = message_height + border_size + y_margin +2153 (render->conf->hide_prompt ? 0 : row_height) +2154 (render->conf->hide_prompt ? 0 : inner_pad);21552156 const size_t match_count = matches_get_count(matches);
10 unmodified lines
2167void2168render_flush_text_run_cache(struct render *render)2169{2170 fcft_text_run_destroy(render->prompt_text_run);2171 fcft_text_run_destroy(render->message_text_run);2172 fcft_text_run_destroy(render->placeholder_text_run);2173 render->prompt_text_run = NULL;2174 render->message_text_run = NULL;2175 render->placeholder_text_run = NULL;2176}
modified:render.h+2 added
25 unmodified lines
26void render_flush_text_run_cache(struct render *render);2728void render_background(const struct render *render, struct buffer *buf);2930void render_message(struct render *render, struct buffer *buf);3132void render_prompt(33 struct render *render, struct buffer *buf,34 const struct prompt *prompt, const struct matches *matches);35
9 unmodified lines
modified:wayland.c+1 added
2589 unmodified lines
2590 render_background(wayl->render, buf);25912592 /* Window content */2593 matches_lock(wayl->matches);2594 render_message(wayl->render, buf);2595 if (!wayl->conf->hide_prompt) {2596 render_prompt(wayl->render, buf, wayl->prompt, wayl->matches);2597 }2598 if (wayl->hide_when_prompt_empty) {
580 unmodified lines