本文整理汇总了Golang中github.com/jroimartin/gocui.View.Cursor方法的典型用法代码示例。如果您正苦于以下问题:Golang View.Cursor方法的具体用法?Golang View.Cursor怎么用?Golang View.Cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.View
的用法示例。
在下文中一共展示了View.Cursor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: changeHost
func changeHost(g *gocui.Gui, v *gocui.View) error {
if err := g.DeleteView("summary"); err != nil {
return err
}
if err := g.DeleteView("detail"); err != nil {
return err
}
_, cy := v.Cursor()
l, err := v.Line(cy)
if err != nil {
return err
}
serverName := strings.TrimSpace(l)
for _, r := range scanHistory.ScanResults {
if serverName == strings.TrimSpace(r.ServerInfoTui()) {
currentScanResult = r
break
}
}
if err := setSummaryLayout(g); err != nil {
return err
}
if err := setDetailLayout(g); err != nil {
return err
}
return nil
}
示例2: codeComplete
func codeComplete(g *gocui.Gui, v *gocui.View) error {
if v != nil {
ox, oy := v.Origin()
cx, cy := v.Cursor()
x, y := ox+cx, oy+cy
f := proj.GetFile("test.go")
off := f.GetOffset(x, y)
cands := codecomplete.Complete(proj, f, off)
maxX, maxY := g.Size()
maxY = maxY/2 - (len(cands) / 2)
if v, err := g.SetView("msg", maxX/2-30, maxY, maxX/2+30, maxY+len(cands)+2); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, x, y, off)
for _, c := range cands {
fmt.Fprintln(v, c.Name, c.Perc)
}
if err := g.SetCurrentView("msg"); err != nil {
return err
}
}
}
return nil
}
示例3: getLine
func getLine(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
g.ShowCursor = false
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
maxX, maxY := g.Size()
length := 10 + len(current_name)
if l != "" {
current_name = l
if v, err := g.SetView("msg", maxX/2-length/2, maxY/2-3, maxX/2+length/2, maxY/2+3); err != nil {
v.BgColor = gocui.ColorGreen
v.FgColor = gocui.ColorBlack
if err != gocui.ErrorUnkView {
return err
}
current_proj = projects[current_name]
current_proj.start()
fmt.Fprintln(v, "")
fmt.Fprintln(v, "")
fmt.Fprintln(v, strings.Repeat(" ", (length-15)/2), "Active Project")
fmt.Fprintln(v, "")
fmt.Fprintln(v, strings.Repeat(" ", 5), current_name)
fmt.Fprintln(v, "")
setView(g, "msg")
}
}
return nil
}
示例4: cursorPageDown
func cursorPageDown(g *gocui.Gui, v *gocui.View) error {
jump := pageUpDownJumpCount(v)
if v != nil {
cx, cy := v.Cursor()
ox, oy := v.Origin()
ok, yLimit := movable(v, oy+cy+jump)
_, maxY := v.Size()
if !ok {
if yLimit < maxY {
v.SetCursor(cx, yLimit)
} else {
v.SetCursor(cx, maxY-1)
v.SetOrigin(ox, yLimit-maxY+1)
}
} else if yLimit < oy+jump+maxY {
if yLimit < maxY {
v.SetCursor(cx, yLimit)
} else {
v.SetOrigin(ox, yLimit-maxY+1)
v.SetCursor(cx, maxY-1)
}
} else {
v.SetCursor(cx, cy)
v.SetOrigin(ox, oy+jump)
}
onMovingCursorRedrawView(g, v)
}
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
}
}
if v, err := g.View("main"); err != nil {
if err != gocui.ErrorUnkView {
return err
}
f := proj.GetFile(l)
if f != nil {
v.Clear()
fmt.Fprintf(v, "%s", f.GetBody())
}
v.Editable = true
v.Wrap = true
}
return nil
}
示例6: removeProject
func removeProject(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
g.ShowCursor = false
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
current_name = l
maxX, maxY := g.Size()
length := 20
if l != "" {
if v, err := g.SetView("del_proj", maxX/2-length/2, maxY/2, maxX/2+length/2, maxY/2+2); err != nil {
v.BgColor = gocui.ColorRed
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, "Press 'd' to delete")
setView(g, "del_proj")
}
}
return nil
}
示例7: confirmListDetail
func (runner *appRunner) confirmListDetail(gui *gocui.Gui, view *gocui.View) error {
_, originY := view.Origin()
_, cursorY := view.Cursor()
runner.activeListDetailController.Confirm(originY + cursorY)
runner.restoreMainView()
runner.gui.DeleteView(view.Name())
return nil
}
示例8: cursorMoveTop
func cursorMoveTop(g *gocui.Gui, v *gocui.View) error {
if v != nil {
cx, _ := v.Cursor()
v.SetCursor(cx, 0)
}
onMovingCursorRedrawView(g, v)
return nil
}
示例9: cursorMoveMiddle
func cursorMoveMiddle(g *gocui.Gui, v *gocui.View) error {
if v != nil {
_, maxY := v.Size()
cx, _ := v.Cursor()
v.SetCursor(cx, maxY/2)
}
onMovingCursorRedrawView(g, v)
return nil
}
示例10: destinationsMenuDown
func destinationsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 9
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
示例11: platformsMenuDown
func platformsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 3
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
示例12: cursorHome
func cursorHome(g *gocui.Gui, v *gocui.View) error {
ox, _ := v.Origin()
cx, _ := v.Cursor()
v.SetCursor(cx, 0)
v.SetOrigin(ox, 0)
updateTracksView(g, v)
return nil
}
示例13: transcriptsMenuDown
func transcriptsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 5
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
示例14: setContact
func setContact(g *gocui.Gui, v *gocui.View) error {
_, cy := v.Cursor()
jid := viewJids[cy]
g.View("main").Clear()
io.Copy(g.View("main"), bytes.NewReader(jidBuffs[jid]))
g.SetCurrentView("input")
return nil
}
示例15: prev
func prev(g *ui.Gui, v *ui.View) error {
cx, cy := v.Cursor()
if cy-1 < 0 {
return nil
}
err := v.SetCursor(cx, cy-1)
printNodes()
printNode(g)
return err
}