From 28730438650e510105a4bff00e24552dac295e0c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 25 Jun 2021 10:23:43 +0200 Subject: doc: benchmarks: update desktop results with 1.8.0 --- doc/benchmark-results-desktop.svg | 550 ++++++++++++++++++++++++++++++++++++++ doc/benchmark.md | 37 ++- 2 files changed, 567 insertions(+), 20 deletions(-) create mode 100644 doc/benchmark-results-desktop.svg (limited to 'doc') diff --git a/doc/benchmark-results-desktop.svg b/doc/benchmark-results-desktop.svg new file mode 100644 index 00000000..aac846c8 --- /dev/null +++ b/doc/benchmark-results-desktop.svg @@ -0,0 +1,550 @@ + + + +Gnuplot +Produced by GNUPLOT 5.4 patchlevel 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 200 + + + + + 400 + + + + + 600 + + + + + 800 + + + + + 1000 + + + + + 1200 + + + + + 1400 + + + + + cursor_motion + + + + + dense_cells + + + + + light_cells + + + + + scrolling + + + + + scrolling_bottom_region + + + + + scrolling_bottom_small_region + + + + + scrolling_fullscreen + + + + + scrolling_top_region + + + + + scrolling_top_small_region + + + + + unicode + + + + + + + + + milliseconds (lower is better) + + + + + gnuplot_plot_1 + + + foot-pgo + + + + + + + + + + gnuplot_plot_2 + + + + + + + gnuplot_plot_3 + + + + + + + gnuplot_plot_4 + + + + + + + gnuplot_plot_5 + + + + + + + gnuplot_plot_6 + + + + + + + gnuplot_plot_7 + + + + + + + gnuplot_plot_8 + + + + + + + gnuplot_plot_9 + + + + + + + gnuplot_plot_10 + + + + + + + gnuplot_plot_11 + + + foot-no-pgo + + + + + + + + + + gnuplot_plot_12 + + + + + + + gnuplot_plot_13 + + + + + + + gnuplot_plot_14 + + + + + + + gnuplot_plot_15 + + + + + + + gnuplot_plot_16 + + + + + + + gnuplot_plot_17 + + + + + + + gnuplot_plot_18 + + + + + + + gnuplot_plot_19 + + + + + + + gnuplot_plot_20 + + + + + + + gnuplot_plot_21 + + + alacritty + + + + + + + + + + gnuplot_plot_22 + + + + + + + gnuplot_plot_23 + + + + + + + gnuplot_plot_24 + + + + + + + gnuplot_plot_25 + + + + + + + gnuplot_plot_26 + + + + + + + gnuplot_plot_27 + + + + + + + gnuplot_plot_28 + + + + + + + gnuplot_plot_29 + + + + + + + gnuplot_plot_30 + + + + + + + gnuplot_plot_31 + + + urxvt + + + + + + + + + + gnuplot_plot_32 + + + + gnuplot_plot_33 + + + + + + + gnuplot_plot_34 + + + + + + + gnuplot_plot_35 + + + + + + + gnuplot_plot_36 + + + + + + + gnuplot_plot_37 + + + + + + + gnuplot_plot_38 + + + + + + + gnuplot_plot_39 + + + + + + + gnuplot_plot_40 + + + + + + + gnuplot_plot_41 + + + xterm + + + + + + + + + + gnuplot_plot_42 + + + + gnuplot_plot_43 + + + + + + + gnuplot_plot_44 + + + + gnuplot_plot_45 + + + + gnuplot_plot_46 + + + + gnuplot_plot_47 + + + + + + + gnuplot_plot_48 + + + + gnuplot_plot_49 + + + + gnuplot_plot_50 + + + + + + + + + + + + + + + + diff --git a/doc/benchmark.md b/doc/benchmark.md index 244f25b9..0510b7ce 100644 --- a/doc/benchmark.md +++ b/doc/benchmark.md @@ -5,20 +5,10 @@ All benchmarks are done using [vtebench](https://github.com/alacritty/vtebench): ```sh -vtebench -h $(tput lines) -w $(tput cols) -b 104857600 alt-screen-random-write > ~/alt-random -vtebench -c -h $(tput lines) -w $(tput cols) -b 104857600 alt-screen-random-write > ~/alt-random-colors -vtebench -h $(tput lines) -w $(tput cols) -b 10485760 scrolling > ~/scrolling -vtebench -h $(tput lines) -w $(tput cols) -b 104857600 scrolling --fill-lines > ~/scrolling-filled-lines -vtebench -h $(tput lines) -w $(tput cols) -b 10485760 unicode-random-write > ~/unicode-random +./target/release/vtebench -b ./benchmarks ``` -They were "executed" using [benchmark.py](../scripts/benchmark.py), -which will load each file into memory, and then print it to the -terminal. This is done **20** times for each test. Then it calculates -the _mean_ and _standard deviation_ for each test. - - -## 2021-03-20 +## 2021-06-25 ### System @@ -40,14 +30,21 @@ Scrollback: 10000 lines ### Results - -| Benchmark | Foot (GCC+PGO) 1.7.0.r2 | Foot 1.7.0.r2 | Alacritty 0.7.2 | URxvt 9.22 | XTerm 366 | -|------------------------|------------------------:|--------------:|-------------------:|---------------:|---------------:| -| alt-random | 0.382s ±0.003 | 0.550s ±0.007 | 0.995s ±0.010 | 1.201s ±0.006 | 12.756s ±0.045 | -| alt-random-colors | 0.380s ±0.002 | 0.543s ±0.003 | 1.017s ±0.013 | 1.399s ±0.018 | 11.591s ±0.141 | -| scrolling | 1.302s ±0.019 | 1.284s ±0.052 | 1.107s ±0.028 | 1.097s ±0.015 | 37.537s ±0.121 | -| scrolling-filled-lines | 0.646s ±0.016 | 0.610s ±0.003 | 1.290s ±0.012 | 1.325s ±0.037 | 6.817s ±0.084 | -| unicode-random | 0.167s ±0.001 | 0.276s ±0.445 | 0.097s ±0.002 [^1] | 18.032s ±0.334 | 29.731s ±3.746 | +| Benchmark (times in ms) | Foot (GCC+PGO) 1.8.0 | Foot 1.8.0 | Alacritty 0.8.0 | URxvt 9.26 | XTerm 368 | +|-------------------------------|---------------------:|-----------:|----------------:|-----------:|----------:| +| cursor motion | 12.93 | 15.37 | 26.47 | 23.41 | 1304.00 | +| dense cells | 39.16 | 47.19 | 87.26 | 9110.00 | 10883.00 | +| light cells | 5.34 | 6.42 | 12.76 | 16.00 | 60.00 | +| scrollling | 144.26 | 139.93 | 133.98 | 117.52 | 3772.67 | +| scrolling bottom region | 130.81 | 125.34 | 116.10 | 117.31 | 3574.67 | +| scrolling bottom small region | 142.46 | 127.52 | 127.32 | 135.18 | 3572.67 | +| scrolling fullscreen | 5.43 | 5.27 | 12.06 | 11.97 | 118.62 | +| scrolling top region | 129.05 | 120.24 | 121.65 | 341.70 | 3567.33 | +| scrolling top small region | 121.59 | 109.82 | 137.03 | 219.96 | 3558.67 | +| unicode | 12.03 | 11.95 | 13.94 | 667.67 | 4905.67 | + + +![Graph of benchmark results for a beefy desktop system](benchmark-results-desktop.svg) ## 2021-03-20 -- cgit v1.3 From e365ac0b10686450329462aa3dac98b54e8d9b8e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 25 Jun 2021 10:24:55 +0200 Subject: doc: benchmark: add --dat to vtebench command line --- doc/benchmark.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/benchmark.md b/doc/benchmark.md index 0510b7ce..73573cc9 100644 --- a/doc/benchmark.md +++ b/doc/benchmark.md @@ -5,7 +5,7 @@ All benchmarks are done using [vtebench](https://github.com/alacritty/vtebench): ```sh -./target/release/vtebench -b ./benchmarks +./target/release/vtebench -b ./benchmarks --dat /tmp/ ``` ## 2021-06-25 -- cgit v1.3 From d206697001a8567f567c4313b313ce4968838283 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 25 Jun 2021 10:56:40 +0200 Subject: doc: benchark: laptop results for 1.8.0 --- doc/benchmark-results-laptop.svg | 572 +++++++++++++++++++++++++++++++++++++++ doc/benchmark.md | 43 +-- 2 files changed, 586 insertions(+), 29 deletions(-) create mode 100644 doc/benchmark-results-laptop.svg (limited to 'doc') diff --git a/doc/benchmark-results-laptop.svg b/doc/benchmark-results-laptop.svg new file mode 100644 index 00000000..df8a3ad7 --- /dev/null +++ b/doc/benchmark-results-laptop.svg @@ -0,0 +1,572 @@ + + + +Gnuplot +Produced by GNUPLOT 5.4 patchlevel 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + 200 + + + + + 400 + + + + + 600 + + + + + 800 + + + + + 1000 + + + + + 1200 + + + + + 1400 + + + + + 1600 + + + + + 1800 + + + + + 2000 + + + + + cursor_motion + + + + + dense_cells + + + + + light_cells + + + + + scrolling + + + + + scrolling_bottom_region + + + + + scrolling_bottom_small_region + + + + + scrolling_fullscreen + + + + + scrolling_top_region + + + + + scrolling_top_small_region + + + + + unicode + + + + + + + + + milliseconds (lower is better) + + + + + gnuplot_plot_1 + + + foot-pgo + + + + + + + + + + gnuplot_plot_2 + + + + + + + gnuplot_plot_3 + + + + + + + gnuplot_plot_4 + + + + + + + gnuplot_plot_5 + + + + + + + gnuplot_plot_6 + + + + + + + gnuplot_plot_7 + + + + + + + gnuplot_plot_8 + + + + + + + gnuplot_plot_9 + + + + + + + gnuplot_plot_10 + + + + + + + gnuplot_plot_11 + + + foot-no-pgo + + + + + + + + + + gnuplot_plot_12 + + + + + + + gnuplot_plot_13 + + + + + + + gnuplot_plot_14 + + + + + + + gnuplot_plot_15 + + + + + + + gnuplot_plot_16 + + + + + + + gnuplot_plot_17 + + + + + + + gnuplot_plot_18 + + + + + + + gnuplot_plot_19 + + + + + + + gnuplot_plot_20 + + + + + + + gnuplot_plot_21 + + + alacritty + + + + + + + + + + gnuplot_plot_22 + + + + + + + gnuplot_plot_23 + + + + + + + gnuplot_plot_24 + + + + + + + gnuplot_plot_25 + + + + + + + gnuplot_plot_26 + + + + + + + gnuplot_plot_27 + + + + + + + gnuplot_plot_28 + + + + + + + gnuplot_plot_29 + + + + + + + gnuplot_plot_30 + + + + + + + gnuplot_plot_31 + + + urxvt + + + + + + + + + + gnuplot_plot_32 + + + + + + + gnuplot_plot_33 + + + + + + + gnuplot_plot_34 + + + + + + + gnuplot_plot_35 + + + + + + + gnuplot_plot_36 + + + + + + + gnuplot_plot_37 + + + + + + + gnuplot_plot_38 + + + + + + + gnuplot_plot_39 + + + + + + + gnuplot_plot_40 + + + + gnuplot_plot_41 + + + xterm + + + + + + + + + + gnuplot_plot_42 + + + + gnuplot_plot_43 + + + + + + + gnuplot_plot_44 + + + + gnuplot_plot_45 + + + + gnuplot_plot_46 + + + + gnuplot_plot_47 + + + + + + + gnuplot_plot_48 + + + + gnuplot_plot_49 + + + + gnuplot_plot_50 + + + + + + + + + + + + + + + + diff --git a/doc/benchmark.md b/doc/benchmark.md index 73573cc9..8c1b5f9b 100644 --- a/doc/benchmark.md +++ b/doc/benchmark.md @@ -70,32 +70,17 @@ Scrollback=10000 lines ### Results -| Benchmark | Foot (GCC+PGO) 1.7.0.r2 | Foot (no PGO) 1.7.0.r2 | Alacritty 0.7.2 | URxvt 9.22 | St 0.8.4 | XTerm 366 | -|------------------------|------------------------:|-----------------------:|-------------------:|-----------------:|--------------:|----------------:| -| alt-random | 0.714s ±0.047 | 0.900s ±0.041 | 1.586s ±0.045 | 1.684s ±0.034 | 2.054s ±0.121 | 37.205s ±0.252 | -| alt-random-colors | 0.736s ±0.054 | 0.950s ±0.082 | 1.565s ±0.043 | 2.150s ±0.137 | 2.195s ±0.154 | 33.112s ±0.167 | -| scrolling | 1.593s ±0.070 | 1.559s ±0.055 | 1.517s ±0.079 | 1.462s ±0.052 | 3.308s ±0.133 | 134.432s ±0.436 | -| scrolling-filled-lines | 1.178s ±0.044 | 1.309s ±0.045 | 2.281s ±0.086 | 2.044s ±0.060 | 2.732s ±0.056 | 20.753s ±0.067 | -| unicode-random | 0.349s ±0.009 | 0.352s ±0.007 | 0.148s ±0.010 [^1] | 19.090s ±0.363 | crashed | 15.579s ±0.093 | - -[^1]: [Alacritty and "unicode-random"](#alacritty-and-unicode-random) - - -# Alacritty and "unicode-random" - -Alacritty is actually **really** slow at rendering this (whether it is -fallback fonts in general, emojis, or something else, I don't know). - -I believe the reason it finishes the benchmark so quickly is because -it reads from the PTY in a separate thread, into a larger receive -buffer which is then consumed by the main thread. This allows the -client program to write its output much faster since it is no longer -stalling on a blocked PTY. - -This means Alacritty only needs to render a couple of frames since it -can reach the final VT state almost immediately. - -On the other hand, `cat`:ing the `unicode-random` test file in an -endless loop, or just manually scrolling up after the benchmark is -done is **slow**, which besides being felt (input lag), can be seen by -setting `debug.render_timer = true` in `alacritty.yml`. +| Benchmark (times in ms) | Foot (GCC+PGO) 1.8.0 | Foot 1.8.0 | Alacritty 0.8.0 | URxvt 9.26 | XTerm 368 | +|-------------------------------|---------------------:|-----------:|----------------:|-----------:|----------:| +| cursor motion | 14.49 | 16.60 | 26.89 | 23.45 | 1303.38 | +| dense cells | 41.00 | 52.45 | 92.02 | 1486.57 | 11957.00 | +| light cells | 7.97 | 8.54 | 21.43 | 20.45 | 111.96 | +| scrollling | 158.85 | 158.90 | 148.06 | 138.98 | 10083.00 | +| scrolling bottom region | 153.83 | 151.38 | 142.13 | 151.30 | 9988.50 | +| scrolling bottom small region | 143.51 | 141.46 | 162.03 | 192.37 | 9938.00 | +| scrolling fullscreen | 11.56 | 11.75 | 22.96 | 21.49 | 295.40 | +| scrolling top region | 148.96 | 148.18 | 155.05 | 482.05 | 10036.00 | +| scrolling top small region | 144.26 | 149.76 | 159.40 | 321.69 | 9942.50 | +| unicode | 21.02 | 22.09 | 25.79 | 14959.00 | 88697.00 | + +![Graph of benchmark results for a laptop](benchmark-results-laptop.svg) -- cgit v1.3 From 5dca0458a09ebc586fda49c50533976f055d8de2 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 26 Jun 2021 22:15:09 +0100 Subject: 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. --- CHANGELOG.md | 6 +++ client.c | 32 +++++++------- completions/bash/foot | 2 +- completions/bash/footclient | 2 +- completions/fish/foot.fish | 2 +- completions/fish/footclient.fish | 2 +- completions/zsh/_foot | 2 +- completions/zsh/_footclient | 2 +- config.c | 6 ++- doc/foot.1.scd | 2 +- doc/footclient.1.scd | 2 +- log.c | 90 ++++++++++++++++++++-------------------- log.h | 9 +++- main.c | 49 ++++++++++++---------- 14 files changed, 114 insertions(+), 94 deletions(-) (limited to 'doc') diff --git a/CHANGELOG.md b/CHANGELOG.md index 3934dadf..0e6b7a73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,11 @@ ## Unreleased + ### Added + +* `--log-level=none` command-line option. + ### Changed ### Deprecated ### Removed @@ -40,6 +44,8 @@ ### Security ### Contributors +* [craigbarnes](https://codeberg.org/craigbarnes) + ## 1.8.0 diff --git a/client.c b/client.c index 9764da11..7b5cd770 100644 --- a/client.c +++ b/client.c @@ -58,22 +58,22 @@ print_usage(const char *prog_name) printf("Usage: %s [OPTIONS...] command [ARGS...]\n", prog_name); printf("\n"); printf("Options:\n"); - printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n" - " -T,--title=TITLE initial window title (foot)\n" - " -a,--app-id=ID window application ID (foot)\n" - " -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n" - " -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n" - " -m,--maximized start in maximized mode\n" - " -F,--fullscreen start in fullscreen mode\n" - " -L,--login-shell start shell as a login shell\n" - " -D,--working-directory=DIR directory to start in (CWD)\n" - " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)\n" - " -H,--hold remain open after child process exits\n" - " -N,--no-wait detach the client process from the running terminal, exiting immediately\n" - " -o,--override=[section.]key=value override configuration option\n" - " -d,--log-level={info|warning|error} log level (info)\n" - " -l,--log-colorize=[{never|always|auto}] enable/disable colorization of log output on stderr\n" - " -v,--version show the version number and quit\n"); + printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n" + " -T,--title=TITLE initial window title (foot)\n" + " -a,--app-id=ID window application ID (foot)\n" + " -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n" + " -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n" + " -m,--maximized start in maximized mode\n" + " -F,--fullscreen start in fullscreen mode\n" + " -L,--login-shell start shell as a login shell\n" + " -D,--working-directory=DIR directory to start in (CWD)\n" + " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)\n" + " -H,--hold remain open after child process exits\n" + " -N,--no-wait detach the client process from the running terminal, exiting immediately\n" + " -o,--override=[section.]key=value override configuration option\n" + " -d,--log-level={info|warning|error|none} log level (info)\n" + " -l,--log-colorize=[{never|always|auto}] enable/disable colorization of log output on stderr\n" + " -v,--version show the version number and quit\n"); } static bool NOINLINE diff --git a/completions/bash/foot b/completions/bash/foot index f03a9f53..f9d9d0fd 100644 --- a/completions/bash/foot +++ b/completions/bash/foot @@ -68,7 +68,7 @@ _foot() which fc-list > /dev/null || return 1 COMPREPLY=( $(compgen -W "$(fc-list : family | sed 's/,/\n/g' | uniq | tr -d ' ')" -- ${cur}) ) elif [[ ${prev} == '--log-level' ]] ; then - COMPREPLY=( $(compgen -W "error warning info" -- ${cur}) ) + COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) elif [[ ${prev} == '--log-colorize' ]] ; then COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) elif [[ ${prev} =~ ^(--app-id|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|--check-config)$ ]] ; then diff --git a/completions/bash/footclient b/completions/bash/footclient index 8e0aa017..fea45945 100644 --- a/completions/bash/footclient +++ b/completions/bash/footclient @@ -59,7 +59,7 @@ _footclient() which toe > /dev/null || return 1 COMPREPLY=( $(compgen -W "$(toe -a | awk '$1 ~ /[+]/ {next}; {print $1}')" -- ${cur}) ) elif [[ ${prev} == '--log-level' ]] ; then - COMPREPLY=( $(compgen -W "error warning info" -- ${cur}) ) + COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) elif [[ ${prev} == '--log-colorize' ]] ; then COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) elif [[ ${prev} =~ ^(--app-id|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|)$ ]] ; then diff --git a/completions/fish/foot.fish b/completions/fish/foot.fish index dbec61e7..81c7da61 100644 --- a/completions/fish/foot.fish +++ b/completions/fish/foot.fish @@ -15,7 +15,7 @@ complete -c foot -x -s W -l window-size-chars complete -c foot -F -s s -l server -d "run as server; open terminals by running footclient" complete -c foot -s H -l hold -d "remain open after child process exits" complete -c foot -r -s p -l print-pid -d "print PID to this file or FD when up and running (server mode only)" -complete -c foot -x -s d -l log-level -a "info warning error" -d "log-level (info)" +complete -c foot -x -s d -l log-level -a "info warning error none" -d "log-level (info)" complete -c foot -x -s l -l log-colorize -a "always never auto" -d "enable or disable colorization of log output on stderr" complete -c foot -s S -l log-no-syslog -d "disable syslog logging (server mode only)" complete -c foot -s v -l version -d "show the version number and quit" diff --git a/completions/fish/footclient.fish b/completions/fish/footclient.fish index 9b8caa84..8133f663 100644 --- a/completions/fish/footclient.fish +++ b/completions/fish/footclient.fish @@ -12,7 +12,7 @@ complete -c footclient -F -s s -l server-socket complete -c footclient -s H -l hold -d "remain open after child process exits" complete -c footclient -s N -l no-wait -d "detach the client process from the running terminal, exiting immediately" complete -c footclient -x -s o -l override -d "configuration option to override, in form SECTION.KEY=VALUE" -complete -c footclient -x -s d -l log-level -a "info warning error" -d "log-level (info)" +complete -c footclient -x -s d -l log-level -a "info warning error none" -d "log-level (info)" complete -c footclient -x -s l -l log-colorize -a "always never auto" -d "enable or disable colorization of log output on stderr" complete -c footclient -s v -l version -d "show the version number and quit" complete -c footclient -s h -l help -d "show help message and quit" diff --git a/completions/zsh/_foot b/completions/zsh/_foot index b3f9b42c..0f184cc0 100644 --- a/completions/zsh/_foot +++ b/completions/zsh/_foot @@ -18,7 +18,7 @@ _arguments \ '(-s --server)'{-s,--server}'[run as server; open terminals by running footclient]:server:_files' \ '(-H --hold)'{-H,--hold}'[remain open after child process exits]' \ '(-p --print-pid)'{-p,--print-pid}'[print PID to this file or FD when up and running (server mode only)]:pidfile:_files' \ - '(-d --log-level)'{-d,--log-level}'[log level (info)]:loglevel:(info warning error)' \ + '(-d --log-level)'{-d,--log-level}'[log level (info)]:loglevel:(info warning error none)' \ '(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \ '(-S --log-no-syslog)'{-s,--log-no-syslog}'[disable syslog logging (server mode only)]' \ '(-v --version)'{-v,--version}'[show the version number and quit]' \ diff --git a/completions/zsh/_footclient b/completions/zsh/_footclient index 3889c488..81b2ea95 100644 --- a/completions/zsh/_footclient +++ b/completions/zsh/_footclient @@ -15,7 +15,7 @@ _arguments \ '(-H --hold)'{-H,--hold}'[remain open after child process exits]' \ '(-N --no-wait)'{-N,--no-wait}'[detach the client process from the running terminal, exiting immediately]' \ '(-o --override)'{-o,--override}'[configuration option to override, in form SECTION.KEY=VALUE]:()' \ - '(-d --log-level)'{-d,--log-level}'[log level (info)]:loglevel:(info warning error)' \ + '(-d --log-level)'{-d,--log-level}'[log level (info)]:loglevel:(info warning error none)' \ '(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \ '(-v --version)'{-v,--version}'[show the version number and quit]' \ '(-h --help)'{-h,--help}'[show help message and quit]' \ diff --git a/config.c b/config.c index a95f8485..c417fb19 100644 --- a/config.c +++ b/config.c @@ -103,8 +103,10 @@ log_and_notify(struct config *conf, enum log_class log_class, case LOG_CLASS_INFO: case LOG_CLASS_DEBUG: - BUG("unsupported log class: %d", log_class); - break; + case LOG_CLASS_NONE: + default: + BUG("unsupported log class: %d", (int)log_class); + return; } va_list va1, va2; diff --git a/doc/foot.1.scd b/doc/foot.1.scd index 80203ad9..ab34a2dd 100644 --- a/doc/foot.1.scd +++ b/doc/foot.1.scd @@ -126,7 +126,7 @@ the foot command line This option can only be used in combination with *-s*,*--server*. -*-d*,*--log-level*={*info*,*warning*,*error*} +*-d*,*--log-level*={*info*,*warning*,*error*,*none*} Log level, used both for log output on stderr as well as syslog. Default: _info_. diff --git a/doc/footclient.1.scd b/doc/footclient.1.scd index 8cb05316..a002a899 100644 --- a/doc/footclient.1.scd +++ b/doc/footclient.1.scd @@ -69,7 +69,7 @@ terminal has terminated. Override an option set in the configuration file. If _SECTION_ is not given, defaults to _main_. -*-d*,*--log-level*={*info*,*warning*,*error*} +*-d*,*--log-level*={*info*,*warning*,*error*,*none*} Log level, used both for log output on stderr as well as syslog. Default: _info_. diff --git a/log.c b/log.c index fba53876..9dfc842d 100644 --- a/log.c +++ b/log.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -15,15 +16,19 @@ static bool colorize = false; static bool do_syslog = true; -static enum log_class log_level = LOG_CLASS_INFO; - -static const char log_level_map[][8] = { - [LOG_CLASS_ERROR] = "error", - [LOG_CLASS_WARNING] = "warning", - [LOG_CLASS_INFO] = "info", -#if defined(_DEBUG) - [LOG_CLASS_DEBUG] = "debug", -#endif +static enum log_class log_level = LOG_CLASS_NONE; + +static const struct { + const char name[8]; + const char log_prefix[7]; + uint8_t color; + int syslog_equivalent; +} log_level_map[] = { + [LOG_CLASS_NONE] = {"none", "none", 5, -1}, + [LOG_CLASS_ERROR] = {"error", " err", 31, LOG_ERR}, + [LOG_CLASS_WARNING] = {"warning", "warn", 33, LOG_WARNING}, + [LOG_CLASS_INFO] = {"info", "info", 97, LOG_INFO}, + [LOG_CLASS_DEBUG] = {"debug", " dbg", 36, LOG_DEBUG}, }; void @@ -35,20 +40,14 @@ log_init(enum log_colorize _colorize, bool _do_syslog, [LOG_FACILITY_DAEMON] = LOG_DAEMON, }; - static const int level_map[] = { - [LOG_CLASS_ERROR] = LOG_ERR, - [LOG_CLASS_WARNING] = LOG_WARNING, - [LOG_CLASS_INFO] = LOG_INFO, - [LOG_CLASS_DEBUG] = LOG_DEBUG, - }; - colorize = _colorize == LOG_COLORIZE_NEVER ? false : _colorize == LOG_COLORIZE_ALWAYS ? true : isatty(STDERR_FILENO); do_syslog = _do_syslog; log_level = _log_level; - if (do_syslog) { + int slvl = log_level_map[_log_level].syslog_equivalent; + if (do_syslog && slvl != -1) { openlog(NULL, /*LOG_PID*/0, facility_map[syslog_facility]); - setlogmask(LOG_UPTO(level_map[_log_level])); + setlogmask(LOG_UPTO(slvl)); } } @@ -63,34 +62,31 @@ static void _log(enum log_class log_class, const char *module, const char *file, int lineno, const char *fmt, int sys_errno, va_list va) { + xassert(log_class > LOG_CLASS_NONE); + xassert(log_class < ALEN(log_level_map)); + if (log_class > log_level) return; - const char *class = "abcd"; - int class_clr = 0; - switch (log_class) { - case LOG_CLASS_ERROR: class = " err"; class_clr = 31; break; - case LOG_CLASS_WARNING: class = "warn"; class_clr = 33; break; - case LOG_CLASS_INFO: class = "info"; class_clr = 97; break; - case LOG_CLASS_DEBUG: class = " dbg"; class_clr = 36; break; - } + const char *prefix = log_level_map[log_class].log_prefix; + unsigned int class_clr = log_level_map[log_class].color; char clr[16]; - snprintf(clr, sizeof(clr), "\033[%dm", class_clr); - fprintf(stderr, "%s%s%s: ", colorize ? clr : "", class, colorize ? "\033[0m" : ""); + xsnprintf(clr, sizeof(clr), "\033[%um", class_clr); + fprintf(stderr, "%s%s%s: ", colorize ? clr : "", prefix, colorize ? "\033[0m" : ""); if (colorize) - fprintf(stderr, "\033[2m"); + fputs("\033[2m", stderr); fprintf(stderr, "%s:%d: ", file, lineno); if (colorize) - fprintf(stderr, "\033[0m"); + fputs("\033[0m", stderr); vfprintf(stderr, fmt, va); if (sys_errno != 0) fprintf(stderr, ": %s", strerror(sys_errno)); - fprintf(stderr, "\n"); + fputc('\n', stderr); } static void @@ -98,19 +94,14 @@ _sys_log(enum log_class log_class, const char *module, const char UNUSED *file, int UNUSED lineno, const char *fmt, int sys_errno, va_list va) { + xassert(log_class > LOG_CLASS_NONE); + xassert(log_class < ALEN(log_level_map)); + if (!do_syslog) return; /* Map our log level to syslog's level */ - int level = -1; - switch (log_class) { - case LOG_CLASS_ERROR: level = LOG_ERR; break; - case LOG_CLASS_WARNING: level = LOG_WARNING; break; - case LOG_CLASS_INFO: level = LOG_INFO; break; - case LOG_CLASS_DEBUG: level = LOG_DEBUG; break; - } - - xassert(level != -1); + int level = log_level_map[log_class].syslog_equivalent; char msg[4096]; int n = vsnprintf(msg, sizeof(msg), fmt, va); @@ -185,14 +176,25 @@ log_errno_provided(enum log_class log_class, const char *module, va_end(va); } +static size_t +map_len(void) +{ + size_t len = ALEN(log_level_map); +#ifndef _DEBUG + /* Exclude "debug" entry for non-debug builds */ + len--; +#endif + return len; +} + int log_level_from_string(const char *str) { if (unlikely(str[0] == '\0')) return -1; - for (int i = 0, n = ALEN(log_level_map); i < n; i++) - if (strcmp(str, log_level_map[i]) == 0) + for (int i = 0, n = map_len(); i < n; i++) + if (strcmp(str, log_level_map[i].name) == 0) return i; return -1; @@ -205,8 +207,8 @@ log_level_string_hint(void) if (buf[0] != '\0') return buf; - for (size_t i = 0, pos = 0, n = ALEN(log_level_map); i < n; i++) { - const char *entry = log_level_map[i]; + for (size_t i = 0, pos = 0, n = map_len(); i < n; i++) { + const char *entry = log_level_map[i].name; const char *delim = (i + 1 < n) ? ", " : ""; pos += xsnprintf(buf + pos, sizeof(buf) - pos, "'%s'%s", entry, delim); } diff --git a/log.h b/log.h index 367fd60e..dc458199 100644 --- a/log.h +++ b/log.h @@ -5,7 +5,14 @@ enum log_colorize { LOG_COLORIZE_NEVER, LOG_COLORIZE_ALWAYS, LOG_COLORIZE_AUTO }; enum log_facility { LOG_FACILITY_USER, LOG_FACILITY_DAEMON }; -enum log_class { LOG_CLASS_ERROR, LOG_CLASS_WARNING, LOG_CLASS_INFO, LOG_CLASS_DEBUG }; + +enum log_class { + LOG_CLASS_NONE, + LOG_CLASS_ERROR, + LOG_CLASS_WARNING, + LOG_CLASS_INFO, + LOG_CLASS_DEBUG +}; void log_init(enum log_colorize colorize, bool do_syslog, enum log_facility syslog_facility, enum log_class log_level); diff --git a/main.c b/main.c index bbe89052..f58bdb52 100644 --- a/main.c +++ b/main.c @@ -61,27 +61,27 @@ print_usage(const char *prog_name) "Usage: %s [OPTIONS...] command [ARGS...]\n" "\n" "Options:\n" - " -c,--config=PATH load configuration from PATH ($XDG_CONFIG_HOME/foot/foot.ini)\n" - " -C,--check-config verify configuration, exit with 0 if ok, otherwise exit with 1\n" - " -o,--override=[section.]key=value override configuration option\n" - " -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n" - " -t,--term=TERM value to set the environment variable TERM to (%s)\n" - " -T,--title=TITLE initial window title (foot)\n" - " -a,--app-id=ID window application ID (foot)\n" - " -m,--maximized start in maximized mode\n" - " -F,--fullscreen start in fullscreen mode\n" - " -L,--login-shell start shell as a login shell\n" - " -D,--working-directory=DIR directory to start in (CWD)\n" - " -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n" - " -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n" - " -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n" - " Without PATH, $XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock will be used.\n" - " -H,--hold remain open after child process exits\n" - " -p,--print-pid=FILE|FD print PID to file or FD (only applicable in server mode)\n" - " -d,--log-level={info|warning|error} log level (info)\n" - " -l,--log-colorize=[{never|always|auto}] enable/disable colorization of log output on stderr\n" - " -s,--log-no-syslog disable syslog logging (only applicable in server mode)\n" - " -v,--version show the version number and quit\n", + " -c,--config=PATH load configuration from PATH ($XDG_CONFIG_HOME/foot/foot.ini)\n" + " -C,--check-config verify configuration, exit with 0 if ok, otherwise exit with 1\n" + " -o,--override=[section.]key=value override configuration option\n" + " -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n" + " -t,--term=TERM value to set the environment variable TERM to (%s)\n" + " -T,--title=TITLE initial window title (foot)\n" + " -a,--app-id=ID window application ID (foot)\n" + " -m,--maximized start in maximized mode\n" + " -F,--fullscreen start in fullscreen mode\n" + " -L,--login-shell start shell as a login shell\n" + " -D,--working-directory=DIR directory to start in (CWD)\n" + " -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n" + " -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n" + " -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n" + " Without PATH, $XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock will be used.\n" + " -H,--hold remain open after child process exits\n" + " -p,--print-pid=FILE|FD print PID to file or FD (only applicable in server mode)\n" + " -d,--log-level={info|warning|error|none} log level (info)\n" + " -l,--log-colorize=[{never|always|auto}] enable/disable colorization of log output on stderr\n" + " -s,--log-no-syslog disable syslog logging (only applicable in server mode)\n" + " -v,--version show the version number and quit\n", prog_name, prog_name, DEFAULT_TERM); } @@ -383,11 +383,14 @@ main(int argc, char *const *argv) log_init(log_colorize, as_server && log_syslog, as_server ? LOG_FACILITY_DAEMON : LOG_FACILITY_USER, log_level); - _Static_assert(LOG_CLASS_ERROR + 1 == FCFT_LOG_CLASS_ERROR, + _Static_assert((int)LOG_CLASS_ERROR == (int)FCFT_LOG_CLASS_ERROR, "fcft log level enum offset"); _Static_assert((int)LOG_COLORIZE_ALWAYS == (int)FCFT_LOG_COLORIZE_ALWAYS, "fcft colorize enum mismatch"); - fcft_log_init((enum fcft_log_colorize)log_colorize, as_server && log_syslog, log_level + 1); + fcft_log_init( + (enum fcft_log_colorize)log_colorize, + as_server && log_syslog, + (enum fcft_log_class)log_level); argc -= optind; argv += optind; -- cgit v1.3 From 9817e44c325f5d44f64bfa768107998134ea7f59 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 30 Jun 2021 18:00:33 +0200 Subject: config: add tweak.grapheme-width-method=wcswidth|at-most-2 --- CHANGELOG.md | 3 +++ config.c | 10 ++++++++++ config.h | 1 + doc/foot.ini.5.scd | 18 ++++++++++++++++++ vt.c | 19 ++++++++++++++----- 5 files changed, 46 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/CHANGELOG.md b/CHANGELOG.md index 78016bae..9337652b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,9 @@ terminfo entries. This should make 24-bit RGB colors work in tmux and neovim, without the need for config hacks or detection heuristics (https://codeberg.org/dnkl/foot/issues/615). +* `[tweak].grapheme-width-method=wcswidth|at-most-2` option to + `foot.ini`. + ### Changed ### Deprecated diff --git a/config.c b/config.c index 372e9f9c..cb407c24 100644 --- a/config.c +++ b/config.c @@ -2255,6 +2255,15 @@ parse_section_tweak( LOG_WARN("tweak: grapheme shaping"); } + else if (strcmp(key, "grapheme-width-method") == 0) { + if (strcmp(value, "at-most-2") == 0) + conf->tweak.grapheme_width_method = GRAPHEME_WIDTH_MAX_2; + else if (strcmp(value, "wcswidth") == 0) + conf->tweak.grapheme_width_method = GRAPHEME_WIDTH_WCSWIDTH; + + LOG_WARN("%s:%d [tweak]: grapheme-width-method=%s", path, lineno, value); + } + else if (strcmp(key, "render-timer") == 0) { if (strcmp(value, "none") == 0) { conf->tweak.render_timer_osd = false; @@ -2823,6 +2832,7 @@ config_load(struct config *conf, const char *conf_path, .fcft_filter = FCFT_SCALING_FILTER_LANCZOS3, .allow_overflowing_double_width_glyphs = true, .grapheme_shaping = false, + .grapheme_width_method = GRAPHEME_WIDTH_MAX_2, .delayed_render_lower_ns = 500000, /* 0.5ms */ .delayed_render_upper_ns = 16666666 / 2, /* half a frame period (60Hz) */ .max_shm_pool_size = 512 * 1024 * 1024, diff --git a/config.h b/config.h index ee427267..57305b22 100644 --- a/config.h +++ b/config.h @@ -246,6 +246,7 @@ struct config { enum fcft_scaling_filter fcft_filter; bool allow_overflowing_double_width_glyphs; bool grapheme_shaping; + enum {GRAPHEME_WIDTH_WCSWIDTH, GRAPHEME_WIDTH_MAX_2} grapheme_width_method; bool render_timer_osd; bool render_timer_log; bool damage_whole_window; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 2e408b3a..a0829ad7 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -997,8 +997,26 @@ any of these options. but is necessary to not break cursor synchronization with the application running in foot. + See also: *grapheme-width-method*. + Default: _no_ +*grapheme-width-method* + Selects which method to use when calculating the width + (i.e. number of columns) of a grapheme cluster. One of *at-most-2* + and *wcswidth*. + + *wcswidth* simply adds together the individual width of all + codepoints making up the cluster. + + *at-most-2* does the same, but limits the maximum number of + columns to 2. This is more correct, but is likely to break + applications since applications typically use *wcswidth*(3) + internally to calculate the width. This results in cursor + de-synchronization issues. + + Default: _at-most-2_ + *max-shm-pool-size-mb* This option controls the amount of virtual address space used by the pixmap memory to which the terminal screen content is diff --git a/vt.c b/vt.c index 5f2b3c0d..6ef2b782 100644 --- a/vt.c +++ b/vt.c @@ -764,17 +764,26 @@ action_utf8_print(struct terminal *term, wchar_t wc) (wanted_count - 2) * sizeof(new_cc->chars[0])); } - int grapheme_width = composed != NULL ? composed->width : base_width; + const int grapheme_width = + composed != NULL ? composed->width : base_width; + + switch (term->conf->tweak.grapheme_width_method) { + case GRAPHEME_WIDTH_MAX_2: + if (unlikely(wc == 0xfe0f)) + width = 2; + new_cc->width = min(grapheme_width + width, 2); + break; - if (wc == 0xfe0f) - width = 2; - new_cc->width = min(max(grapheme_width, width), 2); + case GRAPHEME_WIDTH_WCSWIDTH: + new_cc->width = grapheme_width + width; + break; + } term->composed_count++; composed_insert(&term->composed, new_cc); wc = CELL_COMB_CHARS_LO + key; - width = grapheme_width; + width = new_cc->width; xassert(wc >= CELL_COMB_CHARS_LO); xassert(wc <= CELL_COMB_CHARS_HI); -- cgit v1.3 From 5138f022146e447d8bb0be56a06e9065b35b6489 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 1 Jul 2021 08:00:23 +0200 Subject: config: rename at-most-2 (value for grapheme-width-method) to double-width --- CHANGELOG.md | 2 +- config.c | 6 +++--- config.h | 2 +- doc/foot.ini.5.scd | 8 ++++---- vt.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/CHANGELOG.md b/CHANGELOG.md index 9337652b..0b79b0ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ terminfo entries. This should make 24-bit RGB colors work in tmux and neovim, without the need for config hacks or detection heuristics (https://codeberg.org/dnkl/foot/issues/615). -* `[tweak].grapheme-width-method=wcswidth|at-most-2` option to +* `[tweak].grapheme-width-method=wcswidth|double-width` option to `foot.ini`. diff --git a/config.c b/config.c index cb407c24..e02ca3de 100644 --- a/config.c +++ b/config.c @@ -2256,8 +2256,8 @@ parse_section_tweak( } else if (strcmp(key, "grapheme-width-method") == 0) { - if (strcmp(value, "at-most-2") == 0) - conf->tweak.grapheme_width_method = GRAPHEME_WIDTH_MAX_2; + if (strcmp(value, "double-width") == 0) + conf->tweak.grapheme_width_method = GRAPHEME_WIDTH_DOUBLE; else if (strcmp(value, "wcswidth") == 0) conf->tweak.grapheme_width_method = GRAPHEME_WIDTH_WCSWIDTH; @@ -2832,7 +2832,7 @@ config_load(struct config *conf, const char *conf_path, .fcft_filter = FCFT_SCALING_FILTER_LANCZOS3, .allow_overflowing_double_width_glyphs = true, .grapheme_shaping = false, - .grapheme_width_method = GRAPHEME_WIDTH_MAX_2, + .grapheme_width_method = GRAPHEME_WIDTH_DOUBLE, .delayed_render_lower_ns = 500000, /* 0.5ms */ .delayed_render_upper_ns = 16666666 / 2, /* half a frame period (60Hz) */ .max_shm_pool_size = 512 * 1024 * 1024, diff --git a/config.h b/config.h index 57305b22..2300a0ad 100644 --- a/config.h +++ b/config.h @@ -246,7 +246,7 @@ struct config { enum fcft_scaling_filter fcft_filter; bool allow_overflowing_double_width_glyphs; bool grapheme_shaping; - enum {GRAPHEME_WIDTH_WCSWIDTH, GRAPHEME_WIDTH_MAX_2} grapheme_width_method; + enum {GRAPHEME_WIDTH_WCSWIDTH, GRAPHEME_WIDTH_DOUBLE} grapheme_width_method; bool render_timer_osd; bool render_timer_log; bool damage_whole_window; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index a0829ad7..684497ca 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1003,19 +1003,19 @@ any of these options. *grapheme-width-method* Selects which method to use when calculating the width - (i.e. number of columns) of a grapheme cluster. One of *at-most-2* - and *wcswidth*. + (i.e. number of columns) of a grapheme cluster. One of + *double-width* and *wcswidth*. *wcswidth* simply adds together the individual width of all codepoints making up the cluster. - *at-most-2* does the same, but limits the maximum number of + *double-width* does the same, but limits the maximum number of columns to 2. This is more correct, but is likely to break applications since applications typically use *wcswidth*(3) internally to calculate the width. This results in cursor de-synchronization issues. - Default: _at-most-2_ + Default: _double-width_ *max-shm-pool-size-mb* This option controls the amount of virtual address space used by diff --git a/vt.c b/vt.c index 6ef2b782..b9a4f4b0 100644 --- a/vt.c +++ b/vt.c @@ -768,7 +768,7 @@ action_utf8_print(struct terminal *term, wchar_t wc) composed != NULL ? composed->width : base_width; switch (term->conf->tweak.grapheme_width_method) { - case GRAPHEME_WIDTH_MAX_2: + case GRAPHEME_WIDTH_DOUBLE: if (unlikely(wc == 0xfe0f)) width = 2; new_cc->width = min(grapheme_width + width, 2); -- cgit v1.3