Documentation ¶
Overview ¶
Package edit implements a thread-safe text-editing buffer.
Index ¶
- type Buffer
- func (b *Buffer) CoordsFromIndex(index Index) (col, row int)
- func (b *Buffer) Delete(begin, end Index)
- func (b *Buffer) DisplayLines() []*list.List
- func (b *Buffer) End() Index
- func (b *Buffer) Get(begin, end Index) string
- func (b *Buffer) IndexFromCoords(col, row int) Index
- func (b *Buffer) IndexFromMark(id int) Index
- func (b *Buffer) Insert(index Index, text string)
- func (b *Buffer) Mark(index Index, id ...int)
- func (b *Buffer) Modified() bool
- func (b *Buffer) Redo(mark ...int) bool
- func (b *Buffer) ResetModified()
- func (b *Buffer) ResetUndo()
- func (b *Buffer) Scroll(delta int)
- func (b *Buffer) ScrollFraction() float64
- func (b *Buffer) Separate()
- func (b *Buffer) SetSize(cols, rows int)
- func (b *Buffer) SetSyntax(rules []Rule)
- func (b *Buffer) SetTabWidth(cols int)
- func (b *Buffer) ShiftIndex(index Index, chars int) Index
- func (b *Buffer) Undo(mark ...int) bool
- type Fragment
- type Index
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a thread-safe text-editing buffer.
func (*Buffer) CoordsFromIndex ¶
CoordsFromIndex returns the display coordinates of index. Coordinates may be out of bounds of the buffer's current display.
func (*Buffer) DisplayLines ¶
DisplayLines returns a slice of Lists of Fragments, one list for each line on the buffer's current display.
func (*Buffer) IndexFromCoords ¶
IndexFromCoords returns the closest index to the given display coordinates.
func (*Buffer) IndexFromMark ¶
IndexFromMark returns the current index of the mark with ID id, or a zero-value index if no mark with ID id is set.
func (*Buffer) Mark ¶
Mark sets a mark with ID id at index. The mark's position is automatically updated when the buffer contents are modified. If a mark with ID id already exists, its position is updated. Multiple IDs can be specified to set multiple marks at the same time.
func (*Buffer) Modified ¶
Modified returns true if and only if the buffer's contents differ from the contents at the last time ResetModified was called. This operation is expsensive, since it must hash the entire buffer contents.
func (*Buffer) Redo ¶
Redo redoes the last undone sequence of insertions and deletions and returns true, or returns false if the redo stack is empty. The given marks are positioned at the index of the redone operation.
func (*Buffer) ResetModified ¶
func (b *Buffer) ResetModified()
ResetModified sets the comparison point for future calls to Modified to the current contents of the buffer. This operation is expensive, since it must hash the entire buffer contents.
func (*Buffer) ResetUndo ¶
func (b *Buffer) ResetUndo()
ResetUndo clears the buffer's undo and redo stacks.
func (*Buffer) ScrollFraction ¶
ScrollFraction returns a number in the range [0, 1] describing the vertical scroll fraction of the buffer display. If the entire content is visible, -1 is returned instead.
func (*Buffer) Separate ¶
func (b *Buffer) Separate()
Separate inserts a separator onto the undo stack in order to delimit sequences of insertions and deletions.
func (*Buffer) SetTabWidth ¶
SetTabWidth sets the tab width of the buffer to cols.
func (*Buffer) ShiftIndex ¶
ShiftIndex returns index shifted right by chars. If chars is negative, index is shifted left.