aboutsummaryrefslogtreecommitdiff
path: root/terminal.h (follow)
Commit message (Collapse)AuthorAgeLines
* term: wrap url related fields into a structK42026-09-02-7/+8
|
* terminal: keep saved SGR attributes per-gridaloires2026-08-15-1/+1
| | | | | | | | | | | | | DECSC/DECRC (ESC7/ESC8), CSI s/u and DECSET/DECRST 1048/1049 all save/restore the SGR attributes through the same, global saved_attrs slot. An application emitting ESC7/ESC8 in the alternate screen to wrap sixel rendering in a save/restore-cursor pair overwrites the slot with its own SGR state. DECRST 1049 then restores those attributes, instead of the ones saved by DECSET 1049. The shell prompt is left with the application's attributes, even though the application reset them (sgr0) before exiting.
* terminal: add visibility reportsTim Culverhouse2026-07-30-0/+3
| | | | | | | | | | | | | Applications cannot infer whether their terminal view is observable from keyboard focus alone, so they may continue expensive rendering while the surface is hidden. Implement private mode 2033 and the one-shot visibility query. Report Wayland xdg_toplevel suspension as not visible and otherwise remain conservative by treating the terminal as potentially visible. Amp-Thread-ID: https://ampcode.com/threads/T-019fb2b7-f245-7124-a69a-1484812532bb Co-authored-by: Amp <amp@ampcode.com>
* term: do not allow codepoint merging into grapheme clusters directly after a cursor moveDaniel Eklöf2026-06-12-0/+2
| | | | | | | That is, only do grapheme clustering when printing codepoints in sequence, without any cursor movements in between. Closes #2383
* config: add url.style=none|single|double|curly|dotted|dashedDaniel Eklöf2026-04-06-9/+0
| | | | | | | | | | | This option allows you to configure which underline style to use with URLs. The default is dotted. Since before this patch, URL underlines were always plain underlines, this means the default URL underline style has changed, from single to dotted. Closes #2302
* Add support for background blurDaniel Eklöf2026-03-02-0/+1
| | | | | | | | | This patch adds a new config option: colors{,2}.blur=no|yes. When enabled, transparent background are also blurred. Note that this requires the brand new ext-background-effect-v1 protocol, and specifically, that the compositor implements the blur effect.
* config: add [colors-dark] and [colors-light], replacing [colors] and [colors2]Daniel Eklöf2025-12-20-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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...)
* render: when double-buffering, pre-apply previous frame's damage earlyDaniel Eklöf2025-10-10-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Foot likes it when compositor releases buffer immediately, as that means we only have to re-render the cells that have changed since the last frame. For various reasons, not all compositors do this. In this case, foot is typically forced to switch between two buffers, i.e. double-buffer. In this case, each frame starts with copying over the damage from the previous frame, to the new frame. Then we start rendering the updated cells. Bringing over the previous frame's damage can be slow, if the changed area was large (e.g. when scrolling one or a few lines, or on full screen updates). It's also done single-threaded. Thus it not only slows down frame rendering, but pauses everything else (i.e. input processing). All in all, it reduces performance and increases input latency. But we don't have to wait until it's time to render a frame to copy over the previous frame's damage. We can do that as soon as the compositor has released the buffer (for the frame _before_ the previous frame). And we can do this in a thread. This frees up foot to continue processing input, and reduces frame rendering time since we can now start rendering the modified cells immediately, without first doing a large memcpy(3). In worst case scenarios (or perhaps we should consider them best case scenarios...), I've seen up to a 10x performance increase in frame rendering times (this obviously does *not* include the time it takes to copy over the previous frame's damage, since that doesn't affect neither input processing nor frame rendering). Implemented by adding a callback mechanism to the shm abstraction layer. Use it for the grid buffers, and kick off a thread that copies the previous frame's damage, and resets the buffers age to 0 (so that foot understands it can start render to it immediately when it later needs to render a frame). Since we have certain way of knowing if a compositor releases buffers immediately or not, use a bit of heuristics; if we see 10 consecutive non-immediate releases (that is, we reset the counter as soon as we do see an immediate release), this new "pre-apply damage" logic is enabled. It can be force-disabled with tweak.pre-apply-damage=no. We also need to take care to wait for the thread before resetting the render's "last_buf" pointer (or we'll SEGFAULT in the thread...). We must also ensure we wait for the thread to finish before we start rendering a new frame. Under normal circumstances, the wait time is always 0, the thread has almost always finished long before we need to render the next frame. But it _can_ happen. Closes #2188
* term+input: refactor: move theme switching into term_theme_* functionsDaniel Eklöf2025-06-10-1/+3
|
* render: refactor to allow setting only selection bg or fgDaniel Eklöf2025-05-05-1/+0
| | | | | | | | | | | | Before this, we only applied custom selection colors, if *both* the selection bg and fg had been set. Since the options are already split up into two separate options, and since it makes sense to at least be able to keep the foreground colors unchanged (i.e. only setting the selection background), let's allow only having one of the selection colors set. Closes #1846
* config: add initial-color-theme=1|2Daniel Eklöf2025-04-26-1/+1
| | | | | | | | This option selects which color theme to use by default. I.e. at startup, and after a reset. This is useful with combined theme files, where a single file defines e.g. both a dark and light version of the theme.
* csi: implement private mode 2031 (dark/light mode detection)Daniel Eklöf2025-04-26-0/+2
| | | | | | | | | | | | | | * 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
* key-bindings: add bindings to switch between color themesDaniel Eklöf2025-04-26-0/+3
| | | | | | * color-theme-switch-1: select the primary color theme * color-theme-switch-2: select the alternative color theme * color-theme-toggle: toggle between the primary and alternative color themes
* render: gamma-correct blendingDaniel Eklöf2025-03-05-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements gamma-correct blending, which mainly affects font rendering. The implementation requires compile-time availability of the new color-management protocol (available in wayland-protocols >= 1.41), and run-time support for the same in the compositor (specifically, the EXT_LINEAR TF function and sRGB primaries). How it works: all colors are decoded from sRGB to linear (using a lookup table, generated in the exact same way pixman generates it's internal conversion tables) before being used by pixman. The resulting image buffer is thus in decoded/linear format. We use the color-management protocol to inform the compositor of this, by tagging the wayland surfaces with the 'ext_linear' image attribute. Sixes: all colors are sRGB internally, and decoded to linear before being used in any sixels. Thus, the image buffers will contain linear colors. This is important, since otherwise there would be a decode/encode penalty every time a sixel is blended to the grid. Emojis: we require fcft >= 3.2, which adds support for sRGB decoding color glyphs. Meaning, the emoji pixman surfaces can be blended directly to the grid, just like sixels. Gamma-correct blending is enabled by default *when the compositor supports it*. There's a new option to explicitly enable/disable it: gamma-correct-blending=no|yes. If set to 'yes', and the compositor does not implement the required color-management features, warning logs are emitted. There's a loss of precision when storing linear pixels in 8-bit channels. For this reason, this patch also adds supports for 10-bit surfaces. For now, this is disabled by default since such surfaces only have 2 bits for alpha. It can be enabled with tweak.surface-bit-depth=10-bit. Perhaps, in the future, we can enable it by default if: * gamma-correct blending is enabled * the user has not enabled a transparent background
* terminal: add comment/link to cursor::lcf, to clarify its purposeCraig Barnes2025-02-18-1/+1
|
* term+vt: refactor: move "utf8" char processing to term_process_and_print_non_ascii()Daniel Eklöf2025-02-06-0/+1
| | | | | | | | | | | This function "prints" any non-ascii character (i.e. any character that ends up in the action_utf8_print() function in vt.c) to the grid. This includes grapheme cluster processing etc. action_utf8_print() now simply calls this function. This allows us to re-use the same functionality from other places (like the text-sizing protocol).
* term: insert-mode: handle combining characters correctlyDaniel Eklöf2025-02-06-1/+2
| | | | | | | | | | | | | | | | | 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
* config+url: add support for user-defined regex patternsDaniel Eklöf2025-02-05-0/+1
| | | | | | | | | | | | | | | | | | | | | Users can now define their own regex patterns, and use them via key bindings: [regex:foo] regex=foo(bar)? launch=path-to-script-or-application {match} [key-bindings] regex-launch=[foo] Control+Shift+q regex-copy=[foo] Control+Mod1+Shift+q That is, add a section called 'regex:', followed by an identifier. Define a regex and a launcher command line. Add a key-binding, regex-launch and/or regex-copy (similar to show-urls-launch and show-urls-copy), and connect them to the regex with the "[regex-name]" syntax (similar to how the pipe-* bindings work).
* render: fix order we're checking custom codepointsDaniel Eklöf2025-01-03-6/+6
| | | | | | | Fixes a crash when trying to print a "Legacy Computing" symbol (U+1FB00-U+1FB9B). Closes #1901
* box-drawings: implement octantsDaniel Eklöf2024-12-08-0/+6
|
* config: add color.sixelN optionsDaniel Eklöf2024-10-23-1/+0
| | | | These options allows you to configure the default sixel color palette.
* osc: OSC-1 does not set the icon, it sets the icon _label_Daniel Eklöf2024-09-13-3/+2
| | | | | | | | | | 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-0/+9
| | | | | | | | | | | | | | * 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
* osc: kitty notifications: cleanup and update to latest version of specDaniel Eklöf2024-08-02-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't store a list of unfinished notifications. Use a single one. If the notification ID of the 'current' notification doesn't match the previous, unfinished one, the 'current' notification replaces the previous one, instead of updating it. * Update xstrjoin() to take an optional delimiter (for example ','), and use that when joining categories and 'alive IDs'. * Rename ${action-arg} to ${action-argument} * Update handling of the 'n' parameter (symbolic icon name); the spec allows it to be used multiple times, and the terminal is supposed to pick the first one it can resolve. Foot can't resolve icons at all, neither can 'notify-send' or 'fyi' (which is what foot typically executes to display a notification); it's the notification daemon that resolves icons. The spec _could_ be interpreted to mean the terminal should lookup .desktop files, and use the value of the 'Icon' key from the first matching .desktop files. But foot doesn't read .desktop files, and I don't intend to implement XDG directory scanning and parsing of .desktop files just to figure out which icon to use. Instead, use a simple heuristics; use the *shortest* symbolic names. The idea is pretty simple: plain icon names are typically shorter than .desktop file IDs.
* notify: separate active notifications from unfinished kitty notificationsDaniel Eklöf2024-07-23-1/+2
| | | | | | | | | | | | | | | | | | | | | This fixes an issue where it wasn't possible to trigger multiple notifications with the same kitty notification ID. This is something that works in kitty, and there's no reason why it shouldn't work. The issue was that we track stdout, and the notification helper's PID in the notification struct. Thus, when a notification is being displayed, we can't re-use the same notification struct instance for another notification. This patch fixes this by adding a new notification list, 'active_notifications'. Whenever we detect that we need to track the helper (notification want's to either focus the window on activation, or send an event to the application), we add a copy of the notification to the 'active' list. The notification can then be removed from the 'kitty' list, allowing kitty notifications to re-use the same ID over and over again, even if old notifications are still being displayed.
* osc: kitty notifications: updated support for iconsDaniel Eklöf2024-07-23-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the suggested protocol discussed in https://github.com/kovidgoyal/kitty/issues/7657. Icons are handled by loading a cache. Both in-band PNG data, and symbolic names are allowed. Applications use a graphical ID to reference the icon both when loading the cache, and when showing a notification. * 'g' is the graphical ID * 'n' is optional, and assigns a symbolic name to the icon * 'p=icon' - the payload is icon PNG data. It needs to be base64 encoded, but this is *not* implied. I.e. the application *must* use e=1 explicitly. To load an icon (in-band PNG data): printf '\e]99;g=123:p=icon;<base64-encoded-png-data>\e\\' or (symbolic name) printf '\e]99;g=123:n=firefox:p=icon;\e\\' Of course, we can combine the two, assigning *both* a symbolic name, *and* PNG data: printf '\e]99;g=123:n=firefox:p=icon;<base64-encoded-png>\e\\' Then, to use the icon in a notification: printf '\e]99;g=123;this is a notification\e\\' Foot also allows a *symbolic* icon to be defined and used at the same time: printf '\e]99;g=123:n=firefox;this is a notification\e\\' This obviously won't work with PNG data, since it uses the payload portion of the escape sequence.
* osc: kitty notifications: implement focus|reportDaniel Eklöf2024-07-23-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for window focusing, and sending events back to the client application when a notification is closed. * Refactor notification related configuration options: - add desktop-notifications sub-section - deprecate 'notify' in favor of 'desktop-notifications.command' - deprecate 'notify-focus-inhibit' in favor of 'desktop-notifications.inhibit-when-focused' * Refactor: rename 'struct kitty_notification' to 'struct notification' * Pass a 'struct notification' to notify_notify(), instead of many arguments. * notify_notify() now registers a reaper callback. When the notifier process has terminated, the notification is considered closed, and we either try to focus (activate) the window, or send an event to the client application, depending on the notification setting. * For the window activation, we need an XDG activation token. For now, assume *everything* written on stdout is part of the token. * Refactor: remove much of the warnings from OSC-99; we don't typically log anything when an OSC/CSI has invalid values. * Add icon support to OSC-99. This isn't part of the upstream spec. Foot's implementation: - uses the 'I' parameter - the value is expected to be a symbolic icon name - a quick check for absolute paths is done, and such icon requests are ignored. * Added ${icon} to the 'desktop-notifications.command' template. Uses the icon specified in the notification, or ${app-id} if not set.
* osc/notify: add support for OSC-99, kitty desktop notificationsDaniel Eklöf2024-07-23-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This adds limited support for OSC-99, kitty desktop notifications[^1]. We support everything defined by the "protocol", except: * 'a': action to perform on notification activation. Since we don't trigger the notification ourselves (over D-Bus), we don't know a) which ID the notification got, or b) when it is clicked. * ... and that's it. Everything else is supported To be explicit, we *do* support: * Chunked notifications (d=0|1), allowing the application to append data to a notification in chunks, before it's finally displayed. * Plain UTF-8, or base64-encoded UTF-8 payload (e=0|1). * Notification identifier (i=xyz). * Payload type (p=title|body). * When to honor the notification (o=always|unfocused|invisible), with the following quirks: - we don't know when the window is invisible, thus it's treated as 'unfocused'. - the foot option 'notify-focus-inhibit' overrides 'always' * Urgency (u=0|1|2) [^1]: https://sw.kovidgoyal.net/kitty/desktop-notifications/
* csi: in-band window resize notifications, private mode 2048Daniel Eklöf2024-07-19-0/+7
| | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | 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: implement XTPUSHCOLORS+XTPOPCOLORS+XTREPORTCOLORSDaniel Eklöf2024-07-03-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* osc: merge OSC 10/11/12/17/19 handlingDaniel Eklöf2024-07-03-4/+2
| | | | | | | | | | 10/11/17/19 were already merged, so this patch just stops special casing 12 (cursor color). In preparation for XTPUSHCOLORS/XTPOPCOLORS, the cursor colors are moved from their own struct, into the 'colors' struct. Also fix a bug where OSC 17/19 queries returned OSC-11 data.
* Rename various uses of "curly" in the source code with "underline"Craig Barnes2024-07-01-16/+16
| | | | | 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.
* grid: refactor: remove union range_data_for_insertionDaniel Eklöf2024-06-26-2/+8
| | | | | | | | | This union is identical to row_range_data, except the URI char pointer is const. Let's ignore that, and re-use row_range_data, casting the URI pointer when necessary. Also remove uri_range_insert() and curly_range_insert(), and use the generic version of range_insert() everywhere.
* term: performance: use a bitfield to track which ascii printer to useDaniel Eklöf2024-06-26-0/+11
| | | | | | | | | | | 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: wip: styled underlinesDaniel Eklöf2024-06-26-1/+25
| | | | | | | | | | | | | 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.
* grid: refactor: first step towards a more generic range handlingDaniel Eklöf2024-06-26-8/+19
|
* url-mode: disable IME mode while URL-mode is activeDaniel Eklöf2024-05-21-0/+1
| | | | | | | This prevents the IME from stealing "our" key-presses, and thus preventing the user from opening URLs. Closes #1718, hopefully.
* unicode-mode: move state from seat to termDaniel Eklöf2024-05-21-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where entering unicode-mode in one foot client, also enabled unicode-mode on other foot clients. Both visually (although glitchy), and in effect. The reason the state was originally in the seat objects, was to fully support multi-seat. That is, one seat/keyboard entering unicode-mode should not affect other seats/keyboards. The issue with this is that seat objects are Wayland global. Thus, in server mode, all seat objects are shared between the foot clients. There is a similarity with IME, which also keeps state in the seat. There's one big difference, however, and that is IME has Wayland native enter/leave events, that the compositor emits when windows are focused/unfocused. These events allow us to reset IME state. For our own Unicode mode, there is nothing similar. This patch moves the Unicode state from seats, to the terminal struct. This does mean that if one seat/keyboard enters Unicode mode, then *all* seats/keyboards will affect the unicode state. This potential downside is outweighed by the fact that different foot clients no longer affect each other. Closes #1717
* term: stash last known DPI, and use after a unmapped/mapped sequenceDaniel Eklöf2024-04-17-0/+1
| | | | | | | | | | | | | | | | | | A compositor may unmap, and then remap the window, for example when the window is minimized, or if the user switches workspace. With DPI aware rendering, we *need* to know on which output we're mapped, in order to use the correct DPI. This means the first frame we render, before being mapped, always guesses the DPI. In an unmap/map sequence, guessing the wrong DPI means the window will flicker. Fix by stashing the last used DPI value, and use that instead of guessing. This means the *only* time we _actually_ guess the DPI, is the very first frame, when starting up foot.
* term: send SIGHUP before SIGTERM when shutting downDaniel Eklöf2024-04-05-0/+1
| | | | | | | | If we're the ones initiating shutdown, start by sending SIGHUP. Only if the client application does not terminate, send SIGTERM (and if it still refuses to terminate, send SIGKILL). Also reduce the timeout between the signals from 60s to 30s.
* sixel: RA region does not affect the text cursor positionDaniel Eklöf2024-03-18-0/+1
| | | | | | | | | | | | | | | | | | | | | | | The raster attributes is, really, just a way to erase an area. And, if the sixel is transparent, it's a nop. The final text cursor position depends, not on our image size (which is based on RA), but on the final graphical cursor position. However, we do want to continue using it as a hint of the final image size, to be able to pre-allocate the backing buffer. So, here's what we do: * When trimming trailing transparent rows, only trim the *image*, if the graphical cursor is positioned on the last sixel row, *and* the sixel is transparent. * Opaque sixels aren't trimmed at all, since RA in this acts as an erase that fills the RA region with the background color. * The graphical cursor position is always adjusted (i.e. trimmed), since it affects the text cursor position. * The text cursor position is now calculated from the graphical cursor position, instead of the image height.
* sixel: trim trailing, fully transparent sixel rowsDaniel Eklöf2024-03-18-0/+1
| | | | See https://github.com/hpjansson/chafa/issues/192
* Add support for opening an existing PTYAlyssa Ross2024-03-14-1/+2
| | | | | | | | | | | | | | | | | Virtual machine monitor programs (e.g. QEMU, Cloud Hypervisor) expose guest consoles as PTYs. With this patch, foot can access these guest consoles. Usually, the program used for accessing these PTYs is screen, but screen is barely developed, doesn't support resizing, and has a bunch of other unrelated stuff going on. It would be nice to have a terminal emulator that properly supported opening an existing PTY. The VMM controls the master end of the PTY, so to the other end (in this case foot), it just behaves like any application running in a directly-opened PTY, and all that's needed is to change foot's code to support opening an existing PTY rather than creating one. Co-authored-by: tanto <tanto@ccc.ac>
* term_fill(): change ‘character’ parameter from char -> uint8_tDaniel Eklöf2024-03-07-1/+1
|
* term: modify term_fill() to optionally reset the SGR attributesDaniel Eklöf2024-03-07-1/+2
|
* term: replace term_put_char() with term_fill()Daniel Eklöf2024-03-07-1/+1
|
* term: add term_put_char()Daniel Eklöf2024-03-07-0/+1
| | | | | | | | This function prints a single, non-double width, character to the grid. It handles OSC-8 hyperlinks, but does not: * update the cursor location * erase sixels
* sixel: performance improvementsDaniel Eklöf2024-03-06-1/+1
| | | | | | | | | | | | | * Store pointer to current pixel (i.e. pixel we're about to write to), instead of a row-byte-offset. This way, we don't have to calculate the offset into the backing image every time we emit a sixel band. * Pass data pointer directly to sixel_add_*(), to avoid having to calculate an offset into the backing image. * Special case adding a single 1:1 sixel. This removes a for loop, and simplifies state (position) updates. It is likely LTO does this for us, but this way, we get it optimized in non-LTO builds as well.
* osc: add support for osc 176 (app ID)delthas2024-02-06-0/+7
| | | | | | | | | | This adds support for a new OSC escape sequence: OSC 176, that lets terminal programs tell the terminal the name of the app that is running. foot then sets the app ID of the toplevel to that ID, which lets the compositor know which app is running, and typically sets the appropriate icon, window grouping, ... See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239
* term: drop term->render.title.is_armedDaniel Eklöf2024-02-06-1/+0
| | | | | | | | | | | | | | | | | This boolean isn't needed. The idea was probably to not re-program the timer unnecessarily, or even to prevent it from being moved forward in time indefinitely. However, the logic has (probably) gone through some changes, that now makes it irrelevant. The timer isn't moved forward indefinitely; it is always set to 8ms from the last title update. The closer we get to that point in time, the smaller the timeout we set. Now, is_armed _did_ prevent the timer from being re-programmed. But that tiny performance tweak isn't really necessary, as the title should, in normal cases, not be set that often anyway.
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-6/+6
|
* config: add pipe-command-output key-bindingDaniel Eklöf2024-02-06-0/+2
|
* osc: store column of FTCS_COMMAND_{EXECUTED,FINISHED} in row structDaniel Eklöf2024-02-06-0/+2
|
* term: move row->prompt_marker into new struct, row->shell_integrationDaniel Eklöf2024-02-06-2/+3
|
* wayland: use wl_compositor version 6 when availableLeonardo Hernández Hernández2024-01-24-0/+1
|
* slave: don't skip setting environment variables when using a custom environmentDaniel Eklöf2024-01-11-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When launching footclient with -E,--client-environment the environment variables that should be set by foot, wasn't. Those variables are: * TERM * COLORTERM * PWD * SHELL and all variables defined by the user in the [environment] section in foot.ini. In the same way, we did not *unset* TERM_PROGRAM and TERM_PROGRAM_VERSION. This patch fixes it by "cloning" the custom environment, making it mutable, and then adding/removing the variables above from it. Instead of calling setenv()/unsetenv() directly, we add the wrapper functions add_to_env() and del_from_env(). When *not* using a custom environment, they simply call setenv()/unsetenv(). When we *are* using a custom environment, add_to_env() first loops all existing variables, looking for a match. If a match is found, it's updated with the new value. If it's not found, a new entry is added. del_from_env() loops all entries, and removes it when a match is found. If no match is found, nothing is done. The mutable environment is allocated on the heap, but never free:d. We don't need to free it, since it's only allocated after forking, in the child process. Closes #1568
* term: cache font baselineDaniel Eklöf2023-10-10-0/+1
| | | | | No need to redo the calculation for every single cell we render, every frame...
* csi: implement DECSET/DECRST/DECRQM 2027 - grapheme cluster processingDaniel Eklöf2023-09-25-0/+3
| | | | | | | | | | | 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
* selection: add support for selecting the contents of a quoteDaniel Eklöf2023-09-19-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the default of triple clicking, from selecting the current logical row, to first trying to select the contents of the quote under the cursor, and if failing to find a quote, selecting the current row (like before). This is implemented by adding a new key binding, 'select-quote'. It will search for surrounding quote characters, and if one is found on each side of the cursor, the quote is selected. If not, the entire row is selected instead. Subsequent selection operations will behave as if the selection is either a word selection (a quote was found), or a row selection (no quote found). Escaped quote characters are not supported: "foo \" bar" will match 'foo \', and not 'foo " bar'. Mismatched quotes are not custom handled. They will simply not match. Nested quotes ("123 'abc def' 456") are supported. Closes #1364
* term: improve fallback logic when selecting scaling factor while unmappedDaniel Eklöf2023-08-18-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The foot window may, for various reasons, become completely unmapped (that is, being removed from all outputs) at run time. One example is wlroots based compositors; they unmap all other windows when an opaque window is fullscreened. 21d99f8dced335826964ca96b8ba7ccac059e598 introduced a regression, where instead of picking the scaling factor from one of the available outputs (at random), we started falling back to '1' as soon as we were unmapped. This patch restores the original logic, but also improves upon it. As soon as a scaling factor has been assigned to the window, we store a copy of it in the term struct ('scale_before_unmap'). When unmapped, we check if it has a valid value (the only time it doesn't is before the initial map). If so, we use it. Only if it hasn't been set do we fall back to picking an output at random, and using its scaling factor. Closes #1464
* scaling: always round the scaling factor when converting to intDaniel Eklöf2023-07-25-0/+1
| | | | | | | | | * 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()
* render: apply new baseline calculation everywhereDaniel Eklöf2023-07-25-0/+1
| | | | | | | | * URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430
* terminal: break out scaling factor updating, and reduce number of calls to render_resize()Daniel Eklöf2023-07-18-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Break out the logic that updates the terminal’s scaling factor value, from render_resize(), to a new function, term_update_scale(). This allows us to update the scaling factor without a full grid resize. We also change how we pick the scaling factor (when fractional scaling is not in use). Before, we’d use the highest scaling factor from all monitors we were mapped on. Now, we use the scaling factor from the monitor we were *last* mapped on. Then, add a boolean parameter to term_set_fonts(), and when false, *don’t* call render_resize_force(). Also change term_font_dpi_changed() to only return true if the font was changed in any way. Finally, rewrite update_term_for_output_change() to: * Call term_update_scale() before doing anything else * Call render_resize{,_force} *last*, and *only* if either the scale or the fonts were updated. This fixes several things: * A bug where we failed to update the fonts when fractional scaling was in use, and we guessed the initial scale/DPI wrong. The bug happened because updated the internal "preferred" scale value, and a later call to render_resize() updated the terminal’s scale value, but since that code path didn’t call term_font_dpi_changed() (and it shouldn’t), the fonts weren’t resized properly. * It ensures we only resize the grid *once* when the scaling factor, or DPI is changed. Before this, we’d resize it twice. And this happened when e.g. dragging the window between monitors.
* term: font_dpi_changed: scale (and old_scale) are floating pointDaniel Eklöf2023-07-18-1/+1
| | | | | | This should fix an issue where the font size wasn’t updated when moving the window between outputs whose scaling factors match when truncated.
* refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf2023-07-03-14/+0
|
* sixel: re-scale images when the cell dimensions changeDaniel Eklöf2023-06-30-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, when the cell dimensions changed (i.e. when the font size changes), sixel images were either removed (the new cell dimensions are smaller than the old), or simply kept at their original size (new cell dimensions are larger). With this patch, sixels are instead resized. This means a sixel *always* occupies the same number of rows and columns, regardless of how much the font size is changed. This is done by maintaining two sets of image data and pixman images, as well as their dimensions. These two sets are the new ‘original’ and ‘scaled’ members of the sixel struct. The "top-level" pixman image pointer, and the ‘width’ and ‘height’ members either point to the "original", or the "scaled" version. They are invalidated as soon as the cell dimensions change. They, and the ‘scaled’ image is updated on-demand (when we need to render a sixel). Note that the ‘scaled’ image is always NULL when the current cell dimensions matches the ones used when emitting the sixel (to save run-time memory). Closes #1383
* sixel: special case parsing of images with an aspect ratio of 1:1Daniel Eklöf2023-06-29-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Images with an aspect ratio of 1:1 are by far the most common (though not the default). It makes a lot of sense, performance wise, to special case them. Specifically, the sixel_add() function benefits greatly from this, as it is the inner most, most heavily executed function when parsing a sixel image. sixel_add_many() also benefits, since allows us to drop a multiplication. Since sixel_add_many() always called first (no other call sites call sixel_add() directly), this has a noticeable effect on performance. Another thing that helps (though not as much), and not specifically with AR 1:1 images, is special casing DECGRI a bit. Up until now, it simply updated the current sixel parameter value. The problem is that the default parameter value is 0. But, a value of 0 should be treated as 1. By adding a special ‘repeat_count’ variable to the sixel struct, we can initialize it to ‘1’ when we see DECGRI, and then simply overwrite it as the parameter value gets updated. This allows us to drop an if..else when emitting the sixel.
* term: convert ‘scale’ to a floatDaniel Eklöf2023-06-29-1/+1
|
* sixel: stop cropping images to the last non-transparent rowDaniel Eklöf2023-06-24-1/+0
|
* sixel: respect sixel aspect ratioDaniel Eklöf2023-06-24-0/+9
| | | | | | | | That is, parse P1 when initializing a new sixel, and don’t ignore pad/pad in the raster attributes command. The default aspect ratio is 2:1, but most sixels will override it in the raster attributes command (to 1:1).
* term: add term_cursor_col()Daniel Eklöf2023-06-20-0/+1
| | | | | | | Set cursor column, absolute. term_cursor_to() needs to reload the current row pointer, and is thus not very effective when we only need to modify the column.
* vt: split up action_param() to three separate functionsDaniel Eklöf2023-06-16-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | We’re already switching on the next VT input byte in the state machine; no need to if...else if in action_param() too. That is, split up action_param() into three: * action_param_new() * action_param_new_subparam() * action_param() This makes the code cleaner, and hopefully slightly faster. Next, to improve performance further, only check for (sub)parameter overflow in action_param_new() and action_param_subparam(). Add pointers to the VT struct that points to the currently active parameter and sub-parameter. When the number of parameters (or sub-parameters) overflow, warn, and then point the parameter pointer to a "dummy" value in the VT struct. This way, we don’t have to check anything in action_param().
* term: protect against integer overflow when accumulating scroll damageDaniel Eklöf2023-03-30-1/+1
| | | | | | | | | | | | | | | | | | | When accumulating scroll damage, we check if the last scroll damage’s scrolling region, and type, matches the new/current scroll damage. If so, the number of lines in the last scroll damage is increased, instead of adding a new scroll damage instance to the list. If the scroll damage list isn’t consumed, this build up of scroll damage would eventually overflow. And, even if it didn’t overflow, it could become large enough, that when later used to calculate e.g. the affected surface area, while rendering a frame, would cause an overflow there instead. This patch fixes both issues by: a) do an overflow check before increasing the line count b) limit the line count to UINT16_MAX
* render: fix glitchy selection while resizing the ‘normal’ screenDaniel Eklöf2023-03-27-0/+1
| | | | | | | | | | | The selection coordinates are in absolute row numbers. As such, selection breaks when interactively resizing the normal grid, since we then instantiate a temporary grid mapping directly to the current viewport (for performance reason, to avoid reflowing the entire grid over and over again). Fix by stashing the actual selection coordinates, and ajusting the "active" ones to the temporary grid.
* interactive resize: improve user experienceDaniel Eklöf2022-10-17-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-initialize the temporary ‘normal’ grid instance each time we receive a configure event while doing an interactive resize. This way, window content will not be "erased" when the window is first made smaller, then larger again. And, if the viewport is up in the scrollback history, increasing the window size will reveal more of the scrollback, instead of just being black. The last issue is the cursor; it’s currently not "stuck" where it should be. Instead, it follows the window around. This is due to two things: 1) the temporary grid we create is large enough to contain the current viewport, but not more than that. That means we can’t "scroll up", to hide the cursor. 2) grid_resize_without_reflow() doesn’t know anything about "interactive resizing". As such, it will ensure the cursor is bound to the new grid dimensions. I don’t yet have a solution for this. This patch implements a workaround to at least reduce the impact, by simply hiding the cursor while we’re doing an interactive resize.
* render: rename term->render.resizing -> term->interactive_resizingDaniel Eklöf2022-10-10-5/+6
| | | | | | | | | | | | | | | | | | | | | But also, more importantly, logical fixes: * Stash the number of new scrollback lines the stashed ‘normal’ grid should be resized *to*. There’s also a couple of performance changes here: * When doing a delayed reflow (tiocswinsz timer), call sixel_reflow_grid(term, &term->normal) - there’s no need to reflow sixels in the ‘alt’ screen. * When doing a delayed reflow, free all scroll damage. It’s not needed, since we’re damaging the entire window anyway. * Use minimum size for the temporary ‘normal’ grid (that contains the current viewport). We just need it to be large enough to fit the current viewport, and be a valid grid row count (power of 2). This just so happens to be the current ‘alt’ grid’s row count...
* term_ptmx_{pause,resume}: return success/failDaniel Eklöf2022-10-10-2/+2
|
* render: resize: ignore ptmx read events during interactive resizeDaniel Eklöf2022-10-10-0/+3
|
* render: delay reflow for ‘resize-delay-ms’ millisecondsDaniel Eklöf2022-10-10-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reflowing a large scrollback is *slow*. During an interactive resize, it can easily take long enough that the compositor fills the Wayland socket with configure events. Eventually, the socket becomes full and the compositor terminates the connection, causing foot to exit. This patch is work-in-progress, and the first step towards alleviating this. It delays the reflow by: * Snapshotting (copying) the original grid when an interactive resize is started. * While resizing, we apply a simple truncation resize of the grid (like we handle the alt screen). * When the resize is done, or paused for ‘resize-delay-ms’, the grid is reflowed. TODO: we *must* not allow any changes to the temporary (truncated) grid during the resize. Any changes to the grid would be lost when the final reflow is applied. That is, we must completely pause the ptmx pipe while a resize is in progress. Future improvements: The initial copy can be slow. We should be able to avoid it by rewriting the reflow algorithm to not free anything. This is complicated by the fact that some resources (e.g. sixel images) are currently *moved* to the new grid. They’d instead have to be copied.
* render: apply a dimmed overlay while in Unicode input modeDaniel Eklöf2022-08-08-3/+4
|
* osc: add support for OSC 133;A (prompt markers)Daniel Eklöf2022-06-16-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the OSC-133;A sequence, introduced by FinalTerm and implemented by iTerm2, Kitty and more. See https://iterm2.com/documentation-one-page.html#documentation-escape-codes.html. The shell emits the OSC just before printing the prompt. This lets the terminal know where, in the scrollback, there are prompts. We implement this using a simple boolean in the row struct ("this row has a prompt"). The prompt marker must be reflowed along with the text on window resizes. In an ideal world, erasing, or overwriting the cell where the OSC was emitted, would remove the prompt mark. Since we don't store this information in the cell struct, we can't do that. The best we can do is reset it in erase_line(). This works well enough in the "normal" screen, when used with a "normal" shell. It doesn't really work in fullscreen apps, on the alt screen. But that doesn't matter since we don't support jumping between prompts on the alt screen anyway. To be able to jump between prompts, two new key bindings have been added: prompt-prev and prompt-next, bound to ctrl+shift+z and ctrl+shift+x respectively. prompt-prev will jump to the previous, not currently visible, prompt, by moving the viewport, ensuring the prompt is at the top of the screen. prompt-next jumps to the next prompt, visible or not. Again, by moving the viewport to ensure the prompt is at the top of the screen. If we're at the bottom of the scrollback, the viewport is instead moved as far down as possible. Closes #30
* search: don't modify search.start coord *before* finding next matchDaniel Eklöf2022-04-21-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The match logic uses the last start coordinate to determine which end points in the selection to update. This sometimes fails when the start coordinate has been changed by e.g. a key binding - the new start coordinate is incorrectly matched against the old-but-modified start coordinate, causing foot to e.g. *not* upate the selection start coordinate. Example: $ echo 'test\n\test\ntest' Then do a scrollback search for 'test. The first match is found correctly (the last 'test'), but searching for the previous match (ctrl+r) does not select the middle 'test'. Fix by passing the search direction to search_find_next(), and have _it_ calculate the coordinate to start search. There are three possibilities: * forward * backward * "backward", but at the same position The first two are used when searching for next/prev match with ctrl+s and ctrl+r. The last one is used when the search criteria is updated. In this case, we don't want to move to the previous match, *unless* the current match no longer matches.
* wayland: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf2022-04-17-1/+0
| | | | | | | | | | | | | | The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
* key-binding: new API, for handling sets of key bindingsDaniel Eklöf2022-04-17-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, our Wayland seats have been tracking key bindings. This makes sense, since the seat’s keymap determines how the key bindings are resolved. However, tying bindings to the seat/keymap alone isn’t enough, since we also depend on the current configuration (i.e. user settings) when resolving a key binding. This means configurations that doesn’t match the wayland object’s configuration, currently don’t resolve key bindings correctly. This applies to footclients where the user has overridden key bindings on the command line (e.g. --override key-bindings.foo=bar). Thus, to correctly resolve key bindings, each set of key bindings must be tied *both* to a seat/keymap, *and* a configuration. This patch introduces a key-binding manager, with an API to add/remove/lookup, and load/unload keymaps from sets of key bindings. In the API, sets are tied to a seat and terminal instance, since this makes the most sense (we need to instantiate, or incref a set whenever a new terminal instance is created). Internally, the set is tied to a seat and the terminal’s configuration. Sets are *added* when a new seat is added, and when a new terminal instance is created. Since there can only be one instance of each seat, sets are always removed when a seat is removed. Terminals on the other hand can re-use the same configuration (and typically do). Thus, sets ref-count the configuration. In other words, when instantiating a new terminal, we may not have to instantiate a new set of key bindings, but can often be incref:ed instead. Whenever the keymap changes on a seat, all key bindings sets associated with that seat reloads (re-resolves) their key bindings. Closes #931
* url-mode: add a key binding that enables “persistent” URL modeDaniel Eklöf2022-04-17-1/+1
| | | | | | | This is an alternative to ‘show-urls-launch’, where we stay in URL mode after activating an URL. Closes #964
* search: break out “find next match” logic to a new functionDaniel Eklöf2022-04-16-1/+2
|
* render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf2022-04-16-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Search mode and ‘flash’ (OSC-555) both achieves similar visual effects: flash tints the entire window yellow, and search mode dims it (except the search match). But, they do so in completely different ways. Search mode is detected in render_cell(), and the colors are then dimmed there. Flash is implemented by blending a yellow, semi-transparent color on top of the rendered grid. This patch replaces those two implementations with a single one. We add a new sub-surface, called the ‘overlay’. In normal mode, it’s unmapped. When either search mode, or flash, is enabled, we enable it, and fill it with a semi-transparent color. Yellow for ‘flash’, and “black” (i.e. no color) for search mode. The compositor then blends it with the grid. Hopefully on the GPU, meaning it’ll be faster than if we blend in software. There are more performance benefits however. By using a separate surface, we can do much better damage tracking. The normal grid rendering code no longer have to care about neither search mode, nor flash. Thus, we get rid of a couple of ‘if’ statements in render_cell(), which is nice. But more importantly, we can drop full grid repaints in a couple of circumstances: * Entering/exiting search mode * Every frame while flash is active Now, when rendering the search mode overlay, we do want to do some damage tracking, also of the overlay. This, since search mode doesn’t dim the *entire* window. The search match is *not* dimmed. This is implemented by punching a hole in the overlay sub-surface. That is, we make part of it *fully* transparent. The basic idea is to set a clip region that excludes the search match, and then dim the rest of the overlay. It’s slightly more complicated than that however, if we want to reuse the last frame’s overlay buffer (i.e we don’t want to re-render the *entire* overlay every frame). In short, we need to: * Clear (punch hole) in areas that are part of this frame’s search match, but not the last frame’s (since those parts are _already_ cleared). * Dim the areas that were part of the last frame’s search match, but aren’t anymore (the rest of the overlay should already be dimmed). To do this, we save the last frame’s “holes” (as a pixman region). Then, when rendering the next frame, we first calculate the new frame’s “holes” region. The region to clear is “this frame’s holes minus last frame’s holes” The region to dim is “last frame’s holes minus this frames holes”. Finally, we compute the bounding box of all modified cells by taking the union of the two diff regions mentioned above. This allows us to limit the buffer damage sent to the compositor.
* wayland: optionally disable pointer input on subsurfacesDaniel Eklöf2022-04-16-4/+0
| | | | | | | | | | | | | | | | We have a number of sub-surfaces for which we are *not* interrested in pointer (or touch) input. Up until now, we’ve manually dealt with these, by recognizing these surfaces in all pointer events, and ignoring them. But, lo and behold, there are better ways of doing this. By clearing the subsurface’s input region, the compositor will do this for us - when a pointer is outside a surface’s input region, the event is passed to the next surface underneath it. This is exactly what we want! Do this for all subsurfaces, *except* the CSDs.
* client: add -E,--client-environmentDaniel Eklöf2022-04-12-1/+1
| | | | | | | | | | | | | | | | | When this option is used, the child process in the new terminal instance will inherit its environment from the footclient process, instead of the foot server’s. Implemented by sending (yet another) dynamic string list as part of the client -> server setup packet. When the new option is *not* used, the setup packet is now 2 bytes larger than before. On the server side, the slave process now uses execvpe() instead of execvp(). There’s plumbing to propagate a new ‘envp’ argument from term_init() all the way down to slave_exec(). If ‘envp’ is NULL, we use ‘environ’ instead (thus matching the old behavior of execvp()). Closes #1004
* refactor: add a ‘range’ struct, grouping a start and end coord togetherDaniel Eklöf2022-04-09-8/+8
|
* csi: add support for DECNKM private modeCraig Barnes2022-03-19-0/+1
| | | | | | | | | | | 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/input: remove private mode 27127Craig Barnes2022-02-09-2/+0
| | | | This effectively reverts commit 31c73f0cf01e1d0bdcd1435136b010c1c1ab442c.
* config: move structs and enums used by config from terminal.h -> config.hDaniel Eklöf2022-02-09-9/+1
|
* Specify a fallback mouse cursorAshish SHUKLA2022-02-07-0/+1
| | | | | `text' cursor is not available in lots of cursor themes, but `xterm' is, so specify `xterm' as a fallback cursor name.
* term: add term_set_user_mouse_cursor()Daniel Eklöf2022-02-07-0/+2
| | | | | | | | | This function allows setting a custom mouse cursor. This is done by adding a ‘char*’ member to the term struct. When it is non-NULL, we *always* use that pointer (the exception being when the pointer is hidden), while the pointer is over the grid. This is instead of the hand/beam pointers we otherwise would use.
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* search: remember last searched-for string between searchesDaniel Eklöf2022-01-29-0/+5
| | | | | | | | | Regardless of how we exit search mode (commit or cancel), the search string is remembered. The next time we enter search mode, the last searched-for string will be used when searching for the next/prev match (ctrl+r, ctrl+s), and the search query is empty.
* replace gettimeofday with clock_gettimePranjal Kole2022-01-15-1/+1
| | | | | | | | | | | | | POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
* SGR-Pixels mouse mode, closes #762Autumn Lamonte2022-01-01-0/+5
|