mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
disable timed display refresh while scrolling
This commit is contained in:
13
cursor.go
13
cursor.go
@@ -14,9 +14,10 @@ var enabledConnectors = map[string]func() connector.Connector{
|
||||
}
|
||||
|
||||
type GridCursor struct {
|
||||
selectedID string // id of currently selected container
|
||||
filtered container.Containers
|
||||
cSource connector.Connector
|
||||
selectedID string // id of currently selected container
|
||||
filtered container.Containers
|
||||
cSource connector.Connector
|
||||
isScrolling bool // toggled when actively scrolling
|
||||
}
|
||||
|
||||
func NewGridCursor(connector string) *GridCursor {
|
||||
@@ -109,6 +110,9 @@ func (gc *GridCursor) ScrollPage() {
|
||||
}
|
||||
|
||||
func (gc *GridCursor) Up() {
|
||||
gc.isScrolling = true
|
||||
defer func() { gc.isScrolling = false }()
|
||||
|
||||
idx := gc.Idx()
|
||||
if idx <= 0 { // already at top
|
||||
return
|
||||
@@ -125,6 +129,9 @@ func (gc *GridCursor) Up() {
|
||||
}
|
||||
|
||||
func (gc *GridCursor) Down() {
|
||||
gc.isScrolling = true
|
||||
defer func() { gc.isScrolling = false }()
|
||||
|
||||
idx := gc.Idx()
|
||||
if idx >= gc.Len()-1 { // already at bottom
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user