本文整理汇总了Golang中github.com/kisielk/vigo/editor.Editor类的典型用法代码示例。如果您正苦于以下问题:Golang Editor类的具体用法?Golang Editor怎么用?Golang Editor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Editor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Apply
func (m MoveFOL) Apply(e *editor.Editor) {
v := e.ActiveView()
c := v.Cursor()
pos := utils.IndexFirstNonSpace(c.Line.Data)
c.Boffset = pos
v.MoveCursorTo(c)
}
开发者ID:kisielk,项目名称:vigo,代码行数:7,代码来源:movement.go
示例2: Apply
func (_ DeleteEOL) Apply(e *editor.Editor) {
v := e.ActiveView()
c := v.Cursor()
l := c.Line
d := l.Data[:c.Boffset]
v.Buffer().Delete(c, len(l.Data)-len(d))
}
开发者ID:kisielk,项目名称:vigo,代码行数:7,代码来源:text.go
示例3: storeSearchTerm
// Store the search term on the editor instance.
// This allows us to use it later in other commands.
func storeSearchTerm(e *editor.Editor, term string) {
// don't do anything if no term is given
if term == "" {
return
}
e.LastSearchTerm = term
e.ActiveView().SetHighlightBytes([]byte(term))
}
开发者ID:kisielk,项目名称:vigo,代码行数:10,代码来源:search.go
示例4: Apply
func (r DisplayFileStatus) Apply(e *editor.Editor) {
v := e.ActiveView()
path := v.Buffer().Path
numLines := v.Buffer().NumLines
c := v.Cursor()
pc := (float64(c.LineNum) / float64(numLines)) * 100
v.SetStatus("\"%s\" %d lines --%d%%--", path, numLines, int(pc))
}
开发者ID:kisielk,项目名称:vigo,代码行数:10,代码来源:display.go
示例5: 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
示例6: Apply
func (r Redo) Apply(e *editor.Editor) {
for i := 0; i < r.Count; i++ {
e.ActiveView().Buffer().Redo()
}
}
开发者ID:pombredanne,项目名称:vigo,代码行数:5,代码来源:undo.go
示例7: Enter
func (m *normalMode) Enter(e *editor.Editor) {
e.ActiveView().Buffer().FinalizeActionGroup()
}
开发者ID:kisielk,项目名称:vigo,代码行数:3,代码来源:normal.go
示例8: Apply
func (u Undo) Apply(e *editor.Editor) {
e.ActiveView().Buffer().Undo()
}
开发者ID:kisielk,项目名称:vigo,代码行数:3,代码来源:undo.go
示例9: 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
示例10: execCommand
// Interpret command and apply changes to editor.
func execCommand(e *editor.Editor, command string) error {
fields := strings.Fields(command)
// prevent a crash if no commands are given
if len(fields) == 0 {
return nil
}
cmd, args := fields[0], fields[1:]
switch cmd {
case "q":
// TODO if more than one split, close active one only.
e.Quit()
case "w":
b := e.ActiveView().Buffer()
switch len(args) {
case 0:
b.Save()
case 1:
b.SaveAs(args[0])
default:
return fmt.Errorf("too many arguments to :w")
}
case "e":
var filename string
switch len(args) {
case 0:
return fmt.Errorf("TODO re-read current file, if any")
case 1:
filename = args[0]
default:
return fmt.Errorf("too many arguments for :e")
}
// TODO: Don't replace the current buffer if it has been modified
buffer, err := e.NewBufferFromFile(filename)
if err != nil {
return err
}
e.ActiveView().Attach(buffer)
case "sp", "split":
e.SplitHorizontally()
// TODO file argument | shell command argument
case "vsp", "vsplit":
e.SplitVertically()
case "nohls":
e.ActiveView().ShowHighlights(false)
case "hls":
e.ActiveView().ShowHighlights(true)
}
if lineNum, err := strconv.Atoi(cmd); err == nil {
// cmd is a number, we should move to that line
e.ActiveView().MoveCursorToLine(lineNum)
}
return nil
}
开发者ID:kisielk,项目名称:vigo,代码行数:60,代码来源:command.go
注:本文中的github.com/kisielk/vigo/editor.Editor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论