Commit graph

197 commits

Author SHA1 Message Date
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
Daniel Eklöf
25b09b909c
sixel: application configurable image max width/height 2020-02-22 21:03:24 +01:00
Daniel Eklöf
8e37a18083
sixel: application configurable palette size (color count)
This implements the CSI escapes for retrieving and (re)setting the
palette size.
2020-02-22 14:02:00 +01:00
Daniel Eklöf
a9971f4c32
csi: DA: we now implement sixel 2020-02-22 12:16:19 +01:00
Daniel Eklöf
cc5d596cd9
csi: log only the un-handled parameter in a multi-operation CSI
Assume we don't handle 'CSI 4 X'. Furthermore, assume we receive the
following: 'CSI 1;2;3;4X'. In this case, only log '4X' as un-handled,
not the entire CSI string.
2020-02-01 19:42:31 +01:00
Daniel Eklöf
4dde699107
csi: implement window and cell size reporting escapes
This implements the following queries:

* report window size in pixels
* report cell size in pixels
* report window size in chars

We also log a warning for the remaining window operation queries.
2020-02-01 19:27:52 +01:00
Daniel Eklöf
dfa5cb41e0
csi: recognize the X10 mouse tracking enabler/disabler
We still don't implement it, but now we at least recognize it and log
a warning when it is implemented.
2020-02-01 19:27:06 +01:00
Daniel Eklöf
38e2e037e6
csi: drop '28' from our DA response
We don't support rectangular editing
2020-02-01 19:26:08 +01:00
Daniel Eklöf
f13adf50dc
vt: use 8-bit indices for parameters and sub parameters
We only support 16 (sub) parameters and thus there's no need for
64-bit index variables.
2020-02-01 19:24:46 +01:00
Daniel Eklöf
51f8453f9d
csi: disable save/restore highlight mouse tracking
We don't implement it, so no point in warning about save/restore not
begin implemented.
2020-01-23 17:38:45 +01:00
Daniel Eklöf
e6d1ebbbfc
csi: warn when client tries to enable "highlight mouse tracking" 2020-01-23 17:38:23 +01:00
Daniel Eklöf
a3d919a90d
input: implement metaSendsEscape and eightBitMeta 2020-01-20 18:45:14 +01:00
Daniel Eklöf
4e87426712
csi: implement REP - CSI Ps b 2020-01-20 18:45:14 +01:00
Daniel Eklöf
2667fdd877
csi: change DA3 reply to "FOOT", in hex 2019-12-21 20:35:55 +01:00
Daniel Eklöf
7d29435d86
term: implement cursor blinking
Blinking can be enabled either by setting the cursor style with

 CSI Ps SP q

and selecting a blinking style.

Or, with 'CSI ? 12 h'

Note that both affect the same internal state. I.e. you can disable
blinking with CSI ? 12l after having selected a blinking cursor
style. This is consistent with XTerm behavior.
2019-12-15 15:07:56 +01:00
Daniel Eklöf
afc8ed97a6
csi: describe format of reply to tertiary DA 2019-12-14 19:10:59 +01:00
Daniel Eklöf
7d8327369b
csi: Send Device Attributes, Tertiary DA: require Ps == 0 2019-12-14 14:38:03 +01:00
Daniel Eklöf
9551be492c
csi/vt: don't bad client data as errors
This gets rid of spam when cat:ing binary data.
2019-11-30 00:12:30 +01:00
Daniel Eklöf
616896e2a5
csi/ocs/vt: log unhandled/unrecognized sequences as debug messages
Having them as error messages was nice when we where still missing
lots of sequences.

Now we don't anymore, and these just spam stdout as well as syslog
when e.g. cat:ing binary data.
2019-11-29 23:59:24 +01:00
Daniel Eklöf
0dd37f0a36
terminal: use the 'text' xcursor pointer whenever selection is possible 2019-11-28 19:35:47 +01:00
Daniel Eklöf
d41c4b9195
csi: implement "Send Device Attributes (Tertiary DA)" 2019-11-18 12:46:52 +01:00
Daniel Eklöf
612bf9ef4f
csi: adjust reply to primary DA
Report us as being VT220, as VT420 causes vttest to send a
DECRQSS. This is a DCS request that we don't implement (there's no DCS
handling *at all* - all DCS strings are ignored).

Should be ok as no one appears to care about this one. Other terminals
report a much lower level (urxvt for example, replies with vt100. We
used to reply with vt102, which also was fine).
2019-11-18 12:41:10 +01:00
Daniel Eklöf
2c99f692b3
csi: improve "Send Device Attributes (Primary DA)"
Pretend we're a VT420, with a couple of supported features
indicated. Note that I haven't verified we support *everything* that
each features entails - or even what exactly a feature *is* (locator
port?)
2019-11-18 12:07:17 +01:00
Daniel Eklöf
aa692d19e4
csi: document "Send Device Attributes (Secondary DA)" 2019-11-18 12:06:29 +01:00
Daniel Eklöf
0250a703e4
csi: implement 'Query Device Status'
By replying with "Device OK"
2019-11-18 11:44:03 +01:00
Daniel Eklöf
2d0c4928ee
csi: add debug logs for the various mouse reporting modes 2019-11-18 11:31:05 +01:00
Daniel Eklöf
9902a5732f
term: try to improve on a performance regression
When support was added for DECOM (absolute/relative row addressing), a
small but noticeable (~3.5%) performance regression was introduced.

Try to improve the situation by simplifying the relative-to-absolute
conversion; only the row needs to be transformed.
2019-11-17 18:52:27 +01:00
Daniel Eklöf
7f4b2c5755
csi: implement 'CHT' - Cursor Horizontal Tab 2019-11-17 12:29:52 +01:00
Daniel Eklöf
f4be84871f
csi: implement 'CPL' - Cursor Previous Line 2019-11-17 11:36:24 +01:00
Daniel Eklöf
d8708d1105
csi: implement 'CNL' - Cursor Next Line 2019-11-17 11:35:30 +01:00
Daniel Eklöf
53f4273b17
csi: implement 'HPR' - Horizontal Position Relative 2019-11-17 11:31:35 +01:00
Daniel Eklöf
616e506f2e
csi: fix bad implementation of CBT (back tab)
* It takes a parameter, that indicates the number of tab stops to move
  through
* Use the tab stops defined in the tab stops list, not hard coded mod
  8 columns.
2019-11-17 11:20:59 +01:00
Daniel Eklöf
ca58c4c621
csi: implement 'HPA' - Horizontal Position Absolute 2019-11-17 11:09:16 +01:00
Daniel Eklöf
a70fe1f5d7
term: move lcf flag into 'cursor' struct 2019-11-17 09:46:20 +01:00
Daniel Eklöf
d637b8c9ba
term: add struct cursor 2019-11-17 09:44:31 +01:00
Daniel Eklöf
c1088d77ac
term: rename: print_needs_wrap -> lcf (Last Column Flag) 2019-11-17 09:39:43 +01:00
Daniel Eklöf
f74026ba9b
csi: el/ed/dch/ich/ech: reset 'print_needs_wrap' (lcf)
This makes the result of 'wraptest', by Mattias Engdegård, match the
behavior of 'DEC' (the architectural behavior of DEC terminals).
2019-11-17 09:36:55 +01:00
Daniel Eklöf
9840291100
csi: implement CSI 0g and CSI 3g
* 0g - clear tab stop at current column
* 3g - clear all tab stops
2019-11-16 10:55:28 +01:00
Daniel Eklöf
f6d87e235b
csi: CSI ?4h enables smooth scrolling, ?4l enables jump scrolling 2019-11-05 14:37:17 +01:00
Daniel Eklöf
95eaad7ce4
csi: implement DECOM - switch cursor origin between absolute and relative
The default is absolute mode, where 0,0 is the upper left corner of
the screen.

In relative mode, the origin is relative the top scroll margin.

Internally, we always track the current cursor position in absolute
mode. Every time we the client *sets* or *queries* the cursor position
in relative mode, we translate it to absolute.
2019-11-05 13:27:37 +01:00
Daniel Eklöf
89dbc61a34
csi: DECCOLM erases screen 2019-11-05 13:21:47 +01:00
Daniel Eklöf
342d6036f9
csi: CSI ?3h enables 132 column mode, CSI ?3l 80 column mode 2019-11-05 11:10:56 +01:00