Documentation ¶
Index ¶
- Constants
- type Elog
- type ElogOperation
- type ElogType
- type TextBuffer
- func (t TextBuffer) Constrain(q0, q1 int) (p0, p1 int)
- func (t *TextBuffer) Delete(q0, q1 int, tofile bool)
- func (t *TextBuffer) Insert(q0 int, r []rune, tofile bool)
- func (t *TextBuffer) Nc() int
- func (t *TextBuffer) Q0() int
- func (t *TextBuffer) Q1() int
- func (t *TextBuffer) ReadB(q int, r []rune) (n int, err error)
- func (t *TextBuffer) ReadC(q int) rune
- func (t *TextBuffer) SetQ0(q0 int)
- func (t *TextBuffer) SetQ1(q1 int)
- type Texter
Constants ¶
const ( DeleteType ElogType = iota InsertType FilenameType Wsequence = "warning: changes out of sequence" WsequenceDire = "warning: changes out of sequence, edit result probably wrong" Delete = 'd' Insert = 'i' Filename = 'f' Null = '-' Replace = 'r' )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elog ¶
type Elog struct { Log []ElogOperation // contains filtered or unexported fields }
Elog is a log of changes made by editing commands. Three reasons for this: 1) We want addresses in commands to apply to old file, not file-in-change. 2) It's difficult to track changes correctly as things move, e.g. ,x m$ 3) This gives an opportunity to optimize by merging adjacent changes. It's a little bit like the Undo/Redo log in Files, but Point 3) argues for a separate implementation. To do this well, we use Replace as well as Insert and Delete
There is a significant assumption that the log has increasing q0s. The log is then played back backwards to apply the changes to the text. Out-of-order edits are warned about.
type ElogOperation ¶
type ElogOperation struct { T ElogType // Delete, Insert, Filename // contains filtered or unexported fields }
type TextBuffer ¶
type TextBuffer struct {
// contains filtered or unexported fields
}
TextBuffer implements Texter around a buffer.
func NewTextBuffer ¶
func NewTextBuffer(q0 int, q1 int, buf []rune) *TextBuffer
NewTextBuffer is a constructor for texter.TextBuffer.
func (TextBuffer) Constrain ¶
func (t TextBuffer) Constrain(q0, q1 int) (p0, p1 int)
func (*TextBuffer) Delete ¶
func (t *TextBuffer) Delete(q0, q1 int, tofile bool)
func (*TextBuffer) Nc ¶
func (t *TextBuffer) Nc() int
func (*TextBuffer) Q0 ¶
func (t *TextBuffer) Q0() int
func (*TextBuffer) Q1 ¶
func (t *TextBuffer) Q1() int
func (*TextBuffer) ReadC ¶
func (t *TextBuffer) ReadC(q int) rune
func (*TextBuffer) SetQ0 ¶
func (t *TextBuffer) SetQ0(q0 int)
func (*TextBuffer) SetQ1 ¶
func (t *TextBuffer) SetQ1(q1 int)
type Texter ¶
type Texter interface { Constrain(q0, q1 int) (p0, p1 int) Delete(q0, q1 int, tofile bool) Insert(q0 int, r []rune, tofile bool) Q0() int // Selection start SetQ0(int) Q1() int // End of selelection SetQ1(int) // TODO(rjk): Please call this Nr(). Nc() int // TODO(rjk): Rename this to Read ReadB(q int, r []rune) (n int, err error) ReadC(q int) rune }
Texter abstracts the buffering side of Text, allowing testing of Elog Apply TODO(flux): This is probably lame and will get re-done when I understand how Text stores its text. TODO(rjk): Make this into a streaming interface.