aboutsummaryrefslogtreecommitdiff
path: root/terminal.h (follow)
Commit message (Collapse)AuthorAgeLines
...
* term_mouse_grabbed(): make ‘seat’ argument constDaniel Eklöf2021-12-28-1/+1
|
* term_erase(): replace coord-typed arguments with regular intsDaniel Eklöf2021-12-26-1/+3
|
* kitty: initial support for “report alternate key”Daniel Eklöf2021-12-08-0/+1
| | | | | | | | | | | | | | In this mode, the “shifted” and “base layout” keys are added to the CSIs, as sub-parameters to the “key” parameter. Note that this PR only implements the “shifted” key, not the “base layout key”. This is done by converting the original XKB symbol to it’s corresponding UTF-32 codepoint. If this codepoint is different from the one we use as “key” in the CSI, we add it as a sub-parameter. Related to #319
* kitty: implement “report associated text”Daniel Eklöf2021-12-08-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In this mode, key events that generate text now add a third CSI parameter, indicating the actual codepoint. Remember that we always use the *unshifted* key in the CSI escapes. With this mode, those CSI escapes now also included the text codepoint. I.e. what would have been emitted, had we not generated a CSI escape. As far as I can tell, this mode has no effect unless “report all keys as escape sequences” is enabled (reason being, without that, there aren’t any text events that generate CSIs - they’re always emitted as-is). Note that Kitty itself seems to be somewhat buggy in this mode. At least on Wayland, with my Swedish layout. For example ‘a’ and ‘A’ does generate the expected CSIs, but ‘å’ and ‘Å’ appears to be treated as non-text input. Furthermore, Kitty optimizes away the modifier parameter, if no modifiers are pressed (e.g. CSI 97;;97u), while we always emit the modifier (CSI 97;1;97u). Related to #319
* input: kitty: add support for “report all keys as escape codes”Daniel Eklöf2021-12-06-1/+3
|
* input: kitty: add support for the “report event” mode (0b10)Daniel Eklöf2021-12-04-1/+1
|
* term: rename: KITTY_KBD_MASK -> KITTY_KBD_SUPPORTEDDaniel Eklöf2021-11-28-1/+1
|
* term: kitty kbd: fix typo: ‘BKD’ -> ‘KBD’Daniel Eklöf2021-11-28-1/+1
|
* kitty kbd: add flag state, implement push/pop/update/queryDaniel Eklöf2021-11-28-0/+15
|
* osc8: uri ranges: use a dynamically re-sizable array instead of a tllistDaniel Eklöf2021-11-26-1/+5
|
* osc8: update URI ranges as we print data, *not* when the URI is closedDaniel Eklöf2021-11-25-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | At first, an OSC-8 URI range was added when we received the closing OSC-8 escape (i.e. with an empty URI). But, this meant that cursor movements while the OSC-8 escape was in effect wasn’t handled correctly, since we’d add a range that spanned the cursor movements. Attempts were made to handle this in the cursor movement functions, by closing and re-opening the URI. However, there are too many corner cases to make this a viable approach. Scrolling is one such example, line-wrapping another. This patch takes a different approach; emit, or update the URI range when we print to the grid. This models the intended behavior much more closely, where an active OSC-8 URI act like any other SGR attribute - it is applied to all cells printed to, but otherwise have no effect. To avoid killing performance, this is only done in the “generic” printer. This means OSC-8 open/close calls must now “switch” the ASCII printer. Note that the “fast” printer still needs to *erase* pre-existing OSC-8 URIs. Closes #816
* term: track cell color sourceDaniel Eklöf2021-11-20-3/+9
| | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | | 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.
* config: add {str,value}_to_uint{16,32}()Daniel Eklöf2021-11-13-2/+2
| | | | | This allows us to pass the final pointer directly to the conversion functions, as well as allowing us to print outside-range errors.
* foot/client: implement xdga client activationRonan Pigott2021-11-01-1/+1
| | | | | | | | | | | This is an application of the xdg activation protocol that will allow compositors to associate new foot toplevels with the command that launched them. footclient receives an activation token from the launcher which the compositor can use to track application startup. It passes the token to the foot server, which then activates the new window with the token to complete the startup sequence.
* osc: use BEL terminator in OSC replies to BEL-terminated OSC queriesCraig Barnes2021-10-20-0/+1
| | | | | | | | | This matches the documented (and observed) behavior in xterm: > XTerm accepts either BEL or ST for terminating OSC sequences, and > when returning information, uses the same terminator used in a query -- https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
* term: only scale using DPI if *all* monitors have a scaling factor or oneDaniel Eklöf2021-09-24-2/+1
| | | | | | | | | | | | | | | | | | | | With dpi-aware=auto (the default), scale fonts using DPI *only* if *all* available monitors have a scaling factor of one. The idea is this: if a user, with multiple monitors, have enabled scaling on *at least* one monitor, he/she has most likely done so to match the size of his/hers other monitors. For example, if the user has one monitor with a scaling factor of one, and another one with a scaling factor of two, he/she expects things to be twice as large on the second monitor. If we (foot) scale using DPI on the first monitor, and using the scaling factor on the second monitor, foot will *not* look twice as big on the second monitor (this was the old behavior of dpi-aware=auto). Part of #714
* term: turn ‘box-drawings’ array into three dynamically allocated arraysDaniel Eklöf2021-09-14-7/+20
| | | | | | | | | | | | | | | | | | | The box_drawings array is now quite large, and uses up ~4K when *empty*. This patch splits it up into three separate, dynamically allocated arrays; one for the traditional box+line drawing and block elements glyphs, one for braille, and one for the legacy computing symbols. When we need to render a glyph, the *entire* array (that it belongs to) is allocated. I.e this is one step closer to a dynamic glyph cache (like the one fcft uses), but doesn’t go all the way. This is especially nice for people with ‘box-drawings-uses-font-glyphs=yes’; for them, the custom glyphs now uses 3*8 bytes (for the three array pointers), instead of 4K.
* box-drawing: add braille charactersDaniel Eklöf2021-09-12-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Render braille ourselves, instead of using font glyphs. Decoding a braille character is easy enough; there are 256 codepoints, represented by an 8-bit integer (i.e. subtract the Unicode codepoint offset, 0x2800, and you’re left with an integer in the range 0-255). Each bit corresponds to a dot. The first 6 bits represent the upper 6 dots, while the two last bits represent the fourth (and last) row of dots. The hard part is sizing the dots and the spacing between them. The aim is to have the spacing between the dots be the same size as the dots themselves, and to have the margins on each side be half the size of the dots. In a perfectly sized cell, this means two braille characters next to each other will be evenly spaced. This is however almost never the case. The layout logic currently: * Set dot size to either the width / 4, or height / 8, depending on which one is smallest. * Horizontal spacing is initialized to the width / 4 * Vertical spacing is initialized to the height / 8 * Horizontal margins are initialized to the horizontal spacing / 2 * Vertical margins are initialized to the vertical spacing / 2. Next, we calculate the number of “remaining” pixels. That is, if we add the left margin, two dots and the spacing between, how many pixels are left on the horizontal axis? These pixels are distributed in the following order (we “stop” as soon as we run out of pixels): * If the dot size is 0 (happens for very small font sizes), increase it to 1. * If the margins are 0, increase them to 1. * If we have enough pixels (need at 2 horizontal and 4 vertical), increase the dot size. * Increase spacing. * Increase margins. Closes #702
* sixel: avoid looking up color from palette for each sixelDaniel Eklöf2021-09-05-0/+1
| | | | | | Instead, do the palette lookup when we receive the DECGCI (i.e. when the palette entry is selected), and store the actual color value in our sixel struct.
* sixel: calculate default bg once, in initDaniel Eklöf2021-09-05-0/+1
| | | | | | | | We have all information we need to calculate the default background color in sixel_init(): * Whether the image have transparency or not * The current ANSI background color
* selection: don’t require two cell attr bits for selection updatingDaniel Eklöf2021-08-16-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating the selection (i.e when changing it - adding or removing cells to the selection), we need to do two things: * Unset the ‘selected’ bit on all cells that are no longer selected. * Set the ‘selected’ bit on all cells that *are* selected. Since it’s quite tricky to calculate the difference between the “old” and “new” selection, this is done by first un-selecting the old selection, and then selecting the new, updated selection. I.e. first we clear the ‘selected’ bit from *all* cells, and then we re-set it on those cells that are still selected. This process also dirties the cells, to make sure they are re-rendered (needed to reflect their new selected/un-selected status). To avoid dirtying *all* previously selected, and newly selected cells, we have used an algorithm that first runs a “pre-pass”, marking all cells that *will* be selected as such. The un-select pass would then skip (no dirty) cells that have been marked by the pre-pass. Finally, the select pass would only dirty cells that have *not* been marked by the pre-pass. In short, we only dirty cells whose selection state have *changed*. To do this, we used a second ‘selected’ bit in the cell attribute struct. Those bits are *scarce*. This patch implements an alternative algorithm, that frees up one of the two ‘selected’ bits. This is done by lazy allocating a bitmask for the entire grid. The pre-pass sets bits in the bitmask. Thus, after the pre-pass, the bitmask has set bits for all cells that *will* be selected. The un-select pass simply skips cells with a one-bit in the bitmask. Cells without a one-bit in the bitmask are dirtied, and their ‘selected’ bit is cleared. The select-pass doesn’t even have to look at the bitmask - if the cell already has its ‘selected’ bit set, it does nothing. Otherwise it sets it and dirties the cell. The bitmask is implemented as an array of arrays of 64-bit integers. Each outer element represents one row. These pointers are calloc():ed before starting the pre-pass. The pre-pass allocates the inner arrays on demand. The unselect pass is designed to handle both the complete absence of a bitmask, as well as row entries being NULL (both means the cell is *not* pre-marked, and will thus be dirtied).
* pt-or-px: heed the dpi-aware settingDaniel Eklöf2021-08-13-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Before this patch, pt-or-px values, like letter-spacing, were *always* scaled using the current DPI value. This is wrong; if the fonts are scaled using the output’s scaling factor, then so should all other point values. This also fixes an issue where e.g. letter-spacing would use one DPI value at startup, but then when increasing/decreasing or resetting the font size, would be re-calculated using a different DPI value, leading to completely different spacing. This happened when there were multiple monitors, with different DPI values, and foot guessed the initial DPI value wrong. Normally, foot would correct itself as soon as the window was mapped, and the “correct” DPI value known. But if the fonts were scaled using the scaling factor, it was possible that the font reload never happened. This patch also updates the thickness calculation (for LIGHT and HEAVY box drawing characters) to use the scaling factor when appropriate. Closes #680
* box-drawing: add U+1FB3C-U+1FB6F, U+1FB9A and U+1FB9BDaniel Eklöf2021-08-05-4/+4
| | | | | | These are the “wedges” from the Unicode 13 “Legacy Computing” symbols. Closes #474
* term: consolidate shutdown related state into an anonymous structDaniel Eklöf2021-07-31-6/+9
|
* term: asynchronous client application terminationDaniel Eklöf2021-07-31-0/+1
| | | | | | | | | | | | | | | | | | When the foot window is closed, and we need to terminate the client application, do this in an asynchronous fashion: * Don’t do a blocking call to waitpid(), instead, rely on the reaper callback * Use a timer FD to implement the timeout before sending SIGKILL (instead of using SIGALRM). * Send SIGTERM immediately (we used to *just* close the PTY, and then wait 2 seconds before sending SIGTERM). * Raise the timeout from 2 seconds to 60 Full shutdown now depends on *two* asynchronous tasks - unmapping the window, and waiting for the client application to terminate. Only when *both* of these have completed do we proceed and call term_destroy(), and the user provided shutdown callback.
* render: use a single backing SHM pool for CSD surface buffersDaniel Eklöf2021-07-18-1/+1
|
* csi: erase scrollback: cancel selection if it touches the scrollbackDaniel Eklöf2021-07-18-0/+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
* shm: refactor: move away from a single, global, buffer listDaniel Eklöf2021-07-17-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, *all* buffers have been tracked in a single, global buffer list. We've used 'cookies' to separate buffers from different contexts (so that shm_get_buffer() doesn't try to re-use e.g. a search-box buffer for the main grid). This patch refactors this, and completely removes the global list. Instead of cookies, we now use 'chains'. A chain tracks both the properties to apply to newly created buffers (scrollable, number of pixman instances to instantiate etc), as well as the instantiated buffers themselves. This means there's strictly speaking not much use for shm_fini() anymore, since its up to the chain owner to call shm_chain_free(), which will also purge all buffers. However, since purging a buffer may be deferred, if the buffer is owned by the compositor at the time of the call to shm_purge() or shm_chain_free(), we still keep a global 'deferred' list, on to which deferred buffers are pushed. shm_fini() iterates this list and destroys the buffers _even_ if they are still owned by the compositor. This only happens at program termination, and not when destroying a terminal instance. I.e. closing a window in a “foot --server” does *not* trigger this. Each terminal instatiates a number of chains, and these chains are destroyed when the terminal instance is destroyed. Note that some buffers may be put on the deferred list, as mentioned above.
* render: Allow cells to bleed into their neighborTimur Celik2021-07-17-1/+2
| | | | | | | | | | | | | | | | This patch adds a `confined` flag to each cell to track if the last rendered glyph bled into it's right neighbor. To keep things simple, bleeding into any other neighbor cell than the immediate right one is not allowed. This should cover most use cases. Before rendering a row we now do a prepass and mark all cells unclean that are affected by a bleeding neighbor. If there are consecutive bleeding cells, the whole group must be re-rendered even if only a single cell has changed. The patch also deprecates both old overflowing glyph options *allow-overflowing-double-width-glyphs* and *pua-double-width* in favor of a single new one named *overflowing-glyphs*.
* csi: invert the meaning of DECSDMDaniel Eklöf2021-07-14-1/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* url-mode: fix crash when removing duplicate and/or overlapping URLsDaniel Eklöf2021-07-11-0/+1
| | | | | | | | | | | | | | | | Removing overlaping and duplicated URLs is done by running two nested loops, that both iterate the same URL list. When a duplicate is found, one of the URLs is destroyed and removed from the list. Deleting and removing an item *is* safe, but only as long as _no other_ iterator has references to it. In this case, if we remove an item from e.g. the inner iterator, we’ll crash if the outer iterator’s *next* item is the item being removed. Closes #627
* config: add locked-title=no|yesDaniel Eklöf2021-07-04-0/+1
| | | | Closes #386
* term: CELL_COMB_CHARS chars are keys, not indices -> more range is betterDaniel Eklöf2021-06-24-3/+4
| | | | | Bump the available key range to 30 bits. This helps reduce key collisions when handling a large amount of grapheme clusters.
* composed: store compose chains in a binary search treeDaniel Eklöf2021-06-24-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation stored compose chains in a dynamically allocated array. Adding a chain was easy: resize the array and append the new chain at the end. Looking up a compose chain given a compose chain key/index was also easy: just index into the array. However, searching for a pre-existing chain given a codepoint sequence was very slow. Since the array wasn’t sorted, we typically had to scan through the entire array, just to realize that there is no pre-existing chain, and that we need to add a new one. Since this happens for *each* codepoint in a grapheme cluster, things quickly became really slow. Things were ok:ish as long as the compose chain struct was small, as that made it possible to hold all the chains in the cache. Once the number of chains reached a certain point, or when we were forced to bump maximum number of allowed codepoints in a chain, we started thrashing the cache and things got much much worse. So what can we do? We can’t sort the array, because a) that would invalidate all existing chain keys in the grid (and iterating the entire scrollback and updating compose keys is *not* an option). b) inserting a chain becomes slow as we need to first find _where_ to insert it, and then memmove() the rest of the array. This patch uses a binary search tree to store the chains instead of a simple array. The tree is sorted on a “key”, which is the XOR of all codepoints, truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range. The grid now stores CELL_COMB_CHARS_LO+key, instead of CELL_COMB_CHARS_LO+index. Since the key is truncated, collisions may occur. This is handled by incrementing the key by 1. Lookup is of course slower than before, O(log n) instead of O(1). Insertion is slightly slower as well: technically it’s O(log n) instead of O(1). However, we also need to take into account the re-allocating the array will occasionally force a full copy of the array when it cannot simply be growed. But finding a pre-existing chain is now *much* faster: O(log n) instead of O(n). In most cases, the first lookup will either succeed (return a true match), or fail (return NULL). However, since key collisions are possible, it may also return false matches. This means we need to verify the contents of the chain before deciding to use it instead of inserting a new chain. But remember that this comparison was being done for each and every chain in the previous implementation. With lookups being much faster, and in particular, no longer requiring us to check the chain contents for every singlec chain, we can now use a dynamically allocated ‘chars’ array in the chain. This was previously a hardcoded array of 10 chars. Using a dynamic allocated array means looking in the array is slower, since we now need two loads: one to load the pointer, and a second to load _from_ the pointer. As a result, the base size of a compose chain (i.e. an “empty” chain) has now been reduced from 48 bytes to 32. A chain with two codepoints is 40 bytes. This means we have up to 4 codepoints while still using less, or the same amount, of memory as before. Furthermore, the Unicode random test (i.e. write random “unicode” chars) is now **faster** than current master (i.e. before text-shaping support was added), **with** test-shaping enabled. With text-shaping disabled, we’re _even_ faster.
* term: bump compose chain char array to 10 charsDaniel Eklöf2021-06-24-1/+1
| | | | There are some very long sequences out there... e.g. 👩🏼‍❤️‍💋‍👨🏽
* term: lower maximum number of characters in a compose chainDaniel Eklöf2021-06-24-1/+1
| | | | | | | | | | | | | | | Before the grapheme cluster segmentation work, we limited the number of combining characters to base+5. I.e. 6 in total. For a while now, we’ve had it bumped all the way up to 20. This was the reason the unicode-random benchmark ran so much slower (i.e. cache contention). Looking at emoji’s, there are a couple that need 6 code points, and *three* that needs 7. Now, with the limit at 7 chars, and the new ‘width’ member, the composed struct is 8 bytes larger than before.
* vt: cache grapheme cluster width in composed structDaniel Eklöf2021-06-24-0/+1
| | | | | | * Use regular wcswidth() to calculate the width * Explicitly set to ‘2’ if we see a emoji variant selector * Cache the result in the composed struct
* wip: grapheme shapingDaniel Eklöf2021-06-24-2/+15
|
* render: don’t create/destroy the title update timer each timeDaniel Eklöf2021-06-18-0/+1
| | | | | Create it once when instantiating the terminal. Add a boolean to track whether the timer is running or not.
* render: use a timer instead of relying on the frame callback for title update throttlingDaniel Eklöf2021-06-18-2/+5
| | | | | | | | | | | | | | | | | | | | | Using the frame callback works most of the time, but e.g. Sway doesn’t call it while the window is hidden, and thus prevents us from updating the title in e.g. stacked views. This patch uses a timer FD instead. We store a timestamp from when the title was last updated. When the application wants to update the title, we first check if we already have a timer running, and if so, does nothing. If no timer is running, check the timestamp. If enough time has passed, update the title immediately. If not, instantiate a timer and wait for it to trigger. Set the minimum time between two updates to ~8ms (twice per frame, for a 60Hz output, and ~once per frame on a 120Hz output). Closes #591
* terminal: add 'charset_designator' enum to make code more self-documentingCraig Barnes2021-06-09-3/+4
| | | | | | This commit also renames the term_set_single_shift_ascii_printer() function to term_single_shift(), since the former is overly verbose and not really even accurate.
* vt: fix SS2/SS3 escape sequences to act correctly as single shiftsCraig Barnes2021-06-08-0/+2
| | | | | | These sequences are supposed to affect the next printable ASCII character and then reset to the previous character set, but before this commit they were behaving like locking shifts.
* url-mode: remove overlapping URLs, not just duplicatesDaniel Eklöf2021-05-22-0/+1
| | | | | | | | | | | | | | | | | echo -e '\e]8;;https://www.foo.bar\e\\https://www.foo\e]8;;\e\\.bar' will produce an OSC-8 URL (https://www.foo) that is slightly shorter than the auto-detected one (https://www.foo.bar). This produces strange results in URL mode. For example, if url.osc8-underline=always, the OSC8 underline will be removed when url-mode is exited. This patch changes the behavior so that auto-detected URLs that overlap OSC-8 URLs are removed. Note that OSC-8 URLs cannot overlap with each other, and that auto-detected URLs also cannot overlap with each other.
* term: get rid of term->font_scale, use term->scale onlyDaniel Eklöf2021-05-17-2/+1
| | | | | | | | | We only needed term->font_scale to be able to detect scaling factor changes (term->font_scale != term->scale). But, we already have the old scaling factor in all places where term_font_dpi_changed() is called, so let’s pass the old scaling factor as an argument instead.
* term: remove get_font_scale()Daniel Eklöf2021-05-17-1/+1
| | | | | | | | | | | | | | | | | | | | | | | get_font_scale() was used to get the new scaling factor when loading fonts. This was then compared to the last seen font scaling factor. If there was no difference, the fonts were not reloaded. The problem was, the initial term->scale was set differently. This sometimes led to term->scale=2, while get_font_scale() return 1. That meant, fonts were initially scaled by 2 (when dpi-aware=no). Later, when mapped on an output (and thus term->scale being set to 1), the fonts weren’t reloaded with the correct scaling factor since the cached term->font_scale value was already 1. Since term->scale always reflects the *new* scaling factor when term_font_dpi_changed() is called, use that directly, and remove get_font_scale(). Also rename the following functions: * font_should_size_by_dpi() -> font_size_by_dpi_for_scale() * font_size_by_dpi() -> font_sized_by_dpi() * font_size_by_scale() -> font_sized_by_scale()
* term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definitionDaniel Eklöf2021-05-14-1/+1
| | | | | | | | | | | | | | | | | | | | | Instead of using CELL_SPACER for *all* cells that previously used CELL_MULT_COL_SPACER, include the remaining number of spacers following, and including, itself. This is encoded by adding to the CELL_SPACER value. So, a double width character will now store the character itself in the first cell (just like before), and CELL_SPACER+1 in the second cell. A three-cell character would store the character itself, then CELL_SPACER+2, and finally CELL_SPACER+1. In other words, the last spacer is always CELL_SPACER+1. CELL_SPACER+0 is used when padding at the right margin. I.e. when writing e.g. a double width character in the last column, we insert a CELL_SPACER+0 pad character, and then write the double width character in the first column on the next row.
* box-drawing: add Unicode 13 U+1FB70 - U+1FB8BDaniel Eklöf2021-05-04-1/+2
| | | | Part of #471
* config: add ‘beam-thickness’ optionDaniel Eklöf2021-04-30-1/+4
| | | | | | | | | | | * 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/+1
| | | | See: https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2#note_847720
* term: attributes struct: use ‘bool’ instead of ‘uint32_t’ for 1-bit membersDaniel Eklöf2021-04-17-13/+13
|
* osc: implement OSC 17+19: change selection background/foreground colorsDaniel Eklöf2021-04-08-0/+3
| | | | | And of course, we also implement the corresponding reset sequences, OSC 117+119.
* config/terminal: refactor: remove “default_*” color members from terminal structDaniel Eklöf2021-04-07-4/+0
| | | | Access the original colors in the configuration instead.
* ime: move preedit state from terminal struct to the seat structDaniel Eklöf2021-03-25-15/+2
| | | | | | | | | | | | | | | | | This ensures different seat’s don’t step on each others IME pre-edit state. It also removes most dependencies on having a valid term pointer for many IME operations. We’re still not all the way, since we support disabling IME with a private mode, which is per terminal, not seat. Thus, we still require the seat to have keyboard focus on one of our windows. Closes #324. But note that *rendering* of multiple seat’s IME pre-edit strings is still broken.
* term: increase/decrease custom line-height with font size changesDaniel Eklöf2021-03-21-0/+7
| | | | | | | | When the user has set a custom line-height, we now adjust it when increasing/decreasing (“zooming”) the font size at run-time. Previously, the line-height was fixed at the size specified in foot.ini.
* term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print functionDaniel Eklöf2021-03-16-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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 P2=1 - transparent pixelsDaniel Eklöf2021-03-11-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | When P2=1, empty pixels are transparent. This patch also changes the behavior of P2=0|2, from setting empty pixels to the default background color, to instead use the *current* background color. To implement this, a couple of changes are needed: * Sixel pixels always use alpha=1.0, except for *empty* cells when P2=1 (i.e. transparent pixels). * The renderer draws sixels with the OVER operator, instead of the SRC operator. * The renderer *must* now render the cells beneath the sixel. As an optimization, this is only done for sixels where P2=1. I.e. for fully opaque sixels, there’s no need to render the cells beneath. The sixel renderer isn’t yet hooked into the multi-threaded renderer. This means *rows* (not just the cells) beneath maybe-transparent sixels are rendered single-threaded. Closes #391.
* sixel: empty pixels in the last sixel row doesn’t contribute to the image heightDaniel Eklöf2021-03-11-0/+1
| | | | | | | | | | | | | | All-empty pixels rows in the last sixel row should not be included in the final sixel image. This allows applications to emit sixels whose height is not a multiple of 6, and is how XTerm works. This is done by tracking the largest row number that contains non-empty pixels. In unhook, when emitting the image, the image height is adjusted based on this value.
* sixel: remove ‘max_col’Daniel Eklöf2021-03-11-1/+0
| | | | The image width *is* the maximum number of columns we’ve seen.
* sixel: get rid of an ‘imul’ in sixel_add()Daniel Eklöf2021-03-11-0/+1
| | | | | | | | By storing the current row’s byte offset into the backing image in the terminal struct. This replaces the ‘imul’ with a load, which can potentially be slow. But, this data should already be in the cache.
* sixel: size provided by DECGRA does *not* limit the sixel sizeDaniel Eklöf2021-03-06-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Foot has, up until now, used a fixed image size when the application used DECGRA (Raster Attributes) to “configure” the image size. This was based on a misunderstanding, that this was how you emitted sixels where the height was *not* a multiple of 6. This isn’t the case. The VT340 documentation is actually pretty clear about this: Ph and Pv do not limit the size of the image defined by the sixel data. However, Ph and Pv let you omit background sixel data from the image definition and still have a color background. They also provide a concise way for the application or terminal to encode the size of an image. This is also how XTerm behaves. Test image: \EPq "1;1;1;1 #0;2;0;0;0#1;2;100;100;0#2;2;0;100;0 #1~~@@vv@@~~@@~~$ #2??}}GG}}??}}??- #1!14@ \E\ This uses DECGRA to set the image size to 1x1. The sixel however is *not* clipped to 1x1, but is resized to 14x12
* sixel: implement private mode 80 - sixel scrollingDaniel Eklöf2021-02-26-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* url-mode: snapshot screen state when entering URL modeDaniel Eklöf2021-02-26-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, we automatically exited URL mode whenever we received data on the PTY. This was done since we don’t know _what_ has changed on the screen, and we don’t want to display misleading jump labels. However, this becomes a problem in curses-like applications that periodically updates part of the screen. For example, a statusbar with a clock. This patch changes this behavior; instead of cancelling URL mode when receiving PTY data, we snapshot the grid when entering URL mode. When *rendering*, we use the snapshot:ed grid, while PTY updates modify the “real” grid. Snapshot:ing the grid means taking a full/deep copy of the current grid, including sixel images etc. Finally, it isn’t necessary to “damage” the entire view when *entering* URL mode, since we’re at that point the renderer is in sync with the grid. But we *do* need to damage the entire view when exiting URL mode, since the grid changes on the “real” grid hasn’t been tracked by the renderer.
* terminal: change type from uint32_t to bool in xtsave bitfieldDaniel Eklöf2021-02-23-26/+26
|
* sixel: implement private mode 8452 - cursor positioning after sixelDaniel Eklöf2021-02-23-0/+3
| | | | | | | | | | 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-1/+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
* urls: OSC-8 URLs can now optionally be underlined outside of url-modeDaniel Eklöf2021-02-21-0/+1
| | | | | | | | | | | | | | | | | | | | | This patch adds a new configuration option, ‘osc8-underline=url-mode|always’. When set to ‘url-mode’, OSC-8 URLs are only highlighted (i.e. underlined) in url-mode, just like auto-detected URLs. When set to ‘always’, they are always underlined, regardless of mode, and regardless of their other attributes. This is implemented by tagging collected URLs with a boolean, instructing urls_render() and urls_reset() whether they should update the cells’ ‘url’ attribute or not. The OSC-8 collecter sets this based on the value of ‘osc8-underline’. Finally, when closing an OSC-8 URL, the cells are immediately tagged with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
* urls: add key binding that toggles whether URLs are displayed on jump-labelDaniel Eklöf2021-02-21-0/+1
| | | | | | | | | | | | | | | | | By default, the URL isn’t shown on the jump-label. For auto-detect URLs, doing so is virtually always useless, as the URL is already visible in the grid. For OSC-8 URLs however, the URL is often _not_ visible in the grid. Many times, seeing the URL is still not needed (if you’re doing ‘ls --hyperlink’, you already know what the URIs are). But it is still useful to have a way to show the URLs. This patch adds a new key binding action that can be used in url-mode to toggle the URL on and off in the jump label. It is bound to ctrl+t by default.
* urls: remove free-form ‘text’ member from URL structDaniel Eklöf2021-02-21-1/+0
|
* url-mode: multiple URL (parts) with the same ID is assigned a single key sequenceDaniel Eklöf2021-02-21-0/+1
| | | | | | | | | | In case an URL is split up into multiple parts, those parts are now treated as a single URL when it comes to key assignment. Only the *first* URL part is actually assigned a key combo. The other parts are ignored. We still highlight them, but for all other purposes they are ignored.
* term: add an ‘id’ member to the the ‘row_uri_range’ structDaniel Eklöf2021-02-21-0/+1
| | | | | term_osc8_close() sets it from the OSC-8 ID tracked in the VT sub-struct.
* term: add ‘id’ parameter to term_osc8_open()Daniel Eklöf2021-02-21-2/+3
| | | | | The current OSC-8 URL’s ID is now tracked along with the URI itself, and its starting point.
* terminal: add term_osc8_{open,close} functionsDaniel Eklöf2021-02-21-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | These functions update the OSC-8 URI state in the terminal. term_osc8_open() tracks the beginning of an URL, by storing the start coordinate (i.e. the current cursor location), along with the URL itself. Note that term_osc8_open() may not be called with an empty URL. This is important to notice, since the way OSC-8 works, applications close an URL by “opening” a new, empty one: \E]8;;https://foo.bar\e\\this is an OSC-8 URL\E]8;;\e\\ It is up to the caller to check for this, and call term_osc8_close() instead of term_osc8_open() when the URL is empty. However, it is *also* valid to switch directly from one URL to another: \E]8;;http://123\e\\First URL\E]8;;http//456\e\\Second URL\E]8;;\e\\ This use-case *is* handled by term_osc8_open(). term_osc8_close() uses the information from term_osc8_open() to add per-row URL data (using the new ‘extra’ row data).
* terminal: add OSC-8 state tracking to the VT sub-structDaniel Eklöf2021-02-21-2/+12
|
* grid: enable rows to have ‘extra’ data associated with themDaniel Eklöf2021-02-21-0/+11
| | | | | | | | | | | This patch adds an ‘extra’ member to the row struct. It is a pointer to a struct containing extra data to be associated with this row. Initially, this struct contains a list of URL ranges. These define (OSC-8) URLs on this row. The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by default; it is *not* allocated by grid_row_alloc().
* url-mode: store URL in UTF-8, not UTF-32Daniel Eklöf2021-02-21-1/+1
| | | | | | | | | | | | | The only time the URL is actually in UTF-32 is when we’re collecting it (auto-detecting it) from the grid, since cells store their character(s) in UTF-32. Everything *after* that prefers the URL in UTF-8. So, do the conversion while collecting the URL. This patch also changes the URL activation code to strip the ‘file://user@host/’ prefix from file URIs that refer to files on the *local* computer.
* reaper: monitor SIGCHLD using the FDM instead of via a signalfdDaniel Eklöf2021-02-11-1/+2
| | | | | | | | | | | | | | | | | | | | | | | In addition to letting the FDM do the low-level signal watching, this patch also fixes a bug; multiple SIGCHLDs, be it delivered either through a signal, or via a signalfd, can be coalesced, like all signals. This means we need to loop on waitpid() with WNOHANG until there are no more processes to reap. This in turn requires a small change to the way reaper callbacks are implemented. Previously, the callback was allowed to do the wait(). This was signalled back to the reaper through the callback’s return value. Now, since we’ve already wait():ed, the process’ exit status is passed as an argument to the reaper callback. The callback for the client application has been updated accordingly; it sets a flag in the terminal struct, telling term_destroy() that the process has already been wait():ed on, and also stores the exit status.
* url-mode: fix key sequence generationDaniel Eklöf2021-02-07-1/+1
| | | | | | | | * We were using the ‘back’ element of the list as prefix for the next iteration of sequences, instead of the element at index ‘offset’ * ALEN() on a wchar_t[] includes the NULL terminator. We don’t want that.
* url-mode: urls_collect(): URL list pointer as an argumentDaniel Eklöf2021-02-07-1/+2
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-1/+2
| | | | | | | | | | | | | | | | | | | | | | This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
* term: surface-kind: add TERM_SURF_JUMP_LABELDaniel Eklöf2021-02-07-0/+1
|
* config: add show-urls-copy actionDaniel Eklöf2021-02-07-0/+2
| | | | | | This works just like show-urls-launch, except that instead of opening the URL (typically using xdg-open), it is placed in the clipboard when activated.
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+16
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-0/+2
|
* Print stack trace on assert() failure or when calling fatal_error()Craig Barnes2021-01-16-0/+1
| | | | | | Note: this uses the __sanitizer_print_stack_trace() function from the AddressSanitizer runtime, so it only works when AddressSanitizer is in use.
* term: keep cursor state in grid, for now, but document that it _could_ be movedDaniel Eklöf2021-01-15-0/+8
|
* term/vt/csi: break out cursor save/restore to dedicated functionsDaniel Eklöf2021-01-15-0/+1
|
* config: line-height, letter-spacing: values are in pt by default, but we allow pxDaniel Eklöf2021-01-11-0/+2
| | | | | | | | If the value is specified without a unit, then the value is assumed to be in points, subject to DPI scaling. The value can optionally have a ‘px’ suffix, in which case the value is treated as a raw pixel count.
* selection: combine enum selection_kind with selection_semanticDaniel Eklöf2021-01-06-3/+7
|
* selection: allow selections to pivot around a range instead of a pointDaniel Eklöf2021-01-04-0/+5
| | | | | | | | | | Extend selection pivoting to allow selections to pivot around a range. Use this in word- and row-based selections to pivot around the initial word/row that was selected. This mimics the behavior of at least urxvt and xterm.
* selection: remember whether word-wise selection uses spaces only for delimitersDaniel Eklöf2021-01-04-0/+1
|
* selection: wip: update selection row-wise when initial selection was by rowDaniel Eklöf2021-01-04-1/+1
|
* selection: wip: update selection word-wise when initial selection was by wordDaniel Eklöf2021-01-04-0/+2
|
* box-drawing: SEXTANTS, U+1fb00-1fb3bDaniel Eklöf2021-01-01-1/+5
|
* box-drawing: add infrastructure for rendering box drawing characters ourselvesDaniel Eklöf2021-01-01-0/+2
| | | | | | | | * ‘term’ struct contains an array of 160 fcft glyph pointers * the glyph pointers are lazily allocated when we need to draw a box drawings character * Filtering out box drawings characters is easy - they are (except unicode 13, which isn’t handled yet )all in a single range.
* vt: don’t ignore extra private/intermediate charactersDaniel Eklöf2020-12-16-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* term: enabling application synchronized updates clear pending grid refreshDaniel Eklöf2020-12-14-1/+0
| | | | | | | | | | | This fixes issues with de-synchronized frames being rendered; we may have scheduled a redraw earlier, that hasn’t yet triggered (probably because we’re waiting for a frame callback), when we enable application synchronized updates. This means we risk rendering a partially updated state when the frame callback finally arrives, if the application hasn’t yet ended its synchronized update.
* config: add ‘notify’ to possible values for ‘bell’ in foot.iniDaniel Eklöf2020-12-10-2/+2
| | | | | When `bell=notify`, foot will trigger a desktop notification when it receives a BEL in an unfocused window.
* ime: store wchar version of pre-edit string in terminal structDaniel Eklöf2020-12-07-0/+1
|
* csi: add DECSET 737769 - enables/disables IME inputDaniel Eklöf2020-12-07-0/+1
| | | | 73 77 69 = I M E