mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add pgCount() method to GridCursor
This commit is contained in:
parent
79a3f361a7
commit
c47ba3f804
15
cursor.go
15
cursor.go
@ -142,8 +142,7 @@ func (gc *GridCursor) PgUp() {
|
||||
return
|
||||
}
|
||||
|
||||
var nextidx int
|
||||
nextidx = int(math.Max(0.0, float64(idx-cGrid.MaxRows())))
|
||||
nextidx := int(math.Max(0.0, float64(idx-cGrid.MaxRows())))
|
||||
cGrid.Offset = int(math.Max(float64(cGrid.Offset-cGrid.MaxRows()),
|
||||
float64(0)))
|
||||
|
||||
@ -164,8 +163,7 @@ func (gc *GridCursor) PgDown() {
|
||||
return
|
||||
}
|
||||
|
||||
var nextidx int
|
||||
nextidx = int(math.Min(float64(gc.Len()-1),
|
||||
nextidx := int(math.Min(float64(gc.Len()-1),
|
||||
float64(idx+cGrid.MaxRows())))
|
||||
cGrid.Offset = int(math.Min(float64(cGrid.Offset+cGrid.MaxRows()),
|
||||
float64(gc.Len()-cGrid.MaxRows())))
|
||||
@ -180,3 +178,12 @@ func (gc *GridCursor) PgDown() {
|
||||
cGrid.Align()
|
||||
ui.Render(cGrid)
|
||||
}
|
||||
|
||||
// number of pages at current row count and term height
|
||||
func (gc *GridCursor) pgCount() int {
|
||||
pages := gc.Len() / cGrid.MaxRows()
|
||||
if gc.Len()%cGrid.MaxRows() > 0 {
|
||||
pages++
|
||||
}
|
||||
return pages
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user