Commit graph

5632 commits

Author SHA1 Message Date
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
Daniel Eklöf
90ce4f3008
main/client: use $PWD for cwd, when $PWD is valid
If $PWD is set, and its resolved path matches the *actual* working
directory, use $PWD for cwd when instantiating the terminal.

This makes a difference when $PWD refers to a symlink; before this
patch, we’d instantiate the terminal in the *resolved* path. Now it’ll
use the symlink instead.
2022-10-02 20:11:16 +02:00
Daniel Eklöf
9e58661093
slave: spawn: set PWD environment variable
This improves handling of symlinks (in CWD) when launching a new
terminal instance, either through ctrl+shift+n, or using the
--working-directory command line option.

Closes #1179
2022-10-02 20:11:07 +02:00
Daniel Eklöf
88c3128515
scripts: generate-builtin-terminfo: add synthetic ‘name’ capability
Same as ‘TN’; reports the terminfo name.
2022-09-28 21:09:35 +02:00
Daniel Eklöf
bb02b319d0
terminfo: add kxIN + kxOUT (focus in/out events)
These capabilities are not included in the standard ‘xterm’ or
‘xterm-256color’ terminfos. They’re used in

‘xterm+focus’ ->
‘xterm+sm+1002’ ->
‘xterm-1002|xterm+sm+1003’ ->
‘xterm-1003’

(https://invisible-island.net/ncurses/terminfo.ti.html#tic-xterm_focus)

However, as far as I can tell, ncurses doesn’t use these capabilities
at all.
2022-09-26 18:54:03 +02:00
Daniel Eklöf
c93eb45b42
term: utmp: set ‘host’ to WAYLAND_DISPLAY
This is similar to what XTerm does (setting it to DISPLAY)
2022-09-23 23:04:10 +02:00
Daniel Eklöf
aa10b1d2da
Add support for creating utmp records
This patch adds support for creating utmp records using the ‘utempter’
helper binary from the ‘libutempter’ package.

* New config option ‘main.utempter’
* New meson command line option, -Ddefault-utempter-path. Defaults to
  auto-detecting the path.

The default value of the new ‘main.utempter’ config option depends on
the meson command line option ‘-Ddefault-utempter-path’.

If ‘main.utempter’ is *not* set to ‘none’, foot will try to execute
the utempter helper binary to create utmp records when a new terminal
is instantiated. The record is removed when the terminal instance is
destroyed.
2022-09-23 23:02:25 +02:00
Daniel Eklöf
77b74734a4
Merge branch 'nightfly-and-moonfly' 2022-09-23 20:39:52 +02:00
Daniel Eklöf
3be44fb316
render: overlay: fix visual glitches when double buffering
When rendering the overlay for scrollback search, the logic assumed
buffer re-use. On some compositors this isn’t happening (on
e.g. KDE/plasma we’re forced to double buffer).

This resulted in matches not being highlighted correctly.

The problem is in how we calculated the region for which areas to
clear ("un-dim"). It uses the "previous frame’s see-through area"
minus the current frame’s see-through area.

However, when we’ve detected that the current buffer isn’t the same as
the last one, we set the last frame’s see-through region to "the
entire buffer". Thus, when calculating the diff, we end up with an
empty region, and nothing is highlighted.

Fix by simply using the current frame’s see-through region as-is when
we’ve detected we’re not re-using the last frame’s buffer.
2022-09-23 20:33:02 +02:00
Daniel Eklöf
4340f8a3b4
render: fix application of old scroll damage when double buffering
On compositors that forces us to double buffer, we need to re-apply
the last frame’s damage to the current frame (which uses the buffer
from the next-to-last frame).

General cell updates are handled by simply copying from the last
frame’s pixman buffer to the current frame’s.

In an attempt to improve performance, scroll damage were up until now
handled by re-playing the last frame’s scroll damage (on the current
frame’s buffer). This does not work, and resulted in glitches when
scrolling in the scrollback.

This patch does the following:

* grid_render_scroll{,_reverse}() now update the buffer’s "dirty"
  region. This means the generic copy-old-frames-buffer handles the
  scroll damage (albeit in, potentially, a less efficient way).

* Tracking of, and re-applying old scroll damage is completely
  removed.

Closes #1173
2022-09-23 20:33:02 +02:00
Daniel Eklöf
50ae277d90
wayland: don’t crash with a division-by-zero when monitor dimensions are negative
Some compositors set the physical dimensions to -1...
2022-09-23 20:31:08 +02:00
Daniel Eklöf
b7ba842237
render: timer: print/log *total* rendering time 2022-09-23 20:31:08 +02:00
Daniel Eklöf
4db1dde25c
misc: add timespec_add() 2022-09-23 20:31:08 +02:00
Daniel Eklöf
020148d67c
install.md: add ‘utf8proc’ 2022-09-23 20:20:56 +02:00
Torsten Trautwein
cee59bfb3f Add the moonfly theme 2022-09-22 08:44:21 +02:00
Torsten Trautwein
05aedd52da Add the nightfly theme 2022-09-22 08:44:04 +02:00
Vladimír Magyar
debf1b8453
chore: rename desktop files 2022-09-18 17:57:11 +02:00
Vladimír Magyar
335612cfa4
chore: add appstream file
Appstream file is usefull for many package management tools to show
additional metadata and screenshots.
Also it would solve the packaging for flathub.

References: https://codeberg.org/dnkl/foot/issues/1129#issuecomment-602089
2022-09-18 17:57:06 +02:00
Craig Barnes
46f6bad728
csi: reply with 4 instead of 2 for DECRQM queries of unsupported modes
The status value 4 means "permanently reset", as opposed to 2, which
means "reset". The former implies that there's no way to enable the
mode because it's unsupported (but recognized).

Note: this commit also fixes an unrelated typo in CHANGELOG.md.
2022-09-18 17:55:03 +02:00
Craig Barnes
8dcfa259a2 config: fix "maybe-uninitialized" error when compiling with CFLAGS=-Og
Using GCC 12.2.0 with the following build steps:

    CFLAGS=-Og meson bld
    ninja -C bld

...produces the compiler error:

    ../config.c:2000:18: error: ‘sym_equal’ may be used uninitialized
    [-Werror=maybe-uninitialized]

This commit fixes that by using BUG() to assert that all possible
values are accounted for in the offending switch statement.
2022-09-17 06:34:25 +01:00
Daniel Eklöf
1c072856eb
input: pipe-*: set current CWD when spawning the sub-process
Closes #1166
2022-09-10 12:04:39 +02:00
Daniel Eklöf
d2e67689ea
terminal: don’t unref a not-yet-referenced key-binding set
Key-binding sets are bound to a seat/configuration pair. The conf
reference is done when a new terminal instance is created.

When that same terminal instance is destroyed, the key binding set is
unref:ed.

If the terminal instance is destroyed *before* the key binding set has
been referenced, we’ll still unref it. This creates an imbalance.

In particular, when the there is exactly one other terminal instance
referencing that same key binding set, that terminal instance will
trigger a foot server crash as soon as it receives a key press/release
event. This happens because the next-to-last terminal instance brought
the reference count of the binding set down to 0, causing it to be
free:d.

Thus, we *must* reference the binding set *before* we can error
out (when instantiating a new terminal instance).

At this point, we don’t yet have a valid terminal instance. But,
that’s ok, because all the key_binding_new_for_term() did with the
terminal instance was get the "struct wayland" and "struct config"
pointers. So, rename the function and simply pass these pointers
explicitly.

Similarly, change key_binding_for() to take a "struct config" pointer,
rather than a "struct terminal" pointer.

Also rename key_binding_unref_term() -> key_binding_unref().
2022-09-06 20:44:05 +02:00
Daniel Eklöf
c311229b9e
csi: damage *viewport* when exiting the alt screen
This fixes a redraw issue when the normal screen were somewhere in the
scrollback history when exiting the alt screen.
2022-09-06 17:37:19 +02:00
Daniel Eklöf
2d1ded183a
config: change default ‘pad’ to 0x0 (i.e. no padding) 2022-09-03 12:17:46 +02:00
Daniel Eklöf
473c5f4e76
Merge branch 'releases/1.13' 2022-08-31 19:26:21 +02:00
Daniel Eklöf
cd1933baf1
meson: bump version to 1.13.1 2022-08-31 19:19:15 +02:00
Daniel Eklöf
864de72b17
changelog: prepare for 1.13.1 2022-08-31 19:17:38 +02:00
Daniel Eklöf
5706141d0a
url-mode: connect osc-8 links only when both ID and URI matches
Before this, two OSC-8 links with a matching ID would be connected
even if their URIs weren’t the same. This is against the spec:

  The same id is only used for connecting character cells whose URIs
  is also the same. Character cells pointing to different URIs should
  never be underlined together when hovering over.

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
2022-08-31 19:16:19 +02:00
Daniel Eklöf
688bf1bd59
changelog: crash when resizing window, or scrolling 2022-08-31 19:16:06 +02:00
Daniel Eklöf
23871d4db5
grid: reflow: assert there aren’t any open URIs on the last row 2022-08-31 19:16:05 +02:00
Daniel Eklöf
22989ef9b3
grid: reflow: don’t line-wrap the last row
Before this patch, we would line-wrap the last row, just like any
other row, and then afterwards try to reverse this, by adjusting the
offset and free:ing and NULL:ing the "last row".

The problem with this is if the scrollback is full. In this case, the
row we’re freeing is the first row in the scrollback history. This
means we’ll crash as soon as the viewport is moved to the top of the
scrollback.

The fix is fairly, simple. Skip the post-processing logic, and instead
detect when we’re line-wrapping the last row, and skip the call to
line_wrap().

This way, the last row in the new grid corresponds to the last row in
the old grid.
2022-08-31 19:16:04 +02:00
Daniel Eklöf
649d56a4e5
grid: when setting the new viewport, ensure it’s correctly bounded
Do this by using scrollback relative coordinates, and ensure the new
viewport is not larger than (grid_rows - screen_rows), as that would
mean the viewport crosses the scrollback wrap-around.
2022-08-31 19:16:02 +02:00
Daniel Eklöf
d810e4fc8e
selection: mark_selected_region(): use an enum to encode how the cells are to be updated 2022-08-31 19:15:54 +02:00
Daniel Eklöf
2354298eca
selection: restore <= 1.12 behavior in block selection wrt empty cells
That is, highlight empty cells, regardless of whether they’re trailing
or not.
2022-08-31 19:15:51 +02:00
Daniel Eklöf
03d3887e6b
ci (sr.ht): pull directly from git.sr.ht 2022-08-31 19:15:48 +02:00
Daniel Eklöf
6f1cf6fc56
selection: once again highlight non-trailing empty cells
Foot 1.13.0 introduced a regression where non-trailing empty cells
were highlighted inconsistently (cells that shouldn’t be highlighted,
were, seemingly at random).

86663522d5 “fixed” this by never
highlighting *any* empty cells.

This meant the behavior, compared to foot 1.12 and earlier,
changed. In foot 1.12 and older versions, non-trailing empty cells
were highlighted, as long as the selection covered at least one of the
trailing non-empty cells.

This patch restores that behavior.

To understand how this works, lets first take a look at how selection
works:

When a selection is made, and updated (i.e. the mouse is dragged, or
the selection is extended through RMB etc), we need to (un)tag and dirty
the cells that are a) newly selected, or b) newly deselected. That is,
we look at the diff between the “old” and the “new” selection, and
only update those cells.

This is for performance reasons: iterating the entire selection is not
feasible with large selections. However, it also means we cannot
reason about empty cells; we simply don’t know if an empty cells is a
trailing empty cell, or a non-trailing one.

Then, when we render a frame, we iterate all the *visible*
and *selected* cells, once again tagging them as selected (this is
needed since a selected cell might have lost its selected tag if the
cell was written to, by the client application, after the selection
was made).

At this point, we *can* reason about empty cells.

So, to restore the highlighting behavior to that of foot 1.12, we do
this:

When working with the selection diffs when a selection is updated, we
don’t special case empty cells at all. Thus, all empty cells covered
by the selection is highlighted, and dirtied.

But, when rendering the frame, we _do_ special case them. The only
difference (compared to foot 1.12) is that we *must*
explicitly *clear* the selection tag, and dirty the empty cells. This
is to ensure the empty cells that were incorrectly highlighted by the
selection update algorithm, isn’t rendered as that.

This does have a slight performance impact, as empty cells are now
always re-rendered. The impact should however be small.
2022-08-31 19:15:44 +02:00
Daniel Eklöf
736babcdbc
selection: never highlight selected, empty cells
This fixes a regression, where empty cells "between" non-empty
cells (i.e. non-trailing empty cells) sometimes were incorrectly
highlighted.

The idea has always been to highlight exactly those cells that will
get extracted when they’re copied. This means we’ve not highlighted
trailing empty cells, but we _have_ highlighted other empty cells,
since they are converted to spaces when copied (whereas trailing empty
cells are skipped).

fa2d9f8699 changed how a selection is
updated. That is, which cells gets marked as selected, and which ones
gets unmarked.

Since we no longer walk all the cells, but instead work with pixman
regions representing selection diffs, we can no longer determine (with
certainty) which empty cells should be selected and which shouldn’t.

Before this patch (but after
fa2d9f8699), we sometimes incorrectly
highlighted empty cells that should not have been highlighted. This
happened when we’ve first (correctly) highlighted a region of empty
cells, but then shrink the selection such that all those empty cells
should be de-selected.

This patch changes the selection behavior to *never* highlight empty
cells. This fixes the regression, but also means slightly different
behavior, compared to pre-fa2d9f86996467ba33cc381f810ea966a4323381.

The other alternative is to always highlight all empty cells. But,
since I personally like the fact that we’re skipping trailing empty
cells, I prefer the approach taken by this patch.
2022-08-31 19:14:18 +02:00
Daniel Eklöf
ccef435736
ci: codespell: ignore ‘zar’ (user who contributed) 2022-08-31 19:14:03 +02:00
Daniel Eklöf
c753cf8f45
url-mode: connect osc-8 links only when both ID and URI matches
Before this, two OSC-8 links with a matching ID would be connected
even if their URIs weren’t the same. This is against the spec:

  The same id is only used for connecting character cells whose URIs
  is also the same. Character cells pointing to different URIs should
  never be underlined together when hovering over.

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
2022-08-30 17:55:14 +02:00
Daniel Eklöf
4dd63bcc91
Merge branch 'grid-reflow-viewport-crash-regression'
Closes #1074
2022-08-30 17:52:55 +02:00
Daniel Eklöf
524474728a
changelog: crash when resizing window, or scrolling 2022-08-29 21:04:56 +02:00
Daniel Eklöf
454c82f0f5
grid: reflow: assert there aren’t any open URIs on the last row 2022-08-29 21:03:21 +02:00
Daniel Eklöf
5c86358cd1
grid: reflow: don’t line-wrap the last row
Before this patch, we would line-wrap the last row, just like any
other row, and then afterwards try to reverse this, by adjusting the
offset and free:ing and NULL:ing the "last row".

The problem with this is if the scrollback is full. In this case, the
row we’re freeing is the first row in the scrollback history. This
means we’ll crash as soon as the viewport is moved to the top of the
scrollback.

The fix is fairly, simple. Skip the post-processing logic, and instead
detect when we’re line-wrapping the last row, and skip the call to
line_wrap().

This way, the last row in the new grid corresponds to the last row in
the old grid.
2022-08-29 20:47:33 +02:00
Daniel Eklöf
13281f327b
grid: when setting the new viewport, ensure it’s correctly bounded
Do this by using scrollback relative coordinates, and ensure the new
viewport is not larger than (grid_rows - screen_rows), as that would
mean the viewport crosses the scrollback wrap-around.
2022-08-29 20:46:19 +02:00
Daniel Eklöf
d5df86f785
selection: mark_selected_region(): use an enum to encode how the cells are to be updated 2022-08-26 21:07:20 +02:00
Daniel Eklöf
db2737b96a
selection: restore <= 1.12 behavior in block selection wrt empty cells
That is, highlight empty cells, regardless of whether they’re trailing
or not.
2022-08-26 17:48:00 +02:00
Daniel Eklöf
4f06d413e2
ci (sr.ht): pull directly from git.sr.ht 2022-08-23 16:38:39 +02:00
Daniel Eklöf
21ab16239d
selection: once again highlight non-trailing empty cells
Foot 1.13.0 introduced a regression where non-trailing empty cells
were highlighted inconsistently (cells that shouldn’t be highlighted,
were, seemingly at random).

86663522d5 “fixed” this by never
highlighting *any* empty cells.

This meant the behavior, compared to foot 1.12 and earlier,
changed. In foot 1.12 and older versions, non-trailing empty cells
were highlighted, as long as the selection covered at least one of the
trailing non-empty cells.

This patch restores that behavior.

To understand how this works, lets first take a look at how selection
works:

When a selection is made, and updated (i.e. the mouse is dragged, or
the selection is extended through RMB etc), we need to (un)tag and dirty
the cells that are a) newly selected, or b) newly deselected. That is,
we look at the diff between the “old” and the “new” selection, and
only update those cells.

This is for performance reasons: iterating the entire selection is not
feasible with large selections. However, it also means we cannot
reason about empty cells; we simply don’t know if an empty cells is a
trailing empty cell, or a non-trailing one.

Then, when we render a frame, we iterate all the *visible*
and *selected* cells, once again tagging them as selected (this is
needed since a selected cell might have lost its selected tag if the
cell was written to, by the client application, after the selection
was made).

At this point, we *can* reason about empty cells.

So, to restore the highlighting behavior to that of foot 1.12, we do
this:

When working with the selection diffs when a selection is updated, we
don’t special case empty cells at all. Thus, all empty cells covered
by the selection is highlighted, and dirtied.

But, when rendering the frame, we _do_ special case them. The only
difference (compared to foot 1.12) is that we *must*
explicitly *clear* the selection tag, and dirty the empty cells. This
is to ensure the empty cells that were incorrectly highlighted by the
selection update algorithm, isn’t rendered as that.

This does have a slight performance impact, as empty cells are now
always re-rendered. The impact should however be small.
2022-08-22 20:14:06 +02:00
Daniel Eklöf
3cf11bfea9
theme: change default color theme to solarized-dark-normal-brights
This is my variant of the solarized theme, were only the first eight
colors (i.e. the "normal") colors are from the solarized theme. The
remaining eight (the "bright" colors) are brightened versions of the
"normal" colors. This results in a theme that is usually in all
applications, not just those that are "aware" that the terminal color
theme is "solarized".
2022-08-22 13:37:12 +02:00