diff options
author | kt programs <ktprograms@gmail.com> | 2022-03-14 11:03:34 +0800 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-03-14 22:55:19 +0100 |
commit | 74366d895d5c5cce5c14424926bb5de229894884 (patch) | |
tree | a7f79c483abec9240d31fa1d54c7adfa506de254 /config/config.go | |
parent | 4bc43d2741fa4904e51fc5da71d15b804c556c43 (diff) | |
download | aerc-74366d895d5c5cce5c14424926bb5de229894884.zip |
viewer: add key passthrough mode
When trying to search in less, keys bound to viewer functions can't be
used as part of the search query, which makes the search useless.
Add a view::passthrough binding mode and a :toggle-key-passthrough
command go toggle in and out of that mode. By default, typing '/' in the
viewer is bound to enabling key passthrough and automatically inserting
'/', to easily enter "less" search mode. When in the passthrough mode,
all bindings are ignored by default. The default binds.conf only defines
a single keybinding in that mode: <Esc> to get back out. $ex is bound to
<C-x> to allow typing colons.
Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config/config.go')
-rw-r--r-- | config/config.go | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/config/config.go b/config/config.go index 8a01f50..24ec1b0 100644 --- a/config/config.go +++ b/config/config.go @@ -105,14 +105,15 @@ type AccountConfig struct { } type BindingConfig struct { - Global *KeyBindings - AccountWizard *KeyBindings - Compose *KeyBindings - ComposeEditor *KeyBindings - ComposeReview *KeyBindings - MessageList *KeyBindings - MessageView *KeyBindings - Terminal *KeyBindings + Global *KeyBindings + AccountWizard *KeyBindings + Compose *KeyBindings + ComposeEditor *KeyBindings + ComposeReview *KeyBindings + MessageList *KeyBindings + MessageView *KeyBindings + MessageViewPassthrough *KeyBindings + Terminal *KeyBindings } type BindingConfigContext struct { @@ -143,6 +144,7 @@ type ViewerConfig struct { ShowHeaders bool `ini:"show-headers"` AlwaysShowMime bool `ini:"always-show-mime"` HeaderLayout [][]string `ini:"-"` + KeyPassthrough bool `ini:"-"` } type TriggersConfig struct { @@ -591,14 +593,15 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { file.NameMapper = mapName config := &AercConfig{ Bindings: BindingConfig{ - Global: NewKeyBindings(), - AccountWizard: NewKeyBindings(), - Compose: NewKeyBindings(), - ComposeEditor: NewKeyBindings(), - ComposeReview: NewKeyBindings(), - MessageList: NewKeyBindings(), - MessageView: NewKeyBindings(), - Terminal: NewKeyBindings(), + Global: NewKeyBindings(), + AccountWizard: NewKeyBindings(), + Compose: NewKeyBindings(), + ComposeEditor: NewKeyBindings(), + ComposeReview: NewKeyBindings(), + MessageList: NewKeyBindings(), + MessageView: NewKeyBindings(), + MessageViewPassthrough: NewKeyBindings(), + Terminal: NewKeyBindings(), }, ContextualBinds: []BindingConfigContext{}, @@ -703,13 +706,14 @@ func LoadConfigFromFile(root *string, logger *log.Logger) (*AercConfig, error) { } baseGroups := map[string]**KeyBindings{ - "default": &config.Bindings.Global, - "compose": &config.Bindings.Compose, - "messages": &config.Bindings.MessageList, - "terminal": &config.Bindings.Terminal, - "view": &config.Bindings.MessageView, - "compose::editor": &config.Bindings.ComposeEditor, - "compose::review": &config.Bindings.ComposeReview, + "default": &config.Bindings.Global, + "compose": &config.Bindings.Compose, + "messages": &config.Bindings.MessageList, + "terminal": &config.Bindings.Terminal, + "view": &config.Bindings.MessageView, + "view::passthrough": &config.Bindings.MessageViewPassthrough, + "compose::editor": &config.Bindings.ComposeEditor, + "compose::review": &config.Bindings.ComposeReview, } // Base Bindings |