mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
dettach menus from grid
This commit is contained in:
parent
e73732ae98
commit
409d44e8a3
16
grid.go
16
grid.go
@ -102,17 +102,15 @@ func headerPar(s string) *ui.Par {
|
||||
return p
|
||||
}
|
||||
|
||||
type View func(*Grid)
|
||||
|
||||
func ResetView() {
|
||||
ui.DefaultEvtStream.ResetHandlers()
|
||||
ui.Clear()
|
||||
}
|
||||
|
||||
func (g *Grid) OpenView(v View) {
|
||||
func OpenMenu(m func()) {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
v(g)
|
||||
m()
|
||||
}
|
||||
|
||||
func (g *Grid) ExpandView() {
|
||||
@ -125,7 +123,7 @@ func (g *Grid) ExpandView() {
|
||||
}
|
||||
|
||||
func Display(g *Grid) bool {
|
||||
var newView View
|
||||
var menu func()
|
||||
var expand bool
|
||||
|
||||
// calculate layout
|
||||
@ -144,11 +142,11 @@ func Display(g *Grid) bool {
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Handle("/sys/kbd/h", func(ui.Event) {
|
||||
newView = HelpMenu
|
||||
menu = HelpMenu
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Handle("/sys/kbd/s", func(ui.Event) {
|
||||
newView = SortMenu
|
||||
menu = SortMenu
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
||||
@ -167,8 +165,8 @@ func Display(g *Grid) bool {
|
||||
})
|
||||
|
||||
ui.Loop()
|
||||
if newView != nil {
|
||||
g.OpenView(newView)
|
||||
if menu != nil {
|
||||
OpenMenu(menu)
|
||||
return false
|
||||
}
|
||||
if expand {
|
||||
|
4
menus.go
4
menus.go
@ -11,7 +11,7 @@ var helpDialog = []string{
|
||||
"[q] - exit ctop",
|
||||
}
|
||||
|
||||
func HelpMenu(g *Grid) {
|
||||
func HelpMenu() {
|
||||
m := widgets.NewMenu(helpDialog)
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
m.BorderLabel = "Help"
|
||||
@ -23,7 +23,7 @@ func HelpMenu(g *Grid) {
|
||||
ui.Loop()
|
||||
}
|
||||
|
||||
func SortMenu(g *Grid) {
|
||||
func SortMenu() {
|
||||
m := widgets.NewMenu(SortFields)
|
||||
m.Selectable = true
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
|
Loading…
Reference in New Issue
Block a user