mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
move ui.Init() into main, allow any key to exit help dialog
This commit is contained in:
parent
6e87539b9d
commit
e09bcd0272
4
grid.go
4
grid.go
@ -91,10 +91,6 @@ func OpenView(v View) {
|
|||||||
func Display(g *Grid) bool {
|
func Display(g *Grid) bool {
|
||||||
var newView View
|
var newView View
|
||||||
|
|
||||||
if err := ui.Init(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer ui.Close()
|
|
||||||
// calculate layout
|
// calculate layout
|
||||||
ui.Body.Align()
|
ui.Body.Align()
|
||||||
g.Cursor()
|
g.Cursor()
|
||||||
|
8
main.go
8
main.go
@ -1,15 +1,19 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if err := ui.Init(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer ui.Close()
|
||||||
g := NewGrid()
|
g := NewGrid()
|
||||||
for {
|
for {
|
||||||
exit := Display(g)
|
exit := Display(g)
|
||||||
if exit {
|
if exit {
|
||||||
os.Exit(0)
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func Help() {
|
|||||||
p.BorderLabel = "Help"
|
p.BorderLabel = "Help"
|
||||||
p.BorderFg = ui.ColorCyan
|
p.BorderFg = ui.ColorCyan
|
||||||
ui.Render(p)
|
ui.Render(p)
|
||||||
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
ui.Handle("/sys/kbd/", func(ui.Event) {
|
||||||
ui.StopLoop()
|
ui.StopLoop()
|
||||||
})
|
})
|
||||||
ui.Loop()
|
ui.Loop()
|
||||||
|
Loading…
Reference in New Issue
Block a user