func NewInfoPanel(app *App) *InfoPanel { ipanel := &InfoPanel{ text: topsl.NewTextArea(), info: nil, titlebar: topsl.NewTitleBar(), keybar: topsl.NewKeyBar(), statusbar: topsl.NewStatusBar(), panel: topsl.NewPanel(), app: app, } ipanel.panel.SetBottom(ipanel.keybar) ipanel.panel.SetTitle(ipanel.titlebar) ipanel.panel.SetStatus(ipanel.statusbar) ipanel.panel.SetContent(ipanel.text) ipanel.titlebar.SetRight(app.GetAppName()) // We don't change the keybar, so set it once ipanel.keybar.SetKeys([]string{"[Q] Quit", "[H] Help"}) // Cursor disabled ipanel.text.EnableCursor(false) return ipanel }
func NewMainPanel(app *App, server string) *MainPanel { m := &MainPanel{ content: topsl.NewCellView(), info: nil, titlebar: topsl.NewTitleBar(), keybar: topsl.NewKeyBar(), statusbar: topsl.NewStatusBar(), panel: topsl.NewPanel(), app: app, } m.panel.SetBottom(m.keybar) m.panel.SetTitle(m.titlebar) m.panel.SetStatus(m.statusbar) m.panel.SetContent(m.content) m.content.SetModel(&mainModel{m}) m.titlebar.SetRight(app.GetAppName()) m.titlebar.SetCenter(server) // We don't change the keybar, so set it once m.keybar.SetKeys([]string{"_Quit"}) return m }
func main() { app := &MyApp{} app.model = &model{endx: 60, endy: 15} if e := topsl.AppInit(); e != nil { fmt.Fprintln(os.Stderr, e.Error()) os.Exit(1) } title := topsl.NewTitleBar() title.SetCenter("CellView Test") title.SetRight("Example v1.0") app.keybar = topsl.NewKeyBar() app.keybar.SetKeys([]string{"[Q] Quit"}) app.status = topsl.NewStatusBar() app.status.SetStatus("My status is here.") app.main = topsl.NewCellView() app.main.SetModel(app.model) app.panel = topsl.NewPanel() app.panel.SetBottom(app.keybar) app.panel.SetTitle(title) app.panel.SetContent(app.main) app.panel.SetStatus(app.status) app.updateKeys() topsl.SetApplication(app) topsl.RunApplication() }
func NewLogPanel(app *App) *LogPanel { p := &LogPanel{ text: topsl.NewTextArea(), info: nil, titlebar: topsl.NewTitleBar(), keybar: topsl.NewKeyBar(), statusbar: topsl.NewStatusBar(), panel: topsl.NewPanel(), app: app, } p.panel.SetBottom(p.keybar) p.panel.SetTitle(p.titlebar) p.panel.SetStatus(p.statusbar) p.panel.SetContent(p.text) p.titlebar.SetRight(app.GetAppName()) // We don't change the keybar, so set it once p.keybar.SetKeys([]string{"[Q] Quit", "[H] Help"}) // Cursor disabled p.text.EnableCursor(false) return p }
func NewHelpPanel(app *App) *HelpPanel { h := &HelpPanel{ titlebar: topsl.NewTitleBar(), statusbar: topsl.NewStatusBar(), keybar: topsl.NewKeyBar(), text: topsl.NewTextArea(), panel: topsl.NewPanel(), app: app, } h.titlebar.SetRight(app.GetAppName()) h.titlebar.SetCenter("Help") h.text.SetLines([]string{ "Supported keys (not all keys available in all contexts)", "", " <ESC> : return to main screen", " <CTRL-C> : quit", " <CTRL-L> : refresh the screeen", " <H> : show this help", " <UP>, <DOWN> : navigation", " <E> : enable selected service", " <D> : disable selected service", " <I> : view detailed information for service", " <R> : restart selected service", " <C> : clear faults on selected service", " <L> : view log for selected service", "", "This program is distributed under the Apache 2.0 License", "Copyright 2015 The Govisor Authors", }) h.keybar.SetKeys([]string{"[ESC] Main"}) h.panel.SetTitle(h.titlebar) h.panel.SetStatus(h.statusbar) h.panel.SetBottom(h.keybar) h.panel.SetContent(h.text) return h }
func main() { app := &MyApp{} if e := topsl.AppInit(); e != nil { fmt.Fprintln(os.Stderr, e.Error()) os.Exit(1) } title := topsl.NewTitleBar() title.SetCenter("TextArea Test") title.SetRight("Example v1.0") keyb := topsl.NewKeyBar() keyb.SetKeys([]string{"[Q] Quit"}) panel := topsl.NewPanel() panel.SetBottom(keyb) panel.SetTitle(title) content := topsl.NewTextArea() content.SetContent("This is a test\nAnd another line\nAnd more and more\n" + "A very very very long line. The quick brown fox jumps over the " + "lazy dog. The mouse ran up the clock. Blah blah blah.") content.EnableCursor(true) panel.SetContent(content) status := topsl.NewStatusBar() panel.SetStatus(status) status.SetStatus("Number 5 is Alive!") app.panel = panel topsl.SetApplication(app) topsl.RunApplication() }