aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* term: cursor_refresh(): don't try to dirty the grid if we don't have oneDaniel Eklöf2025-01-18-0/+3
| | | | | | | | | | | If the compositor sends a keyboard enter event before our window has been mapped, foot crashes; the enter event triggers a cursor refresh (hollow -> non-hollow block cursor), which crashes since we haven't yet allocated a grid. Fix by no-op:ing the refresh if the window hasn't been configured yet. Closes #1910
* terminal: Refresh only overlay when flash expiresAlexander Orzechowski2025-01-18-1/+6
| | | | | | | If we call render_refresh, that will wait for a callback to the main surface. In the case of a flash, the main surface might not get callbacks if the compositor implements fancy culling optimizations like wlroots wlr_scene compositors such as sway version >=1.10.
* term: limit app-id to 2048 charactersDaniel Eklöf2025-01-02-0/+15
| | | | | | | | | | | | Unsure if the protocol imposes a limit (haven't found any documentation), or if the issue is in the libwayland implementation, or wlroots (triggers in at least sway+river). The issue is that setting a too long app-id causes the compositor (river at least) to peg the CPU at 100%, and stop sending e.g. frame callbacks to foot. Closes #1897
* term: set_app_id() + set_window_title(): only allow printable charactersDaniel Eklöf2024-12-17-2/+2
|
* box-drawings: implement octantsDaniel Eklöf2024-12-08-0/+4
|
* term: get_font_dpi(): remove invalid assertionDaniel Eklöf2024-11-24-2/+0
| | | | Closes #1874
* osc: OSC-1 does not set the icon, it sets the icon _label_Daniel Eklöf2024-09-13-30/+6
| | | | | | | | | | In fact, there appears there *is* no escape sequence to set the icon. Keep most of the logic in place, but in practice, we'll always set the icon to the app-id. That is, at startup, we set it to the configured app-id (either from config, or the command line). OSC-176, which sets the app-id, also updates the icon (to the app-id).
* toplevel-icon: implement OSC-1, CSI 20/21/22/23 tDaniel Eklöf2024-09-13-2/+89
| | | | | | | | | | | | | | * The toplevel icon is now set to the app-id, unless "overridden" by OSC-1 or OSC-0. * Implemented OSC-1 * OSC-0 extended to also set the icon * Implemented CSI 20 t - report window icon * Implemented CSI 21 t - report window title * Implemented CSI 22 ; 1 t - push window icon * Implemented CS 23 ; 1 t - pop window icon * Extended CSI 22/23 ; 0 t to also push/pop the icon * Verify app-id set by OSC-176 is valid UTF-8 * Verify icon set by OSC-0/1 is valid UTF-8
* xsnprintf: various improvements related to xvsnprintf() and xsnprintf()Craig Barnes2024-09-13-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary of changes: * Make xvsnprintf() static * restrict-qualify pointer arguments (as done by the libc equivalents) * Make comments and spec references more thorough * Remove pointless `n <= INT_MAX` assertion (see comment) * Use FATAL_ERROR() instead of xassert() (since the assertion is inside a shared util function but the caller is responsible for ensuring the condition holds true) * Change some callers to use size_t instead of int for the return value (negative returns are impossible and all subsequent uses are size_t) The updated comments and code were taken (and adapted) from: https://gitlab.com/craigbarnes/dte/-/blob/49260bb154bca0434462a41c061e512540ec2e49/src/util/xsnprintf.c#L6-50 This work was entirely authored by me and I hereby license this contribution under the MIT license (stated explicitly, so that there's no ambiguity w.r.t. the original license).
* notifications: BEL and OSC-777 now focuses the window on notification activationDaniel Eklöf2024-09-05-2/+3
| | | | | | | | | | | Or put more propertly; if the notification daemon, and the notification helper used by foot has been configured properly (i.e. they both support XDG activation tokens), notifications generated by BEL and OSC-777 will now raise/focus the window when the default action of the notification is activated - typically by clicking the notification. Closes #1822
* term_set_window_title(): fix bad check for invalid UTF-8Daniel Eklöf2024-08-20-1/+1
| | | | mbsntoc32() returns (size_t)-1 on failure, not (char32_t)-1.
* feature: add resize-keep-grid to allow text reflow on font changesAndrew J. Hesford2024-08-20-1/+5
|
* term: thrd_join() returns thrd_success on success, not 0Daniel Eklöf2024-08-15-1/+1
| | | | Closes #1812
* term: reload_fonts(): don't ignore return value of thrd_join()Daniel Eklöf2024-08-04-2/+4
| | | | | | | | | | This should fix the ‘ret’ may be used uninitialized warning Closes #1789
* xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3()Craig Barnes2024-08-03-4/+4
| | | | | | | | | | | This avoids the need for an unused third argument for most xstrjoin() calls and replaces the cases where it's needed with a more flexible function. Code generation is the same in both cases, when there are 2 string params and a compile-time known delimiter. This commit also converts 4 uses of xasprintf() to use xstrjoin*(). See also: https://godbolt.org/z/xsjrhv9b6
* osc: kitty notifications: cleanup and update to latest version of specDaniel Eklöf2024-08-02-15/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* osc: kitty notifications: buttons, icons, app-name, categories etcDaniel Eklöf2024-07-31-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, icons have been finalized in the specification. There were only three things we needed to adjust: * symbolic names are base64 encoded * there are a couple of OSC-99 defined symbolic names that need to be translated to the corresponding XDG icon name. * allow in-band icons without a cache ID (that is, allow applications to use p=icon without having to cache the icon first). Second, add support for the following new additions to the protocol: * 'f': custom app-name, overrides the terminal's app-id * 't': categories * 'p=alive': lets applications poll for currently active notifications * 'id' is now 'unset' by default, rather than "0" * 'w': expire time (i.e. notification timeout) * "buttons": aka actions. This lets applications add additional (to the terminal defined "default" action) actions. The 'activated' event has been updated to report which button/action was used to activate the notification. To support button/actions, desktop-notifications.command had to be reworked a bit. There's now a new config option: desktop-notifications.command-action-arg. It has two template arguments ${action-name} and ${action-label}. command-action-arg gets expanded for *each* action. ${action-name} and ${action-label} has been replaced by ${action-arg} in command. This is a somewhat special template, in that it gets replaced by *all* instances of the expanded actions.
* notify: don't close FD 0Daniel Eklöf2024-07-30-0/+4
| | | | | | | | | | | | | | | This fixes a regression where closing a terminal instance, or hard- or soft-resetting a terminal caused FD 0 to be closed. This meant it became re-usable. Usually, by memfd_create() when allocating a new surface buffer. So far nothing _really_ bad has happened. But what if FD 0 is now used by a memfd, and we close _another_ terminal instance? This causes our memfd to be closed. And then, when e.g. trying to scroll the terminal content: fallocate() fails with bad FD.
* notify: separate active notifications from unfinished kitty notificationsDaniel Eklöf2024-07-23-5/+16
| | | | | | | | | | | | | | | | | | | | | 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/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* spawn: add optional reaper callback, return pid_tDaniel Eklöf2024-07-23-4/+4
| | | | | This will allow spawn() callers to do things when the spawned process has terminated.
* osc/notify: add support for OSC-99, kitty desktop notificationsDaniel Eklöf2024-07-23-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | 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/
* input: allow mouse selections to start inside the marginsDaniel Eklöf2024-07-19-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this, margins were special cased: * The mouse cursor was always a pointer, and never an I-beam (thus signaling selections cannot be made). * The internal mouse coords where set to -1 when the cursor was inside the margins, causing: - text selections from being made - mouse events being passed to mouse grabbing applications In particular, even with a one-pixel margin, making selections was unnecessarily hard in e.g. fullscreen mode, where you'd expect to be able to throw the cursor into the corner of the screen and then start a selection. With this patch, the cursor is treated as if it was in the first/last column/row, when inside the margin(s). An unintended side-effect of this, initially, was that auto-scrolling selections where way too easy to trigger, since part of its logic is checking if the cursor is inside the margins. That problem has been reduced by two things: * auto-scrolling does not occur unless a selection has been started. That is, just holding down the mouse in the margins and moving up/down doesn't cause scrolling. You have to first select at least one cell in the visible viewport. * A selection isn't fully started (i.e. a cell is actually selected) unless the cursor is inside the actual grid, and *not* in the margins. What does the last point mean? We now allow a selection to be _started_ when clicking in the margin. What this means internally is we set a start coordinate for a selection, but *not* and end coordinate. At this point, we don't have an actual selection. Nothing is selected, and no cells are highlighted, graphically. This happens when we set an end coordinate. Without the last bullet point, that would happen as soon as the cursor was _moved_, even if still inside the margins. Now, we require the cursor to leave the margins and touch an actual cell before we set an end coordinate. Closes #1702
* csi: in-band window resize notifications, private mode 2048Daniel Eklöf2024-07-19-0/+35
| | | | | | | | | | | | | 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.
* input: don't map wheel events to BTN_{BACK,FORWARD}Daniel Eklöf2024-07-13-10/+16
| | | | | | | | | | | | | | | | | | | | BTN_BACK and BTN_FORWARD are separate buttons. The scroll wheel don't have any button mappings in libinput/wayland, so make up our own defines. This allows us to map them in mouse bindings. Also expose BTN_WHEEL_{LEFT,RIGHT}. These were already defined, and used, internally, to handle wheel tilt events. With this, they can also be used in mouse bindings. Finally, fix encoding used for BTN_{BACK,FORWARD} when sending mouse button events to the client application. Before this, they were mapped to buttons 4/5. But, button 4/5 are for the scroll wheel, and as mentioned above, BTN_{BACK,FORWARD} are not the same as scroll wheel "buttons". Closes #1763
* osc: extend damage-cells-by-color to default fg/bg as wellDaniel Eklöf2024-07-03-0/+90
| | | | | | | | | | | | | | | 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-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+4
| | | | | | | | | | 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-12/+12
| | | | | 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.
* term: performance: use a bitfield to track which ascii printer to useDaniel Eklöf2024-06-26-8/+15
| | | | | | | | | | | 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.
* term: term_fill(): only set OSC-8 + styled hyperlinks when use_sgr_attrs is setDaniel Eklöf2024-06-26-3/+4
|
* terminal: term_fill(): fix osc8 erase bug + handle styled underlinesDaniel Eklöf2024-06-26-2/+16
| | | | | | | | Only clear OSC-8 hyperlinks at the target columns if we don't have an active OSC-8 URI. This corresponds to normal VT attributes; the currently active attributes are set, and all others are cleared. Handle styled underlines in the same way
* csi: wip: styled underlinesDaniel Eklöf2024-06-26-3/+19
| | | | | | | | | | | | | 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.
* render: use single-pixel buffers for overlays, when possibleDaniel Eklöf2024-05-22-1/+3
| | | | | | | | | | | | | | | | | | | The unicode-mode, and flash overlays are single color buffers. This means we can use the single-pixel buffer protocol. It's undefined whether the compositor will release the buffer or not; to make things easier, simply destroy the buffer as soon as we've committed it. Note that since compositors don't necessarily release single-pixel buffers, we can't plug them into our own buffer interface. This means we can't use buffer pointers to check if we can re-use the previous buffer (i.e. we can skip comitting a new buffer), or if we have to create a new one. It's _almost_ enough to just check if the last overlay style is the same as the current one. Except that that doesn't take window resizes into account...
* config: add cursor.blink-rate optionDaniel Eklöf2024-05-20-5/+9
| | | | | | The default is 500ms, which corresponds to the old, hardcoded default. Closes #1707
* term: default to DPI 96, if the monitor's DPI is 0Daniel Eklöf2024-04-20-4/+7
| | | | | This can happen in virtualized environments, or when running a nested Wayland session.
* term: stash last known DPI, and use after a unmapped/mapped sequenceDaniel Eklöf2024-04-17-3/+21
| | | | | | | | | | | | | | | | | | 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: don't print outside grid when printing multi-column charactersDaniel Eklöf2024-04-15-1/+4
| | | | | | | | | | When auto-wrap is disabled, a multi-column character may be printed on a line that doesn't fit the entire character. That is, the "spacers" we print, as place holders in the columns after the first one, may reach outside the grid. We did (try to) check for this, but the check was off by one. Meaning, we could, in some cases, print outside the grid.
* wayland: remove has_wl_compositor_v6Daniel Eklöf2024-04-12-1/+1
| | | | | | | | | We deviate slightly from the specification, in that we don't assume a preferred buffer scale of 1. Instead, we "guess" the scale *until we receive a surface_preferred_buffer_scale event. Because of this, we don't need the has_wl_compositor_v6 member, as it's enough to check if we have a non-zero 'preferred buffer scale'.
* term: send SIGHUP before SIGTERM when shutting downDaniel Eklöf2024-04-05-13/+57
| | | | | | | | 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.
* term: don't shutdown terminal when PTY is closed, unless --pty was usedDaniel Eklöf2024-04-05-1/+13
| | | | | | | | | | | | | | | | | Unless --pty has been used, we do *not* want to shutdown the terminal when the PTY is closed by the client application; we want to wait for the client application to actually terminate. This was the behavior before the --pty patch. This was changed in the --pty patch, since then, we don't *have* a client application. That is, foot has not forked+exec:ed anything. The only way to trigger a shutdown (from the client side) is to close the PTY. This patch restores the old behavior, when --pty is *not* used. Closes #1666
* wayland: only use the surface preferred scale if set by the compositorDaniel Eklöf2024-04-05-1/+1
| | | | | | | | Before this patch, we would, in some cases, fallback to the surface preferred (not fractional) scaling, even though the compositor hadn't actually published a preferred buffer scale; the presence of a v6 compositor interface doesn't mean we've actually received a preferred scale yet.
* xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpyCraig Barnes2024-03-17-4/+1
|
* Add support for opening an existing PTYAlyssa Ross2024-03-14-27/+40
| | | | | | | | | | | | | | | | | 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(): no need to set attrs.clean = 0Daniel Eklöf2024-03-07-2/+0
| | | | The VT state’s attribute is always 0
* term_fill(): change ‘character’ parameter from char -> uint8_tDaniel Eklöf2024-03-07-1/+1
|
* term_fill(): make sure the filled cells have their ‘clean’ bit resetDaniel Eklöf2024-03-07-1/+3
|
* term: modify term_fill() to optionally reset the SGR attributesDaniel Eklöf2024-03-07-2/+7
|
* term: replace term_put_char() with term_fill()Daniel Eklöf2024-03-07-13/+19
|
* term: codespell: limitiations -> limitationsDaniel Eklöf2024-03-07-1/+1
|
* put_char fixupDaniel Eklöf2024-03-07-0/+1
|
* term: print: spacers may be printed all the way up to the last columnDaniel Eklöf2024-03-07-1/+1
|
* term: add term_put_char()Daniel Eklöf2024-03-07-0/+36
| | | | | | | | 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
* term: erase-scrollback: handle non-existing scrollback historyDaniel Eklöf2024-02-15-0/+11
| | | | | | | | | | | | If scrollback.lines == 0, and the window size (number of rows) is a power of two, all rows are always visible. I.e. there is no scrollback history. This threw off the scrollback erase logic, causing visible rows to be erased, and set to NULL. This triggered a crash when trying to update the view. Closes #1610
* osc: add support for osc 176 (app ID)delthas2024-02-06-1/+60
| | | | | | | | | | 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-2/+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.
* term: ignore attempts to set a title that contains an invalid UTF-8 sequenceDaniel Eklöf2024-02-06-0/+7
| | | | | | | | | | Setting the title ultimately leads to a call to xdg_toplevel::set_title(). It is a protocol violation to try to set a title that contains an invalid UTF-8 sequence: The string must be encoded in UTF-8. Closes #1552
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-25/+25
|
* term: command_output_to_text(): don’t skip FTCS_COMMAND_FINISHED on last rowDaniel Eklöf2024-02-06-2/+6
|
* config: add pipe-command-output key-bindingDaniel Eklöf2024-02-06-4/+89
|
* 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-1/+1
|
* input: remove the concept of "significant" modifiersDaniel Eklöf2024-02-06-1/+1
| | | | | | | | | | | | | | | | | | | For the purpose of matching key bindings, "significant" modifiers are no more. We're really only interested in filtering out "locked" modifiers. We're already doing this, so there's no need to *also* match against a set of "significant" modifiers. Furthermore, we *never* want to consider locked keys (e.g. when emitting escapes to the client application), thus we can filter those out already when retrieving the set of active modifiers. The exception is the kitty keyboard protocol, which has support for CapsLock and NumLock. Since we're already re-retrieving the "consumed" modifiers (using the GTK style, rather than normal "XKB" style, to better match the kitty terminal), we might as well re-retrieve the effective modifiers as well.
* feature: add resize-by-cells option to constrain window sizes...Andrew J. Hesford2024-02-05-2/+3
| | | | | ...to multiples of the cell size, and preserve grid size when changing fonts or display scales in floating windows.
* util: add streq() function and use in place of strcmp(...) == 0Craig Barnes2024-02-05-1/+1
|
* wayland: use wl_compositor version 6 when availableLeonardo Hernández Hernández2024-01-24-7/+18
|
* terminal: simplify some string-related code in reload_fonts()Craig Barnes2024-01-23-28/+8
|
* 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/+2
| | | | | No need to redo the calculation for every single cell we render, every frame...
* term_font_baseline(): only center glyph when a custom line-height is being usedDaniel Eklöf2023-10-10-2/+10
| | | | | | | | When using the font's own line-height, simply set the baseline 'descent' pixels above the bottom of the cell. This fixes an issue where some fonts appeared "glued" to the top of the cell, and sometimes getting partially clipped.
* Revert "font baseline: use max(font->height, font->ascent + font->descent) when calculating font ↵Daniel Eklöf2023-10-10-1/+1
| | | | | | | | | | | | | height" This reverts commit fd813d0e6cfff57cf8a8f55e9a249ddb6fbdb6d6. The intent of the reverted commit was to align font height calculation with cell height calculation. However, it turns out this breaks some fonts. Typically those with large:ish differences in their 'height' attribute, and their ascent+descent value. Closes #1511
* term: remove unneeded (and mostly unused) term->flash{,_alpha}Daniel Eklöf2023-10-10-4/+0
|
* Enable the use of flash as visual bellRaimund Sacherer2023-10-10-0/+8
| | | | | | With this patch we can configure flash in the bell section. The colors section allow now to configure the color and translucency of the flash.
* term_reset: log hard vs. soft resetDaniel Eklöf2023-10-04-0/+2
|
* Codespell fixesDaniel Eklöf2023-10-03-2/+2
|
* term: get_font_dpi(): don't crash when there aren't any available monitorsDaniel Eklöf2023-10-01-2/+2
| | | | | | | | | | | | | Seen on plasma; monitor is turned off, and then back on again. Before the "new" output global is emitted, the compositor calls fractional_scale::preferred_scale(). This results in a call to get_font_dpi(), where we crash, since it assumes there is at least one monitor available. Fix by falling back to a DPI of 96. Hopefully closes #1498
* 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
* term: improve fallback logic when selecting scaling factor while unmappedDaniel Eklöf2023-08-18-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* wayland: cursor-shape-v1 is now always availableDaniel Eklöf2023-08-07-6/+2
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: fractional-scale-v1 is now always availableDaniel Eklöf2023-08-07-4/+0
| | | | Since we're requiring wayland-protocols >= 1.32
* font baseline: use max(font->height, font->ascent + font->descent) when calculating font heightDaniel Eklöf2023-07-28-1/+1
| | | | | This is how it's done when calculating the cell height, and we should do the same thing when calculating the font baseline.
* scaling: always round the scaling factor when converting to intDaniel Eklöf2023-07-25-9/+19
| | | | | | | | | * 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/+11
| | | | | | | | * URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430
* term: destroy: unref key bindings *after* destroying windowDaniel Eklöf2023-07-18-2/+2
| | | | | | | | | | | | | | | | | This fixes a crash-on-exit on compositors that emit a _"keyboard leave"_ event when a surface is unmapped. In our case, destroying the window (where we unmap it) in term_destroy(), lead to a crash in term_mouse_grabbed(), due to key_binding_for() returning NULL. The call chain in this is case is, roughly: term_destroy() -> wayl_win_destroy() -> keyboard_leave() -> term_xcursor_update_for_seat() -> term_mouse_grabbed()
* term: get_font_subpixel(): use subpixel from monitor we were *last* mapped onDaniel Eklöf2023-07-18-2/+3
|
* terminal: break out scaling factor updating, and reduce number of calls to render_resize()Daniel Eklöf2023-07-18-15/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* wayland: use physical DPI on fractional-scale capable compositorsDaniel Eklöf2023-07-18-32/+23
| | | | | | | | | | | | | | | | | | | | | With legacy scaling, we need to use a "scaled", or "logical" DPI value, that is basically the real DPI value scaled by the monitor’s scaling factor. This is necessary to compensate for the compositor downscaling the surface, for "fake" fractional scaling. But with true fractional scaling, *we* scale the surface to the final size. This means we should *not* use the scaled DPI, but the monitor’s actual DPI. To facilitate this, store both the scaled and the unscaled DPI value in the monitor struct. This patch also changes how we pick the DPI value. Before, we would use the highest DPI value from all the monitors we were mapped on. Now, we use the DPI value from the monitor we were *last* mapped on (typically the window we’re dragging the window *to*).
* term: font_dpi_changed: scale (and old_scale) are floating pointDaniel Eklöf2023-07-18-4/+4
| | | | | | This should fix an issue where the font size wasn’t updated when moving the window between outputs whose scaling factors match when truncated.
* term: (debug): dpi_aware is no longer an enumDaniel Eklöf2023-07-18-2/+1
|
* render: use rounding for fractional scaleRonan Pigott2023-07-16-1/+4
| | | | | If we truncate the buffer dimensions we may accidentally submit a buffer with inappropriate size.
* term_xcursor_update_for_seat(): fix missing evaluation of render_xcursor_is_valid()Daniel Eklöf2023-07-03-1/+1
| | | | | | | | | | When compiling *without* cursor-shape-v1 support, term_xcursor_update_for_seat() would incorrectly set shape=CURSOR_SHAPE_CUSTOM, even though no custom cursor had been set by the user. This resulted in a crash in render_xcursor_set(), when trying to use a NULL-string as custom cursor.
* terminal: #elif -> #elseDaniel Eklöf2023-07-03-1/+1
|
* cursor-shape: use server-side cursors for custom (OSC-22), if possibleDaniel Eklöf2023-07-03-2/+11
| | | | | | | | | | | | Using a lookup table, try to map the user-provided xcursor string to a cursor-shape-v1 known shape. If we succeed, set the user’s custom cursor using server side cursors (i.e. using cursor-shape-v1). If not, fallback to trying to load the image ourselves (using wl_cursor_theme_get_cursor()), and set it using the legacy wl_pointer_set_cursor().
* render: don’t (can’t) use cursor-shape-v1 when user has set a custom cursorDaniel Eklöf2023-07-03-11/+16
| | | | | Well, we _could_, but we’d have to reverse map the string to a cursor-shape-v1 enum value. Let’s not do that, for now at least.
* refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf2023-07-03-24/+10
|
* sixel: re-scale images when the cell dimensions changeDaniel Eklöf2023-06-30-25/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* config: dpi-aware: remove ‘auto’ value, and default to ‘no’Daniel Eklöf2023-06-29-37/+1
| | | | | | | | | | We now default to scaling fonts using the scaling factor, not monitor DPI. The ‘auto’ value for dpi-aware has been removed. Documentation (man pages and README) have been updated to reflect the new default.
* wayland: refactor: wrap wl_surface pointers in a wayl_surface structDaniel Eklöf2023-06-29-9/+9
| | | | | | | | | And add a viewport object to accompany the surface (to be used when scaling the surface). Also rename the wl_surf_subsurf struct to wayl_sub_surface, and add a wayl_surface object to it, rather than a plain wl_surface pointer (to also get the viewport pointer).
* term: reload_fonts(): ‘scale’ is not a floatDaniel Eklöf2023-06-29-4/+4
|