本文整理汇总了Golang中github.com/grafov/gocui.Gui.View方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.View方法的具体用法?Golang Gui.View怎么用?Golang Gui.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/grafov/gocui.Gui
的用法示例。
在下文中一共展示了Gui.View方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addSource
func addSource(g *gocui.Gui, p *gocui.View) error {
v, _ := g.View("addSource")
v.Editable = true
if v.Visible() {
v.Hide()
} else {
v.Unhide()
}
return nil
}
示例2: cursorDownInEditor
// cursorDownEditor enlarge sql view when a new line added
func cursorDownInEditor(g *gocui.Gui, v *gocui.View) error {
x, y := v.Cursor()
_, sizeY := v.Size()
if y >= sizeY-1 {
if splitY == minSplit {
return nil
}
splitY--
l, _ := g.View("log")
l.Resize(0, -1)
v.Resize(0, 1)
v.SetOrigin(0, 0)
v.SetCursor(x, y+1)
}
return nil
}
示例3: execQuery
func execQuery(g *gocui.Gui, v *gocui.View) error {
dbc := db.Use("test")
query := strings.TrimSpace(v.Buffer())
v.Reset()
fmt.Fprint(v, query)
widtgh, height := v.Size()
if height > v.LinesCount() {
v.SetSize(widtgh, v.LinesCount())
_, maxY := g.Size()
splitY = maxY - v.LinesCount() - 3
}
v.SetCursor(0, 0)
if len(query) == 0 {
return nil
}
log, _ := g.View("log")
rows, err := dbc.Queryx(query)
if err != nil {
fmt.Fprintln(log, err)
return nil
}
fmt.Fprintln(log, "\n", query)
logWidth, _ := log.Size()
log.Write(bytes.Repeat([]byte("─"), logWidth))
for rows.Next() {
log.Write([]byte("\n"))
cols, err := rows.SliceScan()
if err != nil {
fmt.Fprintln(log, err)
err = nil
break
}
for _, col := range cols {
if col != nil {
log.Write(col.([]byte))
log.Write([]byte("\t"))
}
}
}
log.Write([]byte("\n"))
log.Write(bytes.Repeat([]byte("─"), logWidth))
return err
}
示例4: switchPanels
func switchPanels(g *gocui.Gui, v *gocui.View) error {
lp, _ := g.View("lpanel")
rp, _ := g.View("rpanel")
if twoPanelsVisible {
lp.Hide()
rp.Hide()
g.SetCurrentView("sql")
g.ShowCursor = true
twoPanelsVisible = false
} else {
lp.Unhide()
rp.Unhide()
g.SetCurrentView("lpanel")
g.ShowCursor = false
twoPanelsVisible = true
}
return nil
}