aboutsummaryrefslogtreecommitdiff
path: root/csi.c (follow)
Commit message (Collapse)AuthorAgeLines
* csi: DECCRA: clamp and verify destination rectangle coordinatesDaniel Eklöf2026-05-22-3/+14
| | | | | | | | | | | | dst_right was already being clamped, but not dst_left. In addition to that, reject the sequence if dst_left > dst_right, or dst_bottom > dst_top. This is already being done for the source rectangle, in params_to_rectangular_area(). Closes #2352
* csi: secondary DA: fix comment; we don't use an XTerm version numberDaniel Eklöf2025-12-28-4/+4
|
* csi: make sure the ASCII printer function is updated on plain underlinesDaniel Eklöf2025-12-24-3/+3
| | | | | | | | | | Otherwise, a sequence like \E[4:2;4m # Enable double-underline, then immediately switch to single Will switch to the slow printer, and then get stuck there even though we immediately switch to plain underlines (which don't need the slow printer).
* config: add [colors-dark] and [colors-light], replacing [colors] and [colors2]Daniel Eklöf2025-12-20-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main reason for having two color sections is to be able to switch between dark and light. Thus, it's better if the section names reflect this, rather than the more generic 'colors' and 'colors2' (which was the dark one and which was the light one, now again?) When the second color section was added, we kept the original name, colors, to make sure we didn't break existing configurations, and third-party themes. However, in the long run, it's probably better to be specific in the section naming, to avoid confusion. So, add 'colors-dark', and 'colors-light'. Keep 'colors' and 'colors2' as aliases for now, but mark them as deprecated. They WILL be removed in a future release. Also rename the option values for initial-color-theme, from 1/2, to dark/light. Keep the old ones for now, marked as deprecated. Update all bundled themes to use the new names. In the light-only themes (i.e. themes that define a single, light, theme), use colors-light, and set initial-color-theme=light. Possible improvements: disable color switching if only one color section has been explicitly configured (todo: figure out how to handle the default color theme values...)
* csi: focus mode (private mode 1004): send focus event immediate, when enabledDaniel Eklöf2025-11-01-0/+2
| | | | | | | This lets the application now the current state, without having to wait for the user to switch focus. Fixes #2202
* csi: add '52' to the DA reply, to indicate PSC-52 supportDaniel Eklöf2025-06-10-7/+10
| | | | | | Note: only *copy* is required to be enabled in security.osc52; paste is optional, see https://github.com/contour-terminal/contour/issues/1761#issuecomment-2944492097
* csi: when REP:ing a "combining" character, use correct widthDaniel Eklöf2025-05-16-1/+11
| | | | | | | | | | Before this patch, we just called c32width(), which only works on actual codepoints. If the last printed character is a "combining" character, i.e. a key into our lookup table for multi-codepoint graphemes, we need to lookup the grapheme and pick the width from there. See https://gitlab.com/AutumnMeowMeow/jexer/-/issues/119#note_2499712901
* csi: implement private mode 2031 (dark/light mode detection)Daniel Eklöf2025-04-26-0/+33
| | | | | | | | | | | | | | * Recognize 'CSI ? 996 n', and respond with - 'CSI ? 997 ; 1 n' if the primary theme is active - 'CSI ? 997 ; 2 n' if the alternative theme is actice * Implement private mode 2031, where changing the color theme (currently only possible via key bindings) causes the terminal to send the same CSI sequences as above. In this context, foot's primary theme is considered dark, and the alternative theme light (since the default theme is dark). Closes #2025
* csi: don't allow client app to enable grapheme-shaping when disabled at compile-timeDaniel Eklöf2025-04-19-0/+2
| | | | Closes #2039
* DECSCUSR+DECRQSS: treat hollow cursor as a block cursorDaniel Eklöf2025-02-21-1/+2
| | | | | | | | | | | | | | | If the user has configured cursor.style=hollow, make DECSCUSR 1/2 set the cursor to hollow rather than block, and make DECRQSS DECSCUSR respond as if cursor.style=block. The idea is to not expose the hollow variant in DECSCUSR in any way, to avoid having to extend it with custom encodings. Another way to think about it is this is just a slightly more discoverable way of doing: cursor.style=block cursor.block-cursor-is-hollow=yes
* term: insert-mode: handle combining characters correctlyDaniel Eklöf2025-02-06-1/+1
| | | | | | | | | | | | | | | | | When the client application emits combining characters, for example multi-codepoint emojis, in insert-mode, we ended up pushing partial graphemes to the right, for each codepoint, resulting in too many cells (and with the wrong content) being inserted. The fix is fairly simple; don't "insert" when appending characters to an existing grapheme cluster. This isn't something we can detect easily in print_insert() (it would require us to do grapheme clustering again). Fortunately, we do have the required information in action_utf8_print(). So, pass this information as a boolean to term_print(). Closes #1947
* csi: ignore 'CSI 21 t' - report window titleDaniel Eklöf2025-01-07-0/+4
| | | | | It's not widely used (don't know _any_ application that uses it), and can be used to trick users to run unwanted commands.
* csi: revert implementation of CSI 20 tDaniel Eklöf2024-09-13-10/+1
|
* osc: OSC-1 does not set the icon, it sets the icon _label_Daniel Eklöf2024-09-13-11/+0
| | | | | | | | | | In fact, there appears there *is* no escape sequence to set the icon. Keep most of the logic in place, but in practice, we'll always set the icon to the app-id. That is, at startup, we set it to the configured app-id (either from config, or the command line). OSC-176, which sets the app-id, also updates the icon (to the app-id).
* toplevel-icon: implement OSC-1, CSI 20/21/22/23 tDaniel Eklöf2024-09-13-2/+29
| | | | | | | | | | | | | | * The toplevel icon is now set to the app-id, unless "overridden" by OSC-1 or OSC-0. * Implemented OSC-1 * OSC-0 extended to also set the icon * Implemented CSI 20 t - report window icon * Implemented CSI 21 t - report window title * Implemented CSI 22 ; 1 t - push window icon * Implemented CS 23 ; 1 t - pop window icon * Extended CSI 22/23 ; 0 t to also push/pop the icon * Verify app-id set by OSC-176 is valid UTF-8 * Verify icon set by OSC-0/1 is valid UTF-8
* xsnprintf: various improvements related to xvsnprintf() and xsnprintf()Craig Barnes2024-09-13-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary of changes: * Make xvsnprintf() static * restrict-qualify pointer arguments (as done by the libc equivalents) * Make comments and spec references more thorough * Remove pointless `n <= INT_MAX` assertion (see comment) * Use FATAL_ERROR() instead of xassert() (since the assertion is inside a shared util function but the caller is responsible for ensuring the condition holds true) * Change some callers to use size_t instead of int for the return value (negative returns are impossible and all subsequent uses are size_t) The updated comments and code were taken (and adapted) from: https://gitlab.com/craigbarnes/dte/-/blob/49260bb154bca0434462a41c061e512540ec2e49/src/util/xsnprintf.c#L6-50 This work was entirely authored by me and I hereby license this contribution under the MIT license (stated explicitly, so that there's no ambiguity w.r.t. the original license).
* Remove a number of unused includesDaniel Eklöf2024-08-02-1/+0
|
* csi: in-band window resize notifications, private mode 2048Daniel Eklöf2024-07-19-0/+10
| | | | | | | | | | | | | This implements https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83, in-band window resize notifications. When user enables private mode 2048 (in-band resize notifications), *always* send current size, even if the mode is already active. This ensures applications can rely on getting a reply from the terminal.
* osc: extend damage-cells-by-color to default fg/bg as wellDaniel Eklöf2024-07-03-2/+4
| | | | | | | | | | | | | | | When changing part of the color palette, through either OSC-4, or OSC-10 and OSC-11 (and the corresponding reset OSCs: 104, 110 and 111), only dirty affected cells. We've always done this, but only for OSC-4. This patch breaks out that logic, and extends it to handle default fg/bg too. It also fixes a bug where cells with colored underlines were not dirtied if the underline was the only part of the cell that was affected by a OSC-4 change.
* csi: redraw margins after restoring the paletteDaniel Eklöf2024-07-03-0/+1
|
* csi: implement XTPUSHCOLORS+XTPOPCOLORS+XTREPORTCOLORSDaniel Eklöf2024-07-03-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation of these sequences are vague and lacking, as is often the case with XTerm invented control sequences. I've tried to replicate what XTerm does (as of xterm-392). The stack represents *stashed/stored* palettes. The currently active palette is *not* stored on the stack. The stack is dynamically allocated, and starts out with zero elements. Now, XTerm has a somewhat weird definition of "pushing" and "popping" in this context, and the documentation is somewhat misleading. What a push does is this: it stores the current palette to the stack at the specified slot. If the specified slot number (Pm) is 0, the slot used is the current slot index incremented by 1. The "current" slot index is then set to the specified slot (which is current slot + 1 if Pm == 0). Thus, "push" (i.e. when Pm == 0 is used) means store to the "next" slot. This is true even if the current slot index points into the middle of stack. Pop works in a similar way. The palette is restored from the specified slot index. If the specified slot number is 0, we use the current slot index. The "current" slot index is then set to the specified slot - 1 (current slot - 1 if Pm == 0). XTREPORTCOLORS return the current slot index, and the number of palettes stored on the stack, on the format CSI ? <slot index> ; <palette count> # Q When XTPUSHCOLORS grows the stack with more than one element (i.e. via a 'CSI N # P' sequence), make sure *all* new slots are initialized (to the current color palette). This avoids uninitialized slots, that could then be popped with XTPOPCOLORS. Closes #856
* csi: implement SGR 21, double underlinesDaniel Eklöf2024-07-03-1/+7
|
* Rename various uses of "curly" in the source code with "underline"Craig Barnes2024-07-01-24/+24
| | | | | Since "curly" could make it seem as if all underline styles are curled (to people unfamiliar with the codebase), whereas in reality only 1 is.
* csi: sgr_reset(): avoid using memset()Daniel Eklöf2024-06-26-3/+2
| | | | | This _should_ be what the compiler does anyway (i.e. it _should_ replace the memset() with inline MOVs). But let's be sure.
* term: performance: use a bitfield to track which ascii printer to useDaniel Eklöf2024-06-26-5/+14
| | | | | | | | | | | The things affecting which ASCII printer we use have grown... Instead of checking everything inside term_update_ascii_printer(), use a bitfield. Anything affecting the printer used, must now set a bit in this bitfield. This makes term_update_ascii_printer() much faster, since all it needs to do is check if the bitfield is zero or not.
* csi: remove debug logDaniel Eklöf2024-06-26-1/+0
|
* csi: wip: styled underlinesDaniel Eklöf2024-06-26-4/+54
| | | | | | | | | | | | | This is work in progress, and fairly untested. This adds initial tracking of styled underlines. Setting attributes seems to work (both color and underline style). Grid reflow has *not* been tested. When rendering, style is currently ignored (all styles are rendered as a plain, legacy underline). Color however, *is* applied.
* url-mode: disable IME mode while URL-mode is activeDaniel Eklöf2024-05-21-1/+3
| | | | | | | This prevents the IME from stealing "our" key-presses, and thus preventing the user from opening URLs. Closes #1718, hopefully.
* config: add cursor.blink-rate optionDaniel Eklöf2024-05-20-1/+1
| | | | | | The default is 500ms, which corresponds to the old, hardcoded default. Closes #1707
* csi: indicate "permanently reset" for DECRQM queries of mode 67 (DECBKM)Craig Barnes2024-03-16-0/+8
| | | | | This allows dynamic querying for the equivalent of terminfo's "kbs" capability.
* csi: the CSI-t family of queries now report unscaled pixel valuesDaniel Eklöf2024-03-14-9/+6
| | | | | | | | | | | 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
* csi: params_to_rectangular_area(): ensure left/right is within boundsDaniel Eklöf2024-03-10-2/+3
|
* csi: DECCARA+DECRARA: dirty cellsDaniel Eklöf2024-03-07-0/+4
|
* csi: DECRARA: fix comment: DECCARA -> DECRARADaniel Eklöf2024-03-07-1/+1
|
* csi: DECCRA: no need for a counter hereDaniel Eklöf2024-03-07-1/+1
|
* term_fill(): change ‘character’ parameter from char -> uint8_tDaniel Eklöf2024-03-07-17/+18
|
* term: modify term_fill() to optionally reset the SGR attributesDaniel Eklöf2024-03-07-1/+1
|
* term: replace term_put_char() with term_fill()Daniel Eklöf2024-03-07-9/+2
|
* csi: rectangular: add helper function params_to_rectangular_area()Daniel Eklöf2024-03-07-81/+71
| | | | | | | This functions reads the four top/left/bottom/right parameters, validates them, and converts relative row numbers to absolute. Returns true if the params are valid, otherwise false.
* csi: add ‘28’ (rectangular edit) to primary DA responseDaniel Eklöf2024-03-07-2/+2
|
* csi: implement rectangular edit escapesDaniel Eklöf2024-03-07-0/+237
| | | | | | | | | | | | * DECCARA - change attributes in rectangular area * DECRARA - reverse attributes in rectangular area * DECCRA - copy rectangular area * DECFRA - fill rectangular area * DECERA - erase rectangular area Not implemented: * DECSERA - selective erase rectangular area
* csi: support DECRQM queries for ECMA-48 (SM/RM) modesCraig Barnes2024-02-11-0/+17
| | | | | This is in addition to the existing support for DECRQM queries of DEC private modes.
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-4/+4
|
* csi: simplify handling of Set/Reset Mode (SM/RM) sequencesCraig Barnes2024-01-27-32/+17
|
* csi: decrqm: 2027: permanently disabled when grapheme-width-method != double-widthDaniel Eklöf2023-09-25-1/+3
|
* csi: implement DECSET/DECRST/DECRQM 2027 - grapheme cluster processingDaniel Eklöf2023-09-25-0/+7
| | | | | | | | | | | This implements private mode 2027 - grapheme cluster processing, as defined in the "Terminal Unicode Core"[1] specification. Internally, we just flip the already existing option "grapheme shaping". Since it's now runtime changeable, we need a copy of it in the terminal struct, rather than referencing the conf object. [1]: https://github.com/contour-terminal/terminal-unicode-core/blob/13fc5a8993a033ff10c1f3433d08cb618cde4ac2/spec/terminal-unicode-core.tex#L50-L53
* scaling: always round the scaling factor when converting to intDaniel Eklöf2023-07-25-6/+6
| | | | | | | | | * In all calls to wl_subsurface_set_position() * (wp_viewport_set_destination() already does this) * Whenever we use the scale to calculate margins (search box, scrollback indicator etc) * Since the scaling factor is stored as a float (and not a double), use roundf() instead of round()
* term: convert ‘scale’ to a floatDaniel Eklöf2023-06-29-8/+12
|
* csi: CHA+HPA (cursor horizontal absolute): use term_cursor_col()Daniel Eklöf2023-06-20-1/+1
|
* csi: implement "CSI ? m"Daniel Eklöf2023-04-26-1/+34
|
* csi: DECCOLM+DECSCLM: remove all supportDaniel Eklöf2023-03-31-21/+0
| | | | | | | | | | | We don’t support neither 132 column mode, nor smooth scrolling. Thus it makes little sense to recognize these control condes. Note that while XTerm does support 132 columns, it is disabled by default. In this mode, XTerm also doesn’t trigger the side-effects (i.e. clearing the screen). Closes #1265
* fix typosHarri Nieminen2023-03-28-1/+1
|
* selection: selection_on_rows(): typo: row_start -> row_endDaniel Eklöf2022-11-24-2/+2
| | | | | | | This fixes an issue where selections in the scroll margins were not detected correctly. This meant they weren’t canceled as they should have been, which in turn caused a visual glitch where text appeared to be selected, but were in fact not.
* csi: reply with 4 instead of 2 for DECRQM queries of unsupported modesCraig Barnes2022-09-18-43/+55
| | | | | | | | 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.
* csi: damage *viewport* when exiting the alt screenDaniel Eklöf2022-09-06-1/+1
| | | | | This fixes a redraw issue when the normal screen were somewhere in the scrollback history when exiting the alt screen.
* csi: clamp color index for ‘CSI 38/48 ; 5 ; idx m’ sequencesDaniel Eklöf2022-07-22-2/+4
| | | | | | | | | | | | | | Indexed color values are stored in the cell attributes as color indices (into the 256-color table). However, the index from the CSI was not validated in any way, meaning you can do something like this: echo -e ‘\e[38:5:1024m CRASH \e[m’ and foot will crash on an out-of-bounds access. Fix by clamping the color index. Closes #1111
* csi: implement CSI > 4n (reset modifyOtherKeys)Daniel Eklöf2022-04-19-0/+18
|
* csi: reduce duplication in code handling SGR 38 and 48 sequencesCraig Barnes2022-04-11-85/+24
|
* config: add tweak option to allow disabling sixelsjvoisin2022-04-06-2/+12
| | | | Closes #950
* csi: add support for DECNKM private modeCraig Barnes2022-03-19-0/+8
| | | | | | | | | | | This is equivalent to DECKPAM/DECKPNM when enabled/disabled, but can also be saved/restored/queried with XTSAVE/XTRESTORE/DECRQM. See also: * https://vt100.net/docs/vt510-rm/DECNKM.html * https://vt100.net/docs/vt510-rm/DECKPAM.html * https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
* csi: fix case label typo in decrqm()Craig Barnes2022-02-16-1/+1
| | | | | | | | | | The other functions that deal with private modes all use 1070 for term->sixel.use_private_palette. The xterm docs[1] also list this param as 1070: > Ps = 1 0 7 0 ⇒ use private color registers for each graphic Using 1079 seems to have been a mistake in commit 4aa980a6a2ce3c3.
* csi/input: remove private mode 27127Craig Barnes2022-02-09-7/+0
| | | | This effectively reverts commit 31c73f0cf01e1d0bdcd1435136b010c1c1ab442c.
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fcft no longer uses wchar_t, but plain uint32_t to represent codepoints. Since we do a fair amount of string operations in foot, it still makes sense to use something that actually _is_ a string (or character), rather than an array of uint32_t. For this reason, we switch out all wchar_t usage in foot to char32_t. We also verify, at compile-time, that char32_t used UTF-32 (which is what fcft expects). Unfortunately, there are no string functions for char32_t. To avoid having to re-implement all wcs*() functions, we add a small wrapper layer of c32*() functions. These wrapper functions take char32_t arguments, but then simply call the corresponding wcs*() function. For this to work, wcs*() must _also_ be UTF-32 compatible. We can check for the presence of the __STDC_ISO_10646__ macro. If set, wchar_t is at least 4 bytes and its internal representation is UTF-32. FreeBSD does *not* define this macro, because its internal wchar_t representation depends on the current locale. It _does_ use UTF-32 _if_ the current locale is UTF-8. Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is defined. Other fcft API changes: * fcft_glyph_rasterize() -> fcft_codepoint_rasterize() * font.space_advance has been removed * ‘tags’ have been removed from fcft_grapheme_rasterize() * ‘fcft_log_init()’ removed * ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
* SGR-Pixels mouse mode, closes #762Autumn Lamonte2022-01-01-0/+10
|
* term_erase(): replace coord-typed arguments with regular intsDaniel Eklöf2021-12-26-34/+34
|
* csi: store color index, not actual color, in cell’s fg/bg attributesDaniel Eklöf2021-12-26-12/+8
| | | | | | | | | | | | | | | | | | When using indexed colors (i.e. SGR 30/40/90/100), store the index into the cell’s fg/bg attributes, not the actual color value. This has a couple of consequences: Color table lookup is now done when rendering. This means a rendered cell will always reflect the *current* color table, not the color table that was in use when the cell was printed to. This simplifies the OSC-4/104 logic, since we no longer need to update the grid - we just have to damage it to trigger rendering. Furthermore, this change simplifies the VT parsing, since we no longer need to do any memory loads (except loading the SGR parameter values), only writes.
* csi: no need to set VT state’s fg/bg to the default ones on SGR resetDaniel Eklöf2021-12-26-2/+0
|
* term: rename: KITTY_KBD_MASK -> KITTY_KBD_SUPPORTEDDaniel Eklöf2021-11-28-2/+2
|
* csi: kitty: remove unneeded xassertsDaniel Eklöf2021-11-28-2/+0
| | | | | ‘idx’ is calculated just above, and the logic is simple enough that we don’t really need to assert it.
* csi: kitty: log flags after ‘update’ operationDaniel Eklöf2021-11-28-0/+3
|
* csi: kitty: s/mode/flags in debug logsDaniel Eklöf2021-11-28-2/+2
|
* kitty kbd: add flag state, implement push/pop/update/queryDaniel Eklöf2021-11-28-0/+91
|
* term: track cell color sourceDaniel Eklöf2021-11-20-14/+14
| | | | | | | | | | | | | Each cell now tracks it’s current color source: * default fg/bg * base16 fg/bg (maps to *both* the regular and bright colors) * base256 fg/bg * RGB Note that we don’t have enough bits to separate the regular from the bright colors. These _shouldn’t_ be the same, so we ought to be fine...
* input: add support for modifyOtherKeys=2Daniel Eklöf2021-11-13-9/+11
| | | | | | | | | | | | | | | | Similar to modifyOtherKeys=1 (foot’s default, and only, mode), except that: * All modifiers (and not just Ctrl) generate \E[27;m;n~ escapes * Regular keys (with modifiers) also generate \E[27;m;n~ escapes (for example, C-h no longer generates ^H, but \E[27;5;104~) For our keymap based lookups, this is handled by adding MOD_MODIFY_OTHER_KEYS_STATE<N> variants. For “generic” keys, we simply adjust the conditions for when to emit a \E[27;m;n~ escape - the only requirement is that at least one modifier is active.
* csi: various, minor code/formatting improvementsCraig Barnes2021-08-30-32/+13
|
* csi: erase scrollback: cancel selection if it touches the scrollbackDaniel Eklöf2021-07-18-20/+1
| | | | | | | | | | | | | | | | | This breaks out the scrollback erasing logic for \E[3J from csi.c, and moves it to the new function term_erase_scrollback(), and changes the logic to calculate the start and end row (absolute) numbers of the scrollback, and only iterate those, instead of iterating *all* rows, filtering out those that are on-screen. It also adds an intersection range check of the selection range, and cancels the selection if it touches any of the deleted scrollback rows. This fixes a crash when trying to render the next frame, since the selection now references rows that have been freed. Closes #633
* csi: invert the meaning of DECSDMDaniel Eklöf2021-07-14-4/+4
| | | | | | | | | | | | | | | | | | | | | There has been some confusion whether enabling DECSDM (private mode 80) enables or disables sixel scrolling. Foot currently enables scrolling when DECSDM is set, and this patch changes this, such that setting DECSDM now *disables* scrolling. The confusion is apparently due to a documentation error in the VT340 manual, as described in https://github.com/dankamongmen/notcurses/issues/1782#issuecomment-863603641. And that makes sense, in a way: the SDM in DECSDM stands for Sixel Display Mode. I.e. it stands to reason that enabling that disables scrolling. Anyway, this lead to https://github.com/hackerb9/lsix/issues/41, where it was eventually proven (by testing on a real VT340), that foot, and a large number of other terminals (including XTerm) has it wrong: https://github.com/hackerb9/lsix/issues/41#issuecomment-873269599.
* csi: implement XTVERSION (CSI > 0q)Daniel Eklöf2021-06-13-0/+16
| | | | | | | | | | | | This is a fairly new XTerm extension. The reply is on the format: DCS > | text ST XTerm replies with ‘text’ = “XTerm(366)”. Foot replies with ‘text’ = “foot(1.6.4)” Closes #359
* csi: CHT: don’t alter the LCF flagDaniel Eklöf2021-06-08-0/+3
| | | | | This makes us pass the vttest 11.5.4 (Test non-VT100 -> Test ISO-6429 cursor-movement -> CHT) test.
* csi: IL+DL: move cursor to column 0Daniel Eklöf2021-06-08-0/+2
| | | | | | | | | This fixes vttest 11.6.6.3 Test non-VT100 -> Test ISO-6429 colors -> Test of VT102-style features with BCE -> Test Insert/Delete Char/Line
* config: add ‘beam-thickness’ optionDaniel Eklöf2021-04-30-1/+1
| | | | | | | | | | | * Rename cursor.style value ‘bar’ to ‘beam’. ‘bar’ remains recognized, but should eventually be deprecated and then removed. * Add ‘cursor.beam-thickness’ option, a pt-or-px value specifying the thickness of the beam cursor. Defaults to 1.5pt. * Rename (and export) pt_or_px_as_pixels() to term_pt_or_px_as_pixels() * Change term_pt_or_px_as_pixels() to round point values instead of truncating them.
* csi: add support for DECSET 2026, as an alternative to BSU/ESU sequencesCraig Barnes2021-04-25-0/+10
| | | | See: https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2#note_847720
* 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...