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>
This commit is contained in:
parent
4bc43d2741
commit
74366d895d
6 changed files with 91 additions and 24 deletions
commands/msgview
35
commands/msgview/toggle-key-passthrough.go
Normal file
35
commands/msgview/toggle-key-passthrough.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package msgview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.sr.ht/~rjarry/aerc/widgets"
|
||||
)
|
||||
|
||||
type ToggleKeyPassthrough struct{}
|
||||
|
||||
func init() {
|
||||
register(ToggleKeyPassthrough{})
|
||||
}
|
||||
|
||||
func (ToggleKeyPassthrough) Aliases() []string {
|
||||
return []string{"toggle-key-passthrough"}
|
||||
}
|
||||
|
||||
func (ToggleKeyPassthrough) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ToggleKeyPassthrough) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("Usage: toggle-key-passthrough")
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
keyPassthroughEnabled := mv.ToggleKeyPassthrough()
|
||||
if keyPassthroughEnabled {
|
||||
aerc.SetExtraStatus("[passthrough]")
|
||||
} else {
|
||||
aerc.ClearExtraStatus()
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue