mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
init expanded view, add cpu histogram
This commit is contained in:
18
grid.go
18
grid.go
@@ -115,8 +115,18 @@ func (g *Grid) OpenView(v View) {
|
||||
v(g)
|
||||
}
|
||||
|
||||
func (g *Grid) ExpandView() {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
container := g.containerMap.Get(g.cursorID)
|
||||
container.Expand()
|
||||
container.widgets.Render()
|
||||
container.Collapse()
|
||||
}
|
||||
|
||||
func Display(g *Grid) bool {
|
||||
var newView View
|
||||
var expand bool
|
||||
|
||||
// calculate layout
|
||||
ui.Body.Align()
|
||||
@@ -129,6 +139,10 @@ func Display(g *Grid) bool {
|
||||
ui.Handle("/sys/kbd/<down>", func(ui.Event) {
|
||||
g.cursorDown()
|
||||
})
|
||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||
expand = true
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Handle("/sys/kbd/h", func(ui.Event) {
|
||||
newView = HelpMenu
|
||||
ui.StopLoop()
|
||||
@@ -157,5 +171,9 @@ func Display(g *Grid) bool {
|
||||
g.OpenView(newView)
|
||||
return false
|
||||
}
|
||||
if expand {
|
||||
g.ExpandView()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user