aboutsummaryrefslogtreecommitdiff
path: root/csi.c (follow)
Commit message (Collapse)AuthorAgeLines
* csi: update ASCII printer function pointer when switching to/from alt screenDaniel Eklöf2021-03-16-0/+1
| | | | | This is necessary since switching screen may change how many sixels we have in the scrollback.
* term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print functionDaniel Eklöf2021-03-16-0/+2
| | | | | | | | | | | | | | | | | | | | | | | term_print() is called whenever the client application “prints” something to the grid. It is called for both ASCII and UTF-8 characters, and needs to handle sixels, insert mode and ASCII vs. graphical charsets. Since it’s on the hot path, this becomes unnecessarily slow. This patch adds a “fast” version of term_print(), tailored for the common case: ASCII characters in non-insert mode, without any sixels and non-graphical charsets. A new function, term_update_ascii_printer(), has been added, and must be called whenever: * The currently selected charset *index* changes * The currently selected charset changes (from ASCII to graphical, or vice verse) * Sixels are added to the grid * Sixels are removed from the grid * Insert mode is enabled/disabled
* sixel: implement private mode 80 - sixel scrollingDaniel Eklöf2021-02-26-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When enabled (the default), sixels behave much like normal output; the start where the cursor is, and the cursor moves with the sixel. I.e. after emitting a sixel the cursor is left after the image; either to the right, if private mode 8452 is enabled, or otherwise on the next line. Terminal content is scrolled up if the sixel is larger than the screen. When disabled, sixels *always* start at (0,0), the cursor never moves, and the terminal content never scrolls. In other words, the ‘disabled’ mode is a much simpler mode. All we need to do to support both modes is re-write the sixel-emitting loop to: * break early if we’re “out of rows”, i.e. we’ve reached the bottom of the screen. * not linefeed, or move the cursor when scrolling is disabled This patch also fixes a bug in the (new) implementation of private mode 8452. When emitting a sixel, we may break it up into smaller pieces, to ensure a single sixel (as tracked internally) does not cross the scrollback wrap-around. The code that checked if we should do a linefeed or not, would skip the linefeed on the last row of *each* such sixel piece. The correct thing to do is to skip it only on the last row of the *last* piece. I chose not to fix this bug in a separate patch since doing so would have meant re-writing it again when implementing private mode 80.
* sixel: implement private mode 8452 - cursor positioning after sixelDaniel Eklöf2021-02-23-0/+7
| | | | | | | | | | When disabled (the default), the cursor is positioned on a new line after emitting a sixel image. When enabled, the cursor is positioned to the right of the sixel image. Closes #363
* sixel: implement private mode 1070 - private color paletteDaniel Eklöf2021-02-23-0/+7
| | | | | | | | | When enabled (the default), sixels use private color registers. That is, the color palette from the last sixel is *not* re-used. When disabled, sixels share (i.e. re-use) the same color palette. Closes #362
* csi: ‘CSI 13 ; 2 t’ reply is now (0,0)Daniel Eklöf2021-02-16-3/+2
| | | | | | | | Foot previously responded with window local coordinates. But, XTerm responds with screen *absolute* coordinates. This isn’t possible under Wayland, thus we now report (0,0) instead. Same as we do for ‘CSI 13 ; 0 t’.
* csi: add 47+1047 (alt screen) to DECRQMDaniel Eklöf2021-02-09-0/+2
|
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-2/+2
|
* Print stack trace on assert() failure or when calling fatal_error()Craig Barnes2021-01-16-1/+1
| | | | | | Note: this uses the __sanitizer_print_stack_trace() function from the AddressSanitizer runtime, so it only works when AddressSanitizer is in use.
* csi: implement DECSET 47 - use alternate screen bufferDaniel Eklöf2021-01-16-0/+3
|
* term: keep cursor state in grid, for now, but document that it _could_ be movedDaniel Eklöf2021-01-15-2/+0
|
* csi: add support for ?1047 and ?1048Daniel Eklöf2021-01-15-8/+27
| | | | | | | | | | | * 1047 enters/leaves the alt screen, but without saving/restoring the cursor. * 1048 saves/restores the cursor * 1049 is 1047+1048 Note: when xtsaving and xtrestoring 1048, why simply save/restore the cursor. Without having read XTerms sources, this appears to be what it is doing.
* term/vt/csi: break out cursor save/restore to dedicated functionsDaniel Eklöf2021-01-15-5/+1
|
* Add xsnprintf() and remove some unnecessary strlen(3) callsCraig Barnes2021-01-14-18/+19
|
* vt: don’t ignore extra private/intermediate charactersDaniel Eklöf2020-12-16-41/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Take ‘\E(#0’ for example - this is *not* the same as ‘\E(0’. Up until now, foot has however treated them as the same escape, because the handler for ‘\E(0’ didn’t verify there weren’t any _other_ private characters present. Fix this by turning the ‘private’ array into a single 4-byte integer. This allows us to match *all* privates with a single comparison. Private characters are added to the LSB first, and MSB last. This means we can check for single privates in pretty much the same way as before: switch (term->vt.private) { case ‘?’: ... break; } Checking for two (or more) is much uglier, but foot only supports a *single* escape with two privates, and no escapes with three or more: switch (term->vt.private) { case 0x243f: /* ‘?$’ */ ... break; } The ‘clear’ action remains simple (and fast), with a single write operation. Collecting privates is potentially _slightly_ more complex than before; we now need mask and compare, instead of simply comparing, when checking how many privates we already have. We _could_ add a counter, which would make collecting privates easier, but this would add an additional write to the ‘clean’ action which is really bad since it’s in the hot path.
* csi: implement DECRQM (DEC modes), for realDaniel Eklöf2020-12-16-1/+44
| | | | | Previously, we always returned ‘2 - reset’, instead of the actual state of the requested mode.
* csi: SGR 21 is “double underline”, not “disable bold” (according to ECMA-48)Daniel Eklöf2020-12-14-1/+1
|
* csi: fix sub-parameter versions of 38/48 SGR escapesDaniel Eklöf2020-12-12-74/+70
| | | | | | | | | | | | | | | | | | | Well this is embarrassing; the sub-parameter versions of the 38/48 SGR escapes all required an extra ‘:2’ that wasn’t supposed to be there, causing all the other sub-parameters to be shifted one step to the right. That is, foot expected e.g. 38:2:2:r:g:b, or 38:2:5:idx when the correct sequences are 38:2:cs:r:g:b and 38:5:idx. I.e. I mixed up the color-space ID (cs) of 38:2 with *type* of color: RGB or indexed. In addition to fixing this, this patch also adds support for a “bastard” version of the sub-parameter based RGB escapes, where the color-space identifier has been left out: e.g. 38:2:r:g:b. This sequence is invalid, but applications tend to “forget” the color-space ID...
* csi: ‘CSI s’ and ‘CSI u’ now saves/restores attributes and charsetsDaniel Eklöf2020-12-11-0/+4
|
* config: add ‘notify’ to possible values for ‘bell’ in foot.iniDaniel Eklöf2020-12-10-3/+3
| | | | | When `bell=notify`, foot will trigger a desktop notification when it receives a BEL in an unfocused window.
* csi: add DECSET 737769 - enables/disables IME inputDaniel Eklöf2020-12-07-0/+9
| | | | 73 77 69 = I M E
* csi: add new private mode that makes the Escape key emit "\E[27;1;27~"Craig Barnes2020-11-29-0/+6
| | | | | | | | | | 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.
* term: split cursor blink state into twoDaniel Eklöf2020-11-26-32/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* term: remove read-only properties copied from the configDaniel Eklöf2020-11-26-1/+2
| | | | Use the config directly instead.
* csi: implement “CSI ? 1035” - toggle Num Lock overrideDaniel Eklöf2020-11-11-0/+8
| | | | | This adds a num_lock_modifier state to the terminal, and hooks up “CSI?1035h/l” to toggle it.
* csi: implement ‘CSI ? 1042 h/l’ - enable/disable bell-is-urgentDaniel Eklöf2020-10-11-2/+4
|
* csi: only respond to Primary DA when Ps == 0Daniel Eklöf2020-10-09-0/+5
|
* bell: optionally render margins in red when receiving BELDaniel Eklöf2020-10-08-0/+1
| | | | | | | | | | | 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
* csi: xtrestore: add ‘reverse wrap’Daniel Eklöf2020-10-03-0/+1
|
* term: add private mode flag ‘’reverse-wrap’Daniel Eklöf2020-10-02-0/+5
|
* csi: avoid using memcmp() to compare timespec structsCraig Barnes2020-08-23-3/+9
| | | | | | | | | | | | | | | 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
* csi: add 2 missing "break" statements in csi_dispatch()Craig Barnes2020-08-18-2/+2
|
* csi: xtrestore: add 'default' caseDaniel Eklöf2020-08-18-0/+2
| | | | | Don't call decset_decrst() with an unhandled parameter (and with 'enabled' uninitialized!)
* csi: xtrestore: add missing breakDaniel Eklöf2020-08-18-1/+1
|
* csi: xtsave/xtrestore: implement \E[?12s and \E[?12rDaniel Eklöf2020-08-18-2/+18
| | | | I.e. save/restore cursor-blink state.
* csi: decset/decrst: only clear mouse tracking/reporting if mode matchesDaniel Eklöf2020-08-18-9/+24
| | | | | | | | 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.
* csi: implement XTRESTOREDaniel Eklöf2020-08-16-16/+34
|
* csi: xtsave: store modes' SET state, not the current stateDaniel Eklöf2020-08-16-11/+11
|
* csi: implement CSI ? Pm s - XTSAVEDaniel Eklöf2020-08-16-16/+2
|
* csi: add xtsave()Daniel Eklöf2020-08-16-0/+31
| | | | This function stores the current state of DECSET private modes.
* csi: decrst: spell decset correctlyDaniel Eklöf2020-08-16-1/+1
|
* csi: add DEC names to a couple of DECSET modesDaniel Eklöf2020-08-16-1/+6
|
* csi: break out decset/decrstDaniel Eklöf2020-08-16-274/+206
|
* Fix some spelling mistakesCraig Barnes2020-08-15-3/+3
|
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-1/+2
|
* fix printf-format errors in 32-bit buildsDaniel Eklöf2020-08-06-1/+1
|
* term: remove unusued 'damage' listDaniel Eklöf2020-08-04-2/+0
|
* csi: secondary DA: do not pretend we're xtermDaniel Eklöf2020-07-24-2/+16
| | | | | | | | | | | 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
* csi: primary DA: remove features we do not supportDaniel Eklöf2020-07-24-1/+10
| | | | | | | | We do not implement * Selective Erase * Technical Character Set * Terminal state interrogation
* csi: never call term_print() with width <= 0Daniel Eklöf2020-07-16-2/+4
|
* csi: DECAWM: clear LCFDaniel Eklöf2020-07-14-0/+4
|
* csi: IND+RI now clears LCFDaniel Eklöf2020-07-14-0/+2
|
* term: rename term_formfeed() -> term_carriage_return()Daniel Eklöf2020-07-14-0/+3
|
* csi: '\E[0 q' resets the cursor style to the default, not '\E[2 q'Daniel Eklöf2020-06-30-6/+11
| | | | Also update 'Se' capability in the terminfo, to reflect this.
* csi: debug: print 'private' *after* parametersDaniel Eklöf2020-06-30-6/+6
|
* csi: \E[3J: reset render.last_cursor.row if necessaryDaniel Eklöf2020-06-09-0/+3
| | | | | This fixes a crash that occurred when the last rendered cursor cell had scrolled off screen, and \E[3J (clear scrollback) was executed.
* term: scrolling: calling function must clamp scroll amountDaniel Eklöf2020-05-19-4/+12
|
* csi: ignore invalid parameters in 'CSI Ps <space> q'Daniel Eklöf2020-05-04-4/+10
| | | | | Before this patch, an invalid parameter would not change the cursor style, but could cause the cursor to start (or stop) blinking.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-2/+1
|
* csi: log 'unhandled' for invalid 'target' and 'operation' in CSI ? SDaniel Eklöf2020-04-25-0/+7
|
* csi: fix typo - the '(' was in the wrong placeDaniel Eklöf2020-04-19-1/+1
|
* csi: CSI Ps ; Ps ; Ps t: report logical pixelsDaniel Eklöf2020-04-18-5/+8
|
* csi: implement CSI Ps ; Ps ; Ps t reporting escape sequencesDaniel Eklöf2020-04-18-10/+93
| | | | | | | | | | | | | | | | | | | | | | 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
* grid: move 'cursor' state from terminal to gridDaniel Eklöf2020-04-16-61/+67
| | | | | This way, the 'normal' and 'alt' grids have their own cursor state, and we don't need to switch between them.
* Fix clang warningsDaniel Eklöf2020-04-12-1/+1
| | | | | | | | 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
* alt-screen: use a custom 'saved' cursor when switching to alt screenDaniel Eklöf2020-03-16-3/+3
| | | | | | | | | | | | | 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.
* sixel: improve handling of images when reflowing the gridsDaniel Eklöf2020-03-13-5/+3
| | | | | | | | | | | 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.
* term: resize: pre-calculate right/bottom marginsDaniel Eklöf2020-02-24-11/+2
|
* csi: delete all sixels on the 'alt' grid when switching back to 'normal'Daniel Eklöf2020-02-22-0/+8
|
* sixel: application configurable image max width/heightDaniel Eklöf2020-02-22-4/+6
|
* sixel: application configurable palette size (color count)Daniel Eklöf2020-02-22-0/+25
| | | | | This implements the CSI escapes for retrieving and (re)setting the palette size.
* csi: DA: we now implement sixelDaniel Eklöf2020-02-22-1/+1
|
* csi: log only the un-handled parameter in a multi-operation CSIDaniel Eklöf2020-02-01-21/+24
| | | | | | 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.
* csi: implement window and cell size reporting escapesDaniel Eklöf2020-02-01-1/+57
| | | | | | | | | | 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.
* csi: recognize the X10 mouse tracking enabler/disablerDaniel Eklöf2020-02-01-0/+6
| | | | | We still don't implement it, but now we at least recognize it and log a warning when it is implemented.
* csi: drop '28' from our DA responseDaniel Eklöf2020-02-01-1/+1
| | | | We don't support rectangular editing
* vt: use 8-bit indices for parameters and sub parametersDaniel Eklöf2020-02-01-3/+3
| | | | | We only support 16 (sub) parameters and thus there's no need for 64-bit index variables.
* csi: disable save/restore highlight mouse trackingDaniel Eklöf2020-01-23-0/+4
| | | | | We don't implement it, so no point in warning about save/restore not begin implemented.
* csi: warn when client tries to enable "highlight mouse tracking"Daniel Eklöf2020-01-23-0/+8
|
* input: implement metaSendsEscape and eightBitMetaDaniel Eklöf2020-01-20-3/+18
|
* csi: implement REP - CSI Ps bDaniel Eklöf2020-01-20-0/+16
|
* csi: change DA3 reply to "FOOT", in hexDaniel Eklöf2019-12-21-1/+1
|
* term: implement cursor blinkingDaniel Eklöf2019-12-15-5/+6
| | | | | | | | | | | | | | 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.
* csi: describe format of reply to tertiary DADaniel Eklöf2019-12-14-4/+10
|
* csi: Send Device Attributes, Tertiary DA: require Ps == 0Daniel Eklöf2019-12-14-4/+7
|
* csi/vt: don't bad client data as errorsDaniel Eklöf2019-11-29-1/+1
| | | | This gets rid of spam when cat:ing binary data.
* csi/ocs/vt: log unhandled/unrecognized sequences as debug messagesDaniel Eklöf2019-11-29-2/+2
| | | | | | | | 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.
* terminal: use the 'text' xcursor pointer whenever selection is possibleDaniel Eklöf2019-11-28-0/+4
|
* csi: implement "Send Device Attributes (Tertiary DA)"Daniel Eklöf2019-11-18-0/+18
|
* csi: adjust reply to primary DADaniel Eklöf2019-11-18-1/+1
| | | | | | | | | | 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).
* csi: improve "Send Device Attributes (Primary DA)"Daniel Eklöf2019-11-18-2/+32
| | | | | | | 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?)
* csi: document "Send Device Attributes (Secondary DA)"Daniel Eklöf2019-11-18-0/+20
|
* csi: implement 'Query Device Status'Daniel Eklöf2019-11-18-0/+5
| | | | By replying with "Device OK"
* csi: add debug logs for the various mouse reporting modesDaniel Eklöf2019-11-18-1/+4
|
* term: try to improve on a performance regressionDaniel Eklöf2019-11-17-11/+9
| | | | | | | | 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.
* csi: implement 'CHT' - Cursor Horizontal TabDaniel Eklöf2019-11-17-0/+16
|
* csi: implement 'CPL' - Cursor Previous LineDaniel Eklöf2019-11-17-0/+6
|
* csi: implement 'CNL' - Cursor Next LineDaniel Eklöf2019-11-17-0/+6
|
* csi: implement 'HPR' - Horizontal Position RelativeDaniel Eklöf2019-11-17-0/+1
|
* csi: fix bad implementation of CBT (back tab)Daniel Eklöf2019-11-17-6/+13
| | | | | | | * 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.