summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-01-01 18:50:01 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-01-01 19:01:56 +0900
commit7c660aa86ec285f8bd147960ee29da591313f473 (patch)
tree04661dde865b4275b70f9d6639ba99a7838d58ac
parent435d8fa0a285ec565c5f7161f3c808ebdd277232 (diff)
Allow dragging of scrollbar
-rw-r--r--src/terminal.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 9f67032a..ec87593f 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -2582,6 +2582,7 @@ func (t *Terminal) Loop() {
t.eventChan <- t.tui.GetChar()
}
}()
+ dragging := false
for looping {
var newCommand *string
var reloadSync bool
@@ -3038,8 +3039,6 @@ func (t *Terminal) Loop() {
}
} else if t.window.Enclose(my, mx) {
mx -= t.window.Left()
- bar := mx == t.window.Width()-1
- mx = util.Constrain(mx-t.promptLen, 0, len(t.input))
my -= t.window.Top()
min := 2 + len(t.header)
if t.noInfoLine() {
@@ -3056,7 +3055,15 @@ func (t *Terminal) Loop() {
my = h - my - 1
}
}
- if bar && my >= min {
+ dragging = me.Down && (dragging || my >= min && mx == t.window.Width()-1)
+ if me.Double {
+ // Double-click
+ if my >= min {
+ if t.vset(t.offset+my-min) && t.cy < t.merger.Length() {
+ return doActions(actionsFor(tui.DoubleClick))
+ }
+ }
+ } else if dragging && my >= min {
barLength, barStart := t.getScrollbar()
if barLength > 0 {
maxItems := t.maxItems()
@@ -3069,14 +3076,8 @@ func (t *Terminal) Loop() {
req(reqList)
}
}
- } else if me.Double {
- // Double-click
- if my >= min {
- if t.vset(t.offset+my-min) && t.cy < t.merger.Length() {
- return doActions(actionsFor(tui.DoubleClick))
- }
- }
} else if me.Down {
+ mx = util.Constrain(mx-t.promptLen, 0, len(t.input))
if my == t.promptLine() && mx >= 0 {
// Prompt
t.cx = mx + t.xoffset