本文整理汇总了Golang中github.com/apcera/gocui.Gui.SetView方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.SetView方法的具体用法?Golang Gui.SetView怎么用?Golang Gui.SetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/apcera/gocui.Gui
的用法示例。
在下文中一共展示了Gui.SetView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}