Commit graph

1250 commits

Author SHA1 Message Date
Daniel Eklöf
56556e5f23
render: hollow-cursor: use correct cursor color 2024-07-13 10:37:21 +02:00
Daniel Eklöf
c46c124363
render: cursor: use default fg/bg if cell fg/bg are the same
When deciding which colors to use for the cursor, and the cursor text
and background colors are the same, use the default fg/bg instead.

Closes #1761
2024-07-13 10:30:23 +02:00
Daniel Eklöf
5edb0deffe
changelog: XTPUSHCOLORS, XTPOPCOLORS and XTREPORTCOLORS 2024-07-03 09:47:49 +02:00
Daniel Eklöf
e708d19ea3
csi: implement SGR 21, double underlines 2024-07-03 09:46:41 +02:00
Daniel Eklöf
7341ba5ee3
render: cursor color: remove assertion that both cursor fg/bg be set
Before this patch, we asserted both the cursor foreground, and
background colors had been set. This is true in most cases; the config
system enforces it.

It is however possible to set only the cursor background color, while
leaving the foreground (text) color unset:

* Use a foot config that does *not* configure the cursor colors. This
  means foot will invert the default fg/bg colors when rendering the
  cursor.
* Override the cursor color using an OSC-12 sequence. OSC-12 only sets
  the background color of the cursor, and there is no other OSC sequence
  to set the cursor's text color.

To handle this, remove the assertion, and simply split the logic for
the cursor backgound and foreground colors:

* Use the configured background color if set (either through config or
  OSC-12), otherwise use the default foreground color.
* Use the configured foreground color if set (through config),
  otherwise use the default background color.
2024-07-01 10:53:21 +02:00
Daniel Eklöf
0759caec6e
changelog: styled + colored underlines 2024-06-26 18:39:24 +02:00
Daniel Eklöf
9665661445
vt: only apply VS-15/16 to valid sequences
At compile time, build a lookup table from the Unicode data file
'emoji-variation-sequences.txt'.

At run-time, when we detect a VS-15/16 sequence, do a lookup in this
table, and enforce the variation selector iff the sequence is valid.

Closes #1742
2024-06-25 08:20:21 +02:00
Daniel Eklöf
94583703e1
vt: don't ignore VS-15 (text presentation)
When we encounter either VS-15 or VS-16, set the grapheme width to 1
or 2 explicitly.
2024-06-25 08:20:20 +02:00
Daniel Eklöf
795e39de1a
shm: discard shm buffers with mis-matching alpha-setting 2024-06-24 20:09:37 +02:00
Daniel Eklöf
c45231ef89
input: don't reset the XKB compose state in keymap()
When the compositor sends a new keymap, don't reset the XKB compose
state.

This is done by initializing the XKB context, along with the compose
state, when binding the seat, instead of in keymap().

Then, in keymap(), simply stop destroying the old xkb state. Only
destroy, and re-create the keymap state.

Closes #1744
2024-06-22 08:00:13 +02:00
Daniel Eklöf
aea16ba5d2
input: implement wl_pointer::axis_value120()
This implements high resolution mouse wheel scroll events. A "normal"
scroll step corresponds to the value 120. Anything less than that is a
partial scroll step.

This event replaces axis_discrete(), when we bind wl_seat v8 (which we
now do, when available).

We calculate the number of degrees that is required to scroll a single
line, based off of the scrollback.multiplier value.

Each high-res event accumulates, until we have at least the number of
degress required to scroll one, or more lines.

The remaining degrees are kept, and added to in the next scroll event.

Closes #1738
2024-06-18 14:09:03 +02:00
Daniel Eklöf
f3d848da01
osc: 52: treat OSC-52 replies as paste data (after all, they are)
This fixes an issue where other data (such as replies to other
requests) being interleaved with the OSC-52 reply.

The patch piggy backs on the already existing mechanism for handling
regular pastes, where other data is queued up until the paste is done.

There's one corner case that won't work; if the user *just* did a
normal paste (i.e. at virtually the same time the application
requested OSC-52 data), the OSC-52 request will return an empty reply.

Likewise, if there are multiple OSC-52 requests at the same time, only
the first will return data.

Closes #1734
2024-06-09 10:14:57 +02:00
Daniel Eklöf
fb2ad83d79
changelog: wp-single-pixel-buffer-v1 2024-05-22 13:48:47 +02:00
Daniel Eklöf
8716ca5784
url-mode: disable IME mode while URL-mode is active
This prevents the IME from stealing "our" key-presses, and thus
preventing the user from opening URLs.

Closes #1718, hopefully.
2024-05-21 08:37:39 +02:00
Daniel Eklöf
18b702b249
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.

The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.

The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.

There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.

This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.

Closes #1717
2024-05-21 08:36:56 +02:00
Daniel Eklöf
c4f1380943
config: add cursor.blink-rate option
The default is 500ms, which corresponds to the old, hardcoded default.

Closes #1707
2024-05-20 09:17:42 +02:00
Daniel Eklöf
a3debf7741
dcs: xtgettcap: always reply with tigetstr(3) formatted "strings"
That is, instead of sometimes replying with a "source" encoded
string (where e.g. '\E' are returned just like that, and not as an
actual ESC), always unescape all string values.

This also includes \n \r \t \b \f \s, \^ \\ \ \:, as well as ^x-styled
escapes.

Closes #1701
2024-04-27 09:38:55 +02:00
Daniel Eklöf
4d4ef5eed5
dcs: XTGETTCAP: handle empty request
If the XTGETTCAP request is empty (no capabilities in it), reply with
an empty error reply.

Closes #1694
2024-04-20 08:27:25 +02:00
Daniel Eklöf
128c5c3efa
term: default to DPI 96, if the monitor's DPI is 0
This can happen in virtualized environments, or when running a nested
Wayland session.
2024-04-20 08:26:44 +02:00
Daniel Eklöf
a1ac37e771
changelog: add new 'unreleased' section 2024-04-17 11:28:22 +02:00
Daniel Eklöf
f2fbef1f82
changelog: prepare for 1.17.2 2024-04-17 11:26:25 +02:00
Daniel Eklöf
7c20fb247c
term: stash last known DPI, and use after a unmapped/mapped sequence
A compositor may unmap, and then remap the window, for example when
the window is minimized, or if the user switches workspace.

With DPI aware rendering, we *need* to know on which output we're
mapped, in order to use the correct DPI. This means the first frame we
render, before being mapped, always guesses the DPI.

In an unmap/map sequence, guessing the wrong DPI means the window will
flicker.

Fix by stashing the last used DPI value, and use that instead of
guessing.

This means the *only* time we _actually_ guess the DPI, is the very
first frame, when starting up foot.
2024-04-17 09:14:52 +02:00
Daniel Eklöf
3d2588edf8
sixel: don't allow pan/pad changes after sixel data has been emitted
Changing pan/pad changes the sixel's aspect ratio. While I don't know
for certain what a real VT340 would do, I suspect it would change the
aspect ratio of all subsequent sixels, but not those already emitted.

The way we implement sixels in foot, makes this behavior hard to
implement. We currently don't resize the image properly if the aspect
ratio is changed, but not the RA area. We have code that assumes all
sixel lines have the same aspect ratio, etc.

Since no "normal" applications change the aspect ratio in the middle
of a sixel, simply disallow it, and print a warning.

This also fixes a crash, when writing sixels after having modified the
aspect ratio.
2024-04-15 16:07:47 +02:00
Daniel Eklöf
0ab05f4807
sixel: also set 'alloc_height', when short-cutting a resize operation
In some cases, a sixel may be resized vertically, while still having a
zero-width. In this case, the resize operations are short-cutted, and
no actual allocations are done.

However, we forgot to set 'alloc_height' when doing so. As a result,
the trimming code (when the sixel is "done"), trimmed away the entire
sixel.
2024-04-15 16:05:56 +02:00
Daniel Eklöf
71ce17d977
term: don't print outside grid when printing multi-column characters
When auto-wrap is disabled, a multi-column character may be printed on
a line that doesn't fit the entire character. That is, the "spacers"
we print, as place holders in the columns after the first one, may
reach outside the grid.

We did (try to) check for this, but the check was off by one. Meaning,
we could, in some cases, print outside the grid.
2024-04-15 16:03:30 +02:00
Daniel Eklöf
23ada09d14
osc: reject notifications with invalid UTF-8 strings 2024-04-15 16:02:54 +02:00
Daniel Eklöf
4fd26c251c
changelog: add a new 'unreleased' section 2024-04-11 15:32:15 +02:00
Daniel Eklöf
accefc3ae1
changelog: prepare for 1.17.1 2024-04-11 15:28:08 +02:00
Daniel Eklöf
b400903e25
config: add new key-binding 'quit', unbound by default
Closes #1475
2024-04-11 15:12:45 +02:00
Daniel Eklöf
e5a2ac4b57
config: add cursor.unfocused-style
This option controls how we render the cursor when the terminal window
is unfocused.

Possible values are:

* hollow: the default, and how we rendered the cursor before this
  patch.
* unchanged: render the cursor exactly the same way as when the window
  is focused.
* none: do not render any cursor at all

Closes #1582
2024-04-10 16:24:10 +02:00
Daniel Eklöf
9287946b36
dcs: DECRQSS: fix off-by-one when checking for space in the DCS buffer 2024-04-10 05:44:33 +02:00
Daniel Eklöf
7f4328e0b1
term: send SIGHUP before SIGTERM when shutting down
If we're the ones initiating shutdown, start by sending SIGHUP. Only
if the client application does not terminate, send SIGTERM (and if it
still refuses to terminate, send SIGKILL).

Also reduce the timeout between the signals from 60s to 30s.
2024-04-05 19:34:17 +02:00
Daniel Eklöf
c7848c4e75
term: don't shutdown terminal when PTY is closed, unless --pty was used
Unless --pty has been used, we do *not* want to shutdown the terminal
when the PTY is closed by the client application; we want to wait for
the client application to actually terminate.

This was the behavior before the --pty patch.

This was changed in the --pty patch, since then, we don't *have* a
client application. That is, foot has not forked+exec:ed anything. The
only way to trigger a shutdown (from the client side) is to close the
PTY.

This patch restores the old behavior, when --pty is *not* used.

Closes #1666
2024-04-05 18:45:31 +02:00
Daniel Eklöf
4f1aaccf81
log: fix syslog not respecting the configured log level 2024-04-05 16:19:24 +02:00
Daniel Eklöf
51e8b4f533
changelog: add new 'unreleased' section 2024-04-02 16:34:08 +02:00
Daniel Eklöf
d5dc0b2f49
changelog: prepare for 1.17.0 2024-04-02 16:27:25 +02:00
Daniel Eklöf
82c1a28e6f
changelog: move DECRQM for private mode 67 from "added" to "changed" 2024-04-01 08:49:27 +02:00
Daniel Eklöf
3d0d9036fd
terminfo: tighten up the rv/xr regular expressions 2024-03-29 11:40:47 +01:00
Daniel Eklöf
8e79ceba9e
terminfo: add 'nel' capability 2024-03-29 11:40:35 +01:00
Daniel Eklöf
a34ae5d527
terminfo: add fe/fd (focus enable/disable)
These are new capabilities, recently added to ncurses. Applications
are supposed to use these, instead of XM (to enable focus events). So,
remove "CSI ? 1004h" from XM.
2024-03-29 11:40:15 +01:00
Daniel Eklöf
cc660bc7c1
sixel: trim trailing, fully transparent sixel rows
See https://github.com/hpjansson/chafa/issues/192
2024-03-18 17:09:20 +01:00
Daniel Eklöf
282c55aa4a
sixel: place cursor on the last character row touched by the sixel
After emitting a sixel, place the cursor on the character row touched
by the last sixel. The last sixel _may_ not be a multiple of 6
pixels, *if* the sixel had an explicit width/height set via raster
attributes.

This is an intended deviation from the DEC cursor placement algorithm,
where the cursor is placed on the character row touched by the last
sixel's *upper* pixel.

The adjusted algorithm implemented here makes it much easier for
applications to handle text-after-sixels, since they can now simply
assume a single text newline is required to move the cursor to a
character row not touched by the sixel.
2024-03-18 16:58:54 +01:00
Craig Barnes
27330a5dd6
csi: indicate "permanently reset" for DECRQM queries of mode 67 (DECBKM)
This allows dynamic querying for the equivalent of terminfo's "kbs"
capability.
2024-03-16 15:36:00 +01:00
Daniel Eklöf
60fd4a262c
sixel: initialize the color table to colors used by the VT340 2024-03-15 15:19:43 +01:00
Alyssa Ross
86894a1cd2
Add support for opening an existing PTY
Virtual machine monitor programs (e.g. QEMU, Cloud Hypervisor) expose
guest consoles as PTYs.  With this patch, foot can access these guest
consoles.

Usually, the program used for accessing these PTYs is screen, but
screen is barely developed, doesn't support resizing, and has a bunch
of other unrelated stuff going on.  It would be nice to have a
terminal emulator that properly supported opening an existing PTY.
The VMM controls the master end of the PTY, so to the other end (in
this case foot), it just behaves like any application running in a
directly-opened PTY, and all that's needed is to change foot's code to
support opening an existing PTY rather than creating one.

Co-authored-by: tanto <tanto@ccc.ac>
2024-03-14 07:31:03 +01:00
Daniel Eklöf
712bc95db3
csi: the CSI-t family of queries now report unscaled pixel values
Before this patch, we reported scaled pixel values. This was rather
useless, since applications have no way of getting the scaling factor,
to "scale up" e.g. images.

Furthermore, the most common use of these queries are probably to
calculate the dimensions to use when emitting sixels.

Closes #1643
2024-03-14 07:26:37 +01:00
Daniel Eklöf
4ea4e5da4e
changelog: rectangular functions: add bug ref 2024-03-07 16:29:39 +01:00
Daniel Eklöf
cbf55ccacf
changeloge: move DECERA to the 'unreleased' section 2024-03-07 16:28:59 +01:00
Daniel Eklöf
aac24bfa1b
foot.info: add non-standard capability ‘Rect’ (used by tmux)
This tells tmux it can use DECFRA to erase rectangular regions.
2024-03-07 16:25:02 +01:00
Daniel Eklöf
4b4fe9d493
changelog: rectangular edit functions 2024-03-07 16:24:33 +01:00