Documentation ¶
Index ¶
- Variables
- func Jump(m Movable, needle string, isForward bool, isTo bool)
- func WORD(m Movable, isForward, isEnd bool)
- func Word(m Movable, isForward, isEnd bool)
- type Incremental
- func (i *Incremental) Accept()
- func (i *Incremental) Cancel(m Movable)
- func (i *Incremental) Highlight() (line emu.ScreenLine, ok bool)
- func (i *Incremental) IsActive() bool
- func (i *Incremental) IsForward() bool
- func (i *Incremental) Next(m Movable, isForward bool)
- func (i *Incremental) Pattern(m Movable, input string)
- func (i *Incremental) Start(m Movable, isForward bool)
- type LineReader
- type Motion
- type Movable
Constants ¶
This section is empty.
Variables ¶
var ( // vim word // warning: not accurate WORD_REGEX = regexp.MustCompile(`[!-~\w]+`) // vim WORD NON_WHITESPACE_REGEX = regexp.MustCompile(`[^\s]+`) )
var EndOfLine = lineMotion(func(line emu.Line) int { return len(line) - 1 })
EndOfLine corresponds to vim's "$".
var EndOfScreenLine = screenLineMotion(func(width int, line emu.ScreenLine) int {
return line.C1 - 1
})
EndOfScreenLine corresponds to vim's `g$`.
var FirstNonBlank = lineMotion(func(line emu.Line) int {
first, _ := line.Whitespace()
return first
})
FirstNonBlank corresponds to vim's "^".
var FirstNonBlankScreen = screenLineMotion(func(width int, line emu.ScreenLine) int {
first, _ := line.Chars.Whitespace()
return line.C0 + first
})
FirstNonBlankScreen corresponds to vim's `g^`.
var LastNonBlank = lineMotion(func(line emu.Line) int {
_, last := line.Whitespace()
return last
})
LastNonBlank corresponds to vim's "g_".
var LastNonBlankScreen = screenLineMotion(func(width int, line emu.ScreenLine) int {
_, last := line.Chars.Whitespace()
return line.C0 + last
})
LastNonBlankScreen corresponds to vim's `g<end>`.
var MiddleOfLine = lineMotion(func(line emu.Line) int { return len(line) / 2 })
MiddleOfLine corresponds to vim's "gM".
var MiddleOfScreenLine = screenLineMotion(func(width int, line emu.ScreenLine) int {
return line.C0 + width/2
})
MiddleOfScreenLine corresponds to vim's `gm`.
var StartOfLine = lineMotion(func(line emu.Line) int {
return 0
})
StartOfLine corresponds to vim's "0".
var StartOfScreenLine = screenLineMotion(func(width int, line emu.ScreenLine) int {
return line.C0
})
StartOfScreenLine corresponds to vim's `g0`.
Functions ¶
Types ¶
type Incremental ¶
type Incremental struct {
// contains filtered or unexported fields
}
Incremental is a state machine that implements vim/emacs style incremental searching for a Movable.
func NewIncremental ¶
func NewIncremental() *Incremental
func (*Incremental) Accept ¶
func (i *Incremental) Accept()
Accept confirms the motion and stores the pattern. This is equivalent to pressing enter when searching incrementally in vim.
func (*Incremental) Cancel ¶
func (i *Incremental) Cancel(m Movable)
Cancel stops searching incrementally and returns to the origin.
func (*Incremental) Highlight ¶
func (i *Incremental) Highlight() (line emu.ScreenLine, ok bool)
func (*Incremental) IsActive ¶
func (i *Incremental) IsActive() bool
IsActive returns true if the user is currently entering a search pattern.
func (*Incremental) IsForward ¶
func (i *Incremental) IsForward() bool
IsForward returns true if the user is currently searching forward.
func (*Incremental) Next ¶
func (i *Incremental) Next(m Movable, isForward bool)
Next jumps to the next instance of the accepted pattern in the direction of the search. `isForward` is relative to the direction of the original search; if the original search was backwards, `isForward=true` means that the search will go backwards.
func (*Incremental) Pattern ¶
func (i *Incremental) Pattern(m Movable, input string)
Pattern takes a new pattern and jumps to the closest instance of it after the origin in the direction of the search.
func (*Incremental) Start ¶
func (i *Incremental) Start(m Movable, isForward bool)
Start initializes the incremental search by saving the original cursor location and direction.
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
An io.RuneReader that provides a sequence of runes corresponding to the cells in an emu.Line.