mirror of https://github.com/rivo/tview.git
Mouse scrolling to the end turns tracking on. Resolves #945
This commit is contained in:
parent
e350bef1f9
commit
e4a85fc779
11
textview.go
11
textview.go
|
@ -1371,6 +1371,7 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rectX, rectY, width, height := t.GetInnerRect()
|
||||||
switch action {
|
switch action {
|
||||||
case MouseLeftDown:
|
case MouseLeftDown:
|
||||||
setFocus(t)
|
setFocus(t)
|
||||||
|
@ -1378,7 +1379,6 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
||||||
case MouseLeftClick:
|
case MouseLeftClick:
|
||||||
if t.regionTags {
|
if t.regionTags {
|
||||||
// Find a region to highlight.
|
// Find a region to highlight.
|
||||||
rectX, rectY, _, _ := t.GetInnerRect()
|
|
||||||
x -= rectX
|
x -= rectX
|
||||||
y -= rectY
|
y -= rectY
|
||||||
var highlightedID string
|
var highlightedID string
|
||||||
|
@ -1404,6 +1404,15 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
||||||
consumed = true
|
consumed = true
|
||||||
case MouseScrollDown:
|
case MouseScrollDown:
|
||||||
t.lineOffset++
|
t.lineOffset++
|
||||||
|
if len(t.lineIndex)-t.lineOffset < height {
|
||||||
|
// If we scroll to the end, turn on tracking.
|
||||||
|
t.parseAhead(width, func(lineNumber int, line *textViewLine) bool {
|
||||||
|
return len(t.lineIndex)-t.lineOffset < height
|
||||||
|
})
|
||||||
|
if len(t.lineIndex)-t.lineOffset < height {
|
||||||
|
t.trackEnd = true
|
||||||
|
}
|
||||||
|
}
|
||||||
consumed = true
|
consumed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue