render: add support for rendering the selected entry in bold
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent b32836d · Browse files · 14 files·+62 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
14 files+62 added−5 removed
- other:+62 added−5 removed
Provenance
- Commit
8d77e69- Tree
84bcc62- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
b32836d
14 files changed+62 added−5 removed
modified:completions/fish/fuzzel.fish+1 added
11 unmodified lines12 complete -c fuzzel -r -s c -l config -d "path to configuration file (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)"13 complete -c fuzzel -r -l cache -d "file to load most recently launched applications from (XDG_CACHE_HOME/fuzzel)"14 complete -c fuzzel -l check-config -d "verify configuration and exit with 0 if ok, otherwise exit with 1"15 complete -c fuzzel -x -s f -l font -a "(fc-list : family | sed 's/,/\n/g' | sort | uniq)" -d "font name and style in fontconfig format (monospace)"16+complete -c fuzzel -l use-bold -d "allow fuzzel to use bold fonts"17 complete -c fuzzel -x -s o -l output -a "(__fish_complete_fuzzel_output)" -d "output (monitor) do display on (none)"18 complete -c fuzzel -x -s D -l dpi-aware -a "no yes auto" -d "scale fonts using the monitor's DPI (auto)"19 complete -c fuzzel -x -l icon-theme -a "(find /usr/share/icons -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 basename | sort)" -d "icon theme name (hicolor)"20 complete -c fuzzel -s I -l no-icons -d "do not render any icons"51 unmodified linesmodified:completions/zsh/_fuzzel+1 added
8 unmodified lines9 '(-h --help)'{-h,--help}'[show help message and quit]' \10 '(-o --output)'{-o,--output}'[output (monitor) to display on (none)]:output:->outputs' \11 '(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \12 '(-D --dpi-aware)'{-D,--dpi-aware}"[scale fonts using the monitor's DPI (auto)]:dpi_aware:(no yes auto)" \13+ '--use-bold[allow fuzzel to use bold fonts]' \14 '--icon-theme[icon theme name (hicolor)]:theme:->icon_theme' \15 '(-I --no-icons)'{-I,--no-icons}'[do not render any icons]' \16 '(-F --fields)'{-F,--fields}'[comma separated list of XDG Desktop entry fields to match ]:fields:(filename name generic exec categories keywords comment)' \17 '(-p --prompt)'{-p,--prompt}'[string to use as input prompt ("> ")]:()' \64 unmodified linesmodified:doc/fuzzel.1.scd+3 added
47 unmodified lines48 *-f*,*--font*=_FONT_[,_FALLBACK1_,_FALLBACK2_,...]49 Comma separated list of primary font, and fallback fonts, in50 FontConfig format. See *FONT FORMAT*. Default: _monospace_.51 52+*--use-bold*53+ Allow fuzzel to use bold fonts.54+55 *-D*,*--dpi-aware*=_no|yes|auto_56 When set to *yes*, fonts are sized using the monitor's DPI, making57 a font of a given point size have the same physical size,58 regardless of monitor.358 unmodified linesmodified:doc/fuzzel.ini.5.scd+4 added
59 unmodified lines60 - Fantasque Sans Mono:fontfeatures=ss0161 62 Default: _monospace_.63 64+*use-bold*65+ Boolean. When set, fuzzel may use bold fonts. For example, for the66+ currently selected item. Default: _no_67+68 *dpi-aware*69 *auto*, *yes*, or *no*.70 71 When set to *yes*, fonts are sized using the monitor's DPI, making424 unmodified linesmodified:application.c+2 added
383 unmodified lines384 }385 free(app->icon.path);386 387 fcft_text_run_destroy(app->shaped);388+ fcft_text_run_destroy(app->shaped_bold);389 free(app);390 }391 392 mtx_destroy(&apps->lock);5 unmodified lines398 applications_flush_text_run_cache(struct application_list *apps)399 {400 for (size_t i = 0; i < apps->count; i++) {401 fcft_text_run_destroy(apps->v[i]->shaped);402+ fcft_text_run_destroy(apps->v[i]->shaped_bold);403 apps->v[i]->shaped = NULL;404 }405 }modified:application.h+1 added
85 unmodified lines86 bool visible;87 bool startup_notify;88 unsigned count;89 struct fcft_text_run *shaped;90+ struct fcft_text_run *shaped_bold;91 };92 93 bool application_execute(94 const struct application *app, const struct prompt *prompt,11 unmodified linesmodified:CHANGELOG.md+4 added
68 unmodified lines69 prompt.70 * `--count-color` and `colors.count`, controlling the color of the71 match count. The default value is `93a1a1ff` (_base1_ in the72 solarized palette).73+* The currently selected entry may now be rendered with a bold74+ font. It is disabled by default, and can be enabled either via the75+ new `--use-bold` command line option, or by setting `use-bold=yes`,76+ in `fuzzel.ini`.77 78 [344]: https://codeberg.org/dnkl/fuzzel/issues/34479 [131]: https://codeberg.org/dnkl/fuzzel/issues/13180 [189]: https://codeberg.org/dnkl/fuzzel/issues/189700 unmodified linesmodified:config.c+4 added
777 unmodified lines778 779 else if (strcmp(key, "font") == 0)780 return value_to_str(ctx, &conf->font);781 782+ else if (strcmp(key, "use-bold") == 0)783+ return value_to_bool(ctx, &conf->use_bold);784+785 else if (strcmp(key, "dpi-aware") == 0) {786 if (strcmp(value, "auto") == 0)787 conf->dpi_aware = DPI_AWARE_AUTO;788 else {797 unmodified lines1586 },1587 .terminal = NULL,1588 .launch_prefix = NULL,1589 .font = strdup("monospace"),1590+ .use_bold = false,1591 .dpi_aware = DPI_AWARE_AUTO,1592 .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN),1593 .match_worker_count = sysconf(_SC_NPROCESSORS_ONLN),1594 .icons_enabled = true,131 unmodified linesmodified:config.h+2 added
111 unmodified lines112 char *terminal;113 char *launch_prefix;114 115 char *font;116+ bool use_bold;117 enum dpi_aware dpi_aware;118+119 uint16_t render_worker_count;120 uint16_t match_worker_count;121 122 bool filter_desktop;80 unmodified linesmodified:fuzzel.ini+1 added
1 # output=<not set>2 # font=monospace3 # dpi-aware=auto4+# use-bold=no5 # prompt="> "6 # icon-theme=hicolor7 # icons-enabled=yes8 # fields=filename,name,generic99 unmodified linesmodified:main.c+11 added
318 unmodified lines319 " PATH (XDG_CACHE_HOME/fuzzel)\n"320 " -o,--output=OUTPUT output (monitor) to display on (none)\n"321 " -f,--font=FONT font name and style, in FontConfig format\n"322 " (monospace)\n"323+ " --use-bold allow fuzzel to use bold fonts\n"324 " -D,--dpi-aware=no|yes|auto enable or disable DPI aware rendering (auto)\n"325 " --icon-theme=NAME icon theme name (\"hicolor\")\n"326 " -I,--no-icons do not render any icons\n"327 " -F,--fields=FIELDS comma separated list of XDG Desktop entry\n"370 unmodified lines698 #define OPT_PROMPT_COLOR 282699 #define OPT_INPUT_COLOR 283700 #define OPT_PROMPT_ONLY 284701 #define OPT_COUNT_COLOR 285702+ #define OPT_USE_BOLD 286703 #define OPT_MATCH_WORKERS 287704 #define OPT_DELAYED_FILTER_MS 289705 #define OPT_DELAYED_FILTER_LIMIT 290706 2 unmodified lines709 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},710 {"cache", required_argument, 0, OPT_CACHE},711 {"output" , required_argument, 0, 'o'},712 {"font", required_argument, 0, 'f'},713+ {"use-bold", no_argument, 0, OPT_USE_BOLD},714 {"dpi-aware", required_argument, 0, 'D'},715 {"icon-theme", required_argument, 0, OPT_ICON_THEME},716 {"no-icons", no_argument, 0, 'I'},717 {"fields", required_argument, 0, 'F'},107 unmodified lines825 bool no_exit_on_keyboard_focus_loss_set:1;826 bool render_workers_set:1;827 bool match_workers_set:1;828 bool prompt_only_set:1;829+ bool use_bold_set:1;830 bool delayed_filter_ms_set:1;831 bool delayed_filter_limit_set:1;832 } cmdline_overrides = {{0}};833 39 unmodified lines873 case 'f':874 cmdline_overrides.conf.font = optarg;875 break;876 877+ case OPT_USE_BOLD:878+ cmdline_overrides.conf.use_bold = true;879+ cmdline_overrides.use_bold_set = true;880+ break;881+882 case 'D':883 if (strcmp(optarg, "auto") == 0)884 cmdline_overrides.conf.dpi_aware = DPI_AWARE_AUTO;885 else if (strcmp(optarg, "no") == 0)691 unmodified lines1577 if (cmdline_overrides.conf.font != NULL) {1578 free(conf.font);1579 conf.font = strdup(cmdline_overrides.conf.font);1580 }1581+ if (cmdline_overrides.use_bold_set)1582+ conf.use_bold = cmdline_overrides.conf.use_bold;1583 if (cmdline_overrides.conf.icon_theme != NULL) {1584 free(conf.icon_theme);1585 conf.icon_theme = strdup(cmdline_overrides.conf.icon_theme);1586 }318 unmodified linesmodified:render.c+18 added-3 removed
45 unmodified lines46 47 struct render {48 const struct config *conf;49 struct fcft_font *font;50+ struct fcft_font *font_bold;51 enum fcft_subpixel subpixel;52 53 float scale;54 float dpi;739 unmodified lines794 const enum fcft_subpixel subpixel =795 (render->conf->colors.background.a == 1. &&796 render->conf->colors.selection.a == 1.)797 ? render->subpixel : FCFT_SUBPIXEL_NONE;798+799+ struct fcft_font *font =800+ is_selected ? render->font_bold : render->font;801 const struct fcft_glyph *ellipses =798- fcft_rasterize_char_utf32(render->font, U'…', subpixel);802+ fcft_rasterize_char_utf32(font, U'…', subpixel);803 804 const int first_row = first_row_y(render);805 double cur_x = render->border_size + render->x_margin;806 double max_x = width - render->border_size - render->x_margin;99 unmodified lines906 /* Application title */907 render_match_text(908 pix, &cur_x, y, max_x - (ellipses != NULL ? ellipses->width : 0),909 match->application->render_title, match->pos_count, match->pos,906- render->font, subpixel,910+ font, subpixel,911 pt_or_px_as_pixels(render, &render->conf->letter_spacing),912 render->conf->tabs,913 (is_selected914 ? render->pix_selection_text_color915 : render->pix_text_color),916 (is_selected917 ? render->pix_selection_match_color918 : render->pix_match_color),915- &match->application->shaped);919+ (is_selected920+ ? &match->application->shaped_bold921+ : &match->application->shaped));922 }923 924 void925 render_match_list(struct render *render, struct buffer *buf,209 unmodified lines1135 }1136 1137 bool1138 render_set_font_and_update_sizes(struct render *render, struct fcft_font *font,1139+ struct fcft_font *font_bold,1140 float scale, float dpi, bool size_font_by_dpi,1141 int *new_width, int *new_height)1142 {1143 if (font != NULL) {3 unmodified lines1147 assert(render->font != NULL);1148 font = render->font;1149 }1150 1151+ if (font_bold != NULL) {1152+ fcft_destroy(render->font_bold);1153+ render->font_bold = font_bold;1154+ } else {1155+ assert(render->font_bold != NULL);1156+ font_bold = render->font_bold;1157+ }1158+1159 render->scale = scale;1160 render->dpi = dpi;1161 render->size_font_by_dpi = size_font_by_dpi;1162 117 unmodified linesmodified:render.h+1 added-1 removed
14 unmodified lines15 void render_destroy(struct render *render);16 17 void render_set_subpixel(struct render *render, enum fcft_subpixel subpixel);18 bool render_set_font_and_update_sizes(19- struct render *render, struct fcft_font *font,19+ struct render *render, struct fcft_font *font, struct fcft_font *font_bold,20 float scale, float dpi, bool size_font_by_dpi,21 int *new_width, int *new_height);22 23 void render_background(const struct render *render, struct buffer *buf);14 unmodified linesmodified:wayland.c+9 added-1 removed
1343 unmodified lines1344 static bool1345 reload_font(struct wayland *wayl, float new_dpi, float new_scale)1346 {1347 struct fcft_font *font = NULL;1348+ struct fcft_font *font_bold = NULL;1349 1350 bool was_sized_using_dpi = wayl->font_is_sized_by_dpi;1351 bool will_size_using_dpi = size_font_using_dpi(wayl);1352 40 unmodified lines1393 /* Font’s DPI */1394 float dpi = will_size_using_dpi ? new_dpi : 96.;1395 char attrs[256]; snprintf(attrs, sizeof(attrs), "dpi=%.2f", dpi);1396 1397+ char bold_attrs[512];1398+ strcpy(bold_attrs, attrs);1399+1400+ if (wayl->conf->use_bold)1401+ strcat(bold_attrs, ":weight=bold");1402+1403 font = fcft_from_name(wayl->font_count, (const char **)names, attrs);1404+ font_bold = fcft_from_name(wayl->font_count, (const char **)names, bold_attrs);1405 1406 for (size_t i = 0; i < wayl->font_count; i++)1407 free(names[i]);1408 free(names);2 unmodified lines1411 return false;1412 }1413 1414 bool ret = render_set_font_and_update_sizes(1407- wayl->render, font, new_scale, new_dpi,1415+ wayl->render, font, font_bold, new_scale, new_dpi,1416 wayl->font_is_sized_by_dpi, &wayl->width, &wayl->height);1417 1418 if (wayl->font_reloaded.cb != NULL)1419 wayl->font_reloaded.cb(wayl, font, wayl->font_reloaded.data);1073 unmodified lines