本文整理汇总了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)
}
示例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)
}