mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
gofmt main package
This commit is contained in:
parent
28f16c9a17
commit
47d60fe51b
27
cursor.go
27
cursor.go
@ -1,7 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -133,41 +134,41 @@ func (gc *GridCursor) Down() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gc *GridCursor) PgUp() {
|
func (gc *GridCursor) PgUp() {
|
||||||
idx := gc.Idx()
|
idx := gc.Idx()
|
||||||
if idx <= 0 { // already at top
|
if idx <= 0 { // already at top
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextidx int
|
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()),
|
cGrid.Offset = int(math.Max(float64(cGrid.Offset-cGrid.MaxRows()),
|
||||||
float64(0)))
|
float64(0)))
|
||||||
|
|
||||||
active := gc.filtered[idx]
|
active := gc.filtered[idx]
|
||||||
next := gc.filtered[nextidx]
|
next := gc.filtered[nextidx]
|
||||||
|
|
||||||
active.Widgets.Name.UnHighlight()
|
active.Widgets.Name.UnHighlight()
|
||||||
gc.selectedID = next.Id
|
gc.selectedID = next.Id
|
||||||
next.Widgets.Name.Highlight()
|
next.Widgets.Name.Highlight()
|
||||||
|
|
||||||
cGrid.Align()
|
cGrid.Align()
|
||||||
ui.Render(cGrid)
|
ui.Render(cGrid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gc *GridCursor) PgDown() {
|
func (gc *GridCursor) PgDown() {
|
||||||
idx := gc.Idx()
|
idx := gc.Idx()
|
||||||
if idx >= gc.Len()-1 { // already at bottom
|
if idx >= gc.Len()-1 { // already at bottom
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextidx int
|
var nextidx int
|
||||||
nextidx = int(math.Min(float64(gc.Len() - 1),
|
nextidx = int(math.Min(float64(gc.Len()-1),
|
||||||
float64(idx + cGrid.MaxRows())))
|
float64(idx+cGrid.MaxRows())))
|
||||||
cGrid.Offset = int(math.Min(float64(cGrid.Offset + cGrid.MaxRows()),
|
cGrid.Offset = int(math.Min(float64(cGrid.Offset+cGrid.MaxRows()),
|
||||||
float64(gc.Len() - cGrid.MaxRows())))
|
float64(gc.Len()-cGrid.MaxRows())))
|
||||||
|
|
||||||
active := gc.filtered[idx]
|
active := gc.filtered[idx]
|
||||||
next := gc.filtered[nextidx]
|
next := gc.filtered[nextidx]
|
||||||
|
|
||||||
active.Widgets.Name.UnHighlight()
|
active.Widgets.Name.UnHighlight()
|
||||||
gc.selectedID = next.Id
|
gc.selectedID = next.Id
|
||||||
@ -175,4 +176,4 @@ func (gc *GridCursor) PgDown() {
|
|||||||
|
|
||||||
cGrid.Align()
|
cGrid.Align()
|
||||||
ui.Render(cGrid)
|
ui.Render(cGrid)
|
||||||
}
|
}
|
||||||
|
3
keys.go
3
keys.go
@ -4,7 +4,6 @@ import (
|
|||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Common action keybindings
|
|
||||||
// Common action keybindings
|
// Common action keybindings
|
||||||
var keyMap = map[string][]string{
|
var keyMap = map[string][]string{
|
||||||
"up": []string{
|
"up": []string{
|
||||||
@ -22,7 +21,7 @@ var keyMap = map[string][]string{
|
|||||||
"pgdown": []string{
|
"pgdown": []string{
|
||||||
"/sys/kbd/<next>",
|
"/sys/kbd/<next>",
|
||||||
"/sys/kbd/C-<down>",
|
"/sys/kbd/C-<down>",
|
||||||
},
|
},
|
||||||
"exit": []string{
|
"exit": []string{
|
||||||
"/sys/kbd/q",
|
"/sys/kbd/q",
|
||||||
"/sys/kbd/C-c",
|
"/sys/kbd/C-c",
|
||||||
|
Loading…
Reference in New Issue
Block a user