Commit graph

338 commits

Author SHA1 Message Date
Daniel Eklöf
15d20af2a2
config: add ‘notify’ to possible values for ‘bell’ in foot.ini
When `bell=notify`, foot will trigger a desktop notification when it
receives a BEL in an unfocused window.
2020-12-10 18:22:48 +01:00
Daniel Eklöf
0536bc41f4
csi: add DECSET 737769 - enables/disables IME input
73 77 69 = I M E
2020-12-07 20:44:12 +01:00
Craig Barnes
31c73f0cf0 csi: add new private mode that makes the Escape key emit "\E[27;1;27~"
This mode can be set by client programs with the DECSET, DECRST,
XTSAVE and XTRESTORE sequences by using 27127 as the parameter.

The sequence "\E[27;1;27~" is encoded in the same way as is done by
xterm's "modifyOtherKeys" mode. Even though xterm itself never emits
such a sequence for the Escape key, many programs already have
support for parsing this style of key sequence.
2020-11-29 04:04:57 +00:00
Daniel Eklöf
cb2f496269
term: split cursor blink state into two
There are two different escape sequences that can be used to set the
cursor blink state: ‘CSI ? 12 h/l’ and ‘CSI Ps SP q’.

Up until now, they both modified the same internal state in foot. This
meant you could enable a blinking cursor with e.g. ‘CSI ? 12 h’ and
then disable it with ‘CSI 2 SP q’.

Since the ‘CSI ? 12’ escapes are used in the civis/cnorm/cvvis
terminfo entries, applications often ended up disabling the blink
state on exit (typically be emitting ‘cnorm’), requiring users to
manually re-enable blinking.

By splitting the internal state into two separate states, we can
improve the situation.

The cursor will blink if at least one of the two have been enabled.

The setting in foot.ini sets the default state of the ‘CSI Ps SP q’
escape.

This means if the user has enabled blinking in the configuration, the
cursor will blink regardless of civis/cnorm/cvvis. Which probably is
what the user wants.

If the user has NOT enabled blinking, civis/cnorm/cvvis act as
intended: cvvis blink, civis and cnorm do not.

If an application overrides the cursor blink/style with ‘CSI Ps SP q’,
that will override the user’s setting in foot.ini. But most likely
that too is intended (for example, the user may have configured the
application to use a different cursor style). And, a well written
application will emit the ‘Se’ terminfo sequence on exit, which in
foot is defined to ‘CSI SP q’, which will reset both the style and
blink state to the user configured style/state.

Closes #218
2020-11-26 18:09:32 +01:00
Daniel Eklöf
360cc8e6de
term: remove read-only properties copied from the config
Use the config directly instead.
2020-11-26 18:08:28 +01:00
Daniel Eklöf
2382d6b448
csi: implement “CSI ? 1035” - toggle Num Lock override
This adds a num_lock_modifier state to the terminal, and hooks up
“CSI?1035h/l” to toggle it.
2020-11-11 18:26:47 +01:00
Daniel Eklöf
17761dce63
csi: implement ‘CSI ? 1042 h/l’ - enable/disable bell-is-urgent 2020-10-11 17:44:29 +02:00
Daniel Eklöf
5b0af8ed59
csi: only respond to Primary DA when Ps == 0 2020-10-09 18:53:00 +02:00
Daniel Eklöf
7c6686221f
bell: optionally render margins in red when receiving BEL
Add anew config option, ‘bell=none|set-urgency’. When set to
‘set-urgency’, the margins will be painted in red (if the window did
not have keyboard focus).

This is intended as a cheap replacement for the ‘urgency’ hint, that
doesn’t (yet) exist on Wayland.

Closes #157
2020-10-08 19:55:32 +02:00
Daniel Eklöf
71c54fb87c
csi: xtrestore: add ‘reverse wrap’ 2020-10-03 11:53:03 +02:00
Daniel Eklöf
060be30803
term: add private mode flag ‘’reverse-wrap’ 2020-10-02 21:29:56 +02:00
Craig Barnes
0e7723e75f csi: avoid using memcmp() to compare timespec structs
This struct may contain padding bytes, whose values are indeterminate
after any store operation[1]. It may also contain unnamed members,
whose values are always indeterminate[2]. Using memcmp() isn't a
reliable way to compare structs where either of these may be present.

[1]: ISO/IEC 9899:1999 §6.2.6.1, paragraph 6
[2]: ISO/IEC 9899:1999 §6.7.8, paragraph 9

See also:

* https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data
* https://sourceware.org/git/?p=glibc.git;a=blob;f=time/bits/types/struct_timespec.h;hb=756c306502498f9
2020-08-23 03:08:35 +01:00
Craig Barnes
7c58648238 csi: add 2 missing "break" statements in csi_dispatch() 2020-08-18 20:49:44 +01:00
Daniel Eklöf
a48578c857
csi: xtrestore: add 'default' case
Don't call decset_decrst() with an unhandled parameter (and with
'enabled' uninitialized!)
2020-08-18 21:14:05 +02:00
Daniel Eklöf
79d20d75d2
csi: xtrestore: add missing break 2020-08-18 21:13:50 +02:00
Daniel Eklöf
22dcbeacb7
csi: xtsave/xtrestore: implement \E[?12s and \E[?12r
I.e. save/restore cursor-blink state.
2020-08-18 07:00:26 +02:00
Daniel Eklöf
15ae82e62e
csi: decset/decrst: only clear mouse tracking/reporting if mode matches
E.g. only set mouse reporting to NONE, if mouse reporting mode is SGR
and an DECRST SGR is issued.

Do *not* reset the mouse mode if e.g. mouse reporting mode is SGR and
an DECRST URXVT is issued.
2020-08-18 06:53:47 +02:00
Daniel Eklöf
23a5ff53eb
csi: implement XTRESTORE 2020-08-16 17:02:52 +02:00
Daniel Eklöf
b4f868e566
csi: xtsave: store modes' SET state, not the current state 2020-08-16 16:57:39 +02:00
Daniel Eklöf
cc48366f02
csi: implement CSI ? Pm s - XTSAVE 2020-08-16 16:47:46 +02:00
Daniel Eklöf
5593868471
csi: add xtsave()
This function stores the current state of DECSET private modes.
2020-08-16 16:46:21 +02:00
Daniel Eklöf
0787080023
csi: decrst: spell decset correctly 2020-08-16 16:38:30 +02:00
Daniel Eklöf
cf315de174
csi: add DEC names to a couple of DECSET modes 2020-08-16 16:25:52 +02:00
Daniel Eklöf
2eebf9b8cc
csi: break out decset/decrst 2020-08-16 16:23:17 +02:00
Craig Barnes
104fe2fa55 Fix some spelling mistakes 2020-08-15 19:39:00 +01: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
019b6bc039
fix printf-format errors in 32-bit builds 2020-08-06 23:20:46 +02:00
Daniel Eklöf
4919ccbc70
term: remove unusued 'damage' list 2020-08-04 18:07:22 +02:00
Daniel Eklöf
60984e7a24
csi: secondary DA: do not pretend we're xterm
Previously, our secondary DA response indicated a) VT420, b) an XTerm
version number.

Now, we indicate VT220 (which corresponds to the primary DA response),
and we report foot's version number as MMmmpp. I.e major, minor and
patch versions, using two digits.

E.g. 1.4.2 is encoded as 010402
2020-07-24 17:47:47 +02:00
Daniel Eklöf
cc60d3a670
csi: primary DA: remove features we do not support
We do not implement

* Selective Erase
* Technical Character Set
* Terminal state interrogation
2020-07-24 17:46:18 +02:00
Daniel Eklöf
47d6dd0eee
csi: never call term_print() with width <= 0 2020-07-16 08:06:37 +02:00
Daniel Eklöf
bc2fc778ae
csi: DECAWM: clear LCF 2020-07-14 10:54:53 +02:00
Daniel Eklöf
7fce1720d6
csi: IND+RI now clears LCF 2020-07-14 10:52:46 +02:00
Daniel Eklöf
b9719673a1
term: rename term_formfeed() -> term_carriage_return() 2020-07-14 09:29:10 +02:00
Daniel Eklöf
7f65bd1c20
csi: '\E[0 q' resets the cursor style to the default, not '\E[2 q'
Also update 'Se' capability in the terminfo, to reflect this.
2020-06-30 17:44:43 +02:00
Daniel Eklöf
fd4904d82a
csi: debug: print 'private' *after* parameters 2020-06-30 17:42:57 +02:00
Daniel Eklöf
bf57d0c606
csi: \E[3J: reset render.last_cursor.row if necessary
This fixes a crash that occurred when the last rendered cursor cell
had scrolled off screen, and \E[3J (clear scrollback) was executed.
2020-06-09 17:32:34 +02:00
Daniel Eklöf
550667a9ea
term: scrolling: calling function must clamp scroll amount 2020-05-19 18:47:38 +02:00
Daniel Eklöf
af9e5aef2b
csi: ignore invalid parameters in 'CSI Ps <space> q'
Before this patch, an invalid parameter would not change the cursor
style, but could cause the cursor to start (or stop) blinking.
2020-05-04 20:19:24 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
33a53efa71
csi: log 'unhandled' for invalid 'target' and 'operation' in CSI ? S 2020-04-25 11:39:31 +02:00
Daniel Eklöf
08485ce412
csi: fix typo - the '(' was in the wrong place 2020-04-19 14:52:14 +02:00
Daniel Eklöf
e93757198a
csi: CSI Ps ; Ps ; Ps t: report logical pixels 2020-04-18 23:20:09 +02:00
Daniel Eklöf
fa8b0cbd80
csi: implement CSI Ps ; Ps ; Ps t reporting escape sequences
A lot of the escape sequences on the "CSI Ps ; Ps ; Ps t" form are
expected to return a reply. Thus, not having these implemented means
we will hang if the client sends these escapes.

Not all of these escapes can be meaningfully implemented on Wayland,
and thus this implementation is best effort.

We now support the following escapes:

* 11t   - report if window is iconified (always replies "no")
* 13t   - report window position (always replies 0,0)
* 13;2t - report text area position (replies with margins, since we
          cannot get the window's position)
* 14t   - report text area size, in pixels
* 14;2t - report window size, in pixels
* 15t   - report screen size, in pixels
* 16t   - report cell size, in pixels
* 18t   - report text area size, in cells
* 19t   - report screen size, in cells
2020-04-18 11:51:53 +02:00
Daniel Eklöf
89559d5466
grid: move 'cursor' state from terminal to grid
This way, the 'normal' and 'alt' grids have their own cursor state,
and we don't need to switch between them.
2020-04-16 18:51:14 +02:00
Daniel Eklöf
1776f8bf1e
Fix clang warnings
All are printf() formatter related. Even if a variable is e.g. a
'short', when used in an expression like '<variable> - 1' it is
promoted to an 'int'.

Closes #16
2020-04-12 18:20:52 +02:00
Daniel Eklöf
1006608093
alt-screen: use a custom 'saved' cursor when switching to alt screen
This fixes an issue where we failed to restore the cursor correctly
when exiting from the alternate screen, if the client had sent escapes
to save the cursor position while inside the alternate screen.

This was because we used the *same* storage for saving the cursor
position through escapes, as for saving it when entering the alternate
screen.

Fix by using a custom variable dedicated to normal <--> alt screen
switching.
2020-03-16 12:00:25 +01:00
Daniel Eklöf
d482bf0a30
sixel: improve handling of images when reflowing the grids
Update the sixels' 'row' attribute when re-flowing a grid, to ensure
it is rendered at the correct place.

This should work in most cases, but will break when the cell size has
changed (e.g. font size increase/decrease, or a DPI change).

This patch also moves the sixel image list from the terminal struct
into the grid struct. The sixels are per-grid after all.
2020-03-13 18:47:16 +01:00
Daniel Eklöf
d804bc8579
term: resize: pre-calculate right/bottom margins 2020-02-24 18:38:11 +01:00
Daniel Eklöf
7fd380f253
csi: delete all sixels on the 'alt' grid when switching back to 'normal' 2020-02-23 00:41:55 +01:00