8000 Add configurable modifier key behaviour for hint actions by Chic-Tweetz · Pull Request #5551 · tridactyl/tridactyl · GitHub
[go: up one dir, main page]

Skip to content

Add configurable modifier key behaviour for hint actions - #5551

Open
Chic-Tweetz wants to merge 1 commit into
tridactyl:masterfrom
Chic-Tweetz:feat-hinting-modifier-keys
Open

Chic-Tweetz wants to merge 1 commit into
tridactyl:masterfrom
Chic-Tweetz:feat-hinting-modifier-keys

Conversation

@Chic-Tweetz
@Chic-Tweetz Chic-Tweetz commented Oct 9, 2026 •
Copy link
Copy Markdown
Contributor

a go at #725 to let modifier keys change hint actions

this pr touches a few files:

keyseq.ts

because we want to be able to hold shift while typing hint chars, we need to be able to "unshift" keys to make sure the hints can still be matched

adds a code field and flippedShiftKey method to MinimalKey

because some chars can't just have their case flipped (e.g. numbers), flippedShiftKey looks up the key code in the key translation map to try and get the unshifted key (or shifted if the original was not)

the key code (already used when using :set keyboardlayoutforce true) needs to be stored for that lookup

hinting.ts

the modifier keys from the latest key event in the parser are stored in the hint state as an "ACMS"-like string (this could be moved somewhere more generally accessible like content state or something)

when a hint is selected, the modifier keys are passed along with the hint element and used to change the hint action if applicable

config.ts

adds a config object, hintmodifiers to map hint actions (using their :hint flags, specifically those from the OpenMode enum in hint_util.ts) and modifiers to other actions

"default" is used for bare :hint and "all" can be used to quickly set something for all actions

the syntax ends up a bit fiddly

these would make holding shift in :hint open a new tab and holding shift in :hint -t open in the current tab for example

:set hintmodifiers default.S -t
:set hintmodifiers -t.S default

excmds.ts

when performing a hint action, looks up the hint action in the config then uses the modifier string to find any overrides


open to suggestions! there 8000 are other ways to go and i'm not massively keen on the syntax i've made


after playing with this a bit i've found that if you add a ctrl modifier and try to use it with a "w" hint you'll close the tab with the usual ctrl-w shortcut which is annoying

might have to restrict the allowed modifiers to only shift and alt to avoid that, or at least include a warning to exclude "w" from hintchars or unbind ctrl-w in about:keyboard

unsure if there are other browser binds which can't be prevented

@bovine3dom
Copy link
Copy Markdown
Member

hmm i am not sure how i feel about this. in use it seems fine from my limited testing - although i would expect only the last character of the hint to matter rather than any of them

but in general i would like hinting to become more like any other mode. we already have gobble/nmode which can accept some characters and then do something. and this moves us further away from that ideal.

i would be happier if we could think of some general way of saying 'if a modifier is held for the last character in this bind/mode, do something else'

that is obviously a much harder problem to solve and maybe we shouldn't bother...

@Chic-Tweetz
Copy link
Copy Markdown
Contributor Author

i made it store the modifiers for every key event mainly because it was easy :) it should still only be the last key that actually has an effect

it's all kind of at odds with how bindings usually work seeing as you can normally just add a separate bind with a modifier

unifying all gobble-type modes and letting them know about modifiers makes more sense but yes does sound like a lot of bother

i'm not sure how to envision it really, maybe any mode could be allowed have a gobbleish fallback for unmatched keys (like to match hint chars in hint mode)

@bovine3dom
Copy link
Copy Markdown
Member

it's all kind of at odds with how bindings usually work seeing as you can normally just add a separate bind with a modifier

i agree mostly. but if it's useful to start typing out a command and then change your mind about what it does in hint mode, maybe it is useful in other modes? i don't really understand the appeal for hint mode either, i just press F rather than f. but maybe e.g. (and this is a bad example) quickmarks could be such that got and goT did the current tab / a new tab. or gd/gD for tab duplicate + tab detach, or not

i don't have a great intuition for how this should or could work. but i don't want to add a setting and back ourselves into a corner before we have had a chance to think about it for a bit

@bovine3dom
Copy link
Copy Markdown
Member

i have been sitting on this for a while and i think either

  1. we go for a general system of 'i am in the process of filtering some results iteratively and want to change what i do to the selected result once i am done', which i think basically only applies to hints and completions

or

  1. we go the other route and simplify this as far as possible to only allow shift/bare to toggle between background tab and foreground tab/current tab, hardcoded per hint mode open mode

i suspect option 2) would be the best thing. because the configuration we're introducing looks kind of gnarly?

what do you think @Chic-Tweetz?

@Chic-Tweetz
Copy link
Copy Markdown
Contributor Author

the config is my least favourite part

a flag might be better, something like :hint --shift=b / :hint -b --shift=default

option 2 could be quite simple if we also only let it work for lowercase alpha hintchars

then we would only need to check if the key is uppercase and not worry about storing a "raw shift" in MinimalKeys or looking up key codes

the main thing would be deciding how to let the hint excmd know whether shift was held

@bovine3dom
Copy link
Copy Markdown
Member

hmm, i think

option 2 could be quite simple if we also only let it work for lowercase alpha hintchars

is probably going too far since lots of people use numeric hint characters

which made me test and realise that

set hintnames numeric
set hintfiltermode vimperator

is broken on this PR for typing out link names to filter down to them


i dunno how i feel about :hint --shift=b. it's tidier, but i don't see when someone would want it to be anything other than to open a background tab. do you have a usecase in mind?

@Chic-Tweetz
Copy link
Copy Markdown
Contributor Author

best to keep/refine the MinimalKey case flipping stuff in that case

set hintnames numeric
set hintfiltermode vimperator

is broken on this PR for typing out link names to filter down to them

is this consistently broken for you? It seems to work as expected for me (including holding shift to open in a new tab)


i dunno how i feel about :hint --shift=b. it's tidier, but i don't see when someone would want it to be anything other than to open a background tab. do you have a usecase in mind?

hmm, good point. with any modifier/modifier combo i could see people using f for multiple open modes but not so much if there's only shift/no-shift

@bovine3dom
Copy link
Copy Markdown
Member

is this consistently broken for you?

it's working for me now 🤷

i'll put it down to pebkac or some dodgy build cache for now. thanks for checking :)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0