config: add image-size-ratio
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This allows us to override the default size of the “large” icon we display when there are only a “few” matches. This patch also changes the default ratio from 0.618 to 0.500
authored by Daniel Eklöf · committed by Daniel Eklöf · parent bbec76c · Browse files · 6 files·+30 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+30 added−2 removed
- other:+30 added−2 removed
Provenance
- Commit
3a40b47- Tree
5ae5b9c- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
bbec76c
6 files changed+30 added−2 removed
modified:doc/fuzzel.ini.5.scd+4 added
145 unmodified lines146 *inner-pad*147 Vertical padding between prompt and match list, in148 pixels. Default: _0_.149 150+*image-size-ratio*151+ The ratio of the large image displayed when there are only a "few"152+ matches, compared to the full window size. Default: _0.5_.153+154 *line-height*155 Override line height from font metrics. Default: use font metrics.156 157 *letter-spacing*59 unmodified linesmodified:CHANGELOG.md+5 added-1 removed
32 unmodified lines33 * Escape sequences in `Exec` arguments are now supported.34 * Multiple space-separated search words can now be entered at the prompt.35 * `-M,--selection-match-color`, that lets you configure the color of36 matched substrings of the currently selected item37+* New config option `image-size-ratio`, allowing you to control the38+ size of the large image displayed when there are only a “few”39+ matches.40 38-41 [3]: https://codeberg.org/dnkl/fuzzel/issues/342 [107]: https://codeberg.org/dnkl/fuzzel/issues/10743 [108]: https://codeberg.org/dnkl/fuzzel/issues/10844 [120]: https://codeberg.org/dnkl/fuzzel/issues/12011 unmodified lines56 ([#106][106]).57 * Improved performance of initial rendering of icons ([#124][124]).58 * `--terminal` now defaults to `$TERMINAL -e`.59 * Font shaping is now applied to the prompt60+* The large image displayed when there are only a “few” matches is now61+ smaller by default.62 63 [101]: https://codeberg.org/dnkl/fuzzel/issues/10164 [106]: https://codeberg.org/dnkl/fuzzel/issues/10665 [124]: https://codeberg.org/dnkl/fuzzel/issues/124318 unmodified linesmodified:config.c+15 added
473 unmodified lines474 475 else if (strcmp(key, "letter-spacing") == 0)476 return value_to_pt_or_px(ctx, &conf->letter_spacing);477 478+ else if (strcmp(key, "image-size-ratio") == 0) {479+ float ratio;480+ if (!value_to_double(ctx, &ratio))481+ return false;482+483+ if (ratio < 0. || ratio > 1.) {484+ LOG_CONTEXTUAL_ERR("not in range 0.0 - 1.0");485+ return false;486+ }487+488+ conf->image_size_ratio = ratio;489+ return true;490+ }491+492 else493 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);494 495 return false;449 unmodified lines945 .border = {946 .size = 1u,947 .radius = 10u,948 },949+ .image_size_ratio = 0.5,950 .line_height = {-1, 0.0},951 .letter_spacing = {0},952 };953 70 unmodified linesmodified:config.h+2 added
82 unmodified lines83 unsigned size;84 unsigned radius;85 } border;86 87+ float image_size_ratio;88+89 struct pt_or_px line_height;90 struct pt_or_px letter_spacing;91 };92 8 unmodified linesmodified:fuzzel.ini+2 added
15 unmodified lines16 # horizontal-pad=4017 # vertical-pad=818 # inner-pad=019 20+# image-size-ratio=0.521+22 # line-height=<use font metrics>23 # letter-spacing=024 25 [colors]14 unmodified linesmodified:render.c+2 added-1 removed
618 unmodified lines619 /* If currently selected item has a scalable icon, and if620 * there's "enough" free space, render a large621 * representation of the icon */622 623- const double size = min(buf->height * 0.618, buf->width * 0.618);623+ const double ratio = render->conf->image_size_ratio;624+ const double size = min(buf->height * ratio, buf->width * ratio);625 const double img_x = (buf->width - size) / 2.;626 const double img_y_bottom = max(buf->height - first_row, 0.);627 const double img_y = max(img_y_bottom - size, 0.);628 188 unmodified lines