当前位置: 首页>>代码示例>>Golang>>正文


Golang gocui.NewGui函数代码示例

本文整理汇总了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
}
开发者ID:ymomoi,项目名称:vuls,代码行数:27,代码来源:tui.go

示例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)
	}
}
开发者ID:jroimartin,项目名称:gocui,代码行数:27,代码来源:widgets.go

示例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)
	}
}
开发者ID:YouROK,项目名称:GoProjectManager,代码行数:29,代码来源:edit.go

示例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)
}
开发者ID:jmptrader,项目名称:gocui,代码行数:26,代码来源:bufs.go

示例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)
		}
	}
}
开发者ID:cswank,项目名称:quimby,代码行数:25,代码来源:main.go

示例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)
	}
}
开发者ID:hojgr,项目名称:cook,代码行数:31,代码来源:gui.go

示例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)
	}
}
开发者ID:kgilmer,项目名称:statsdtop,代码行数:33,代码来源:statsdtop.go

示例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)
	}
}
开发者ID:shibukraj,项目名称:synapseconsole,代码行数:30,代码来源:console-dev.go

示例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
}
开发者ID:Rompei,项目名称:vuls,代码行数:30,代码来源:tui.go

示例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)
	}
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:28,代码来源:go-watch.go

示例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()

}
开发者ID:pombredanne,项目名称:stroop,代码行数:28,代码来源:stroop.go

示例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
	}
}
开发者ID:ketchupsalt,项目名称:debugger,代码行数:55,代码来源:main.go

示例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()
}
开发者ID:cofyc,项目名称:expvarstats,代码行数:14,代码来源:main.go

示例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)
	}

}
开发者ID:benwtr,项目名称:d2top,代码行数:48,代码来源:d2top.go

示例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)
	}
}
开发者ID:gofmt,项目名称:gocui,代码行数:16,代码来源:overlap.go


注:本文中的github.com/jroimartin/gocui.NewGui函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。