Commit graph

309 commits

Author SHA1 Message Date
Craig Barnes
0e5e68d82e main: improve handling of setlocale(3) return value
There's no need to call setlocale() twice, since the first call
returns the same value as the second.

We also handle a NULL return value explicitly and show a distinct
error message for that case, since it typically indicates a
misconfigured locale and not just a non-UTF8 locale.
2021-11-10 17:41:48 +00:00
Ronan Pigott
99d5bf64bc foot/client: implement xdga client activation
This is an application of the xdg activation protocol that will allow
compositors to associate new foot toplevels with the command that
launched them.

footclient receives an activation token from the launcher which the
compositor can use to track application startup. It passes the token
to the foot server, which then activates the new window with the token
to complete the startup sequence.
2021-10-31 18:52:29 -07:00
Daniel Eklöf
3155ab45fe
foot/client: version info: add +/- assertions 2021-10-23 15:40:54 +02:00
Craig Barnes
ef7919e64d main/client: add no-op "-e" command-line option 2021-09-18 23:40:40 +01:00
Craig Barnes
537cd9b367 main/client: replace some uses of printf() with puts() in print_usage()
FOOT_DEFAULT_TERM is a string literal passed as a -D argument to
the compiler, so it can just be concatenated with the other string
literals, instead of being formatted with printf().
2021-09-18 19:44:04 +01:00
Daniel Eklöf
8ffc556d44
main: verify primary font is monospaced at startup
Load a couple of ASCII glyphs and check if their advance widths
matches. If not, warn the user that the font is probably not
monospaced.

This can be disabled by setting tweak.font-monospace-warn=no.

Closes #704.
2021-08-31 19:58:35 +02:00
Daniel Eklöf
7639186865
terminfo: install to $datadir/foot/terminfo by default, append to TERMINFO_DIRS
As of 2021-07-31, ncurses ships its own version of foot’s terminfo.

Since:

* It doesn’t have the non-standard Sync,Tc,setrgbf,setrgbb
  capabilities.
* It doesn’t set hs,fsl,dsl (statusbar).
* We want to be able to update our termminfo without waiting for an
  ncurses release.
* Foot should be installable and usable on Linux systems that doesn’t
  have the latest ncurses.

we still want to ship our own version. We can however not install it
to the default terminfo location (e.g. /usr/share/terminfo), since it
will collide with the ncurses provided files.

Our options are to either rename our terminfo to something else, or to
keep the name, but install our terminfo files somewhere else.

The first option would be the easy one. However, I think it makes
sense to use the same name. For example, a user that SSH’s into a
remote system that does *not* have our own version installed,
but *does* have the ncurses one, will gracefully fall back to that
one, which is better than manually having to set
e.g. TERM=xterm-256color.

Now, if we want to use the same name, we need to install it somewhere
else. But where? And how do we ensure our version is preferred over
the ncurses one?

I opted to $datadir/foot/terminfo (e.g. /usr/share/foot/terminfo) by
default. It makes it namespaced to foot (i.e. we’re not introducing a
new “standard” terminfo location), thus guaranteeing it wont collide
with ncurses.

To enable applications to find it, we export TERMINFO_DIRS. This is a
list of *additional* directories to search for terminfo files. If it’s
already defined, we *append* to it.

The nice thing with this is, if there’s no terminfo in that
location (e.g. when you SSH into a remote), the default terminfo
location is *also* searched. But only *after* having searched through
TERMINFO_DIRS.

In short: our version is preferred, but the ncurses one (or an older
version of our terminfo package!) will be used if ours cannot be
found.

To enable packagers full control over the new behavior, the existing
meson command line options have been modified, and a new option added:

-Dterminfo=disabled|enabled|auto: *build* and *install* the terminfo
files.

-Dcustom-terminfo-install-location=<path>: *where* the terminfo files
are expected to be found.

This *needs* to be set *even* if -Dterminfo=disabled. For example, if
the packaging script builds and packages the terminfo files separate
from the regular foot build. The path is *relative to $prefix*, and
defaults to $datadir/foot/terminfo.

This is the value that will be appended to TERMINFO_DIRS. Note that
you can set it to ‘no’, in which case foot will *not* set/modify
TERMINFO_DIRS. Only do this if you don’t intend to package foot’s
terminfo files at all (i.e. you plan on using the ncurses ones only).

-Ddefault-terminfo=foot. Allows overriding the default TERM
value. This should only be changed if the target platform doesn’t
support terminfo files.

Closes #671
2021-08-17 21:04:30 +02:00
Craig Barnes
5dca0458a0 log: add LOG_CLASS_NONE and use as initializer for log_level
This means that logging will be completely disabled until log_init()
has been called, which is useful to prevent log spam when running
UNITTEST{} blocks in debug builds.

Note that this doesn't change the default log level at runtime, which
was already being set to LOG_CLASS_INFO in main.c and client.c.

The new log level is also exposed to the command-line interface as
`--log-level=none`, which allows disabling logging entirely.
2021-06-26 22:15:09 +01:00
Daniel Eklöf
a319ddf094
foot: add +/-graphemes to version output 2021-06-24 17:50:30 +02:00
Daniel Eklöf
c6b5ac9299
main: usage: add ‘=’ between --override and its value
This is how all other long options are documented in the usage.
2021-06-23 15:12:08 +02:00
Daniel Eklöf
495c730487
config: don’t use tllist where it isn’t necessary
tllists are great when dealing with dynamically changing lists. They
are also very easy to use when building lists/arrays where the final
size is unknown.

However, this ease of use comes at a price: code size. tll-macros
expand to a lot of code.

Since things in the config are static, once the config has been
loaded, using tllists for configuration data structures doesn’t make
much sense.

This patch replaces nearly all tllists used by the configuration, with
dynamically allocated arrays.
2021-06-18 15:35:57 +02:00
Ryan Farley
f379ffb8ed Override options from command line
Allow any configuration option to be overridden with -o/--override
'section.key=value' arguments, as suggested in #554

update completitions for override

slight refactoring to ease footclient support
2021-06-12 03:05:15 -05:00
Daniel Eklöf
da923100ca
main/client: change exit code
* foot exits with -26/230
* footclient exits with -36/220

This is to give each application a range of exit codes. Currently
unused, but we may want to change this in the future.
2021-05-04 10:41:22 +02:00
Daniel Eklöf
a1b41bd186
foot/footclient: use a custom exit code when foot/footclient fail to run
Normally, foot and footclient uses the exit code from the client
application (i.e. the shell).

However, foot (or footclient) itself may fail to run; if run outside
of a Wayland session, or no fonts are installed, or the client
application/shell cannot be found (“foot lsdjfldsjf”) etc.

Up until now, there has been no way to differentiate these kind of
failures from the client application exiting with code 1.

This patch changes foot’s failure exit code to -27/229, and
footclient’s to -28/228. Note that footclient will exit with foot’s
-27/229 if footclient ran successfully, but the foot server failed to
instantiate a new window.

Closes #466.
2021-05-04 10:40:38 +02:00
Daniel Eklöf
40686303ef
main: explicitly cast log_colorize to enum fcft_log_colorize
Fixes error in Clang builds:

  ../../foot/main.c:376:19: error: implicit conversion from enumeration type 'enum log_colorize' to different enumeration type 'enum fcft_log_colorize' [-Werror,-Wenum-conversion]
      fcft_log_init(log_colorize, as_server && log_syslog, log_level + 1);
      ~~~~~~~~~~~~~ ^~~~~~~~~~~~
2021-04-17 20:09:39 +02:00
Daniel Eklöf
353c2f012a
main: call fcft_log_init(). Note that this requires fcft >= 2.3.90 2021-04-17 19:31:17 +02:00
Daniel Eklöf
9b20764f35
features: --version now logs +/-pgo
That is, whether the binary was compiled with PGO or not.
2021-03-26 20:30:13 +01:00
Chloe Kudryavtsev
80b95eeb7e
config: reuse HAVE_TERMINFO via DEFAULT_TERM
add detection in --help output
also make it more easily accessible for other locations to change
2021-02-26 15:15:05 +01:00
Daniel Eklöf
c600e131e2
main: initialize pseudo-random generator 2021-02-21 20:14:51 +01:00
Daniel Eklöf
f896f12967
main: -D,--working-directory: check path exists and is a directory 2021-02-13 10:48:31 +01:00
Daniel Eklöf
19868c9c8d
main/client: add -D,--working-directory=DIR
This overrides the CWD the slave process chdir()’s into before
exec:ing the client application.
2021-02-12 21:42:53 +01:00
Daniel Eklöf
59b127dc69
main/client: add missing short options to usage (--help output)
Initially, these options *did not* have short options. Then, in
e813883367, the short options were added
to footclient’s getopt_long() call.

This was in a sense incorrect. But instead of reverting it, the short
options were made official in
8eaa195990, by adding the short options
to foot, documenting them in the man pages, and adding them to the
shell completions.

Though the commit message of 8eaa195990
says the options have now been included in usage(), they were in
fact *not* added to usage.

This patch does just that.
2021-02-12 09:02:25 +01:00
Daniel Eklöf
da7da4cba5
Merge branch 'log-level'
Closes #337
2021-02-11 19:00:09 +01:00
Daniel Eklöf
7c3a126b22
main: monitor SIGINT+SIGTERM using the FDM 2021-02-11 18:55:30 +01:00
Craig Barnes
5437321f97 main: client: factor out some common code for "--log-level" option 2021-02-11 11:08:18 +00:00
Daniel Eklöf
ca3974cc24
main: add -d,--log-level=[debug,info,warning,error] 2021-02-09 21:22:16 +01:00
Daniel Eklöf
0d012db3a8
main: include uname.sysname when logging host architecture 2021-02-07 10:24:48 +01:00
Jan Beich
3c379b243b
main: correct header for mode macros
main.c:13:10: fatal error: 'sys/sysinfo.h' file not found
 #include <sys/sysinfo.h>
          ^~~~~~~~~~~~~~~
main.c:122:28: error: use of undeclared identifier 'S_IRUSR'
                           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
                           ^
main.c:122:38: error: use of undeclared identifier 'S_IWUSR'
                           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
                                     ^
main.c:122:48: error: use of undeclared identifier 'S_IRGRP'
                           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
                                               ^
main.c:122:58: error: use of undeclared identifier 'S_IROTH'
                           S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
                                                         ^
2021-01-21 12:00:02 +01:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Craig Barnes
3f4cfa338b Add xsnprintf() and remove some unnecessary strlen(3) calls 2021-01-14 21:30:06 +00:00
Craig Barnes
0791fba9c7 main: remove deprecated "--geometry" option
Closes #287
2021-01-13 20:01:05 +00:00
Daniel Eklöf
0d6b5f522e
config_font_parse(): return fail/success 2020-12-15 18:55:27 +01:00
Daniel Eklöf
77bc7c8b2c
features: include compile-time enable/disable state of features when printing version 2020-12-07 20:44:11 +01:00
Craig Barnes
adde947fc5 config: replace union in config struct with simple width/height members 2020-11-30 02:24:38 +00:00
Daniel Eklöf
addc374655
main: tag fdm loop with likely() and unlikely() 2020-11-26 18:23:28 +01:00
Daniel Eklöf
8eaa195990
foot/footclient: add short options to all command line options
e813883367 added “missing” short command
line options to footclient.

Except they weren’t missing; they were intentionally missing short
options and only supported long options.

This commit makes the new/missing short options “official”, by adding
documentation, zsh completions and including them in usage().
2020-11-23 19:19:19 +01:00
Daniel Eklöf
2928ef5fbe
main: remove trailing ‘, ’ from arch log line 2020-10-25 19:27:57 +01:00
Daniel Eklöf
2c101a21ee
config: add font-bold, font-italic and font-bold-italic options
These options lets the user configure custom fonts and styles, to use
with the bold and italic cell attributes.

By default, they are unset, meaning we use the bold/italic variants of
the regular font.

Closes #169.
2020-10-20 21:04:47 +02:00
Daniel Eklöf
4d17c23224
main: configure locale *before* loading the config
Without this, config_load() can’t use wide-character functions
properly.
2020-10-09 19:45:26 +02:00
Daniel Eklöf
51a7e44fa2
config: add tweak.scaling-filter
Use the new fcft_set_scaling_filter() API to use a non-default scaling
filter.

By default, we use lanczo3, the ‘best’ filter. This overrides the
default in fcft, which is ‘cubic’ filtering.
2020-09-13 17:59:56 +02:00
Daniel Eklöf
eb6737ca25
Add -W,--window-size-chars, and foot.ini:initial-window-size-chars
* Add -W,--window-size-chars command line option
* Add initial-window-size-chars foot.ini option
* Add -w,--window-size-pixels command line option
* Add initial-window-size-pixels foot.ini option
* Deprecate -g,--geometry command line option in favor of
  -w,--window-size-pixels
* Deprecate geometry option in foot.ini in favor of
  initial-window-size-pixels
2020-09-08 19:41:00 +02:00
Daniel Eklöf
df35b09142
main: usage: footrc -> foot.ini 2020-08-27 20:03:30 +02:00
Daniel Eklöf
6f5f7f1411
main: include our own bitness when logging the architecture 2020-08-11 17:23:10 +02:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
5e26d3ef47
server/client: use $WAYLAND_DISPLAY instead of $XDG_SESSION_ID in default socket path
Foot is a Wayland client and cannot be run outside of a Wayland
session. As such, it makes more sense to use $WAYLAND_SESSION instead
of $XDG_SESSION_ID in the default socket path since this makes it
clearer which Wayland session we belong to.

Closes #55.
2020-08-02 13:10:31 +02:00
Daniel Eklöf
387e8de751
main: update --help with correct default path for -s,--server
I missed this in f3c301ee8b when fixing
2020-08-02 12:41:48 +02:00
Daniel Eklöf
b00dfcf7b6
config: configuration errors are no longer fatal
Instead of refusing to start foot on configuration errors, we start
and print a user-notification.
2020-07-31 17:07:14 +02:00
Daniel Eklöf
86e7cb04c4
main: add --check-config command line option 2020-07-29 17:48:22 +02:00
Daniel Eklöf
74c3b4be1a
main: free 'cwd' at exit
This fixes an issue where e.g. failing to initialize the Wayland
backend would leave cwd un-free:d
2020-07-13 14:17:55 +02:00
Daniel Eklöf
69e4213e4a
term: don't use deprecated fcft_size_adjust()
When resizing the font on-the-fly, we now do a complete
font-reload (this is basically what fcft_size_adjust() did anyway).

To get the correct size, we maintain the current size ourselves.

We get the initial size from the user-provided font pattern, by
converting the string to an FcPattern, and using FcPatternGet() to
retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These
attributes are then removed from the pattern, and the pattern is
converted back to a string.

The terminal struct maintains a copy of the font sizes. These are
initially set to the sizes from the config.

When the user resizes the font, the terminal-local sizes are
adjusted. To ensure the primary and user-configured fallback fonts are
resizes equally much, convert any pixel sizes to point sizes at this
point.

When the font size is reset, we reload the font sizes from the
config (thus once again returning actual pixel-sizes, if that's what
the user has configured).
2020-07-07 10:44:55 +02:00