aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c (follow)
Commit message (Collapse)AuthorAgeLines
* url-mode: for some reason we sorted the label letters before assigning themDaniel Eklöf2025-07-29-12/+0
| | | | | | | Don't do this. Now that we **don't** sort them, the first letter chosen by the user is always assigned to the bottom most URL. Closes #2140 (again)
* url-mode: assign label keys in reverse orderDaniel Eklöf2025-07-17-4/+4
| | | | | | | The _last_ URL is often the one you are interested in, and with this change, it is always assigned the first (and thus the same) key. Closes #2140
* quirks: remove subsurface unmap quirk for SwayDaniel Eklöf2025-06-09-4/+0
| | | | | | | | Sway used to have an issue where unmapping a subsurface did not damage the surface below (https://github.com/swaywm/sway/issues/6960). This has been fixed for quite some time now, so let's remove the quirk.
* Paste URL/regex selection to prompt if key is uppercase.Ryan Roden-Corrent2025-05-01-2/+12
| | | | | | | | | | | | | | | | In copy-regex/show-urls-copy mode, if the last input character was uppercase, copy the selection to the clipboard _and_ paste it. This is useful for taking a file path from a command output:(log, git, test failure, etc.) and using it in another command. This is inspired by the behavior of copy mode in wezterm: https://wezterm.org/quickselect.html I could have made it check every character in the hint, but it seemed fine to assume that if the last character was uppercase, the user wanted this behavior. Closes #1975.
* url-mode: fix double-width characters not being handled correctlyDaniel Eklöf2025-04-13-2/+6
| | | | | | | | | When a regex matches a string containing double-width characters, the CELL_SPACER values were included in the URL string. This meant the final URL (either launched, or copied) weren't handled correctly, as invalid UTF-8 sequences were inserted in the middle of the string. Closes #2027
* url-mode: fix crash when opening multiple urls with persist modellyyr2025-03-20-2/+0
| | | | | Fixes: 051cd6ecfc8b98e1d80b399ebea40207fe040750 Closes #2000
* url-mode: regex: don't try to NULL-terminate an invalid vlineDaniel Eklöf2025-02-10-1/+4
|
* url-mode: terminate last virtual line before regex matchingDaniel Eklöf2025-02-10-1/+5
| | | | | If the last line doesn't have a hard linebreak, it was never NULL terminated, causing regexec() to crash on an out-of-bounds access.
* Fix URL detection regression on lines with NUL bytesJohannes Altmanninger2025-02-10-1/+2
| | | | | | | | | | | | Commit 859b4c89 (url-mode: wip: more work on regex matching, 2025-01-30) regressed URL detection in weechat. Some of the URLs still work but others don't. This is because regexec() stops at the first NUL, thus skipping the rest of the line. weechat seems create NUL cells between their UI widgets. Work around this by replacing NUL with space. This is probably correct because selecting and copying those cells also translates to space (not sure where in the code).
* url-mode: use the first *sub* expression as URLDaniel Eklöf2025-02-05-3/+3
| | | | | | | | When auto-matching URLs (or custom regular expressions), use the first *subexpression* as URL, rather than the while regex match. This allows us to write custom regular expressions with prefix/suffix strings that should not be included in the presented match.
* config+url: add support for user-defined regex patternsDaniel Eklöf2025-02-05-10/+19
| | | | | | | | | | | | | | | | | | | | | Users can now define their own regex patterns, and use them via key bindings: [regex:foo] regex=foo(bar)? launch=path-to-script-or-application {match} [key-bindings] regex-launch=[foo] Control+Shift+q regex-copy=[foo] Control+Mod1+Shift+q That is, add a section called 'regex:', followed by an identifier. Define a regex and a launcher command line. Add a key-binding, regex-launch and/or regex-copy (similar to show-urls-launch and show-urls-copy), and connect them to the regex with the "[regex-name]" syntax (similar to how the pipe-* bindings work).
* url-mode: regex: make sure there's always room for the NULL terminatorDaniel Eklöf2025-02-05-1/+2
|
* url-mode+config: wip: add url.regex optionDaniel Eklöf2025-02-05-53/+4
|
* url-mode: wip: regex: tweak debug log messageDaniel Eklöf2025-02-05-2/+2
|
* url-mode: wip: regex: mention changes from original regexDaniel Eklöf2025-02-05-1/+5
|
* url-mode: wip: regex: don't allow {}, do allow matched []Daniel Eklöf2025-02-05-3/+7
|
* url-mode: wip: more work on regex matchingDaniel Eklöf2025-02-05-286/+75
| | | | Remove the old auto-detection and instead use the regex matches.
* url-mode: wip: convert to regex matching for auto-detectionDaniel Eklöf2025-02-05-0/+145
|
* input: match unshifted key-bindings before shiftedDaniel Eklöf2025-01-31-13/+13
| | | | | | | | | | | | | | | | | | | | That is, try to match e.g. Control+shift+a, before trying to match Control+A. In most cases, order doesn't matter. There are however a couple of symbols where the layout consumes the shift-modifier, and the generated symbol is the same in both the shifted and unshifted form. One such example is backspace. Before this patch, key-bindings with shift-backspace would be ignored, if there were another key-binding with backspace. So, for example, if we had one key-binding with Control+Backspace, and another with Control+Shift+Backspace, the latter would never trigger, as we would always match the first one. By checking for unshifted matches first, we ensure Control+Shift+Backspace does match.
* input: ignore key-bindings without modifiers when matching untranslated/rawDaniel Eklöf2025-01-31-2/+2
| | | | | | | | | When matching the unshifted symbol, or the raw key code, ignore all key bindings that don't have any modifiers. This fixes an issue where it was impossible to enter (some of the) numbers on the keypad, **if** there was a key-binding for e.g. KP_Page_Up, or KP_Page_Down.
* key-bindings: try all bindings in translated mode before matching untranslated, and then finally rawDaniel Eklöf2025-01-27-2/+17
| | | | | | | | | | | | | | | | | | | When trying to match key bindings, we do three types of matching: * Match the _translated_ symbol (e.g. Control+C) * Match the _untranslated_ symbol (e.g. Control+Shift+c) * Match raw keyboard codes This was done for *each* key binding. This meant we sometimes matched a keybinding in raw mode, even though there was a translated/untranslated binding that would match it too. All depending on the internal order of the key binding list. This patch changes it, so that we first try all bindings in translated mode, then all bindings in untranslated mode, and finally all bindings in raw mode. Closes #1929
* Revert "url-mode: don't strip the file:// prefix from localhost URIs"Daniel Eklöf2024-10-23-2/+31
| | | | This reverts commit 54722369d8ca0c6b90c6d874b0f712e133cd4925.
* spawn: add optional reaper callback, return pid_tDaniel Eklöf2024-07-23-2/+3
| | | | | This will allow spawn() callers to do things when the spawned process has terminated.
* grid: refactor: first step towards a more generic range handlingDaniel Eklöf2024-06-26-3/+3
|
* url-mode: disable IME mode while URL-mode is activeDaniel Eklöf2024-05-21-0/+12
| | | | | | | This prevents the IME from stealing "our" key-presses, and thus preventing the user from opening URLs. Closes #1718, hopefully.
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-10/+10
|
* input: remove the concept of "significant" modifiersDaniel Eklöf2024-02-06-9/+3
| | | | | | | | | | | | | | | | | | | 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.
* util: add streq() function and use in place of strcmp(...) == 0Craig Barnes2024-02-05-2/+2
|
* Codespell fixesDaniel Eklöf2023-10-03-1/+1
|
* url-mode: don't strip the file:// prefix from localhost URIsDaniel Eklöf2023-09-21-31/+2
| | | | | | | | | | | | | | | | | Before this patch, the file://<host> prefix was stripped from URIs, when the hostname matched the current host (that is, for "local" URLs). Unfortunately, the way this was done caused other parts of the URI to be stripped as well. For example, the 'query' and 'fragment' parts. This patch simply removes all special casing of file:// URIs. Since the URL is passed to a generic opener (i.e. we don't have a special opener application for file:// URIs), the opener helper must handle the file:// prefix anyway. Closes #1474
* url-mode: handle wide chars and grapheme clusters when auto-detecting URLsDaniel Eklöf2023-08-21-90/+115
| | | | | | | | | | * Skip spacer cells. This fixes an issue where characters following a double-width character weren't detect properly. * Unpack grapheme clusters (i.e. cells with multiple codepoints), and iterate all their codepoints. Closes #1465
* wayland: xdg-activation is now always availableDaniel Eklöf2023-08-07-4/+0
| | | | Since we're requiring wayland-protocols >= 1.32
* quirks: sway does not damage surface beneath sub-surface, when unmappedDaniel Eklöf2023-05-12-0/+5
| | | | | | | | | | | | | | | | | | | | | When unmapping a sub-surface, Sway <= 1.8 does not damage the surface beneath the sub-surface. https://github.com/swaywm/sway/issues/6960 The workaround is to manually damage the main surface. Previously, this was done when exiting scrollback search, and after the ‘flash’ OSC. But other sub-surfaces, that may also be unmapped, did not. This patch adds a quirk handler that does this, and calls it when: * Exiting scrollback search * Ending the ‘flash’ OSC * Exiting unicode input mode * Clearing URL labels * Removing the scrollback position indicator Closes #1335
* url-mode: tag cells after snapshot:ing the gridDaniel Eklöf2022-11-30-15/+17
| | | | | | | | | | | | | | | | | | | Before this patch, hyperlinked cells were tagged with the “URL” attribute (thus instructing the renderer to draw an underline) *before* the grid was snapshot. When exiting URL mode, the cells were once again updated, this time removing the URL attribute. But what if an escape sequence had modified the grid _while we were in URL mode_? Depending on the sequence, it could move cells around in such a way, that when exiting URL mode, the affected cells weren’t updated correctly. I.e. we left some cells with the URL attribute still set. The fix is simple: tag cells in the snapshot:ed grid only (which isn’t affected by any escape sequence received while in URL mode). Not in the *actual* grid (which _is_ affected).
* url-mode: connect osc-8 links only when both ID and URI matchesDaniel Eklöf2022-08-30-6/+10
| | | | | | | | | | | Before this, two OSC-8 links with a matching ID would be connected even if their URIs weren’t the same. This is against the spec: The same id is only used for connecting character cells whose URIs is also the same. Character cells pointing to different URIs should never be underlined together when hovering over. https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter
* url-mode: add support for XDG activation when opening URLsDaniel Eklöf2022-05-05-26/+81
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* url-mode: allow locked modifiers while handling label letter inputDaniel Eklöf2022-04-20-1/+1
| | | | | This fixes an issue where labels couldn’t be activated if e.g. NumLock was enabled.
* key-binding: new API, for handling sets of key bindingsDaniel Eklöf2022-04-17-2/+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
* url-mode: add a key binding that enables “persistent” URL modeDaniel Eklöf2022-04-17-2/+14
| | | | | | | This is an alternative to ‘show-urls-launch’, where we stay in URL mode after activating an URL. Closes #964
* wayland: optionally disable pointer input on subsurfacesDaniel Eklöf2022-04-16-1/+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.
* fix some small typosMerlin Büge2022-04-13-1/+1
|
* refactor: add a ‘range’ struct, grouping a start and end coord togetherDaniel Eklöf2022-04-09-10/+14
|
* input: don’t allow non-significant modifiers when matching untranslated symbolsDaniel Eklöf2022-03-20-2/+8
| | | | | | | | | | | | | | | | | | When matching “untranslated” bindings (by matching the base symbol of the key, e.g. ctrl+shift+2 in US layout), require that no non-significant modifiers are active. This fixes an issue where AltGr was “ignored”, and would cause certain combinations to match a key binding. Example: ctrl+altgr+0, on many European layouts matched against the default ctrl+0 (reset the font size), instead of emitting ^] To make this work, we now need to filter out “locked” modifiers (e.g. NumLock and CapsLock). Otherwise having e.g. NumLock active would prevent *all* untranslated matching to fail. Closes #983
* input/search/url: pass pointer-to key-binding struct to execute()Daniel Eklöf2022-02-09-4/+6
|
* wayland: unify key- and mouse-binding structsDaniel Eklöf2022-02-09-3/+3
|
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-55/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* osc8: uri ranges: use a dynamically re-sizable array instead of a tllistDaniel Eklöf2021-11-26-6/+9
|
* config: add url.uri-charactersDaniel Eklöf2021-08-09-40/+69
| | | | | | | | | | | | This option specifies the characters allowed in the auto-detected URLs. Any character not in this set constitutes an URL delimiter, and will never be included in auto-detected URLs. This option does not affect OSC-8 URLs. Closes #654
* url-mode: use shm_get_many()Daniel Eklöf2021-07-15-3/+0
| | | | | | | | | | | | | | | | If we have lots of URLs, we use up a *lot* of SHM buffers (and thus pools). Each and every one is a single mmap(), of at least 4K. Since all URL labels are created and destroyed at the same time, it makes sense to use a single pool for all buffers. To do this, we must now do two passes; first one to generate the actual string (label content), and to calculate the label sizes. Then we use this information to allocate all SHM buffers at once, from the same pool. Finally, we iterate the URLs again, this time to actually render them.
* url-mode: abort when running into un-allocated scrollback memoryDaniel Eklöf2021-07-11-0/+5
| | | | | | | | | | | | | | | | | | | | When tagging URL cells (in preparation for rendering URL mode), we loop the URL’s entire range, setting the `url` attribute of all cells, and dirtying the rows. It is possible to create URLs that are invalid, and wrap around the scrollback, even though the scrollback hasn’t yet been filled. For example, by starting an OSC-8 URL, moving the cursor, and then closing the OSC-8 URL. These URLs are invalid, but are still rendered just fine. “Fine” being relative - they will typically fill the entire screen. But at least that’s a very clear indication for the user that’s something is wrong. The problem is when we hit un-allocated scrollback rows. We didn’t check for NULL rows, and crashed. This has now been fixed.
* url-mode: fix crash when removing duplicate and/or overlapping URLsDaniel Eklöf2021-07-11-7/+11
| | | | | | | | | | | | | | | | Removing overlaping and duplicated URLs is done by running two nested loops, that both iterate the same URL list. When a duplicate is found, one of the URLs is destroyed and removed from the list. Deleting and removing an item *is* safe, but only as long as _no other_ iterator has references to it. In this case, if we remove an item from e.g. the inner iterator, we’ll crash if the outer iterator’s *next* item is the item being removed. Closes #627
* url-mode: purge SHM pixmaps when destroying URLsDaniel Eklöf2021-07-11-0/+3
| | | | | | | | | | Unlike other surface types, the SHM cookie depends on the address of each URL instance. This means if we enable, disable, and then enable URL mode again (thus showing exactly the same URLs as the first time), the URLs will have new addresses, and thus the old SHM pixmaps will not get purged automatically. So, manually purge them when destroying the URLs.
* url-mode: off-by-one error in end-point column of auto-detected URLsDaniel Eklöf2021-06-02-5/+11
| | | | | | When an auto-detected URL ended *on* the right-most column, the URL endpoint was off by one, resulting in the underline in URL mode being one character short.
* url-mode: codespellDaniel Eklöf2021-05-22-1/+1
|
* url-mode: remove overlapping URLs, not just duplicatesDaniel Eklöf2021-05-22-10/+36
| | | | | | | | | | | | | | | | | echo -e '\e]8;;https://www.foo.bar\e\\https://www.foo\e]8;;\e\\.bar' will produce an OSC-8 URL (https://www.foo) that is slightly shorter than the auto-detected one (https://www.foo.bar). This produces strange results in URL mode. For example, if url.osc8-underline=always, the OSC8 underline will be removed when url-mode is exited. This patch changes the behavior so that auto-detected URLs that overlap OSC-8 URLs are removed. Note that OSC-8 URLs cannot overlap with each other, and that auto-detected URLs also cannot overlap with each other.
* config: add url.protocolsDaniel Eklöf2021-05-22-19/+5
| | | | | | | This makes the protocols recognized by auto-detected URLs configurable. Closes #531
* config: move url-mode related options to a dedicated section, ‘url’Daniel Eklöf2021-05-22-3/+3
|
* url-mode: fix auto-detection of URLs in the top corner of the viewportDaniel Eklöf2021-03-06-4/+4
| | | | | | | | | | | | | | | | The ‘proto_chars’ variable is kind of like a FIFO, where characters from the grid is pushed to the back of it. I.e. the last <n> bytes are at the *end* of the array. This was what the protocol matching logic expected. However, it was only true after reading ‘max_prot_len’ characters from the grid. Before that, the last <n> bytes from the grid was in the *beginning* of ‘proto_chars’. This meant we did not detect URLs starting in the top left corner of the viewport. Test case: foot sh -c "echo http://test.com && sleep 9999"
* url-mode: ignore keys with modifiersDaniel Eklöf2021-03-04-0/+3
|
* input: rewrite of how we match foot’s own key bindingsDaniel Eklöf2021-03-04-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bindings are matched in one out of three ways: * By translated (by XKB) symbols * By untranslated symbols * By raw key codes A translated symbol is affected by pressed modifiers, some of which can be “consumed”. Consumed modifiers to not partake in the comparison with the binding’s modifiers. In this mode, ctrl+shift+2 maps to ctrl+@ on a US layout. Untranslated symbols, or un-shifted symbols refer to the “base” symbol of the pressed key, i.e. it’s unaffected by modifiers. In this mode, consumed modifiers *do* partake in the comparison with the binding’s modifiers, and ctrl+shift+2 maps to ctrl+shift+2 on a US layout. More examples: ctrl+shift+u maps to ctrl+U in the translated lookup, while ctrl+shift+u maps to ctrl+shift+u in the untranslated lookup. Finally, we also match raw key codes. This allows our bindings to work using the same physical keys when the user switches between latin and non-latin layouts. This means key bindings in foot.ini *must* not include both +shift+ and a *shifted* key. I.e. ctrl+shift+U is not a valid combo as it cannot be triggered. Unfortunately, this was how you were supposed to write bindings up until now... so, we try to detect such bindings, log a deprecation warning and then “fix” the binding for the user. When specifying bindings in foot.ini, both ctrl+U and ctrl+shift+u are valid, and will work. The latter is preferred though, since we cannot detect the raw key code for the former variant. Personally, I also prefer the latter one because it is more explicit; it’s more obvious which keys are involved. However, in some cases it makes more sense to use the other variant. Typically for non-letter combos.
* Revert "url-mode: ignore keys with modifiers"Daniel Eklöf2021-03-04-3/+0
| | | | | | | This reverts commit e5cd09bf3f3b78b408052688645321e99ae2dc5e. This needs to be applied on the consume-modifiers-for-key-bindings branch.
* url-mode: ignore keys with modifiersDaniel Eklöf2021-03-04-0/+3
|
* url-mode: damage current view before entering URL modeDaniel Eklöf2021-02-26-0/+8
| | | | | | | | | | | | | Clear scroll damage and damage the entire viewport before entering URL mode. This will cause us to do a full screen redraw both when entering URL mode, and later when exiting it. Clearing the scroll damage is necessary to ensure we don’t apply it twice (once for the snapshot:ed grid, and later again for the real grid), as that would result in an incorrect pixmap. But, since we’ve cleared the scroll damage, we need to damage the entire view to ensure we redraw the contents correctly.
* url-mode: dirty the “last cursor” cell before taking the snapshotDaniel Eklöf2021-02-26-0/+20
| | | | | | | | | | This ensures the “last cursor” cell is re-drawn (without a cursor, if the cursor has moved), both in the snapshot:ed grid, and later, when we switch back to the real grid. We must also be careful and reset term->render.last_cursor.row both when *entering* and *leaving* URL mode, to ensure it doesn’t point to an invalid row.
* url-mode: no need to damage the entire view when exiting URL modeDaniel Eklöf2021-02-26-1/+0
| | | | | The renderer will simply apply *all* accumulated damage at once, when we render the real grid.
* url-mode: snapshot screen state when entering URL modeDaniel Eklöf2021-02-26-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* url-mode: redirect stdin/stdout/stderr to /dev/null when opening an URLDaniel Eklöf2021-02-24-1/+14
| | | | | This fixex an issue where TUI programs started in the parent terminal (when running nested terminals).
* url-mode: disable debug loggingDaniel Eklöf2021-02-23-1/+1
|
* url-mode: use the same key combo for all occurrences of an URLDaniel Eklöf2021-02-21-5/+25
|
* urls: OSC-8 URLs can now optionally be underlined outside of url-modeDaniel Eklöf2021-02-21-1/+17
| | | | | | | | | | | | | | | | | | | | | This patch adds a new configuration option, ‘osc8-underline=url-mode|always’. When set to ‘url-mode’, OSC-8 URLs are only highlighted (i.e. underlined) in url-mode, just like auto-detected URLs. When set to ‘always’, they are always underlined, regardless of mode, and regardless of their other attributes. This is implemented by tagging collected URLs with a boolean, instructing urls_render() and urls_reset() whether they should update the cells’ ‘url’ attribute or not. The OSC-8 collecter sets this based on the value of ‘osc8-underline’. Finally, when closing an OSC-8 URL, the cells are immediately tagged with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
* urls: add key binding that toggles whether URLs are displayed on jump-labelDaniel Eklöf2021-02-21-0/+6
| | | | | | | | | | | | | | | | | By default, the URL isn’t shown on the jump-label. For auto-detect URLs, doing so is virtually always useless, as the URL is already visible in the grid. For OSC-8 URLs however, the URL is often _not_ visible in the grid. Many times, seeing the URL is still not needed (if you’re doing ‘ls --hyperlink’, you already know what the URIs are). But it is still useful to have a way to show the URLs. This patch adds a new key binding action that can be used in url-mode to toggle the URL on and off in the jump label. It is bound to ctrl+t by default.
* urls: remove free-form ‘text’ member from URL structDaniel Eklöf2021-02-21-8/+3
|
* url-mode: remove duplicate URLsDaniel Eklöf2021-02-21-1/+24
| | | | | | | | Remove URLs with the same start and end coordinates. Such duplicate URLs can be created by emitting an OSC-8 URL with matching grid content: \E]8;;http://foo\E\\http://foo\E]8;;\E\\
* url-mode: activate_url(): ensure ‘scheme’, ‘host’ and ‘path’ are free:dDaniel Eklöf2021-02-21-11/+15
| | | | | | uri_parse() may succeed. But if the scheme isn’t “file”, or if the hostname isn’t localhost, then we failed to free ‘scheme’, ‘host’ and ‘path’.
* url-mode: multiple URL (parts) with the same ID is assigned a single key sequenceDaniel Eklöf2021-02-21-3/+30
| | | | | | | | | | In case an URL is split up into multiple parts, those parts are now treated as a single URL when it comes to key assignment. Only the *first* URL part is actually assigned a key combo. The other parts are ignored. We still highlight them, but for all other purposes they are ignored.
* url-mode: initial support for OSC-8 URLsDaniel Eklöf2021-02-21-0/+31
| | | | | | | Things left to do: since OSC-8 URLs are stored as ranges in the per-row ‘extra’ data member, we currently do not handle line-wrapping URLs very well; they will be considered two separate URLs, and assigned two different key sequences.
* url-mode: store URL in UTF-8, not UTF-32Daniel Eklöf2021-02-21-41/+58
| | | | | | | | | | | | | The only time the URL is actually in UTF-32 is when we’re collecting it (auto-detecting it) from the grid, since cells store their character(s) in UTF-32. Everything *after* that prefers the URL in UTF-8. So, do the conversion while collecting the URL. This patch also changes the URL activation code to strip the ‘file://user@host/’ prefix from file URIs that refer to files on the *local* computer.
* url-mode: convert struct wl_url to use wayl_win_subsurface_new()Daniel Eklöf2021-02-17-37/+3
|
* url-mode: use ‘jump-label-letters’ as the alphabet for key sequencesDaniel Eklöf2021-02-13-6/+6
| | | | | | | Instead of hard coding the alphabet to “sadfjklewcmpgh”, use the letters from ‘jump-label-letters’. Closes #355
* url-mode: do case insensitive comparison when matching key sequenceDaniel Eklöf2021-02-13-2/+2
|
* Merge branch 'refactor-key-bindings'Daniel Eklöf2021-02-08-3/+3
|\
| * key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
* | url-mode: ‘%’ is a valid URI character (but don’t allow it at the end)Daniel Eklöf2021-02-08-2/+2
| | | | | | | | Closes #338
* | misc: when free:ing tll lists, prefer tll_remove() over tll_free()Daniel Eklöf2021-02-08-2/+2
|/ | | | | | | | | | | | | | | | | | | 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: urls_render(): early exit when URL list is emptyDaniel Eklöf2021-02-07-0/+3
|
* url-mode: generate-key-combos: minor efficiency tweaksDaniel Eklöf2021-02-07-7/+8
| | | | | | | | | | | | * Use a do..while loop; this lets us drop the second half of the loop condition. * Call wcslen(prefix) once, *before* iterating the alphabet characters. * Step through the alphabet characters using a pointer, as this avoids an indexed load (with possibly an imul instruction in e.g. -Os builds).
* url-mode: be consistent; use xmalloc() + xrealloc()Daniel Eklöf2021-02-07-4/+4
|
* url-mode: early exit when assigning key combos to empty listDaniel Eklöf2021-02-07-0/+3
|
* url-mode: input: backspace reverts the last keyDaniel Eklöf2021-02-07-2/+11
|
* url-mode: fix key sequence generationDaniel Eklöf2021-02-07-32/+52
| | | | | | | | * We were using the ‘back’ element of the list as prefix for the next iteration of sequences, instead of the element at index ‘offset’ * ALEN() on a wchar_t[] includes the NULL terminator. We don’t want that.
* url-mode: generate key combinations using vimium’s algorithmDaniel Eklöf2021-02-07-16/+47
|
* url-mode: refresh rendered URLs after accepting a keyDaniel Eklöf2021-02-07-0/+1
|
* url-mode: urls_assign_key_combos(): remove URLs when all key combos have been used upDaniel Eklöf2021-02-07-15/+24
|
* url-mode: add ftp://, ftps://, file://, gemini:// and gopher://Daniel Eklöf2021-02-07-0/+5
|
* url-mode: urls_collect(): URL list pointer as an argumentDaniel Eklöf2021-02-07-48/+50
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+46
| | | | | | | | | | | | | | | | | | | | | | 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.
* url-mode: store absolute row numbers in start/end coordinatesDaniel Eklöf2021-02-07-0/+3
| | | | | | | | | | | | | | | | | This allows us to update the jump label positions when the viewport changes. This in turn allows us to stay in URL mode while the user is using the mouse to scroll in the scrollback history. Scrolling with the keyboard is currently not possible, since input handling in URL mode does not recognize “regular” key bindings. We _could_ add scrollback up/down bindings to URL mode too, but lets not, for the time being. (Note: an alternative to this patch is to disallow mouse scrolling too. Then we could have kept the URL start/end as viewport local coordinates).
* url-mode: make the end coordinate *inclusive*Daniel Eklöf2021-02-07-0/+5
|
* url-mode: refactor: break out URL activation to a separate functionDaniel Eklöf2021-02-07-37/+42
|
* url-mode: auto-detect: use wcsncasecmp() instead of towlower()Daniel Eklöf2021-02-07-7/+8
| | | | | When matching the URI scheme, use wcsncasecmp() when comparing the strings, instead of calling towlower() on each cell.