microsoft / microsoft/terminal
conditional keybindings (alternate screen buffer)
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
# Description of the new feature/enhancement
there are situations where it would be useful to *conditionally* bind/unbind keys: e.g. the default find `{ "command": "find", "keys": "ctrl+shift+f" }` behavior to search all output text is usually undesirable in editors like emacs.
similarly, other common commands like copying and pane management* can be inappropriate in certain situations, where one would prefer those keys to be unbound from the terminal actions.
(*suspects this one may be up to personal preference/workflow)
the reverse situation also exists: a common hack is to have the terminal remap certain modifier sequences to sequences that can be interpreted safely. consider the mapping:
`{ "command": { "action": "sendInput", "input": "\u001b[27;5;73~" }, "keys": "ctrl+i" }`
where the processed sequence can be understood by emacs and friends for keybinding.
so a proposal is to be able to designate conditional activation for keybindings.
motivating failed workaround
a while back, tried having an settings-emacs.json and a settings-normal.json that on activate/suspend get copied to settings.json. this... technically works... but is bad for a number of reasons, obviously. there's a lot of redundancy, every change has to be made twice, settings editing can't be done from the gui (it'll be overwritten), the swap condition itself has many flaws and inevitably breaks with multiple windows/tabs/panes...
# Proposed technical implementation details (optional)
for this use case, an acceptable solution is to just have keybinding groups and/or properties that can respect alt buffer state.
but maybe a more generic solution is useful? to be able to listen for arbitrary control sequences. 'enable these commands after CSI 104;93m and disable after CSI 0m.'
...hopefully there are no situations where one needs hacks like that. regardless, it would be very powerful.
can't remember if per-profile bindings are already possible. ignoring the overkill option, it would be good to at least detect profile and altbuf state.
---
maybe duplicate of but proposes alternate/more general solution to:
#9045 ("support alt buffer correctly and pass keys through")
sort of related:
#9534
#7006
#5857
Contributor guide
Research direction
The issue names no files, tests, or implementation entry points. Start by reviewing related issues #9045, #9534, #7006, and #5857, then inspect the existing keybinding and alternate-screen-buffer behavior. Done requires a decided scope and an implemented, testable approach for conditional bindings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100