aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/aerc.go6
-rw-r--r--app/compose.go9
-rw-r--r--app/dirlist.go12
-rw-r--r--app/dirtree.go11
-rw-r--r--app/msglist.go11
-rw-r--r--app/partswitcher.go11
-rw-r--r--app/terminal.go9
-rw-r--r--lib/ui/grid.go3
-rw-r--r--lib/ui/stack.go5
-rw-r--r--lib/ui/tab.go15
-rw-r--r--lib/ui/textinput.go7
11 files changed, 43 insertions, 56 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 2d7ca2e9..fd36b72b 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -15,7 +15,6 @@ import (
"git.sr.ht/~rockorager/vaxis"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/emersion/go-message/mail"
- "github.com/gdamore/tcell/v2"
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
@@ -395,9 +394,8 @@ func (aerc *Aerc) Event(event vaxis.Event) bool {
}
return false
}
- case *tcell.EventMouse:
- x, y := event.Position()
- aerc.grid.MouseEvent(x, y, event)
+ case vaxis.Mouse:
+ aerc.grid.MouseEvent(event.Col, event.Row, event)
return true
case vaxis.PasteStartEvent:
aerc.pasting = true
diff --git a/app/compose.go b/app/compose.go
index 7bc3fd66..be8e5563 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -17,7 +17,6 @@ import (
"time"
"github.com/emersion/go-message/mail"
- "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
"github.com/pkg/errors"
@@ -1149,8 +1148,8 @@ func (c *Composer) resetReview() {
}
func (c *Composer) termEvent(event vaxis.Event) bool {
- if event, ok := event.(*tcell.EventMouse); ok {
- if event.Buttons() == tcell.Button1 {
+ if event, ok := event.(vaxis.Mouse); ok {
+ if event.Button == vaxis.MouseLeftButton {
c.FocusTerminal()
return true
}
@@ -1568,8 +1567,8 @@ func (he *headerEditor) Draw(ctx *ui.Context) {
}
func (he *headerEditor) MouseEvent(localX int, localY int, event vaxis.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
- if event.Buttons() == tcell.Button1 {
+ if event, ok := event.(vaxis.Mouse); ok {
+ if event.Button == vaxis.MouseLeftButton {
he.focused = true
}
diff --git a/app/dirlist.go b/app/dirlist.go
index e9228374..71db2b6a 100644
--- a/app/dirlist.go
+++ b/app/dirlist.go
@@ -8,8 +8,6 @@ import (
"sort"
"time"
- "github.com/gdamore/tcell/v2"
-
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/parse"
@@ -376,16 +374,16 @@ func (dirlist *DirectoryList) drawScrollbar(ctx *ui.Context) {
}
func (dirlist *DirectoryList) MouseEvent(localX int, localY int, event vaxis.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
- switch event.Buttons() {
- case tcell.Button1:
+ if event, ok := event.(vaxis.Mouse); ok {
+ switch event.Button {
+ case vaxis.MouseLeftButton:
clickedDir, ok := dirlist.Clicked(localX, localY)
if ok {
dirlist.Select(clickedDir)
}
- case tcell.WheelDown:
+ case vaxis.MouseWheelDown:
dirlist.Next()
- case tcell.WheelUp:
+ case vaxis.MouseWheelUp:
dirlist.Prev()
}
}
diff --git a/app/dirtree.go b/app/dirtree.go
index 30ef2480..995c8889 100644
--- a/app/dirtree.go
+++ b/app/dirtree.go
@@ -15,7 +15,6 @@ import (
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
"git.sr.ht/~rockorager/vaxis"
- "github.com/gdamore/tcell/v2"
)
type DirectoryTree struct {
@@ -168,16 +167,16 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) {
}
func (dt *DirectoryTree) MouseEvent(localX int, localY int, event vaxis.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
- switch event.Buttons() {
- case tcell.Button1:
+ if event, ok := event.(vaxis.Mouse); ok {
+ switch event.Button {
+ case vaxis.MouseLeftButton:
clickedDir, ok := dt.Clicked(localX, localY)
if ok {
dt.Select(clickedDir)
}
- case tcell.WheelDown:
+ case vaxis.MouseWheelDown:
dt.NextPrev(1)
- case tcell.WheelUp:
+ case vaxis.MouseWheelUp:
dt.NextPrev(-1)
}
}
diff --git a/app/msglist.go b/app/msglist.go
index ac0012b4..e46f3f24 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -7,7 +7,6 @@ import (
sortthread "github.com/emersion/go-imap-sortthread"
"github.com/emersion/go-message/mail"
- "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
"git.sr.ht/~rjarry/aerc/config"
@@ -272,9 +271,9 @@ func (ml *MessageList) drawScrollbar(ctx *ui.Context) {
}
func (ml *MessageList) MouseEvent(localX int, localY int, event vaxis.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
- switch event.Buttons() {
- case tcell.Button1:
+ if event, ok := event.(vaxis.Mouse); ok {
+ switch event.Button {
+ case vaxis.MouseLeftButton:
selectedMsg, ok := ml.Clicked(localX, localY)
if ok {
ml.Select(selectedMsg)
@@ -298,12 +297,12 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event vaxis.Event) {
NewTab(viewer, msg.Envelope.Subject)
})
}
- case tcell.WheelDown:
+ case vaxis.MouseWheelDown:
if ml.store != nil {
ml.store.Next()
}
ml.Invalidate()
- case tcell.WheelUp:
+ case vaxis.MouseWheelUp:
if ml.store != nil {
ml.store.Prev()
}
diff --git a/app/partswitcher.go b/app/partswitcher.go
index 5dc996f7..5a935a8c 100644
--- a/app/partswitcher.go
+++ b/app/partswitcher.go
@@ -6,7 +6,6 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rockorager/vaxis"
- "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
)
@@ -168,7 +167,7 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event vaxis.Event) {
return
}
- e, ok := event.(*tcell.EventMouse)
+ e, ok := event.(vaxis.Mouse)
if !ok {
return
}
@@ -177,8 +176,8 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event vaxis.Event) {
ps.parts[ps.selected].term.Focus(false)
}
- switch e.Buttons() {
- case tcell.Button1:
+ switch e.Button {
+ case vaxis.MouseLeftButton:
i := localY - ps.offset + ps.Scroll()
if i < 0 || i >= len(ps.parts) {
break
@@ -188,10 +187,10 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event vaxis.Event) {
}
ps.selected = i
ps.Invalidate()
- case tcell.WheelDown:
+ case vaxis.MouseWheelDown:
ps.NextPart()
ps.Invalidate()
- case tcell.WheelUp:
+ case vaxis.MouseWheelUp:
ps.PreviousPart()
ps.Invalidate()
}
diff --git a/app/terminal.go b/app/terminal.go
index c4ec374e..4814ff29 100644
--- a/app/terminal.go
+++ b/app/terminal.go
@@ -9,8 +9,6 @@ import (
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rockorager/vaxis"
"git.sr.ht/~rockorager/vaxis/widgets/term"
-
- "github.com/gdamore/tcell/v2"
)
type HasTerminal interface {
@@ -108,7 +106,7 @@ func (term *Terminal) Terminal() *Terminal {
}
func (term *Terminal) MouseEvent(localX int, localY int, event vaxis.Event) {
- ev, ok := event.(*tcell.EventMouse)
+ ev, ok := event.(vaxis.Mouse)
if !ok {
return
}
@@ -118,8 +116,9 @@ func (term *Terminal) MouseEvent(localX int, localY int, event vaxis.Event) {
if term.isClosed() {
return
}
- e := tcell.NewEventMouse(localX, localY, ev.Buttons(), ev.Modifiers())
- term.vterm.Update(e)
+ ev.Row = localY
+ ev.Col = localX
+ term.vterm.Update(ev)
}
func (term *Terminal) Focus(focus bool) {
diff --git a/lib/ui/grid.go b/lib/ui/grid.go
index 00f759bf..ce3d37d6 100644
--- a/lib/ui/grid.go
+++ b/lib/ui/grid.go
@@ -5,7 +5,6 @@ import (
"sync"
"git.sr.ht/~rockorager/vaxis"
- "github.com/gdamore/tcell/v2"
)
type Grid struct {
@@ -130,7 +129,7 @@ func (grid *Grid) Draw(ctx *Context) {
}
func (grid *Grid) MouseEvent(localX int, localY int, event vaxis.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
+ if event, ok := event.(vaxis.Mouse); ok {
grid.mutex.RLock()
defer grid.mutex.RUnlock()
diff --git a/lib/ui/stack.go b/lib/ui/stack.go
index a4017007..890ab272 100644
--- a/lib/ui/stack.go
+++ b/lib/ui/stack.go
@@ -4,8 +4,7 @@ import (
"fmt"
"git.sr.ht/~rjarry/aerc/config"
-
- "github.com/gdamore/tcell/v2"
+ "git.sr.ht/~rockorager/vaxis"
)
type Stack struct {
@@ -34,7 +33,7 @@ func (stack *Stack) Draw(ctx *Context) {
}
}
-func (stack *Stack) MouseEvent(localX int, localY int, event tcell.Event) {
+func (stack *Stack) MouseEvent(localX int, localY int, event vaxis.Event) {
if len(stack.children) > 0 {
if element, ok := stack.Peek().(Mouseable); ok {
element.MouseEvent(localX, localY, event)
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index 704b01db..5d824955 100644
--- a/lib/ui/tab.go
+++ b/lib/ui/tab.go
@@ -3,7 +3,6 @@ package ui
import (
"sync"
- "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
"git.sr.ht/~rjarry/aerc/config"
@@ -407,7 +406,7 @@ func (strip *TabStrip) Invalidate() {
Invalidate()
}
-func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
+func (strip *TabStrip) MouseEvent(localX int, localY int, event vaxis.Event) {
strip.parent.m.Lock()
defer strip.parent.m.Unlock()
changeFocus := func(focus bool) {
@@ -418,9 +417,9 @@ func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
}
unfocus := func() { changeFocus(false) }
refocus := func() { changeFocus(true) }
- if event, ok := event.(*tcell.EventMouse); ok {
- switch event.Buttons() {
- case tcell.Button1:
+ if event, ok := event.(vaxis.Mouse); ok {
+ switch event.Button {
+ case vaxis.MouseLeftButton:
selectedTab, ok := strip.clicked(localX, localY)
if !ok || selectedTab == strip.parent.curIndex {
return
@@ -428,7 +427,7 @@ func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
unfocus()
strip.parent.selectPriv(selectedTab)
refocus()
- case tcell.WheelDown:
+ case vaxis.MouseWheelDown:
unfocus()
index := strip.parent.curIndex + 1
if index >= len(strip.parent.tabs) {
@@ -436,7 +435,7 @@ func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
}
strip.parent.selectPriv(index)
refocus()
- case tcell.WheelUp:
+ case vaxis.MouseWheelUp:
unfocus()
index := strip.parent.curIndex - 1
if index < 0 {
@@ -444,7 +443,7 @@ func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
}
strip.parent.selectPriv(index)
refocus()
- case tcell.Button3:
+ case vaxis.MouseMiddleButton:
selectedTab, ok := strip.clicked(localX, localY)
if !ok {
return
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index d52ee07a..a01184f2 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -6,7 +6,6 @@ import (
"sync"
"time"
- "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth"
"git.sr.ht/~rjarry/aerc/config"
@@ -144,9 +143,9 @@ func (ti *TextInput) drawPopover(ctx *Context) {
ctx.Popover(pos, 0, width, height, cmp)
}
-func (ti *TextInput) MouseEvent(localX int, localY int, event tcell.Event) {
- if event, ok := event.(*tcell.EventMouse); ok {
- if event.Buttons() == tcell.Button1 {
+func (ti *TextInput) MouseEvent(localX int, localY int, event vaxis.Event) {
+ if event, ok := event.(vaxis.Mouse); ok {
+ if event.Button == vaxis.MouseLeftButton {
if localX >= len(ti.prompt)+1 && localX <= len(ti.text[ti.scroll:])+len(ti.prompt)+1 {
ti.index = localX - len(ti.prompt) - 1
ti.ensureScroll()