(削除) Only works from ini file, there's a problem with cmdline parsing fixed by subsequent commit(s)
I need to find and fix. (削除ここまで)
Initial anchor support #213
jficz/fuzzel:add-window-anchor into master Only works from ini file, there's a problem with cmdline parsing I need to find and fix.
fixes #130
Did a few tests, so far no apparent issues.
Updated man and ini docs.
Probably needs more polishing but works well (enough).
Nice, thanks!
In addition to the changes below, can you also add a CHANGELOG entry?
@ -42,0 +64,4 @@
{"bottom-left", ANCHOR_BOTTOM_LEFT},
{"bottom", ANCHOR_BOTTOM},
{"bottom-right", ANCHOR_BOTTOM_RIGHT},
};
Please move this to config.c, to avoid a copy of it being instantiated in every .c file that includes config.h. Also please make the name member const.
I'd also prefer if you could down-case the variable name. Upper case is usually "reserved" for enum values and macros.
To make it externally visible (for command line parsing), remove static, and add an extern declaration in the header file. There's a small down side to this: you can't use sizeof() on it, outside of config.c. A simple workaround is to terminate the list with a NULL entry (see below).
config.h:
struct anchors_map {
const char *name;
enum anchors value;
};
extern const struct anchors_map anchors_map[];
config.c:
const struct anchors_map anchors_map[] = {
{"top-left", ANCHOR_TOP_LEFT},
...
{NULL, 0},
};
To iterate it in e.g. main.c:
for (size_t i = 0; anchors_map[i].name != NULL; i++) {
...
}
@ -106,2 +106,4 @@
Default: _not set_.
*-a*,*--anchor*=ANCHOR
The window anchor. Default: _center_.
I think we should list all the allowed values here.
@ -245,6 +245,7 @@ print_usage(const char *prog_name)
" -T,--terminal terminal command to use when launching\n"
" 'terminal' programs, e.g. \"xterm -e\".\n"
" Not used in dmenu mode (not set)\n"
" -a,--anchor window anchor (top, bottom, left, right and combinations)"
I would suggest removing the top, bottom ... examples, and instead mention the default value:
window anchor (center)
This is similar to how other options are handled.
I was thinking the anchoring in addition to an option for an invisible external margin would be cool. This would prevent potential overlap with bars and allow for some breathing room from the edge of the screen. Not sure if this feasible as I'm not familiar with C or how Wayland deals with windows, but wanted to throw the idea out.
I was thinking the anchoring in addition to an option for an invisible external margin would be cool. This would prevent potential overlap with bars and allow for some breathing room from the edge of the screen. Not sure if this feasible as I'm not familiar with C or how Wayland deals with windows, but wanted to throw the idea out.
Sure, it's possible to set anchor margins in Wayland. And I agree that'd be nice to have as well.
Note that bars usually set an exclusion zone, meaning nothing should ever overlap with them anyway.
* Update anchors_map iteration logic * Update documentation * Add changelog entry
@dnkl made the changes you requested (finally :) )
Mostly looking good, but I do have a couple of nits, see below.
I'd also like to see the new command line option being added to the shell completions (completions/*).
@ -778,0 +795,4 @@
anchor = anchors_map[i].value;
break;
}
}
There's a value_to_enum() function in config.c that you should be able to use here.
sorry, I'm a bit slower lately - what would I use the function for?
so I gave it another thought and I think that unless I want to statically enumerate all the options (again!) in the code, the function value_to_enum() doesn't really help here. But the idea itself is good so I went on with a little experiment, which resulted in this: jficz/fuzzel@10c5d9370d
It's a rather large change in the codebase outside the scope of this MR and it's probably pretty bad, but it allows for ultimately cleaner code without duplicated static arrays of strings in the middle of the code and also allows better code reuse outside of config.c.
off topic: I found the name of the function confusing and I'd suggest to rename the function to value_in_enum() or perhaps even more accurately value_from_enum() but that would require a lot of refactoring since there are other functions with the same naming logic.
Let's keep it as is for now :)
@ -108,0 +117,4 @@
- _bottom-left_
- _bottom_
- _bottom-right_
I would suggest copying the description from fuzzel.ini.
zsh completion tested and working, fish untested
Thanks!
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?