當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。