Repository navigation
Add configurable modifier key behaviour for hint actions - #5551
Chic-Tweetz wants to merge 1 commit into
Conversation
|
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... |
|
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) |
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 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 |
|
i have been sitting on this for a while and i think either
or
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? |
|
the config is my least favourite part a flag might be better, something like 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 |
|
hmm, i think
is probably going too far since lots of people use numeric hint characters which made me test and realise that is broken on this PR for typing out link names to filter down to them i dunno how i feel about |
|
best to keep/refine the MinimalKey case flipping stuff in that case
is this consistently broken for you? It seems to work as expected for me (including holding shift to open in a new tab)
hmm, good point. with any modifier/modifier combo i could see people using |
it's working for me now 🤷 i'll put it down to pebkac or some dodgy build cache for now. thanks for checking :) |
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
codefield andflippedShiftKeymethod toMinimalKeybecause some chars can't just have their case flipped (e.g. numbers),
flippedShiftKeylooks 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 lookuphinting.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,
hintmodifiersto map hint actions (using their:hintflags, specifically those from the OpenMode enum in hint_util.ts) and modifiers to other actions"default" is used for bare
:hintand "all" can be used to quickly set something for all actionsthe syntax ends up a bit fiddly
these would make holding shift in
:hintopen a new tab and holding shift in:hint -topen in the current tab for exampleexcmds.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