Commit graph

5830 commits

Author SHA1 Message Date
Daniel Eklöf
94bac0513a
term: update user-set line-height just before calculating the cell dimensions
This ensures *all* font-size affecting changes (DPI, output scaling,
font size increment/decrement) also updates the line-height.
2022-11-24 14:34:31 +01:00
Daniel Eklöf
f31ea4f56d
changelog: line-height adjustment with user-set line-height 2022-11-23 16:29:42 +01:00
Daniel Eklöf
5a54423000
term: adjust user-set line-height by the same percentage as the primary font
Before this patch, a user-set line-height was increased/decreased by
the exact same amount of pt’s as the font(s).

This means, that when there’s a large discrepancy between the
line-height and the font size, the proportion between the line’s
height and the font size will change as we increase or decrease the
font size.

This patch changes how the line height is adjusted when the font size
is incremented or decremented. We calculate the difference, in
percent, between the primary font’s original (default) size, and its
current size, and then apply that to the configured line-height.

Closes #1218
2022-11-23 16:29:42 +01:00
Daniel Eklöf
dfabc5d754
readme/foot.1: mention that we now need “-d info” to get log output 2022-11-23 16:27:50 +01:00
Antoine Beaupré
b80c7f75fe
change default log level to WARNING
The default foot output looks like this, in Debian testing "bookworm"
at the time of writing:

    anarcat@angela:pubpaste$ foot true
    info: main.c:421: version: 1.13.1 +pgo +ime +graphemes -assertions
    info: main.c:428: arch: Linux x86_64/64-bit
    info: main.c:440: locale: fr_CA.UTF-8
    info: config.c:3003: loading configuration from /home/anarcat/.config/foot/foot.ini
    info: fcft.c:338: fcft: 3.1.5 +graphemes -runs +svg(nanosvg) -assertions
    info: fcft.c:377: fontconfig: 2.13.1, freetype: 2.12.1, harfbuzz: 5.2.0
    info: fcft.c:838: /home/anarcat/.local/share/fonts/Fira-4.202/otf/FiraMono-Regular.otf: size=8.00pt/8px, dpi=75.00
    info: wayland.c:1353: eDP-1: 2256x1504+0x0@60Hz 0x095F 13.32" scale=2 PPI=205x214 (physical) PPI=136x143 (logical), DPI=271.31
    info: wayland.c:1509: requesting SSD decorations
    info: fcft.c:838: /home/anarcat/.local/share/fonts/Fira-4.202/otf/FiraMono-Bold.otf: size=24.00pt/32px, dpi=96.00
    info: fcft.c:838: /home/anarcat/.local/share/fonts/Fira-4.202/otf/FiraMono-Regular.otf: size=24.00pt/32px, dpi=96.00
    info: fcft.c:838: /home/anarcat/.local/share/fonts/Fira-4.202/otf/FiraMono-Bold.otf: size=24.00pt/32px, dpi=96.00
    info: fcft.c:838: /home/anarcat/.local/share/fonts/Fira-4.202/otf/FiraMono-Regular.otf: size=24.00pt/32px, dpi=96.00
    info: terminal.c:700: cell width=19, height=39
    info: terminal.c:588: using 16 rendering threads
    info: wayland.c:859: using SSD decorations
    info: main.c:680: goodbye
    anarcat@angela:pubpaste$

That's 17 lines of output that are *mostly* useless for most use
cases. I might understand having this output during the project's
startup, when it's helpful for diagnostics, but now Foot just mostly
works everywhere, and I've never had a use for any of that stuff in
the (arguably short) time I've been using Foot so far.

And if I do, there's the `--log-level` commandline option to tweak
this. At first, I looked at tweaking the log level through the config
file. But as explained in this issue:

https://codeberg.org/dnkl/foot/issues/1142

... there's a chicken and egg problem there that makes it hard to
implement and possibly confusing for users as well.

There's also the possibility for users to change the shortcut with
which they start foot, for example a `.desktop` file so that menu
systems that support those start foot properly. But that only works in
that environment, and not through the so many things that will just
call `foot` and hope it will do the right thing.

In my case, I have `foot` hardcoded in a lot of places now, between
sway and waybar, and this is only going to grow. Others have suggested
adding the flag to a $TERMINAL global variable, but that won't help
.desktop users.

So, instead of playing whack-a-mole with the log levels, just make it
so that, by default, foot is silent. This is actually one of the
[basics of UNIX philosophy][1]:

> Rule of Silence: When a program has nothing surprising to say, it
> should say nothing.

And yes, I am aware I am severely violating that principle by writing
a way too long commit log for a one-line patch, but there you go, I
figured it was good to document the why of this properly.

[1]: https://web.archive.org/web/20031102053334/http://www.faqs.org/docs/artu/ch01s06.html
2022-11-22 10:22:22 -05:00
Daniel Eklöf
4d2b8a993f
Merge branch 'fp-calc-dpi'
Closes #1209
2022-11-22 09:34:53 +01:00
Daniel Eklöf
42c6af0914
wayland: force monitor DPI to 96 when it’s unreasonably high
If an output has a bogus physical width or height, the DPI can become
so high that the cell width/height is too large for
pixman_image_fill_rectangles(), resulting in a crash in pixman_fill().

Since it doesn’t make any sense to use a DPI that is obviously bogus,
don’t. Force it 96 instead.
2022-11-04 17:49:01 +01:00
Daniel Eklöf
2910ca354c
wayland: use fp math all the way when calculating DPI
This fixes an FPE when the monitor’s physical width/height is so small
that the conversion from mm to inch resulted in inches being zero.
2022-11-04 17:42:52 +01:00
Soren A D
fa9beae3a6
added modus themes 2022-11-02 19:11:12 +01:00
Craig Barnes
8f2bda6703 wayland: use BUG() instead of xassert(false)
The latter will expand to the former anyway, so we may as well provide
an explicit error message instead of "assertion failed: 'false'".
2022-11-01 21:04:22 +00:00
Daniel Eklöf
30d088376c
render: maybe_resize(): remove debug assert
This, depending on which compiler being used, caused issues not only
in debug builds, but release builds as well (with NDEBUG defined).
2022-11-01 17:12:16 +01:00
Daniel Eklöf
2c2a39317b
render: never apply alpha to text color
When drawing a block cursor using inversed fg/bg colors, we didn’t
strip the alpha from the background color. This meant that the text
"behind" the cursor was rendered with transparency. If alpha was set
to 0, the text was completely invisible.

We should never apply alpha to the text color. So, detect this, and
force alpha to 1.0.

Normally, when selecting the cursor’s color, we don’t really know
_where_ the background color is coming from (or more accurately,
_what_ it is).

However, the *only* background color that can have a non-1.0 alpha is
the *default* background color.

This is why we can ignore the bg parameter, and use term->colors.fg/bg
instead.

Closes #1205
2022-10-30 19:43:18 +01:00
Andrea Pappacoda
49fa751953
chore: use MIT license for appstream metadata
The Appstream metadata file introduced in commit
335612cfa4
has been submitted as licensed under the CC0-1.0 license. People
generally use the CC0-1.0 to put the file in the "public domain", but
this isn't actually possible in lots of countries, so the file ends up
being licensed under CC0's fallback permissive license; unfortunately,
the fallback license contains some terms that are seen as problematic to
some (notably, Fedora has recently decided to consider the license
pretty much non-free).

As foot is already MIT-licensed, and since this license is in the list
of allowed [metadata licenses], this patch changes the license of the
metadata file from CC0-1.0 to MIT.

[metadata licenses]: https://freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-metadata_license
2022-10-27 13:58:52 +02:00
Andrea Pappacoda
1313e6352a
build: fix GCC detection in pgo.sh
On my system, GCC doesn't output its name when passing the --version
flag:

    $ cc --version
    cc (Debian 12.2.0-3) 12.2.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

As the Free Software Foundation is unlikely to write another compiler, I
think that searching for the foundation's name instead of GCC is a good
enough fix (and I'm almost sure we wouldn't be the first ones to do so).
2022-10-23 23:56:34 +02:00
Daniel Eklöf
59c9dfe109
render: resize: do full text reflow immediately if resize-delay-ms == 0
That is, skip all custom grid handling when doing an interactive
resize, if resize-delay-ms == 0.
2022-10-23 10:34:18 +02:00
Daniel Eklöf
3ba03901b8
pgo: don’t re-use the rows between the ‘normal’ and ‘alt’ grids
This used to work because we never free:d any of the rows. Now
however, we do free (some of) them when reverse scrolling. This means
we can no longer re-use the rows between the two screens.

Closes #1196
2022-10-18 18:31:18 +02:00
Daniel Eklöf
c4f08a3b9a
grid_free(): allow being called with grid == NULL 2022-10-18 18:30:02 +02:00
Daniel Eklöf
09d52d5db6
term_destroy(): free interactive_resizing.grid
This grid is normally unallocated, but may be allocated if we are
exiting (for whatever reason) in the middle of an interactive resize.
2022-10-18 18:29:20 +02:00
Daniel Eklöf
2e9b3ceb95
fdm_ptmx(): regression: don’t return false when an interactive resize is in progress 2022-10-18 18:28:51 +02:00
Daniel Eklöf
b0c30c7ed2
doc: foot.ini: improve documentation of cursor.color 2022-10-17 20:16:53 +02:00
Daniel Eklöf
0ac0d0647a
interactive resize: improve user experience
Re-initialize the temporary ‘normal’ grid instance each time we
receive a configure event while doing an interactive resize.

This way, window content will not be "erased" when the window is first
made smaller, then larger again.

And, if the viewport is up in the scrollback history, increasing the
window size will reveal more of the scrollback, instead of just being
black.

The last issue is the cursor; it’s currently not "stuck" where it
should be. Instead, it follows the window around. This is due to two
things:

1) the temporary grid we create is large enough to contain the current
   viewport, but not more than that. That means we can’t "scroll up", to
   hide the cursor.

2) grid_resize_without_reflow() doesn’t know anything about
   "interactive resizing". As such, it will ensure the cursor is bound
   to the new grid dimensions.

I don’t yet have a solution for this. This patch implements a
workaround to at least reduce the impact, by simply hiding the cursor
while we’re doing an interactive resize.
2022-10-17 18:49:57 +02:00
Daniel Eklöf
3c9a51afa6
changelog: crash after reverse-scrolling in the normal screen 2022-10-16 10:31:15 +02:00
Daniel Eklöf
89744f8123
selection: scroll down: handle non-full scrollback correctly
When determining whether or not to cancel a selection (due to it, or
part of it, being "scrolled out"), we assumed the scrollback was full.

This patch changes the implementation to compare the scrollback
relative selection coordinates with the scrollback relative
end-of-the-scrollback coordinates.
2022-10-16 10:31:15 +02:00
Daniel Eklöf
3d9a429499
term: reverse scroll: free scrolled out lines
This ensures *everything* in the circular scrollback history, after
the bottom of the screen, is either NULL rows, or belong to the
scrollback *history* (as opposed to the future history).

This fixes an issue when calculating the scrollback start, which for
example would trigger a crash when moving the viewport (i.e. scrolling
with the mouse, or PgUp/PgDown).

Closes #1190
2022-10-16 10:31:08 +02:00
Daniel Eklöf
43a48f53d4
sixel: don’t crash when sixel image exceeds current sixel max height
When we try to resize a sixel past the current max height, we set
col > image-width to signal this.

This means ‘width’ could be smaller than ‘col’. When calculating how
many sixels to emit in sixel_add_many(), we didnt’ account for this.

The resulting value was -1, converted to ‘unsigned’. I.e. a very large
value. This resulted in an assert triggering in sixel_add() in debug
builds, and a crash in release builds.
2022-10-13 17:52:34 +02:00
Daniel Eklöf
3949e34271
Merge branch 'delayed-reflow' 2022-10-10 17:19:43 +02:00
Daniel Eklöf
298f210ed9
render: rename term->render.resizing -> term->interactive_resizing
But also, more importantly, logical fixes:

* Stash the number of new scrollback lines the stashed ‘normal’ grid
  should be resized *to*.

There’s also a couple of performance changes here:

* When doing a delayed reflow (tiocswinsz timer), call
  sixel_reflow_grid(term, &term->normal) - there’s no need to reflow
  sixels in the ‘alt’ screen.

* When doing a delayed reflow, free all scroll damage. It’s not
  needed, since we’re damaging the entire window anyway.

* Use minimum size for the temporary ‘normal’ grid (that contains the
  current viewport). We just need it to be large enough to fit the
  current viewport, and be a valid grid row count (power of 2). This
  just so happens to be the current ‘alt’ grid’s row count...
2022-10-10 17:19:18 +02:00
Daniel Eklöf
c550d67cd8
render: resize: do delayed reflow immediately when failing to arm tiocswinsz timer 2022-10-10 17:19:18 +02:00
Daniel Eklöf
c5c97c2fd4
term_ptmx_{pause,resume}: return success/fail 2022-10-10 17:19:18 +02:00
Daniel Eklöf
54d637e2b4
term: ptmx: don’t consume anything while doing an interactive resize
The ‘normal’ grid in use during an interactive resize is temporary;
all changes done to it will be lost when the resize is finished.
2022-10-10 17:19:18 +02:00
Daniel Eklöf
66e4592d91
term: use SIZE_MAX instead of (size_t)-1ll 2022-10-10 17:19:18 +02:00
Daniel Eklöf
18ef36523f
grid: resize: assert grid->cur_row is not NULL after a grid resize 2022-10-10 17:19:18 +02:00
Daniel Eklöf
d4b0b0887e
render: delayed reflow: not enough to damage current view; need to refresh too 2022-10-10 17:19:18 +02:00
Daniel Eklöf
f70c34c5a8
sixel: add sixel_reflow_grid()
This function reflows all sixels in the specified grid.

The pre-existing sixel_reflow() function is a shortcut for

  sixel_reflow_grid(term, &term->normal)
  sixel_reflow_grid(term, &term->alt);
2022-10-10 17:19:18 +02:00
Daniel Eklöf
b52262da8e
changelog: fixed crash when resizing window with a very large scrollback 2022-10-10 17:19:18 +02:00
Daniel Eklöf
f4f1989b6e
render: resize: ignore ptmx read events during interactive resize 2022-10-10 17:19:18 +02:00
Daniel Eklöf
3565cbd636
render: performance improvements during interactive resize
Instead of copying the entire grid when an interactive resize is
started, stash the complete grid (to be used in the final reflow).

Copy the current viewport only, to be used during the interactive
resize.

This gets rid of the initial "pause" when snapshotting the grid when
an interactive resize is started.
2022-10-10 17:19:17 +02:00
Daniel Eklöf
8179d73daa
render: delay reflow for ‘resize-delay-ms’ milliseconds
Reflowing a large scrollback is *slow*. During an interactive resize,
it can easily take long enough that the compositor fills the Wayland
socket with configure events. Eventually, the socket becomes full and
the compositor terminates the connection, causing foot to exit.

This patch is work-in-progress, and the first step towards alleviating
this.

It delays the reflow by:

* Snapshotting (copying) the original grid when an interactive resize
  is started.
* While resizing, we apply a simple truncation resize of the
  grid (like we handle the alt screen).
* When the resize is done, or paused for ‘resize-delay-ms’, the grid
  is reflowed.

TODO: we *must* not allow any changes to the temporary (truncated)
grid during the resize. Any changes to the grid would be lost when the
final reflow is applied. That is, we must completely pause the ptmx
pipe while a resize is in progress.

Future improvements:

The initial copy can be slow. We should be able to avoid it by
rewriting the reflow algorithm to not free anything. This is
complicated by the fact that some resources (e.g. sixel images) are
currently *moved* to the new grid. They’d instead have to be copied.
2022-10-10 17:19:17 +02:00
Daniel Eklöf
a9fc7ce180
pgo: run xtgettcap without any arguments
We execute xtgettcap in the parent terminal. Thus we don’t know if it
implements XTGETTCAP, and thus it’s not guaranteed to exit - it may
hang indefinitely waiting for a reply.

Fix by not actually quering anything.
2022-10-10 17:18:04 +02:00
Daniel Eklöf
807e193854
xtgettcap: exit immediately when there are no capabilities to query for 2022-10-10 17:17:38 +02:00
Daniel Eklöf
4fca380585
install.md: add ./utils/xtgettcap name to "full PGO" instructions too 2022-10-09 16:27:10 +02:00
Daniel Eklöf
f747650b77
install.md: add xtgettcap to PGO build instructions 2022-10-08 16:56:28 +02:00
Daniel Eklöf
503740f836
pgo: execute xtgettcap utility, to get profiling data
Fixes:

  ../utils/xtgettcap.c:175:1: error: ‘/home/daniel/src/foot/src/utils/xtgettcap.p/xtgettcap.c.gcda’ profile count data file not found [-Werror=missing-profile]
2022-10-07 21:47:56 +02:00
Daniel Eklöf
9937d92c85
utils: xtgettcap: new utility, to send XTGETTCAP queries 2022-10-07 14:40:22 +02:00
Daniel Eklöf
f359a8d6bc
scripts: generate-builtin-terminfo: escape fixes
* Remove ‘:’ escaping only in raw (non-parameterized) sequences
* Double-escape *all* escape characters in parameterized sequences
2022-10-05 16:53:55 +02:00
Daniel Eklöf
fd743b5173
scripts: generate-builtin-terminfo: double-escape backslash in ST
Fixes an issue with XTGETTCAP, where escape sequences terminated with
ST, and containing parameters were missing a trailing backslash.
2022-10-05 16:53:54 +02:00
Alexey Sakovets
37218be648
render: fix nanosec "overflow" when calculating timeout value 2022-10-05 16:51:25 +02:00
Hugo Osvaldo Barrera
2d4f0535c6
Add zenburn theme
This is the one included by default in previous releases.
2022-10-04 21:23:07 +02:00
Nick Hastings
cbebafbfe8 doc: fix tiny typo 2022-10-04 13:04:03 +09:00
Daniel Eklöf
332cb90134
spawn: set $PWD, in addition to calling chdir(cwd) 2022-10-02 20:11:16 +02:00