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


Golang Editor.SetStatus方法代码示例

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


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

示例1: Apply

func (s Search) Apply(e *editor.Editor) {
	v := e.ActiveView()
	c := v.Cursor()

	if e.LastSearchTerm == "" {
		e.SetStatus("Nothing to search for.")
		return
	}
	word := []byte(e.LastSearchTerm)

	switch s.Dir {
	case Forward:
		e.SetStatus("Search forward for: %s", e.LastSearchTerm)
		for {

			// move the cursor one run forward.
			// this allows us to move to the next match.
			// without this, if the word under the cursor is a match,
			// then we won't be able to advance to the next match
			c.NextRune(false)

			i := bytes.Index(c.Line.Data[c.Boffset:], word)
			if i != -1 {
				c.Boffset += i
				break
			}

			c.Line = c.Line.Next
			if c.Line == nil {
				e.SetStatus("No more results")
				return
			}

			c.LineNum++
			c.Boffset = 0
		}
	case Backward:
		e.SetStatus("Search backward for: %s", e.LastSearchTerm)
		for {
			i := bytes.LastIndex(c.Line.Data[:c.Boffset], word)

			if i != -1 {
				c.Boffset = i
				break
			}

			c.Line = c.Line.Prev
			if c.Line == nil {
				e.SetStatus("No previous results")
				return
			}
			c.LineNum--
			c.Boffset = len(c.Line.Data)
		}
	}

	v.MoveCursorTo(c)
}
开发者ID:kisielk,项目名称:vigo,代码行数:58,代码来源:search.go

示例2: Apply

func (m MoveWord) Apply(e *editor.Editor) {
	// moveCursorWordForward
	v := e.ActiveView()
	c := v.Cursor()
	ok := c.NextWord()
	if !ok {
		e.SetStatus("End of buffer")
		return
	}
	v.MoveCursorTo(c)
}
开发者ID:pombredanne,项目名称:vigo,代码行数:11,代码来源:movement.go


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