commit 4c7c6de
delthas
·
2024-07-18 16:23:59 +0000 UTC
parent 4aa4ccb
Update the mouse cursor even when no button is pressed Thanks to inwit for the suggestion.
M
app.go
+7,
-2
1@@ -489,6 +489,7 @@ func (app *App) uiLoop() {
2 }
3
4 func (app *App) handleUIEvent(ev interface{}) bool {
5+ // TODO: when a no-modifier no-button mouse motion event is sent, just set the mouse cursor and avoid redrawing
6 // TODO: eat QuitEvent here?
7 switch ev := ev.(type) {
8 case vaxis.Resize:
9@@ -600,14 +601,12 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
10 if ev.Button == vaxis.MouseLeftButton {
11 if x == app.win.ChannelWidth()-1 {
12 app.win.ClickChannelCol(true)
13- app.win.SetMouseShape(vaxis.MouseShapeResizeHorizontal)
14 } else if x < app.win.ChannelWidth() {
15 app.win.ClickBuffer(app.win.VerticalBufferOffset(y))
16 } else if app.win.ChannelWidth() == 0 && y == h-1 {
17 app.win.ClickBuffer(app.win.HorizontalBufferOffset(x))
18 } else if x == w-app.win.MemberWidth() {
19 app.win.ClickMemberCol(true)
20- app.win.SetMouseShape(vaxis.MouseShapeResizeHorizontal)
21 } else if x > w-app.win.MemberWidth() && y >= 2 {
22 app.win.ClickMember(y - 2 + app.win.MemberOffset())
23 } else {
24@@ -709,6 +708,12 @@ func (app *App) handleMouseEvent(ev vaxis.Mouse) {
25 app.win.ClickMember(-1)
26 app.win.ClickChannelCol(false)
27 app.win.ClickMemberCol(false)
28+ }
29+ if x == app.win.ChannelWidth()-1 || x == w-app.win.MemberWidth() {
30+ app.win.SetMouseShape(vaxis.MouseShapeResizeHorizontal)
31+ } else if app.win.HasEvent(x, y) {
32+ app.win.SetMouseShape(vaxis.MouseShapeClickable)
33+ } else {
34 app.win.SetMouseShape(vaxis.MouseShapeDefault)
35 }
36 }
M
ui/ui.go
+9,
-0
1@@ -253,6 +253,15 @@ func (ui *UI) Click(x, y int, event vaxis.Mouse) {
2 }
3 }
4
5+func (ui *UI) HasEvent(x, y int) bool {
6+ for _, ev := range ui.clickEvents {
7+ if x >= ev.xb && x < ev.xe && y == ev.y {
8+ return true
9+ }
10+ }
11+ return false
12+}
13+
14 func (ui *UI) ScrollUp() {
15 ui.bs.ScrollUp(ui.bs.tlHeight / 2)
16 }