Add margin (spacing relative the anchor point) support
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #344
authored by Jordi Estrada · committed by Daniel Eklöf · parent 0086085 · Browse files · 10 files·+77 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+77 added−0 removed
- other:+77 added−0 removed
Provenance
- Commit
926e936- Tree
cadf670- Author
Jordi Estrada <qoo6diz8@duck.com>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
0086085
10 files changed+77 added−0 removed
modified:completions/fish/fuzzel.fish+2 added
22 unmodified lines23 # TODO: this currently doesn’t quote the completed argument24 complete -c fuzzel -x -s T -l terminal -a "(__fish_complete_subcommand)" -d "terminal command, with arguments ($TERMINAL -e)"25 26 complete -c fuzzel -x -s a -l anchor -a "top-left top top-right left center right bottom-left bottom bottom-right" -d "set window anchor (center)"27+complete -c fuzzel -x -l x-margin -d "horizontal margin away from the anchor point in pixels (0)"28+complete -c fuzzel -x -l y-margin -d "vertical margin away from the anchor point in pixels (0)"29 complete -c fuzzel -x -l select -d "select the first entry that matches the given string"30 complete -c fuzzel -x -s l -l lines -d "maximum number of matches to displayh (15)"31 complete -c fuzzel -x -s w -l width -d "window width, in characters (30)"32 complete -c fuzzel -x -s x -l horizontal-pad -d "horizontal padding, in pixels (40)"30 unmodified linesmodified:completions/zsh/_fuzzel+2 added
14 unmodified lines15 '(-p --prompt)'{-p,--prompt}'[string to use as input prompt ("> ")]:()' \16 '--password[render all input using either "*", or the specified character]:()' \17 '(-T --terminal)'{-T,--terminal}'[terminal command, with arguments ($TERMINAL -e)]:terminal:_command_names -e' \18 '(-a --anchor)'{-a,--anchor}'[set window anchor (center)]:anchors:(top-left top top-right left center right bottom-left bottom bottom-right)' \19+ '--x-margin[horizontal margin away from the anchor point in pixels (0)]:()' \20+ '--y-margin[vertical margin away from the anchor point in pixels (0)]:()' \21 '--select[select the first entry that matches the given string]:()' \22 '(-l --lines)'{-l,--lines}'[maximum number of matches to display (15)]:()' \23 '(-w --width)'{-w,--width}'[window width, in characters (30)]:()' \24 '(-x --horizontal-pad)'{-x,--horizontal-pad}'[horizontal padding, in pixels (40)]:()' \48 unmodified linesmodified:doc/fuzzel.1.scd+10 added
119 unmodified lines120 - bottom-right121 122 Default: _center_123 124+*--x-margin*=_MARGIN_125+ Horizontal margin away from the anchor point in pixels. Default: _0_.126+127+ Note: this option has no effect when anchor=center, top or bottom.128+129+*--y-margin*=_MARGIN_130+ Vertical margin away from the anchor point in pixels. Default: _0_.131+132+ Note: this option has no effect when anchor=center, left or right.133+134 *select*=_STRING_135 Select the first entry that matches the given string (case136 insensitive).137 222 unmodified linesmodified:doc/fuzzel.ini.5.scd+10 added
172 unmodified lines173 - bottom-right174 175 Default: _center_176 177+*x-margin*178+ Horizontal margin away from the anchor point in pixels. Default: _0_.179+180+ Note: this option has no effect when anchor=center, top or bottom.181+182+*y-margin*183+ Vertical margin away from the anchor point in pixels. Default: _0_.184+185+ Note: this option has no effect when anchor=center, left or right.186+187 *lines*188 Number of matches to show. Default: _15_.189 190 *width*254 unmodified linesmodified:CHANGELOG.md+5 added
28 unmodified lines29 ## Unreleased30 ### Added31 32 * Nanosvg updated to 93ce879dc4c04a3ef1758428ec80083c38610b1f33+* New options `--x-margin` `--y-margin` which place the launcher some34+ distance away from the anchor point, in pixels. Default to 035+ ([#344][344]).36 37+[344]: https://codeberg.org/dnkl/fuzzel/issues/34438 39+40 ### Changed41 42 * The cache now stores desktop file **IDs** instead of the application43 titles. This way, we do not store multiple cache entries with the664 unmodified linesmodified:config.c+9 added
897 unmodified lines898 899 conf->anchor = anchor;900 return true;901 }902+ else if (strcmp(key, "x-margin") == 0)903+ return value_to_uint32(ctx, 10, &conf->margin.x);904+ 905+ else if (strcmp(key, "y-margin") == 0)906+ return value_to_uint32(ctx, 10, &conf->margin.y);907 908 else if (strcmp(key, "lines") == 0)909 return value_to_uint32(ctx, 10, &conf->lines);910 637 unmodified lines1548 .exit_immediately_if_empty = false,1549 .delim = '\n',1550 },1551 .anchor = ANCHOR_CENTER,1552+ .margin = {1553+ .x = 0,1554+ .y = 0,1555+ },1556 .lines = 15,1557 .chars = 30,1558 .tabs = 8,1559 .pad = {103 unmodified linesmodified:config.h+5 added
129 unmodified lines130 } dmenu;131 132 enum anchors anchor;133 134+ struct {135+ unsigned x;136+ unsigned y;137+ } margin;138+139 unsigned lines;140 unsigned chars;141 unsigned tabs; /* Tab stop every number of #spaces */142 40 unmodified linesmodified:fuzzel.ini+2 added
12 unmodified lines13 # launch-prefix=<not set>14 # list-executables-in-path=no15 16 # anchor=center17+# x-margin=018+# y-margin=019 # lines=1520 # width=3021 # tabs=822 # horizontal-pad=4075 unmodified linesmodified:main.c+28 added
265 unmodified lines266 " -T,--terminal terminal command to use when launching\n"267 " 'terminal' programs, e.g. \"xterm -e\".\n"268 " Not used in dmenu mode (not set)\n"269 " -a,--anchor window anchor (center)\n"270+ " --x-margin=MARGIN horizontal margin, in pixels (0)\n"271+ " --y-margin=MARGIN vertical margin, in pixels (0)\n"272 " --select=STRING select first entry that matches the given string\n"273 " -l,--lines number of matches to show\n"274 " -w,--width window width, in characters (margins and\n"275 " borders not included)\n"298 unmodified lines574 #define OPT_FILTER_DESKTOP 274575 #define OPT_CHECK_CONFIG 275576 #define OPT_SELECT 276577 #define OPT_LIST_EXECS_IN_PATH 277578+ #define OPT_X_MARGIN 278579+ #define OPT_Y_MARGIN 279580 581 static const struct option longopts[] = {582 {"config", required_argument, 0, OPT_CONFIG},583 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},4 unmodified lines588 {"no-icons", no_argument, 0, 'I'},589 {"fields", required_argument, 0, 'F'},590 {"password", optional_argument, 0, OPT_PASSWORD},591 {"anchor", required_argument, 0, 'a'},592+ {"x-margin", required_argument, 0, OPT_X_MARGIN},593+ {"y-margin", required_argument, 0, OPT_Y_MARGIN},594 {"select", required_argument, 0, OPT_SELECT},595 {"lines", required_argument, 0, 'l'},596 {"width", required_argument, 0, 'w'},597 {"tabs", required_argument, 0, OPT_TABS},52 unmodified lines650 bool dpi_aware_set:1;651 bool match_fields_set:1;652 bool icons_disabled_set:1;653 bool anchor_set:1;654+ bool x_margin_set : 1;655+ bool y_margin_set : 1;656 bool lines_set:1;657 bool chars_set:1;658 bool tabs_set:1;659 bool pad_x_set:1;200 unmodified lines860 cmdline_overrides.anchor_set = true;861 break;862 }863 864+ case OPT_X_MARGIN:865+ if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.x) != 1) {866+ fprintf(stderr, "%s: invalid horizontal margin\n", optarg);867+ return EXIT_FAILURE;868+ }869+ cmdline_overrides.x_margin_set = true;870+ break;871+872+ case OPT_Y_MARGIN:873+ if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.y) != 1) {874+ fprintf(stderr, "%s: invalid vertical margin\n", optarg);875+ return EXIT_FAILURE;876+ }877+ cmdline_overrides.y_margin_set = true;878+ break;879+880 case OPT_SELECT:881 select = optarg;882 break;883 429 unmodified lines1313 if (cmdline_overrides.icons_disabled_set)1314 conf.icons_enabled = cmdline_overrides.conf.icons_enabled;1315 if (cmdline_overrides.anchor_set)1316 conf.anchor = cmdline_overrides.conf.anchor;1317+ if (cmdline_overrides.x_margin_set)1318+ conf.margin.x = cmdline_overrides.conf.margin.x;1319+ if (cmdline_overrides.y_margin_set)1320+ conf.margin.y = cmdline_overrides.conf.margin.y;1321 if (cmdline_overrides.lines_set)1322 conf.lines = cmdline_overrides.conf.lines;1323 if (cmdline_overrides.chars_set)1324 conf.chars = cmdline_overrides.conf.chars;275 unmodified linesmodified:wayland.c+4 added
1362 unmodified lines1363 1364 zwlr_layer_surface_v1_set_size(1365 wayl->layer_surface, wayl->width / scale, wayl->height / scale);1366 1367+ zwlr_layer_surface_v1_set_margin(1368+ wayl->layer_surface, wayl->conf->margin.y, wayl->conf->margin.x,1369+ wayl->conf->margin.y, wayl->conf->margin.x);1370+1371 zwlr_layer_surface_v1_set_anchor(1372 wayl->layer_surface, wayl->conf->anchor);1373 1374 /* Trigger a 'configure' event, after which we'll have the actual width+height */1002 unmodified lines