aboutsummaryrefslogtreecommitdiff
path: root/url-mode.h (follow)
Commit message (Collapse)AuthorAgeLines
* config+url: add support for user-defined regex patternsDaniel Eklöf2025-02-05-2/+3
| | | | | | | | | | | | | | | | | | | | | 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).
* input: remove the concept of "significant" modifiersDaniel Eklöf2024-02-06-1/+0
| | | | | | | | | | | | | | | | | | | 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.
* key-binding: new API, for handling sets of key bindingsDaniel Eklöf2022-04-17-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* input: don’t allow non-significant modifiers when matching untranslated symbolsDaniel Eklöf2022-03-20-0/+1
| | | | | | | | | | | | | | | | | | 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: rewrite of how we match foot’s own key bindingsDaniel Eklöf2021-03-04-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* url-mode: use ‘jump-label-letters’ as the alphabet for key sequencesDaniel Eklöf2021-02-13-1/+2
| | | | | | | Instead of hard coding the alphabet to “sadfjklewcmpgh”, use the letters from ‘jump-label-letters’. Closes #355
* url-mode: urls_collect(): URL list pointer as an argumentDaniel Eklöf2021-02-07-2/+5
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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.
* config: add show-urls-copy actionDaniel Eklöf2021-02-07-1/+1
| | | | | | This works just like show-urls-launch, except that instead of opening the URL (typically using xdg-open), it is placed in the clipboard when activated.
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+18
The jump labels work, but is currently hardcoded to use xdg-open