本文整理匯總了Golang中github.com/apcera/gocui.Gui類的典型用法代碼示例。如果您正苦於以下問題:Golang Gui類的具體用法?Golang Gui怎麽用?Golang Gui使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Gui類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: delMsg
func delMsg(g *gocui.Gui, v *gocui.View) error {
if err := g.DeleteView("msg"); err != nil {
return err
}
if err := g.SetCurrentView("side"); err != nil {
return err
}
return nil
}
示例2: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.Highlight = true
fmt.Fprintln(v, "Item 1")
fmt.Fprintln(v, "Item 2")
fmt.Fprintln(v, "Item 3")
fmt.Fprintln(v, "Item 4")
}
if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt")
if err != nil {
panic(err)
}
fmt.Fprintf(v, "%s", b)
v.Editable = true
if err := g.SetCurrentView("main"); err != nil {
return err
}
}
return nil
}
示例3: nextView
func nextView(g *gocui.Gui, v *gocui.View) error {
currentView := g.CurrentView()
if currentView == nil || currentView.Name() == "side" {
return g.SetCurrentView("main")
}
return g.SetCurrentView("side")
}
示例4: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if _, err := g.SetView("side", -1, -1, int(0.2*float32(maxX)), maxY-5); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("main", int(0.2*float32(maxX)), -1, maxX, maxY-5); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("cmdline", -1, maxY-5, maxX, maxY); err != nil &&
err != gocui.ErrorUnkView {
return err
}
return nil
}
示例5: getLine
func getLine(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
maxX, maxY := g.Size()
if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, l)
if err := g.SetCurrentView("msg"); err != nil {
return err
}
}
return nil
}
示例6: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if _, err := g.SetView("v1", -1, -1, 10, 10); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v2", maxX-10, -1, maxX, 10); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v3", maxX/2-5, -1, maxX/2+5, 10); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v4", -1, maxY/2-5, 10, maxY/2+5); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v5", maxX-10, maxY/2-5, maxX, maxY/2+5); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v6", -1, maxY-10, 10, maxY); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v7", maxX-10, maxY-10, maxX, maxY); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v8", maxX/2-5, maxY-10, maxX/2+5, maxY); err != nil &&
err != gocui.ErrorUnkView {
return err
}
if _, err := g.SetView("v9", maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5); err != nil &&
err != gocui.ErrorUnkView {
return err
}
return nil
}
示例7: keybindings
func keybindings(g *gocui.Gui) error {
if err := g.SetKeybinding("side", gocui.KeyCtrlSpace, 0, nextView); err != nil {
return err
}
if err := g.SetKeybinding("main", gocui.KeyCtrlSpace, 0, nextView); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyArrowDown, 0, cursorDown); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyArrowUp, 0, cursorUp); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyArrowLeft, 0, cursorLeft); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyArrowRight, 0, cursorRight); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyCtrlC, 0, quit); err != nil {
return err
}
if err := g.SetKeybinding("side", gocui.KeyEnter, 0, getLine); err != nil {
return err
}
if err := g.SetKeybinding("msg", gocui.KeyEnter, 0, delMsg); err != nil {
return err
}
return nil
}