1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-07-15 15:43:50 +02:00
aerc/commands/msgview/toggle-key-passthrough.go
Robin Jarry 03777bec28 viewer: disable passthrough mode on pager exit
To avoid accidentally closing the pager while the passthrough mode is
enabled (and therefore all key presses go to /dev/null), make sure to
exit the passthrough mode when the pager exits.

Also, to make the user experience more pleasant, exit the passthrough
mode upon pressing the <enter> key in the pager virtual terminal. This
should match the workflow where the users press "/" to start searching
in the pager, and press enter to validate their search.

Move the toggling of passthrough mode in a global function. Since that
setting is global to all accounts, make sure to update all the status
lines. Reuse that function for the :toggle-key-passthrough command and
when exiting the message viewer or pressing enter.

Reported-by: Jonathan Dowland <jon@dow.land>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2025-03-06 09:59:32 +01:00

30 lines
660 B
Go

package msgview
import (
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/config"
)
type ToggleKeyPassthrough struct{}
func init() {
commands.Register(ToggleKeyPassthrough{})
}
func (ToggleKeyPassthrough) Description() string {
return "Enter or exit the passthrough key bindings context."
}
func (ToggleKeyPassthrough) Context() commands.CommandContext {
return commands.MESSAGE_VIEWER
}
func (ToggleKeyPassthrough) Aliases() []string {
return []string{"toggle-key-passthrough"}
}
func (ToggleKeyPassthrough) Execute(args []string) error {
app.SetKeyPassthrough(!config.Viewer.KeyPassthrough)
return nil
}