terminal: improve mouse support

Improve terminal mouse support by forwarding mouse events to the
terminal widget. Clicking and dragging are supported.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-09-14 15:33:11 -05:00 committed by Robin Jarry
parent 77f69501d6
commit 599b9f6d46
3 changed files with 12 additions and 12 deletions

View File

@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
be sent. The output will be stored until aerc is shut down. This behaviour be sent. The output will be stored until aerc is shut down. This behaviour
can be disabled by setting `outgoing-cred-cmd-cache=false` in can be disabled by setting `outgoing-cred-cmd-cache=false` in
`accounts.conf`. `accounts.conf`.
- Mouse support for embedded editors when `mouse-enabled=true`.
## [0.12.0](https://git.sr.ht/~rjarry/aerc/refs/0.12.0) - 2022-09-01 ## [0.12.0](https://git.sr.ht/~rjarry/aerc/refs/0.12.0) - 2022-09-01

View File

@ -348,9 +348,6 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
return false return false
} }
case *tcell.EventMouse: case *tcell.EventMouse:
if event.Buttons() == tcell.ButtonNone {
return false
}
x, y := event.Position() x, y := event.Position()
aerc.grid.MouseEvent(x, y, event) aerc.grid.MouseEvent(x, y, event)
return true return true

View File

@ -140,16 +140,18 @@ func (term *Terminal) draw() {
} }
func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) { func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) {
if event, ok := event.(*tcell.EventMouse); ok { ev, ok := event.(*tcell.EventMouse)
if term.OnEvent != nil { if !ok {
if term.OnEvent(event) { return
return
}
}
if term.closed {
return
}
} }
if term.OnEvent != nil {
term.OnEvent(ev)
}
if term.closed {
return
}
e := tcell.NewEventMouse(localX, localY, ev.Buttons(), ev.Modifiers())
term.vterm.HandleEvent(e)
} }
func (term *Terminal) Focus(focus bool) { func (term *Terminal) Focus(focus bool) {