Merge branch 'tabs'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #137
authored by Daniel Eklöf · committed by Daniel Eklöf · parents 6aa9881, 072438f · Browse files · 8 files·+48 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+48 added−1 removed
- other:+48 added−1 removed
Provenance
- Commit
1aae9fe- Tree
3f3710f- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent 1
6aa9881- Parent 2
072438f
8 files changed+48 added−1 removed
modified:doc/fuzzel.1.scd+9 added
105 unmodified lines106 *-w*,*--width*107 Window width, in characters. Margins and borders not108 included. Default: _30_.109 110+*--tabs*=_COUNT_111+ Number of spaces a tab is expanded to. Default: _8_.112+113 *-x*,*--horizontal-pad*=_PAD_114 Horizontal padding between border and icons and text. In pixels,115 subject to output scaling. Default: _40_.116 88 unmodified lines205 that means fuzzel may or may not appear on top of a lock screen.206 207 Default: _top_208 209+*--no-exit-on-keyboard-focus-loss*210+ Do not exit when losing keyboard focus. This can be useful on211+ compositors where enabling "focus-follows-mouse" causes fuzzel to212+ exit as soon as the mouse is moved over another window. Sway (at213+ least up to, and including 1.7) exhibits this behavior.214+215 *--launch-prefix*=_COMMAND_216 Command to launch XDG applications with. Example: _swaymsg exec --_.217 Default: _not set_.218 88 unmodified linesmodified:doc/fuzzel.ini.5.scd+3 added
133 unmodified lines134 *width*135 Window width, in characters. Border and margins are not included136 in this. Default: _30_.137 138+*tabs*139+ Number of spaces a tab is expanded to. Default: _8_.140+141 *horizontal-pad*142 Horizontal padding, in pixels, between border and143 content. Default: _40_.144 221 unmodified linesmodified:CHANGELOG.md+2 added
33 unmodified lines34 35 ### Added36 37 * Fish completions ([#176][176])38+* Convert tabs to spaces when rendering ([#137][137]).39 40 [176]: https://codeberg.org/dnkl/fuzzel/issues/17641+[137]: https://codeberg.org/dnkl/fuzzel/issues/13742 43 44 ### Fixed45 413 unmodified linesmodified:config.c+4 added
773 unmodified lines774 775 else if (strcmp(key, "width") == 0)776 return value_to_uint32(ctx, 10, &conf->chars);777 778+ else if (strcmp(key, "tabs") == 0)779+ return value_to_uint32(ctx, 10, &conf->tabs);780+781 else if (strcmp(key, "horizontal-pad") == 0)782 return value_to_uint32(ctx, 10, &conf->pad.x);783 784 else if (strcmp(key, "vertical-pad") == 0)615 unmodified lines1400 .exit_immediately_if_empty = false,1401 },1402 .lines = 15,1403 .chars = 30,1404+ .tabs = 8,1405 .pad = {1406 .x = 40,1407 .y = 8,1408 .inner = 0,99 unmodified linesmodified:config.h+1 added
102 unmodified lines103 } dmenu;104 105 unsigned lines;106 unsigned chars;107+ unsigned tabs; /* Tab stop every number of #spaces */108 109 struct {110 unsigned x;111 unsigned y;35 unmodified linesmodified:fuzzel.ini+1 added
11 unmodified lines12 # launch-prefix=<not set>13 14 # lines=1515 # width=3016+# tabs=817 # horizontal-pad=4018 # vertical-pad=819 # inner-pad=020 69 unmodified linesmodified:main.c+14 added
246 unmodified lines247 " Not used in dmenu mode (not set)\n"248 " -l,--lines number of matches to show\n"249 " -w,--width window width, in characters (margins and\n"250 " borders not included)\n"251+ " --tabs=INT number of spaces a tab is expanded to (8)\n"252 " -x,--horizontal-pad=PAD horizontal padding, in pixels (40)\n"253 " -y,--vertical-pad=PAD vertical padding, in pixels (8)\n"254 " -P,--inner-pad=PAD vertical padding between prompt and match list,\n"255 " in pixels (0)\n"259 unmodified lines515 #define OPT_CONFIG 268516 #define OPT_LAYER 269517 #define OPT_ICON_THEME 270518 #define OPT_NO_EXIT_ON_KB_LOSS 271519+ #define OPT_TABS 272520 521 static const struct option longopts[] = {522 {"config", required_argument, 0, OPT_CONFIG},523 {"output" , required_argument, 0, 'o'},4 unmodified lines528 {"fields", required_argument, 0, 'F'},529 {"password", optional_argument, 0, OPT_PASSWORD},530 {"lines", required_argument, 0, 'l'},531 {"width", required_argument, 0, 'w'},532+ {"tabs", required_argument, 0, OPT_TABS},533 {"horizontal-pad", required_argument, 0, 'x'},534 {"vertical-pad", required_argument, 0, 'y'},535 {"inner-pad", required_argument, 0, 'P'},536 {"background-color", required_argument, 0, 'b'},44 unmodified lines581 bool match_fields_set:1;582 bool icons_disabled_set:1;583 bool lines_set:1;584 bool chars_set:1;585+ bool tabs_set:1;586 bool pad_x_set:1;587 bool pad_y_set:1;588 bool pad_inner_set:1;589 bool background_color_set:1;175 unmodified lines765 }766 cmdline_overrides.chars_set = true;767 break;768 769+ case OPT_TABS:770+ if (sscanf(optarg, "%u", &cmdline_overrides.conf.tabs) != 1) {771+ fprintf(stderr, "%s: invalid tab count\n", optarg);772+ return EXIT_FAILURE;773+ }774+ cmdline_overrides.tabs_set = true;775+ break;776+777 case 'x':778 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.x) != 1) {779 fprintf(stderr, "%s: invalid padding\n", optarg);780 return EXIT_FAILURE;351 unmodified lines1132 if (cmdline_overrides.lines_set)1133 conf.lines = cmdline_overrides.conf.lines;1134 if (cmdline_overrides.chars_set)1135 conf.chars = cmdline_overrides.conf.chars;1136+ if (cmdline_overrides.tabs_set)1137+ conf.tabs = cmdline_overrides.conf.tabs;1138 if (cmdline_overrides.pad_x_set)1139 conf.pad.x = cmdline_overrides.conf.pad.x;1140 if (cmdline_overrides.pad_y_set)1141 conf.pad.y = cmdline_overrides.conf.pad.y;261 unmodified linesmodified:render.c+14 added-1 removed
268 unmodified lines269 render_match_text(struct buffer *buf, double *_x, double _y, double max_x,270 const char32_t *text, size_t match_count,271 const struct match_substring matches[static match_count],272 struct fcft_font *font, enum fcft_subpixel subpixel,273- int letter_spacing,273+ int letter_spacing, int tabs,274 pixman_color_t regular_color, pixman_color_t match_color,275 struct fcft_text_run **run)276 {277 int x = *_x;39 unmodified lines317 }318 }319 320 for (size_t i = 0; i < count; i++) {321+ if (text[clusters[i]] == U'\t') {322+ const struct fcft_glyph *space =323+ fcft_rasterize_char_utf32(font, U' ', subpixel);324+325+ if (space != NULL) {326+ const size_t chars_to_next_tab_stop = tabs - (clusters[i] % tabs);327+ x += chars_to_next_tab_stop * space->advance.x;328+ }329+330+ continue;331+ }332+333 bool is_match = false;334 for (size_t j = 0; j < match_count; j++) {335 const struct match_substring *match = &matches[j];336 assert(match->start >= 0);373 unmodified lines710 buf, &cur_x, y, max_x - (ellipses != NULL ? ellipses->width : 0),711 match->application->title, match->pos_count, match->pos,712 font, subpixel,713 pt_or_px_as_pixels(render, &render->conf->letter_spacing),714+ render->conf->tabs,715 (i == selected716 ? render->pix_selection_text_color717 : render->pix_text_color),718 (i == selected122 unmodified lines