diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-09-14 15:33:11 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-09-15 20:59:13 +0200 |
commit | 599b9f6d468ffb31665d0d97f4ae09ba651d306a (patch) | |
tree | 0a00425ade7fcd9ff218fcaec568dfea0ba1af6f | |
parent | 77f69501d6483bf94e85cd8b9cb520c3d9175a54 (diff) | |
download | aerc-599b9f6d468ffb31665d0d97f4ae09ba651d306a.tar.gz |
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>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | widgets/aerc.go | 3 | ||||
-rw-r--r-- | widgets/terminal.go | 20 |
3 files changed, 12 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2002c711..ca99feb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 can be disabled by setting `outgoing-cred-cmd-cache=false` in `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 diff --git a/widgets/aerc.go b/widgets/aerc.go index e210916f..7ba1ea4e 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -348,9 +348,6 @@ func (aerc *Aerc) Event(event tcell.Event) bool { return false } case *tcell.EventMouse: - if event.Buttons() == tcell.ButtonNone { - return false - } x, y := event.Position() aerc.grid.MouseEvent(x, y, event) return true diff --git a/widgets/terminal.go b/widgets/terminal.go index c8b97d3a..f0d9dc96 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -140,16 +140,18 @@ func (term *Terminal) draw() { } func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) { - if event, ok := event.(*tcell.EventMouse); ok { - if term.OnEvent != nil { - if term.OnEvent(event) { - return - } - } - if term.closed { - return - } + ev, ok := event.(*tcell.EventMouse) + if !ok { + 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) { |