aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorkt programs <ktprograms@gmail.com>2022-03-14 11:03:34 +0800
committerRobin Jarry <robin@jarry.cc>2022-03-14 22:55:19 +0100
commit74366d895d5c5cce5c14424926bb5de229894884 (patch)
treea7f79c483abec9240d31fa1d54c7adfa506de254 /widgets/msgviewer.go
parent4bc43d2741fa4904e51fc5da71d15b804c556c43 (diff)
downloadaerc-74366d895d5c5cce5c14424926bb5de229894884.tar.gz
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 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index da81ec95..9771a905 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -286,6 +286,11 @@ func (mv *MessageViewer) ToggleHeaders() {
switcher.Invalidate()
}
+func (mv *MessageViewer) ToggleKeyPassthrough() bool {
+ mv.conf.Viewer.KeyPassthrough = !mv.conf.Viewer.KeyPassthrough
+ return mv.conf.Viewer.KeyPassthrough
+}
+
func (mv *MessageViewer) SelectedMessagePart() *PartInfo {
switcher := mv.switcher
part := switcher.parts[switcher.selected]
@@ -325,6 +330,14 @@ func (mv *MessageViewer) NextPart() {
mv.Invalidate()
}
+func (mv *MessageViewer) Bindings() string {
+ if mv.conf.Viewer.KeyPassthrough {
+ return "view::passthrough"
+ } else {
+ return "view"
+ }
+}
+
func (mv *MessageViewer) Close() error {
mv.switcher.Cleanup()
return nil