當前位置: 首頁>>代碼示例>>Golang>>正文


Golang View.SetCursor方法代碼示例

本文整理匯總了Golang中github.com/jroimartin/gocui.View.SetCursor方法的典型用法代碼示例。如果您正苦於以下問題:Golang View.SetCursor方法的具體用法?Golang View.SetCursor怎麽用?Golang View.SetCursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/jroimartin/gocui.View的用法示例。


在下文中一共展示了View.SetCursor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: tabUpdateInput

// TODO: fix \x00 issues
func tabUpdateInput(input *gocui.View) (string, bool) {

	// logger.Logger.Println(spew.Sdump(input.Buffer()))

	search := strings.TrimSpace(input.ViewBuffer())
	searchSplit := strings.Split(search, " ")
	search = searchSplit[len(searchSplit)-1]

	if inCacheTab {
		cacheTabIndex++

		if cacheTabIndex > len(cacheTabResults)-1 {
			cacheTabIndex = 0
		}

		searchSplit[len(searchSplit)-1] = cacheTabResults[cacheTabIndex]

		newInputData := strings.Join(searchSplit, " ")

		input.Clear()

		if !strings.HasPrefix(newInputData, "/") && !strings.HasPrefix(newInputData, "#") {
			newInputData = newInputData + ":"
		}

		fmt.Fprint(input, newInputData+" ")
		input.SetCursor(len(input.Buffer())-1, 0)

		// logger.Logger.Println(spew.Sdump(newInputData + ""))
		// logger.Logger.Printf("WORD %s -- %s -- %s\n", search, cacheTabSearch, cacheTabResults[cacheTabIndex])
		return "", true
	}

	return search, false
}
開發者ID:mephux,項目名稱:komanda-cli,代碼行數:36,代碼來源:util.go

示例2: 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
}
開發者ID:Rompei,項目名稱:vuls,代碼行數:31,代碼來源:tui.go

示例3: 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
}
開發者ID:Rompei,項目名稱:vuls,代碼行數:8,代碼來源:tui.go

示例4: 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
}
開發者ID:Rompei,項目名稱:vuls,代碼行數:9,代碼來源:tui.go

示例5: 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
}
開發者ID:simonwoerpel,項目名稱:sconsify,代碼行數:9,代碼來源:cui_navigation.go

示例6: 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
}
開發者ID:cswank,項目名稱:quimby,代碼行數:10,代碼來源:main.go

示例7: next

func next(g *ui.Gui, v *ui.View) error {
	cx, cy := v.Cursor()
	if cy+1 >= len(cli.Nodes) {
		return nil
	}
	err := v.SetCursor(cx, cy+1)
	printNodes()
	printNode(g)
	return err
}
開發者ID:cswank,項目名稱:quimby,代碼行數:10,代碼來源:main.go

示例8: FocusInputView

func FocusInputView(g *gocui.Gui, v *gocui.View) error {

	v.SetCursor(len(v.Buffer()+"")-1, 0)

	if _, err := g.SetCurrentView("input"); err != nil {
		return err
	}

	return nil
}
開發者ID:mephux,項目名稱:komanda-cli,代碼行數:10,代碼來源:util.go

示例9: moveRight

func moveRight(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx+1, cy); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox+1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:thorncp,項目名稱:hello-go,代碼行數:12,代碼來源:main.go

示例10: cursorLeft

func cursorLeft(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx-1, cy); err != nil && ox > 0 {
			if err := v.SetOrigin(ox-1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:balu-,項目名稱:gocui,代碼行數:12,代碼來源:demo2.go

示例11: cursorDown

func cursorDown(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:jroimartin,項目名稱:gocui,代碼行數:12,代碼來源:demo.go

示例12: cursorUp

func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:jroimartin,項目名稱:gocui,代碼行數:12,代碼來源:demo.go

示例13: cursorUp

func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && 0 < oy {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	onMovingCursorRedrawView(g, v)
	return nil
}
開發者ID:ymomoi,項目名稱:vuls,代碼行數:13,代碼來源:tui.go

示例14: cursorUp

func (runner *appRunner) cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
		runner.layout(g)
	}
	return nil
}
開發者ID:inkyblackness,項目名稱:shocked-client,代碼行數:13,代碼來源:Run.go

示例15: moveDown

func moveDown(g *gocui.Gui, v *gocui.View) error {
	fmt.Println("yo")
	if v != nil {
		fmt.Println("hey")
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
開發者ID:thorncp,項目名稱:hello-go,代碼行數:14,代碼來源:main.go


注:本文中的github.com/jroimartin/gocui.View.SetCursor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。