aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* term: protect against integer overflow when accumulating scroll damageDaniel Eklöf2023-03-30-6/+11
| | | | | | | | | | | | | | | | | | | 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
* config: add ‘font-size-adjustment=N[px|%]’ optionDaniel Eklöf2022-12-17-17/+68
| | | | | | | | | | | This patch adds a new config option, font-size-adjustment. It lets you configure how much the font size should be incremented/decremented when zooming in or out (ctrl-+, ctrl+-). Values can be specified in points, pixels or percent. Closes #1188
* term: apply scale factor when converting a px value to ptDaniel Eklöf2022-11-24-1/+1
|
* term: initialize term->font_line_height when there’s no user-set line-heightDaniel Eklöf2022-11-24-1/+4
|
* term: update user-set line-height just before calculating the cell dimensionsDaniel Eklöf2022-11-24-19/+30
| | | | | This ensures *all* font-size affecting changes (DPI, output scaling, font size increment/decrement) also updates the line-height.
* term: adjust user-set line-height by the same percentage as the primary fontDaniel Eklöf2022-11-23-4/+12
| | | | | | | | | | | | | | | | | Before this patch, a user-set line-height was increased/decreased by the exact same amount of pt’s as the font(s). This means, that when there’s a large discrepancy between the line-height and the font size, the proportion between the line’s height and the font size will change as we increase or decrease the font size. This patch changes how the line height is adjusted when the font size is incremented or decremented. We calculate the difference, in percent, between the primary font’s original (default) size, and its current size, and then apply that to the configured line-height. Closes #1218
* term_destroy(): free interactive_resizing.gridDaniel Eklöf2022-10-18-0/+2
| | | | | This grid is normally unallocated, but may be allocated if we are exiting (for whatever reason) in the middle of an interactive resize.
* fdm_ptmx(): regression: don’t return false when an interactive resize is in progressDaniel Eklöf2022-10-18-1/+1
|
* term: reverse scroll: free scrolled out linesDaniel Eklöf2022-10-16-0/+12
| | | | | | | | | | | | This ensures *everything* in the circular scrollback history, after the bottom of the screen, is either NULL rows, or belong to the scrollback *history* (as opposed to the future history). This fixes an issue when calculating the scrollback start, which for example would trigger a crash when moving the viewport (i.e. scrolling with the mouse, or PgUp/PgDown). Closes #1190
* term_ptmx_{pause,resume}: return success/failDaniel Eklöf2022-10-10-12/+12
|
* term: ptmx: don’t consume anything while doing an interactive resizeDaniel Eklöf2022-10-10-0/+11
| | | | | The ‘normal’ grid in use during an interactive resize is temporary; all changes done to it will be lost when the resize is finished.
* term: use SIZE_MAX instead of (size_t)-1llDaniel Eklöf2022-10-10-1/+2
|
* render: resize: ignore ptmx read events during interactive resizeDaniel Eklöf2022-10-10-0/+12
|
* term: utmp: set ‘host’ to WAYLAND_DISPLAYDaniel Eklöf2022-09-23-2/+2
| | | | This is similar to what XTerm does (setting it to DISPLAY)
* Add support for creating utmp recordsDaniel Eklöf2022-09-23-0/+31
| | | | | | | | | | | | | | | | | This patch adds support for creating utmp records using the ‘utempter’ helper binary from the ‘libutempter’ package. * New config option ‘main.utempter’ * New meson command line option, -Ddefault-utempter-path. Defaults to auto-detecting the path. The default value of the new ‘main.utempter’ config option depends on the meson command line option ‘-Ddefault-utempter-path’. If ‘main.utempter’ is *not* set to ‘none’, foot will try to execute the utempter helper binary to create utmp records when a new terminal is instantiated. The record is removed when the terminal instance is destroyed.
* terminal: don’t unref a not-yet-referenced key-binding setDaniel Eklöf2022-09-06-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Key-binding sets are bound to a seat/configuration pair. The conf reference is done when a new terminal instance is created. When that same terminal instance is destroyed, the key binding set is unref:ed. If the terminal instance is destroyed *before* the key binding set has been referenced, we’ll still unref it. This creates an imbalance. In particular, when the there is exactly one other terminal instance referencing that same key binding set, that terminal instance will trigger a foot server crash as soon as it receives a key press/release event. This happens because the next-to-last terminal instance brought the reference count of the binding set down to 0, causing it to be free:d. Thus, we *must* reference the binding set *before* we can error out (when instantiating a new terminal instance). At this point, we don’t yet have a valid terminal instance. But, that’s ok, because all the key_binding_new_for_term() did with the terminal instance was get the "struct wayland" and "struct config" pointers. So, rename the function and simply pass these pointers explicitly. Similarly, change key_binding_for() to take a "struct config" pointer, rather than a "struct terminal" pointer. Also rename key_binding_unref_term() -> key_binding_unref().
* selection: selection_on_rows(): use scrollback relative coordsDaniel Eklöf2022-07-28-6/+6
| | | | | | | | | | | When checking if the current selection intersects with the region (passed as parameter to the function), use scrollback relative coordinates. This fixes an issue where selections crossing the scrollback wrap-around being misdetected, resulting in either the selection being canceled while scrolling, even though it wasn’t scrolled out, or the selection _not_ being canceled, when it _was_ scrolled out.
* Revert "grid: invert the default value of ‘linebreak’, from false to true"Daniel Eklöf2022-06-30-1/+3
| | | | This reverts commit cdd46cdf85b1087ac7465c646bb05078f1bbe85b.
* osc: add support for OSC 133;A (prompt markers)Daniel Eklöf2022-06-16-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* config: add a new ‘environment’ sectionDaniel Eklöf2022-06-13-1/+1
| | | | | | | | This section allows the user to define custom environment variables to be set in the child process: [environment] name=value
* grid: invert the default value of ‘linebreak’, from false to trueDaniel Eklöf2022-06-11-3/+1
|
* terminal: move viewport when part of it is scrolled outDaniel Eklöf2022-05-11-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | If the viewport is at the top of the scrollback, and a program is scrolling (e.g. by emitting newlines), the viewport needs to be moved. Otherwise, the top of the viewport will show the *bottom* of the scrollback (i.e. the newly emitted lines), and the bottom of the viewport shows the top of the scrollback. How do we detect if the viewport needs to be moved? We convert its absolute row number to a scrollback relative row. This number is also the maximum number of rows we can scroll without the viewport being scrolled out. In other words, if the number of rows to scroll is larger than the viewports scrollback relative row number, the viewport needs to moved. How much do we need to move it? The difference between the number of rows to scroll, and the viewports scrollback relative row number. Example: if the viewport is at the very top of the scrollback, its scrollback relative row number is 0. In this case, it needs to be moved the same number of rows as is being scrolled.
* url-mode: add support for XDG activation when opening URLsDaniel Eklöf2022-05-05-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | First, add a ‘token’ argument to spawn(). When non-NULL, spawn() will set the ‘XDG_ACTIVATION_TOKEN’ environment variable in the forked process. If DISPLAY is non-NULL, we also set DESKTOP_STARTUP_ID, for compatibility with X11 applications. Note that failing to set either of these environment variables are considered non-fatal - i.e. we ignore failures. Next, add a helper function, wayl_get_activation_token(), to generate an XDG activation token, and call a user-provided callback when it’s ‘done (since token generation is asynchronous). This function takes an optional ‘seat’ and ‘serial’ arguments - when both are non-NULL/zero, we set the serial on the token. ‘win’ is a required argument, used to set the surface on the token. Re-write wayl_win_set_urgent() to use the new helper function. Finally, rewrite activate_url() to first try to get an activation token (and spawn the URL launcher in the token callback). If that fails, or if we don’t have XDG activation support, spawn the URL launcher immediately (like before this patch). Closes #1058
* term: reset sixel options when hard resetting the terminal stateDaniel Eklöf2022-04-26-0/+10
|
* term: flash: work around Sway sub-surface unmap bugDaniel Eklöf2022-04-26-1/+5
| | | | | | | | | | | | | | | Unmapping a sub-surface in Sway does not damage the underlying surface. As a result, the OSC-555 escape (“flash”) will leave yellow margins on ~every second frame. Out of sway, river, weston and mutter, only Sway needs this workaround. This is a workaround for https://github.com/swaywm/sway/issues/6960 Closes #1046
* sixel/terminal: use the new grid and selection APIsDaniel Eklöf2022-04-25-12/+13
| | | | | | | Use grid_row_abs_to_sb() instead of manually “rebasing” row numbers. Use selection_get_{start,end}() to retrieve the current selection coordinates.
* wayland: remove selection_override_modmask memberDaniel Eklöf2022-04-19-1/+3
| | | | | This member is no longer valid - we need to use one from the current key-binding set.
* 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-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf2022-04-16-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-16/+1
| | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | 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-18/+22
|
* Explicitly initialize sigaction::sa_mask members with sigemptyset(3)Craig Barnes2022-02-12-2/+5
| | | | | | | | | | | | | | | | | | | | Not doing so before calling sigaction(3) is "undefined" according to POSIX[1]: > Applications shall call either sigemptyset() or sigfillset() at least > once for each object of type sigset_t prior to any other use of that > object. If such an object is not initialized in this way, but is > nonetheless supplied as an argument to any of pthread_sigmask(), > sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), > sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or > sigwaitinfo(), the results are undefined. The use of designated initializers means that sa_mask members were still being initialized, but sigset_t is an opaque type and implicit initialization doesn't necessarily produce the same results as using sigemptyset(3) (although it typically does on most implementations). [1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaddset.html
* csi/input: remove private mode 27127Craig Barnes2022-02-09-1/+0
| | | | This effectively reverts commit 31c73f0cf01e1d0bdcd1435136b010c1c1ab442c.
* 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/+15
| | | | | | | | | 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.
* term: scrollback-to-text: crash when trying to extract the entire scrollbackDaniel Eklöf2022-02-07-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | We calculated the ‘start’ row by adding the number of screen rows to the current grid offset. This works in most cases. But not when the offset is close to the wrap-around. This triggered a crash when we tried to access a row number larger than the number of available grid rows. Fix by bounding the start row to the number of grid rows. This unearthed a second bug, where trying to extract the scrollback resulted in nothing getting copied. The extraction logic did: for (r = start; r != (end + 1); r++) .... This works, as long as end isn’t start-1. When we try to extract the entire scrollback, it _is_ start-1. Fix by rewriting the loop logic to check for r==end *after* copying the row contents, but *before* incrementing r. Closes #926
* term: init: initialize selection pivot point coords to -1,-1Daniel Eklöf2022-02-07-0/+4
| | | | | | While this _shouldn’t_ be necessary (pivot points are only used while a selection is ongoing). But it doesn’t hurt to initialize them anyway.
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | 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-5/+4
| | | | | | | | | | | | | 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.
* terminal: use CLOCK_MONOTONIC instead of literal.Érico Nogueira2022-01-14-1/+1
| | | | | CLOCK_MONOTONIC isn't guaranteed to have the same value on all platforms, and this makes the code more readable.
* SGR-Pixels mouse mode, closes #762Autumn Lamonte2022-01-01-6/+14
|
* term_mouse_grabbed(): make ‘seat’ argument constDaniel Eklöf2021-12-28-2/+3
|
* term: print: erase existing OSC-8 URIDaniel Eklöf2021-12-26-1/+2
| | | | | | | | | | If we have an “active” OSC-8 URI, term_print() would correctly replace an existing URI with the new one. But, if we don’t have an active URI, an existing URI was not erased. This can be reproduced with e.g echo -e '\e]8;;http://foo.bar\e\\foobar\e]8;;\e\\\b\b\b\b\b😀\n'
* term_erase(): replace coord-typed arguments with regular intsDaniel Eklöf2021-12-26-14/+15
|
* term: font_size_adjust: use DPI=96 when font is *not* scaled by DPIDaniel Eklöf2021-12-14-8/+8
| | | | Closes #842
* term: ensure cell dimensions are non-zeroDaniel Eklöf2021-12-04-0/+5
| | | | Closes #830
* config, input: allow configuring select-override modifiersfeeptr@codeberg.org2021-12-02-3/+8
|
* term: xcursor_update_for_seat(): BUG on xcursor == NULLDaniel Eklöf2021-11-30-1/+4
|
* term: xcursor_update_for_seat(): remove duplicate check for term->is_searchingDaniel Eklöf2021-11-30-1/+0
|
* term: xcursor_update_for_seat(): remove switch default caseDaniel Eklöf2021-11-30-1/+0
| | | | Let the compiler catch missing enum values
* Merge branch 'window-menu'Daniel Eklöf2021-11-30-8/+35
|\
| * terminal: Make seat xcursor update focus awareJonas Ådahl2021-11-29-8/+35
| | | | | | | | | | | | | | When term_xcursor_update_for_seat() was called on e.g. keyboard focus loss, it'd update the curret xcursor to 'text' even if it was e.g. on top of the window title, or resize areas. This makes the function a bit more focus aware, and will not be so eager to set the text xcursor.
* | input: rename ‘meta’ to ‘super’Daniel Eklöf2021-11-28-1/+1
| |
* | kitty kbd: add flag state, implement push/pop/update/queryDaniel Eklöf2021-11-28-0/+4
| |
* | osc8: update URI ranges as we print data, *not* when the URI is closedDaniel Eklöf2021-11-25-80/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At first, an OSC-8 URI range was added when we received the closing OSC-8 escape (i.e. with an empty URI). But, this meant that cursor movements while the OSC-8 escape was in effect wasn’t handled correctly, since we’d add a range that spanned the cursor movements. Attempts were made to handle this in the cursor movement functions, by closing and re-opening the URI. However, there are too many corner cases to make this a viable approach. Scrolling is one such example, line-wrapping another. This patch takes a different approach; emit, or update the URI range when we print to the grid. This models the intended behavior much more closely, where an active OSC-8 URI act like any other SGR attribute - it is applied to all cells printed to, but otherwise have no effect. To avoid killing performance, this is only done in the “generic” printer. This means OSC-8 open/close calls must now “switch” the ASCII printer. Note that the “fast” printer still needs to *erase* pre-existing OSC-8 URIs. Closes #816
* | term: print: reset ‘col’ after padding the right marginDaniel Eklöf2021-11-21-0/+1
| |
* | Revert "term: print: erase URI range when printing right-margin padding"Daniel Eklöf2021-11-21-3/+0
| | | | | | | | This reverts commit bb967fd2f927d90e881ed2b05db1fa6946033580.
* | term: print: erase URI range when printing right-margin paddingDaniel Eklöf2021-11-21-0/+3
| |
* | term: print: re-order col/row/cell assigmentsDaniel Eklöf2021-11-21-10/+9
| |
* | term: erase_cell_range(): check if row->extra != NULLDaniel Eklöf2021-11-21-1/+2
| |
* | term: tail-call optimize calls to grid_row_uri_range_erase()Daniel Eklöf2021-11-21-2/+8
| |
* | term: call grid_row_uri_range_erase() when printing cellsDaniel Eklöf2021-11-21-19/+34
| |
* | grid: add grid_row_uri_range_erase()Daniel Eklöf2021-11-21-72/+2
| | | | | | | | | | | | | | | | | | This function handles erasing of an URI range. That is, a range of the row is being either erased, or overwritten (from the URI perspective, these two are the same thing). We handle both partial overwrites (split up, or truncate URI), as well as complete overwrites (remove URI).
* | term: track cell color sourceDaniel Eklöf2021-11-20-2/+4
|/ | | | | | | | | | | | | Each cell now tracks it’s current color source: * default fg/bg * base16 fg/bg (maps to *both* the regular and bright colors) * base256 fg/bg * RGB Note that we don’t have enough bits to separate the regular from the bright colors. These _shouldn’t_ be the same, so we ought to be fine...
* config: add [colors].dim0-7Daniel Eklöf2021-11-13-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This allows you to configure custom colors to be used when colors are being dimmed (`\E[2m`). It is implemented by color matching (just like bold-text-in-bright=palette-based); the color-to-be-dimmed is matched against the current color palette. If it matches one of the regular colors (colors 0-7), the corresponding “dim” color will be used. If it matches one of the bright colors (colors 8-15), the corresponding “regular” color will be used (but *only* if the “dim” color has been set). Otherwise, the color is dimmed by reducing its luminance. The default behavior, i.e. when dim0-7 hasn’t been configured, is to dim by reducing luminance for *all* colors. I.e. we don’t do any color matching at all. In particular, this means that dimming a bright color will *not* result in the corresponding “regular” color. Closes #776
* config: add {str,value}_to_uint{16,32}()Daniel Eklöf2021-11-13-1/+1
| | | | | This allows us to pass the final pointer directly to the conversion functions, as well as allowing us to print outside-range errors.
* foot/client: implement xdga client activationRonan Pigott2021-11-01-2/+2
| | | | | | | | | | | This is an application of the xdg activation protocol that will allow compositors to associate new foot toplevels with the command that launched them. footclient receives an activation token from the launcher which the compositor can use to track application startup. It passes the token to the foot server, which then activates the new window with the token to complete the startup sequence.
* term: bell: simplify if-statement - we don’t need two nested levelsDaniel Eklöf2021-10-22-11/+9
|
* term: ignore window title updates if title is un-changedDaniel Eklöf2021-10-22-0/+3
|
* notify: add the notify-focus-inhibit config optionMitja Horvat2021-10-06-3/+3
| | | | | | | | | | | | | | | foot doesn't show desktop notifications (via OSC777) if the current terminal has keyboard focus. This is probably a sane default, but there are use cases where showing a notification regardless of the focus status may be desired. For example, a completion notification of a long running task inside a non-focused tmux window. This PR adds the notify-focus-inhibit option which can be used to disable inhibition of notifications when the window has focus. The default value is `yes`, which retains the old behavior.
* term: only scale using DPI if *all* monitors have a scaling factor or oneDaniel Eklöf2021-09-24-18/+41
| | | | | | | | | | | | | | | | | | | | With dpi-aware=auto (the default), scale fonts using DPI *only* if *all* available monitors have a scaling factor of one. The idea is this: if a user, with multiple monitors, have enabled scaling on *at least* one monitor, he/she has most likely done so to match the size of his/hers other monitors. For example, if the user has one monitor with a scaling factor of one, and another one with a scaling factor of two, he/she expects things to be twice as large on the second monitor. If we (foot) scale using DPI on the first monitor, and using the scaling factor on the second monitor, foot will *not* look twice as big on the second monitor (this was the old behavior of dpi-aware=auto). Part of #714
* term: turn ‘box-drawings’ array into three dynamically allocated arraysDaniel Eklöf2021-09-14-10/+32
| | | | | | | | | | | | | | | | | | | The box_drawings array is now quite large, and uses up ~4K when *empty*. This patch splits it up into three separate, dynamically allocated arrays; one for the traditional box+line drawing and block elements glyphs, one for braille, and one for the legacy computing symbols. When we need to render a glyph, the *entire* array (that it belongs to) is allocated. I.e this is one step closer to a dynamic glyph cache (like the one fcft uses), but doesn’t go all the way. This is especially nice for people with ‘box-drawings-uses-font-glyphs=yes’; for them, the custom glyphs now uses 3*8 bytes (for the three array pointers), instead of 4K.
* term: reduce scope of variableDaniel Eklöf2021-09-05-3/+1
|
* terminal: prefer the advance width of ‘M’ over that of a spaceDaniel Eklöf2021-08-31-3/+8
| | | | | | | | This makes some non-monospaced fonts more readable, allowing users to read errors and warnings printed in the window. Furthermore, fcft-3.0 will remove the space_advance member, so once we upgrade, we’ll have to rasterize a glyph ourselves anyway.
* term: check visual-focus, not kbd-focus when enabling/disabling cursor blinkDaniel Eklöf2021-08-17-2/+2
| | | | | | | | | | | | term_cursor_blink_update() is called when the visual focus changes state (i.e. when our top-level surface is activated de-activated). Checking keyboard focus worked on Sway, but on e.g. GNOME, the order in which keyboard focus and visual focus are updated is different, and we ended up either making the cursor invisible, or visible, but not blinking, when changing focus back to the window. Closes #686
* pt-or-px: heed the dpi-aware settingDaniel Eklöf2021-08-13-18/+20
| | | | | | | | | | | | | | | | | | | | | | | | Before this patch, pt-or-px values, like letter-spacing, were *always* scaled using the current DPI value. This is wrong; if the fonts are scaled using the output’s scaling factor, then so should all other point values. This also fixes an issue where e.g. letter-spacing would use one DPI value at startup, but then when increasing/decreasing or resetting the font size, would be re-calculated using a different DPI value, leading to completely different spacing. This happened when there were multiple monitors, with different DPI values, and foot guessed the initial DPI value wrong. Normally, foot would correct itself as soon as the window was mapped, and the “correct” DPI value known. But if the fonts were scaled using the scaling factor, it was possible that the font reload never happened. This patch also updates the thickness calculation (for LIGHT and HEAVY box drawing characters) to use the scaling factor when appropriate. Closes #680
* input: implement support for mouse wheel left/rightDaniel Eklöf2021-08-07-9/+12
| | | | | | | | | | | | | We now emit button 6/7 events (when the client application grabs the mouse). This buttons map to mouse wheel horizontal scroll events. Or, left/right tilting, if you like. Wayland report these as ‘axis’ events (just like regular scroll wheel events), and thus we need to translate those scroll events to button events. libinput does not define any mouse buttons for wheel tilts, so we add our own defitions. These are added last in the BTN_* range, just before the BTN_JOYSTICK events.
* term: disable debug loggingDaniel Eklöf2021-08-05-1/+1
|
* term: send SIGTERM/SIGKILL to the entire process groupDaniel Eklöf2021-07-31-8/+8
|
* term: fix release builds when LOG_ENABLE_DBG=0Daniel Eklöf2021-07-31-1/+2
|
* term: consolidate shutdown related state into an anonymous structDaniel Eklöf2021-07-31-27/+31
|
* term: rename: slave_died() -> fdm_client_terminated()Daniel Eklöf2021-07-31-5/+6
|
* term: asynchronous client application terminationDaniel Eklöf2021-07-31-42/+168
| | | | | | | | | | | | | | | | | | When the foot window is closed, and we need to terminate the client application, do this in an asynchronous fashion: * Don’t do a blocking call to waitpid(), instead, rely on the reaper callback * Use a timer FD to implement the timeout before sending SIGKILL (instead of using SIGALRM). * Send SIGTERM immediately (we used to *just* close the PTY, and then wait 2 seconds before sending SIGTERM). * Raise the timeout from 2 seconds to 60 Full shutdown now depends on *two* asynchronous tasks - unmapping the window, and waiting for the client application to terminate. Only when *both* of these have completed do we proceed and call term_destroy(), and the user provided shutdown callback.
* render: use a single backing SHM pool for CSD surface buffersDaniel Eklöf2021-07-18-12/+2
|
* term: erase_scrollback(): destroy sixels that touch the scrollbackDaniel Eklöf2021-07-18-12/+54
|
* term: add unit test for term_erase_scrollback()Daniel Eklöf2021-07-18-0/+97
|
* csi: erase scrollback: cancel selection if it touches the scrollbackDaniel Eklöf2021-07-18-0/+63
| | | | | | | | | | | | | | | | | This breaks out the scrollback erasing logic for \E[3J from csi.c, and moves it to the new function term_erase_scrollback(), and changes the logic to calculate the start and end row (absolute) numbers of the scrollback, and only iterate those, instead of iterating *all* rows, filtering out those that are on-screen. It also adds an intersection range check of the selection range, and cancels the selection if it touches any of the deleted scrollback rows. This fixes a crash when trying to render the next frame, since the selection now references rows that have been freed. Closes #633
* shm: refactor: move away from a single, global, buffer listDaniel Eklöf2021-07-17-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, *all* buffers have been tracked in a single, global buffer list. We've used 'cookies' to separate buffers from different contexts (so that shm_get_buffer() doesn't try to re-use e.g. a search-box buffer for the main grid). This patch refactors this, and completely removes the global list. Instead of cookies, we now use 'chains'. A chain tracks both the properties to apply to newly created buffers (scrollable, number of pixman instances to instantiate etc), as well as the instantiated buffers themselves. This means there's strictly speaking not much use for shm_fini() anymore, since its up to the chain owner to call shm_chain_free(), which will also purge all buffers. However, since purging a buffer may be deferred, if the buffer is owned by the compositor at the time of the call to shm_purge() or shm_chain_free(), we still keep a global 'deferred' list, on to which deferred buffers are pushed. shm_fini() iterates this list and destroys the buffers _even_ if they are still owned by the compositor. This only happens at program termination, and not when destroying a terminal instance. I.e. closing a window in a “foot --server” does *not* trigger this. Each terminal instatiates a number of chains, and these chains are destroyed when the terminal instance is destroyed. Note that some buffers may be put on the deferred list, as mentioned above.
* shm: replace 'locked' attribute with a ref-counterDaniel Eklöf2021-07-17-0/+2
| | | | | | | | | | | | | | | | | The initial ref-count is either 1 or 0, depending on whether the buffer is supposed to be released "immeidately" (meaning, as soon as the compositor releases it). Two new user facing functions have been added: shm_addref() and shm_unref(). Our renderer now uses these two functions instead of manually setting and clearing the 'locked' attribute. shm_unref() will decrement the ref-counter, and destroy the buffer when the counter reaches zero. Except if the buffer is currently "busy" (compositor owned), in which case destruction is deferred to the release event. The buffer is still removed from the list though.
* config: add locked-title=no|yesDaniel Eklöf2021-07-04-0/+4
| | | | Closes #386
* term: rows printed to now defaults to having a hard linebreakDaniel Eklöf2021-07-03-2/+3
| | | | | | | That is, instead of requiring a ‘\n’ to be printed, non-empty lines are now treated as having a hard linebreak by default. The linebreak is cleared on an explicit wrap.
* term: destroy: free URLs before free:ing the gridsDaniel Eklöf2021-06-28-3/+5
| | | | | Fixes use-after-free when destroying a terminal with “live” URLs (i.e. when URL mode is active).
* composed: store compose chains in a binary search treeDaniel Eklöf2021-06-24-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation stored compose chains in a dynamically allocated array. Adding a chain was easy: resize the array and append the new chain at the end. Looking up a compose chain given a compose chain key/index was also easy: just index into the array. However, searching for a pre-existing chain given a codepoint sequence was very slow. Since the array wasn’t sorted, we typically had to scan through the entire array, just to realize that there is no pre-existing chain, and that we need to add a new one. Since this happens for *each* codepoint in a grapheme cluster, things quickly became really slow. Things were ok:ish as long as the compose chain struct was small, as that made it possible to hold all the chains in the cache. Once the number of chains reached a certain point, or when we were forced to bump maximum number of allowed codepoints in a chain, we started thrashing the cache and things got much much worse. So what can we do? We can’t sort the array, because a) that would invalidate all existing chain keys in the grid (and iterating the entire scrollback and updating compose keys is *not* an option). b) inserting a chain becomes slow as we need to first find _where_ to insert it, and then memmove() the rest of the array. This patch uses a binary search tree to store the chains instead of a simple array. The tree is sorted on a “key”, which is the XOR of all codepoints, truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range. The grid now stores CELL_COMB_CHARS_LO+key, instead of CELL_COMB_CHARS_LO+index. Since the key is truncated, collisions may occur. This is handled by incrementing the key by 1. Lookup is of course slower than before, O(log n) instead of O(1). Insertion is slightly slower as well: technically it’s O(log n) instead of O(1). However, we also need to take into account the re-allocating the array will occasionally force a full copy of the array when it cannot simply be growed. But finding a pre-existing chain is now *much* faster: O(log n) instead of O(n). In most cases, the first lookup will either succeed (return a true match), or fail (return NULL). However, since key collisions are possible, it may also return false matches. This means we need to verify the contents of the chain before deciding to use it instead of inserting a new chain. But remember that this comparison was being done for each and every chain in the previous implementation. With lookups being much faster, and in particular, no longer requiring us to check the chain contents for every singlec chain, we can now use a dynamically allocated ‘chars’ array in the chain. This was previously a hardcoded array of 10 chars. Using a dynamic allocated array means looking in the array is slower, since we now need two loads: one to load the pointer, and a second to load _from_ the pointer. As a result, the base size of a compose chain (i.e. an “empty” chain) has now been reduced from 48 bytes to 32. A chain with two codepoints is 40 bytes. This means we have up to 4 codepoints while still using less, or the same amount, of memory as before. Furthermore, the Unicode random test (i.e. write random “unicode” chars) is now **faster** than current master (i.e. before text-shaping support was added), **with** test-shaping enabled. With text-shaping disabled, we’re _even_ faster.
* config: add new function config_clone()Daniel Eklöf2021-06-23-2/+2
|
* term: fix regression after merging #599Daniel Eklöf2021-06-18-3/+3
| | | | | Don’t increment ‘j’ twice in each loop iteration, and fix typo in loop condition (check ‘j’, not ‘i’).
* render: don’t create/destroy the title update timer each timeDaniel Eklöf2021-06-18-7/+42
| | | | | Create it once when instantiating the terminal. Add a boolean to track whether the timer is running or not.
* render: use a timer instead of relying on the frame callback for title update throttlingDaniel Eklöf2021-06-18-3/+7
| | | | | | | | | | | | | | | | | | | | | Using the frame callback works most of the time, but e.g. Sway doesn’t call it while the window is hidden, and thus prevents us from updating the title in e.g. stacked views. This patch uses a timer FD instead. We store a timestamp from when the title was last updated. When the application wants to update the title, we first check if we already have a timer running, and if so, does nothing. If no timer is running, check the timestamp. If enough time has passed, update the title immediately. If not, instantiate a timer and wait for it to trigger. Set the minimum time between two updates to ~8ms (twice per frame, for a 60Hz output, and ~once per frame on a 120Hz output). Closes #591