当前位置: 首页>>代码示例>>Golang>>正文


Golang View.EditWrite方法代码示例

本文整理汇总了Golang中github.com/jroimartin/gocui.View.EditWrite方法的典型用法代码示例。如果您正苦于以下问题:Golang View.EditWrite方法的具体用法?Golang View.EditWrite怎么用?Golang View.EditWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jroimartin/gocui.View的用法示例。


在下文中一共展示了View.EditWrite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: cmdEditor

func cmdEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
	switch {
	case ch != 0 && mod == 0:
		v.EditWrite(ch)
	case key == gocui.KeySpace:
		v.EditWrite(' ')
	case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
		cx, _ := v.Cursor()
		if cx > len(fmt.Sprintf(cmdPrefix, cTubes.Selected)) {
			v.EditDelete(true)
		}
	case key == gocui.KeyDelete:
		v.EditDelete(false)
	}
}
开发者ID:george-infinity,项目名称:bsw,代码行数:15,代码来源:main.go

示例2: simpleEditor

func simpleEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
	var tab = false
	var inHistroy = false

	switch {
	case key == gocui.KeyTab:
		tab = true
	case ch != 0 && mod == 0:
		v.EditWrite(ch)
	case key == gocui.KeySpace:
		v.EditWrite(' ')
	case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
		v.EditDelete(true)
	case key == gocui.KeyDelete:
		v.EditDelete(false)
	case key == gocui.KeyInsert:
		v.Overwrite = !v.Overwrite
	case key == gocui.KeyEnter:

		if line := v.ViewBuffer(); len(line) > 0 {
			GetLine(Server.Gui, v)
		}
		// v.EditNewLine()
		// v.Rewind()

	case key == gocui.KeyArrowDown:
		inHistroy = true

		if line := InputHistory.Next(); len(line) > 0 {
			v.Clear()
			fmt.Fprint(v, line)
			v.SetCursor(len(v.Buffer()), 0)
		}
	case key == gocui.KeyArrowUp:
		inHistroy = true

		if line := InputHistory.Prev(); len(line) > 0 {
			v.Clear()
			fmt.Fprint(v, line)
			v.SetCursor(len(v.Buffer()), 0)
		}
	case key == gocui.KeyArrowLeft:
		v.MoveCursor(-1, 0, false)
	case key == gocui.KeyArrowRight:

		cx, _ := v.Cursor()
		line := v.ViewBuffer()

		logger.Logger.Println(len(line), cx)
		logger.Logger.Println(spew.Sdump(line))

		// if cx == 0 {
		// v.MoveCursor(-1, 0, false)
		if cx < len(line)-1 {
			v.MoveCursor(1, 0, false)
		}

	case key == gocui.KeyCtrlA:
		v.SetCursor(0, 0)
	case key == gocui.KeyCtrlK:
		v.Clear()
		v.SetCursor(0, 0)
	case key == gocui.KeyCtrlE:
		v.SetCursor(len(v.Buffer())-1, 0)
	case key == gocui.KeyCtrlLsqBracket:
		// logger.Logger.Println("word...")
	}

	if !inHistroy {
		// InputHistory.Current()
	}

	if !tab {
		// logger.Logger.Print("CALL\n")

		inCacheTab = false
		cacheTabSearch = ""
		cacheTabResults = []string{}
	}
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:80,代码来源:util.go


注:本文中的github.com/jroimartin/gocui.View.EditWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。