本文整理汇总了Golang中github.com/jroimartin/gocui.NewGui函数的典型用法代码示例。如果您正苦于以下问题:Golang NewGui函数的具体用法?Golang NewGui怎么用?Golang NewGui使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewGui函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunTui
// RunTui execute main logic
func RunTui(history models.ScanHistory) subcommands.ExitStatus {
scanHistory = history
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Errorf("%s", err)
return subcommands.ExitFailure
}
defer g.Close()
g.SetManagerFunc(layout)
if err := keybindings(g); err != nil {
log.Errorf("%s", err)
return subcommands.ExitFailure
}
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
g.Cursor = true
if err := g.MainLoop(); err != nil {
g.Close()
log.Errorf("%s", err)
os.Exit(1)
}
return subcommands.ExitSuccess
}
示例2: main
func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
}
defer g.Close()
g.Highlight = true
g.SelFgColor = gocui.ColorRed
help := NewHelpWidget("help", 1, 1, helpText)
status := NewStatusbarWidget("status", 1, 7, 50)
butdown := NewButtonWidget("butdown", 52, 7, "DOWN", statusDown(status))
butup := NewButtonWidget("butup", 58, 7, "UP", statusUp(status))
g.SetManager(help, status, butdown, butup)
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, toggleButton); err != nil {
log.Panicln(err)
}
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
}
示例3: main
func main() {
var err error
proj, err = project.OpenProject("testprj/test.gop")
if err != nil {
log.Println(err)
return
}
codecomplete.Init(proj)
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := keybindings(g); err != nil {
log.Panicln(err)
}
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
g.ShowCursor = true
err = g.MainLoop()
if err != nil && err != gocui.Quit {
log.Panicln(err)
}
}
示例4: main
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
g.SetLayout(layout)
if err := g.SetKeybinding("main", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
g.SetLayout(layout)
if err := g.SetKeybinding("main", gocui.KeyCtrlI, gocui.ModNone, overwrite); err != nil {
log.Panicln(err)
}
g.Cursor = true
g.Mouse = true
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
g.Close()
fmt.Printf("VBUF:\n%s\n", vbuf)
fmt.Printf("BUF:\n%s\n", buf)
}
示例5: main
func main() {
login()
g = ui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
current = "cursor"
defer g.Close()
if err := keybindings(g); err != nil {
log.Fatal(err)
}
g.Editor = ui.EditorFunc(commands)
current = "nodes-cursor"
g.SetLayout(layout)
g.Cursor = true
if err := g.MainLoop(); err != nil {
if err != ui.ErrQuit {
log.Fatal(err)
}
}
}
示例6: Setup
func (gui *GUI) Setup(callback func(g *GUI)) {
var err error
g := gocui.NewGui()
g.ShowCursor = true
if err = g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
gui.Gocui = g
registerKeybindings(gui)
go func() {
waitForMainLoop := time.NewTimer(time.Millisecond * 10)
<-waitForMainLoop.C
callback(gui)
}()
err = gui.Gocui.MainLoop()
if err != nil && err != gocui.Quit {
log.Panicln(err)
}
}
示例7: main
func main() {
flag.Parse()
if *showVersion {
fmt.Printf("statsdaemon v%s (built w/%s)\n", VERSION, runtime.Version())
return
}
signalchan = make(chan os.Signal, 1)
signal.Notify(signalchan, syscall.SIGTERM)
*persistCountKeys = -1 * (*persistCountKeys)
go udpListener()
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := g.SetKeybinding("", gocui.KeyCtrlC, 0, quit); err != nil {
log.Panicln(err)
}
go updateViews(g)
go monitor()
err := g.MainLoop()
if err != nil && err != gocui.ErrorQuit {
log.Panicln(err)
}
}
示例8: main
func main() {
log.Println("This is a test")
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := keybindings(g); err != nil {
log.Panicln(err)
}
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
//g.SelBgColor = gocui.ColorGreen
//g.SelFgColor = gocui.ColorBlack
g.Cursor = true
g.FgColor = gocui.ColorGreen
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
}
示例9: RunTui
// RunTui execute main logic
func RunTui(historyID string) subcommands.ExitStatus {
var err error
scanHistory, err = selectScanHistory(historyID)
if err != nil {
log.Fatal(err)
return subcommands.ExitFailure
}
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := keybindings(g); err != nil {
log.Panicln(err)
}
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
g.Cursor = true
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
return subcommands.ExitFailure
}
return subcommands.ExitSuccess
}
示例10: main
func main() {
var err error
if _, err := os.Stat(projFile); os.IsNotExist(err) {
projects = Projects{}
} else {
projects = read(projFile)
}
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := keybindings(g); err != nil {
log.Panicln(err)
}
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
//g.ShowCursor = true
err = g.MainLoop()
if err != nil && err != gocui.Quit {
log.Panicln(err)
}
}
示例11: main
func main() {
flag.Parse()
capnslog.SetFormatter(capnslog.NewGlogFormatter(os.Stderr))
client := startClient()
client.MustDetectRemote()
c := NewController(client)
c.RefreshColumns()
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Fatal(err)
}
g.SetLayout(c.layout)
if err := initKeybindings(g, c); err != nil {
log.Fatal(err)
}
err := g.MainLoop()
if err != nil && err != gocui.Quit {
g.Close()
log.Fatal(err)
}
g.Close()
}
示例12: main
func main() {
var user, pass string
flag.StringVar(&user, "u", "", "Username on stockfighter.io (or env SFJB_USER")
flag.StringVar(&pass, "p", "", "Password on stockfighter.io (or env SFJB_PASS")
flag.Parse()
if user == "" {
user = os.Getenv("SFJB_USER")
}
if pass == "" {
pass = os.Getenv("SFJB_PASS")
}
if user == "" || pass == "" {
fmt.Fprintf(os.Stderr, "provide -u user -p password\n")
return
}
Session.URL = "https://www.stockfighter.io/trainer"
if err := Session.login(user, pass); err != nil {
fmt.Fprintf(os.Stderr, "login failed: %s\n", err)
return
}
g = gocui.NewGui()
if err := g.Init(); err != nil {
return
}
defer g.Close()
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
g.Cursor = true
boot()
setBindings()
// gocui takes over our keyboard, so listen for SIGHUP to panic
// the process if it hangs
c := make(chan os.Signal)
go func() {
_ = <-c
panic("signal")
}()
signal.Notify(c, syscall.SIGHUP)
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
return
}
}
示例13: main
func main() {
flag.Parse()
g = gocui.NewGui()
if err := g.Init(); err != nil {
log.Exitf("gocui init error: %v", err)
}
defer g.Close()
g.SelBgColor = gocui.ColorGreen
g.SelFgColor = gocui.ColorBlack
g.ShowCursor = true
g.SetLayout(layout)
g.MainLoop()
}
示例14: main
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage : %s </path/to/apache/access_log> \n ", os.Args[0])
os.Exit(1)
}
g := gocui.NewGui()
g.ShowCursor = true
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
rawlog_output = make(chan RawLogEvent)
alerts_output = make(chan string)
averages_output = make(chan string)
logdump_output = make(chan string)
main_output = make(chan string)
sparks_output = make(chan string)
status_output = make(chan string)
alert_state_chan = make(chan bool)
ts = make([]*Bucket, 0)
go updateTimeView(g)
go updateMainView(g)
go updateLogDumpView(g)
go updateAlertsView(g)
go updateStatusView(g)
go updateSparksView(g)
go updateAveragesView(g)
go readLog()
go bucketize()
err := g.MainLoop()
if err != nil && err != gocui.Quit {
log.Panicln(err)
}
}
示例15: main
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetLayout(layout)
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
}