`ncuses-6.3` added printf-style function attributes and now makes
it easier to catch cases when user input is used in palce of format
string when built with CFLAGS=-Werror=format-security:
lib/renderers/curses/curses.c:234:9:
error: format not a string literal and no format arguments [-Werror=format-security]
234 | mvprintw(0, 0, menu->title);
| ^~~~~~~~
Let's wrap all the missing places with "%s" format.
This caused issue when using the -b (bottom) and -l (line) arguments on
scaled outputs.
When using a scaled output, the set_size use a wrong value as height.
We generated a scalled buffer so we used a scale x too high size.
We just have to divide the scaling to use a good size.
On most systems it's fairly uncommon to have hidden files within
`$PATH`, but in case of NixOS this is fairly regularly the case as we
have the convention to add `foo` and `.foo-wrapped` to a `bin`-directory
if `foo` is supposed to be a wrapper which sets e.g. env-vars for the
program.
These `.foo-wrapped`-executables are almost never needed, but are shown
in `bemenu` right at the start, so I modified the selection code to skip
hidden files which is also what `dmenu` does for instance.
This seems to be broken at least on some terminals and the high bit
toggle corrupts input. In addition there was printf for the esc/alt key
detection that can break the UI.
Neovim seems to have noncompatible way of detecting alt, so I think
neovim should be looked for proper way for handling this.
Previously, any seat without a keyboard could destroy our selected
keyboard. Now, select by seat instead and only destroy the keyboard if
it vanishes from that seat. This isn't actually multi-seat support, but
at least it will allow bemenu to accept input.
This adds an alias 'focused' for selecting the current monitor, which
becomes the default on x11 and wayland. The previous wayland default of
displaying on all outputs moves under '-2' or 'all'.
ref: https://github.com/Cloudef/bemenu/issues/102#issuecomment-604562234
Signed-off-by: Robert Günzler <r@gnzler.io>
With dmenu, monitor indices start at 0 and a value of -1 (the default)
is used to spawn dmenu on the current monitor. While bemenu strives to
be compatible with dmenu, bemenu monitor indices previously started at 1
and a value of 0 (the default) was used to spawn on the current monitor.
This commit aligns the behaviour of bemenu's x11 backend with dmenu. For
this purposes, the affected code in the x11 backend is synced with the
current dmenu implementation. While doing so the monitor type has also
been switched from a uint32_t to a int32_t.
The previous version of this code operated under the assumption that
getline(3) lines are always \n\0 terminated. Unfortunately, this is not
the case as readline will return input which is not terminated with a
newline character if EOF is reached before encountering this newline. In
these cases, the code would falsely strip the last character. As an
example, consider the following bemenu invocation:
printf foo | ./bemenu
This would start bemenu with `fo` instead of `foo` as a menu item. This
commit fixes this edge case and also hardens the loop body a bit by only
entering it if getline wrote more than zero characters to the buffer.
Not sure why the code didn't use this function previously, but
getline(3) is mandatory since POSIX.1-2008 and should thus be supported
by all maintstream operating systems. The proposed changes make the code
easier to read and should also make it more efficient memory-wise as it
does not necessarily cause the entire input to be copied into memory at
once.
- Much of the existing text was reworded for better understandability.
- The new manpage uses mdoc(7) for better formatting.
Because of this, we can merge bemenu and bemenu-run into a single
file.