summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-08-15 11:39:36 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-08-15 11:40:40 +0200
commitebdfd8046add89c1a5c978cee55d4355b5db417b (patch)
tree7c168425d7fe58880f53eaa5051b093e93578390 /vendor
parentd99e983236dc2126da583b118448bd17ee692ddb (diff)
Bump gocui
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/gocui/view.go44
-rw-r--r--vendor/modules.txt2
2 files changed, 27 insertions, 19 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go
index 939ceaa29..5c6fed903 100644
--- a/vendor/github.com/jesseduffield/gocui/view.go
+++ b/vendor/github.com/jesseduffield/gocui/view.go
@@ -273,25 +273,33 @@ func (v *View) FocusPoint(cx int, cy int) {
ly = 0
}
- // if line is above origin, move origin and set cursor to zero
- // if line is below origin + height, move origin and set cursor to max
- // otherwise set cursor to value - origin
- if ly > lineCount {
- v.cx = cx
- v.cy = cy
- v.oy = 0
- } else if cy < v.oy {
- v.cx = cx
- v.cy = 0
- v.oy = cy
- } else if cy > v.oy+ly {
- v.cx = cx
- v.cy = ly
- v.oy = cy - ly
- } else {
- v.cx = cx
- v.cy = cy - v.oy
+ v.oy = calculateNewOrigin(cy, v.oy, lineCount, ly)
+ v.cx = cx
+ v.cy = cy - v.oy
+}
+
+func calculateNewOrigin(selectedLine int, oldOrigin int, lineCount int, viewHeight int) int {
+ if viewHeight > lineCount {
+ return 0
+ } else if selectedLine < oldOrigin || selectedLine > oldOrigin+viewHeight {
+ // If the selected line is outside the visible area, scroll the view so
+ // that the selected line is in the middle.
+ newOrigin := selectedLine - viewHeight/2
+
+ // However, take care not to overflow if the total line count is less
+ // than the view height.
+ maxOrigin := lineCount - viewHeight - 1
+ if newOrigin > maxOrigin {
+ newOrigin = maxOrigin
+ }
+ if newOrigin < 0 {
+ newOrigin = 0
+ }
+
+ return newOrigin
}
+
+ return oldOrigin
}
func (s *searcher) search(str string) {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 9561f09eb..539b8a488 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -124,7 +124,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
-# github.com/jesseduffield/gocui v0.3.1-0.20230807090044-83a7161c8727
+# github.com/jesseduffield/gocui v0.3.1-0.20230815093813-9f3df4a6da3b
## explicit; go 1.12
github.com/jesseduffield/gocui
# github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10