mirror of
https://github.com/theniceboy/.config.git
synced 2026-05-09 08:08:31 +08:00
agent tracker + tmux update
This commit is contained in:
parent
cd9c92b1c2
commit
5064629d61
68 changed files with 15041 additions and 3483 deletions
17
agent-tracker/cmd/agent/scroll.go
Normal file
17
agent-tracker/cmd/agent/scroll.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
func stableListOffset(currentOffset, selectedIndex, visibleRows, totalRows int) int {
|
||||
if totalRows <= 0 || visibleRows <= 0 {
|
||||
return 0
|
||||
}
|
||||
maxOffset := maxInt(0, totalRows-visibleRows)
|
||||
offset := clampInt(currentOffset, 0, maxOffset)
|
||||
selected := clampInt(selectedIndex, 0, totalRows-1)
|
||||
if selected < offset {
|
||||
offset = selected
|
||||
}
|
||||
if selected >= offset+visibleRows {
|
||||
offset = selected - visibleRows + 1
|
||||
}
|
||||
return clampInt(offset, 0, maxOffset)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue