aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* 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
* config: don’t use tllist where it isn’t necessaryDaniel Eklöf2021-06-18-20/+32
| | | | | | | | | | | | | | | | tllists are great when dealing with dynamically changing lists. They are also very easy to use when building lists/arrays where the final size is unknown. However, this ease of use comes at a price: code size. tll-macros expand to a lot of code. Since things in the config are static, once the config has been loaded, using tllists for configuration data structures doesn’t make much sense. This patch replaces nearly all tllists used by the configuration, with dynamically allocated arrays.
* term: erase_cell_range: early break out from URI loopDaniel Eklöf2021-06-15-0/+6
| | | | | | | URI ranges are sorted. This means we don’t have to check any more ranges once we’ve seen one that starts *after* the erase range. Closes #594
* term: no need to set attrs.clean=0 right after copying the VT attrs structDaniel Eklöf2021-06-15-3/+0
| | | | | | | | | When printing a character to a cell, we copy the current VT state’s attributes to the cell. And then clear the ‘clean’ bit. But the ‘clean’ bit is part of the VT state, and is *always* zero. Thus there’s no need to explicitly clear it right after copying the VT state.
* term: free the data associated with the pixman image when destroying box-drawing glyphsDaniel Eklöf2021-06-09-13/+16
| | | | Closes #586
* terminal: add 'charset_designator' enum to make code more self-documentingCraig Barnes2021-06-09-7/+7
| | | | | | This commit also renames the term_set_single_shift_ascii_printer() function to term_single_shift(), since the former is overly verbose and not really even accurate.
* vt: fix SS2/SS3 escape sequences to act correctly as single shiftsCraig Barnes2021-06-08-0/+16
| | | | | | These sequences are supposed to affect the next printable ASCII character and then reset to the previous character set, but before this commit they were behaving like locking shifts.
* terminal: fix compilation error when debug logging is enabledCraig Barnes2021-06-08-2/+2
| | | | | | | | | | Without this fix, setting LOG_ENABLE_DBG to 1 in terminal.c would cause the following error: > terminal.c:1787: 'struct terminal' has no member named 'font_scale' The 'font_scale' member was removed in commit 2afc6782361d0deaa443234466775b1121feec8f.
* term: fix crash when an OSC-8 URI wraps around the scrollbackDaniel Eklöf2021-05-26-2/+8
| | | | | | | | | | | | | | | | Long OSC-8 URIs, that are split up over multiple rows, are handled by emitting one URI range on each row the URL touches. This was done by initializing a row index variable, and then incrementing it each loop iteration. This caused an out-of-bounds array access when the row index reached the maximum number of scrollback lines. The fix is simple: make sure the row index variable wraps around, instead of incrementing without any bounds. Closes #552
* term: osc8_close: debug: assert all URI coordinates are uniqueDaniel Eklöf2021-05-23-0/+14
|
* config: move url-mode related options to a dedicated section, ‘url’Daniel Eklöf2021-05-22-1/+1
|
* extract: move ‘strip_trailing_empty’ parameter from extra_finish() to extract_begin()Daniel Eklöf2021-05-17-2/+2
|
* extract: add extract_finish_wide(), and optionally skip stripping trailing empty cellsDaniel Eklöf2021-05-17-1/+1
| | | | | | | | extract_finish() returns the extracted text in UTF-8, while extract_finish_wide() returns the extracted text in Unicode. This patch also adds a new argument to extract_finish{,_wide}, that when set to true, skips stripping trailing empty cells.
* term: get rid of term->font_scale, use term->scale onlyDaniel Eklöf2021-05-17-19/+12
| | | | | | | | | We only needed term->font_scale to be able to detect scaling factor changes (term->font_scale != term->scale). But, we already have the old scaling factor in all places where term_font_dpi_changed() is called, so let’s pass the old scaling factor as an argument instead.
* term: remove get_font_scale()Daniel Eklöf2021-05-17-38/+13
| | | | | | | | | | | | | | | | | | | | | | | get_font_scale() was used to get the new scaling factor when loading fonts. This was then compared to the last seen font scaling factor. If there was no difference, the fonts were not reloaded. The problem was, the initial term->scale was set differently. This sometimes led to term->scale=2, while get_font_scale() return 1. That meant, fonts were initially scaled by 2 (when dpi-aware=no). Later, when mapped on an output (and thus term->scale being set to 1), the fonts weren’t reloaded with the correct scaling factor since the cached term->font_scale value was already 1. Since term->scale always reflects the *new* scaling factor when term_font_dpi_changed() is called, use that directly, and remove get_font_scale(). Also rename the following functions: * font_should_size_by_dpi() -> font_size_by_dpi_for_scale() * font_size_by_dpi() -> font_sized_by_dpi() * font_size_by_scale() -> font_sized_by_scale()
* term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definitionDaniel Eklöf2021-05-14-4/+4
| | | | | | | | | | | | | | | | | | | | | Instead of using CELL_SPACER for *all* cells that previously used CELL_MULT_COL_SPACER, include the remaining number of spacers following, and including, itself. This is encoded by adding to the CELL_SPACER value. So, a double width character will now store the character itself in the first cell (just like before), and CELL_SPACER+1 in the second cell. A three-cell character would store the character itself, then CELL_SPACER+2, and finally CELL_SPACER+1. In other words, the last spacer is always CELL_SPACER+1. CELL_SPACER+0 is used when padding at the right margin. I.e. when writing e.g. a double width character in the last column, we insert a CELL_SPACER+0 pad character, and then write the double width character in the first column on the next row.
* xdg-activation: initial support for setting urgency using XDG activationDaniel Eklöf2021-05-14-5/+13
|
* term: reset: combine memset+initializers of vt structDaniel Eklöf2021-05-08-3/+4
|
* term: reset: fix reset of the VT structDaniel Eklöf2021-05-08-4/+3
| | | | | | | | | | | | 1. Free buffers and strings 2. memset() the vt struct 3. re-initialize members that must not be zero We _could_ replace the memset() with explicit zeroing of all the members. It’s just that there’s a lot of arrays, so this is much easier. Closes #495
* term: osc8-open: assert URI in VT struct is NULLDaniel Eklöf2021-05-08-0/+2
|
* style, consistent bool names, deprecate old configRyan Farley2021-05-07-1/+1
|
* enhanced bell configurationRyan Farley2021-05-07-13/+16
| | | | | | | | | | Add a separate section for bell configuration, with a bell-specific command option and a setting to allow that command to run without regard to keyboard focus (for those of us who enjoy being beeped at at all times, for example). The actions are also no longer mutually exclusive; this is primarily anticipating urgency support which cannot be replicated outside the process (in server mode anyway) and would thus be complementary to any notification or arbitrary command.
* config: add ‘beam-thickness’ optionDaniel Eklöf2021-04-30-8/+8
| | | | | | | | | | | * Rename cursor.style value ‘bar’ to ‘beam’. ‘bar’ remains recognized, but should eventually be deprecated and then removed. * Add ‘cursor.beam-thickness’ option, a pt-or-px value specifying the thickness of the beam cursor. Defaults to 1.5pt. * Rename (and export) pt_or_px_as_pixels() to term_pt_or_px_as_pixels() * Change term_pt_or_px_as_pixels() to round point values instead of truncating them.
* Fix commentOleh Hushchenkov2021-04-18-3/+1
|
* term: stop reading on eofOleh Hushchenkov2021-04-18-0/+5
|
* term/vt: only do reverse-wrapping (‘bw’) on cub1Daniel Eklöf2021-04-08-38/+3
| | | | | | | | | | | | | | Foot currently does reverse-wrapping (‘auto_left_margin’, or ’bw’) on everything that calls ‘term_cursor_left()’. This is wrong; it should only be done for cub1. From man terminfo: auto_left_margin | bw | bw | cub1 wraps from column 0 to last column This patch moves the reverse-wrapping logic from term_cursor_left() to the handling of BS (backspace). Closes #441
* osc: implement OSC 17+19: change selection background/foreground colorsDaniel Eklöf2021-04-08-0/+6
| | | | | And of course, we also implement the corresponding reset sequences, OSC 117+119.
* osc: reset background alpha when resetting the background colorDaniel Eklöf2021-04-08-0/+1
|
* terminal: drain PTY when client terminatesDaniel Eklöf2021-04-07-4/+9
| | | | | | | | | | This is done by: * Not limiting the number of times we try to read from the PTY when we’ve have POLLHUP * Not requiring the entire the previous read to have filled our buffer. * Not erroring out on EIO.
* config/terminal: refactor: remove “default_*” color members from terminal structDaniel Eklöf2021-04-07-45/+6
| | | | Access the original colors in the configuration instead.
* term: free vt.osc8.uri when destroying a terminalDaniel Eklöf2021-03-28-0/+2
| | | | | Free vt.osc8.uri in term_destroy(), in the off chance, that the client application emitted an un-terminated OSC-8 URI.
* ime: move preedit state from terminal struct to the seat structDaniel Eklöf2021-03-25-20/+20
| | | | | | | | | | | | | | | | | This ensures different seat’s don’t step on each others IME pre-edit state. It also removes most dependencies on having a valid term pointer for many IME operations. We’re still not all the way, since we support disabling IME with a private mode, which is per terminal, not seat. Thus, we still require the seat to have keyboard focus on one of our windows. Closes #324. But note that *rendering* of multiple seat’s IME pre-edit strings is still broken.
* term: term_print(): clear line break flagDaniel Eklöf2021-03-23-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The line break flag is used by the text reflow and text extraction (i.e. copy-paste) logic, to determine whether or not to insert a newline between two lines. There’s some amount of heuristics involved in this. For example, the client application could emit a newline, move the cursor back up, and print text. What does that mean for us? Foot’s behavior up until now has been this: The line break flag is set on the row, when the application emits an explicit linefeed. The flag is cleared when the line is erased. But otherwise not. This meant that emitting a linefeed and then moving the cursor back up and printing text, did not clear the line break flag. This in turn meant that text copied always had newlines inserted, even though that was not the client applications intention. By clearing the line break flag whenever _anything_ is printed to a row, the new behavior is, in practice, that the line break flag is only set on a row if a linefeed was that *last* thing printed to that row. Closes #410
* term: increase/decrease custom line-height with font size changesDaniel Eklöf2021-03-21-2/+13
| | | | | | | | When the user has set a custom line-height, we now adjust it when increasing/decreasing (“zooming”) the font size at run-time. Previously, the line-height was fixed at the size specified in foot.ini.
* term: update_ascii_printer(): log when we (actually) switch printerDaniel Eklöf2021-03-16-1/+11
|
* term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print functionDaniel Eklöf2021-03-16-0/+64
| | | | | | | | | | | | | | | | | | | | | | | term_print() is called whenever the client application “prints” something to the grid. It is called for both ASCII and UTF-8 characters, and needs to handle sixels, insert mode and ASCII vs. graphical charsets. Since it’s on the hot path, this becomes unnecessarily slow. This patch adds a “fast” version of term_print(), tailored for the common case: ASCII characters in non-insert mode, without any sixels and non-graphical charsets. A new function, term_update_ascii_printer(), has been added, and must be called whenever: * The currently selected charset *index* changes * The currently selected charset changes (from ASCII to graphical, or vice verse) * Sixels are added to the grid * Sixels are removed from the grid * Insert mode is enabled/disabled
* term: term_print(): assume we’re *not* at the right marginDaniel Eklöf2021-03-14-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That is, assume we can, and should, increment the cursor column. This changes the emitted assembly from: 518fb: 8b 8b f8 05 00 00 mov 0x5f8(%rbx),%ecx 51901: ff c9 dec %ecx 51903: 39 d1 cmp %edx,%ecx 51905: 7e 11 jle 51918 <term_print.constprop.0+0x78> 51907: ff c2 inc %edx 51909: 89 50 10 mov %edx,0x10(%rax) 5190c: 5b pop %rbx 5190d: 5d pop %rbp 5190e: 41 5c pop %r12 51910: c3 ret 51911: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 51918: c6 40 18 01 movb $0x1,0x18(%rax) 5191c: 5b pop %rbx 5191d: 5d pop %rbp 5191e: 41 5c pop %r12 51920: c3 ret To: 5191c: 41 8d 50 01 lea 0x1(%r8),%edx 51920: 89 50 10 mov %edx,0x10(%rax) 51923: 3b 93 f8 05 00 00 cmp 0x5f8(%rbx),%edx 51929: 0f 8d 21 01 00 00 jge 51a50 <term_print.constprop.0+0x190> 5192f: 5b pop %rbx 51930: 5d pop %rbp 51931: 41 5c pop %r12 51933: c3 ret ... 51a50: c6 40 18 01 movb $0x1,0x18(%rax) 51a54: 44 89 40 10 mov %r8d,0x10(%rax) 51a58: 5b pop %rbx 51a59: 5d pop %rbp 51a5a: 41 5c pop %r12 51a5c: c3 ret I.e. it cuts the normal path from 10 instructions down to 8. It increases the "bad" path with one extra instruction.
* term: don’t close PTY when client application diesDaniel Eklöf2021-03-12-10/+2
| | | | | | | | | Closing it as soon as we detect that the client has died, means we may not have drained it completely. The PTY is either closed _by_ the client application, or by us when we shutdown the terminal. Thus, leaving it open (until we call term_shutdown()) is fine.
* sixel: implement private mode 80 - sixel scrollingDaniel Eklöf2021-02-26-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When enabled (the default), sixels behave much like normal output; the start where the cursor is, and the cursor moves with the sixel. I.e. after emitting a sixel the cursor is left after the image; either to the right, if private mode 8452 is enabled, or otherwise on the next line. Terminal content is scrolled up if the sixel is larger than the screen. When disabled, sixels *always* start at (0,0), the cursor never moves, and the terminal content never scrolls. In other words, the ‘disabled’ mode is a much simpler mode. All we need to do to support both modes is re-write the sixel-emitting loop to: * break early if we’re “out of rows”, i.e. we’ve reached the bottom of the screen. * not linefeed, or move the cursor when scrolling is disabled This patch also fixes a bug in the (new) implementation of private mode 8452. When emitting a sixel, we may break it up into smaller pieces, to ensure a single sixel (as tracked internally) does not cross the scrollback wrap-around. The code that checked if we should do a linefeed or not, would skip the linefeed on the last row of *each* such sixel piece. The correct thing to do is to skip it only on the last row of the *last* piece. I chose not to fix this bug in a separate patch since doing so would have meant re-writing it again when implementing private mode 80.
* grid: grid_free(): free scroll damage listDaniel Eklöf2021-02-26-3/+0
|
* url-mode: snapshot screen state when entering URL modeDaniel Eklöf2021-02-26-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, we automatically exited URL mode whenever we received data on the PTY. This was done since we don’t know _what_ has changed on the screen, and we don’t want to display misleading jump labels. However, this becomes a problem in curses-like applications that periodically updates part of the screen. For example, a statusbar with a clock. This patch changes this behavior; instead of cancelling URL mode when receiving PTY data, we snapshot the grid when entering URL mode. When *rendering*, we use the snapshot:ed grid, while PTY updates modify the “real” grid. Snapshot:ing the grid means taking a full/deep copy of the current grid, including sixel images etc. Finally, it isn’t necessary to “damage” the entire view when *entering* URL mode, since we’re at that point the renderer is in sync with the grid. But we *do* need to damage the entire view when exiting URL mode, since the grid changes on the “real” grid hasn’t been tracked by the renderer.
* grid: add grid_free()Daniel Eklöf2021-02-26-14/+2
|
* terminal: erase_cell_range: erase URI ranges affected by the erase.Daniel Eklöf2021-02-23-2/+52
| | | | | * Partially affected URI ranges are split up * Completely covered URI ranges are removed
* sixel: implement private mode 1070 - private color paletteDaniel Eklöf2021-02-23-0/+1
| | | | | | | | | When enabled (the default), sixels use private color registers. That is, the color palette from the last sixel is *not* re-used. When disabled, sixels share (i.e. re-use) the same color palette. Closes #362
* urls: OSC-8 URLs can now optionally be underlined outside of url-modeDaniel Eklöf2021-02-21-1/+13
| | | | | | | | | | | | | | | | | | | | | This patch adds a new configuration option, ‘osc8-underline=url-mode|always’. When set to ‘url-mode’, OSC-8 URLs are only highlighted (i.e. underlined) in url-mode, just like auto-detected URLs. When set to ‘always’, they are always underlined, regardless of mode, and regardless of their other attributes. This is implemented by tagging collected URLs with a boolean, instructing urls_render() and urls_reset() whether they should update the cells’ ‘url’ attribute or not. The OSC-8 collecter sets this based on the value of ‘osc8-underline’. Finally, when closing an OSC-8 URL, the cells are immediately tagged with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
* terminal: osc8_close(): refactor: use grid_row_add_uri_range()Daniel Eklöf2021-02-21-5/+1
|
* terminal: scroll: use grid_row_reset_extra()Daniel Eklöf2021-02-21-16/+2
|
* term: osc-8: close: ignore zero-length URLsDaniel Eklöf2021-02-21-0/+5
| | | | | | | | | | If the client application emitted e.g: \E]8;;http://foo\E\\\E]8;;\E\\ i.e. an anchor without content, then we ended up with an ‘end’ coordinate that lied *before* the ‘start’ coordinate, since we subtract one (column) from the end point to make it inclusive.
* term: osc-8: open: typo: close previous URL if ‘begin’ coords are *non-negative*Daniel Eklöf2021-02-21-1/+1
|
* term_osc8_close(): the URL *end* column is inclusiveDaniel Eklöf2021-02-21-0/+6
|
* term: add an ‘id’ member to the the ‘row_uri_range’ structDaniel Eklöf2021-02-21-0/+1
| | | | | term_osc8_close() sets it from the OSC-8 ID tracked in the VT sub-struct.
* term: add ‘id’ parameter to term_osc8_open()Daniel Eklöf2021-02-21-1/+3
| | | | | The current OSC-8 URL’s ID is now tracked along with the URI itself, and its starting point.
* terminal: add term_osc8_{open,close} functionsDaniel Eklöf2021-02-21-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | These functions update the OSC-8 URI state in the terminal. term_osc8_open() tracks the beginning of an URL, by storing the start coordinate (i.e. the current cursor location), along with the URL itself. Note that term_osc8_open() may not be called with an empty URL. This is important to notice, since the way OSC-8 works, applications close an URL by “opening” a new, empty one: \E]8;;https://foo.bar\e\\this is an OSC-8 URL\E]8;;\e\\ It is up to the caller to check for this, and call term_osc8_close() instead of term_osc8_open() when the URL is empty. However, it is *also* valid to switch directly from one URL to another: \E]8;;http://123\e\\First URL\E]8;;http//456\e\\Second URL\E]8;;\e\\ This use-case *is* handled by term_osc8_open(). term_osc8_close() uses the information from term_osc8_open() to add per-row URL data (using the new ‘extra’ row data).
* terminal: add OSC-8 state tracking to the VT sub-structDaniel Eklöf2021-02-21-0/+6
|
* grid: enable rows to have ‘extra’ data associated with themDaniel Eklöf2021-02-21-4/+24
| | | | | | | | | | | This patch adds an ‘extra’ member to the row struct. It is a pointer to a struct containing extra data to be associated with this row. Initially, this struct contains a list of URL ranges. These define (OSC-8) URLs on this row. The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by default; it is *not* allocated by grid_row_alloc().
* wayland: drop ‘_surface’ suffix from subsurface struct instancesDaniel Eklöf2021-02-17-3/+3
|
* render-timer: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-1/+1
|
* scrollback-indicator: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-1/+1
|
* search: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-1/+1
|
* csd: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-8/+8
|
* url-mode: convert struct wl_url to use wayl_win_subsurface_new()Daniel Eklöf2021-02-17-1/+1
|
* reaper: monitor SIGCHLD using the FDM instead of via a signalfdDaniel Eklöf2021-02-11-51/+59
| | | | | | | | | | | | | | | | | | | | | | | In addition to letting the FDM do the low-level signal watching, this patch also fixes a bug; multiple SIGCHLDs, be it delivered either through a signal, or via a signalfd, can be coalesced, like all signals. This means we need to loop on waitpid() with WNOHANG until there are no more processes to reap. This in turn requires a small change to the way reaper callbacks are implemented. Previously, the callback was allowed to do the wait(). This was signalled back to the reaper through the callback’s return value. Now, since we’ve already wait():ed, the process’ exit status is passed as an argument to the reaper callback. The callback for the client application has been updated accordingly; it sets a flag in the terminal struct, telling term_destroy() that the process has already been wait():ed on, and also stores the exit status.
* Convert some uses of xassert(false) to BUG("some error message")Craig Barnes2021-02-09-6/+5
|
* misc: when free:ing tll lists, prefer tll_remove() over tll_free()Daniel Eklöf2021-02-08-13/+20
| | | | | | | | | | | | | | | | | | | In many places we have the following pattern: tll_foreach(list, it) free(it->item.thing); tll_free(list); Since all tll functions are macros, and thus inlined, and since tll_free in itself expands to a tll_foreach(), the above pattern expands to more native code than necessary. This is somewhat smaller: tll_foreach(list, it) { free(it->item.thing); tll_remove(list, it); }
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+2
| | | | | | | | | | | | | | | | | | | | | | This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
* term: surface-kind: add TERM_SURF_JUMP_LABELDaniel Eklöf2021-02-07-1/+6
|
* term: destroy: set term->window = NULL after destroying itDaniel Eklöf2021-02-07-1/+3
| | | | | | This fixes a crash in urls_reset() on destroy, where we tried to access an already free:d window pointer in order to destroy the jump label surfaces.
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+3
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* selection: remove selection_enabled()Daniel Eklöf2021-02-02-1/+4
| | | | | Its name did not reflect its semantics. Since it was only used in a single place, “inline” it there, and get rid of it.
* term: term_mouse_grabbed: return true if mouse tracking is disabledDaniel Eklöf2021-02-02-3/+4
|
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-0/+16
|
* Merge branch 'mouse-button-encoding-of-button-6-7'Daniel Eklöf2021-01-23-5/+1
|\
| * terminal: fix encoding of mouse buttons 6 and 7 in mouse eventsDaniel Eklöf2021-01-22-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These two buttons were encoded using the *exact* same numbers as button 4 and 5 (scroll wheel up/down), making it impossible to distinguish them. The relevant section from XTerm’s control sequences documentation is: Some wheel mice can send additional button events, e.g., by tilting the scroll wheel left and right. Additional buttons are encoded like the wheel mice, o by adding 64 (for buttons 6 and 7), or o by adding 128 (for buttons 8 through 11).
* | terminal: add/exclude missing headersJan Beich2021-01-21-0/+3
|/ | | | | | | | | | | | terminal.c:3:10: fatal error: 'malloc.h' file not found #include <malloc.h> ^~~~~~~~~~ terminal.c:1512:9: error: implicit declaration of function 'sigaction' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sigaction(SIGALRM, &(const struct sigaction){.sa_handler = &sig_alarm}, NULL); ^ terminal.c:1532:21: error: implicit declaration of function 'kill' is invalid in C99 [-Werror,-Wimplicit-function-declaration] kill(term->slave, kill_signal); ^