Documentation
¶
Overview ¶
Package edit implements a compiler for Acme Edit command language. The compiled Command operates on types satisfying the text.Editor interface. See github.com/as/text for more.
Index ¶
- Variables
- func Commit(ed Editor, hist worm.Logger) (err error)
- type Address
- type Append
- type Byte
- type Change
- type Command
- type Compound
- type Delete
- type Dot
- type Editor
- type Emitted
- type File
- type Insert
- type Kind
- type Line
- type Options
- type Pipe
- type Print
- type ReadFile
- type Recorder
- type Regexp
- type ReplaceAmp
- type S
- type Sender
- type Trade
- type WriteFile
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilFunc = errors.New("empty program") ErrNilEditor = errors.New("nil editor") )
Functions ¶
func Commit ¶ added in v0.6.10
Commit plays back the history onto ed, starting from the last event to the first in reverse order. This is useful only when hist contains a set of independent events applied as a transaction where shifts in the address offsets are not observed.
If the command is
a,abc, x,.,a,Q,
The result is:
abc -> aQbQcQ
The log should contain
i 1 Q i 2 Q (not i 3 Q) i 3 Q (not i 5 Q)
Commit will only reallocate ed's size once. If ed implements io.WriterAt, a write-through fast path is used to commit the transaction.
Types ¶
type Address ¶
type Address interface { // Set computes and sets the address on the provided Editor Set(f Editor) // Back returns true if the address semantics should be executed in reverse Back() bool }
Address implements Set on the Editor. Possibly selecting some range of text (a dot).
type Byte ¶
type Byte struct { Q int64 // contains filtered or unexported fields }
Bytes is an address computed by a relative or absolute byte offset
type Command ¶
type Command struct { Emit *Emitted // contains filtered or unexported fields }
func MustCompile ¶
func (*Command) Modified ¶
Modified returns true if the last call to c.Run() modified the contents of the editor
func (*Command) Next ¶
Next returns the next instruction for the compiled program. This effectively steps through x,..., and y,...,
func (*Command) RunTransaction ¶ added in v0.6.10
Run runs the compiled program on ed
type Compound ¶
type Compound struct {
// contains filtered or unexported fields
}
Compound combines two address values with an operator
type Line ¶
type Line struct { Q int64 // contains filtered or unexported fields }
Line is an address computed by a relative or absolute byte offset
type Recorder ¶ added in v0.6.11
type Recorder struct {
Editor
}
Recorder is an overlay over an Editor that prevents mutable changes from occuring.
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Regexp is an address computed by a regexp
type ReplaceAmp ¶
func (ReplaceAmp) Gen ¶
func (r ReplaceAmp) Gen(replace []byte) (b []byte)