term: add bracketed paste support

Allow forwarding paste events to embedded applications. When a bracketed
paste is in progress, do not process any command bindings.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
Tim Culverhouse 2022-09-14 21:36:42 +02:00 committed by Robin Jarry
parent 518f3e962c
commit cf319129de
3 changed files with 24 additions and 0 deletions

View file

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Hide local timezone with `send-as-utc = true` in `accounts.conf`.
- Persistent command history in `~/.cache/aerc/history`.
- Cursor shape support in embedded terminals.
- Bracketed paste support.
### Changed

View file

@ -28,6 +28,7 @@ func Initialize(content DrawableInteractive) (*UI, error) {
screen.Clear()
screen.HideCursor()
screen.EnablePaste()
width, height := screen.Size()

View file

@ -33,6 +33,7 @@ type Aerc struct {
simulating int
statusbar *ui.Stack
statusline *StatusLine
pasting bool
pendingKeys []config.KeyStroke
prompts *ui.Stack
tabs *ui.Tabs
@ -290,6 +291,15 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
switch event := event.(type) {
case *tcell.EventKey:
// If we are in a bracketed paste, don't process the keys for
// bindings
if aerc.pasting {
interactive, ok := aerc.SelectedTabContent().(ui.Interactive)
if ok {
return interactive.Event(event)
}
return false
}
aerc.statusline.Expire()
aerc.pendingKeys = append(aerc.pendingKeys, config.KeyStroke{
Modifiers: event.Modifiers(),
@ -344,6 +354,18 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
x, y := event.Position()
aerc.grid.MouseEvent(x, y, event)
return true
case *tcell.EventPaste:
if event.Start() {
aerc.pasting = true
}
if event.End() {
aerc.pasting = false
}
interactive, ok := aerc.SelectedTabContent().(ui.Interactive)
if ok {
return interactive.Event(event)
}
return false
}
return false
}