Documentation
¶
Overview ¶
Package textbuffer provides a multi-line text editor with cursor movement, history navigation, and auto-completion support.
Index ¶
- type ActionType
- type Buffer
- func (b *Buffer) AddToHistory()
- func (b *Buffer) Clear()
- func (b *Buffer) Cursor() (int, int)
- func (b *Buffer) CursorOffset() int
- func (b *Buffer) DeleteChar()
- func (b *Buffer) DeleteCharForward()
- func (b *Buffer) DeleteWordLeft()
- func (b *Buffer) HistoryDown() bool
- func (b *Buffer) HistoryUp() bool
- func (b *Buffer) Insert(text string)
- func (b *Buffer) Line(row int) string
- func (b *Buffer) LineCount() int
- func (b *Buffer) Lines() []string
- func (b *Buffer) MoveDown()
- func (b *Buffer) MoveLeft()
- func (b *Buffer) MoveRight()
- func (b *Buffer) MoveToEnd()
- func (b *Buffer) MoveToEndOfText()
- func (b *Buffer) MoveToStart()
- func (b *Buffer) MoveToStartOfText()
- func (b *Buffer) MoveUp()
- func (b *Buffer) MoveWordLeft()
- func (b *Buffer) MoveWordRight()
- func (b *Buffer) NewLine()
- func (b *Buffer) Redo() bool
- func (b *Buffer) SetCursor(row, col int)
- func (b *Buffer) SetCursorOffset(offset int)
- func (b *Buffer) SetText(text string)
- func (b *Buffer) SetViewport(height, width int)
- func (b *Buffer) Text() string
- func (b *Buffer) Undo() bool
- func (b *Buffer) VisualLines() []VisualLine
- type EditAction
- type VisualLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType int
ActionType is the type of edit action.
const ( ActionInsert ActionType = iota ActionDelete ActionReplace )
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a text buffer for multi-line editing.
func (*Buffer) AddToHistory ¶
func (b *Buffer) AddToHistory()
AddToHistory adds the current text to history.
func (*Buffer) CursorOffset ¶
CursorOffset returns the cursor offset from the start of the text.
func (*Buffer) DeleteChar ¶
func (b *Buffer) DeleteChar()
DeleteChar deletes the character before the cursor (backspace).
func (*Buffer) DeleteCharForward ¶
func (b *Buffer) DeleteCharForward()
DeleteCharForward deletes the character at the cursor position.
func (*Buffer) DeleteWordLeft ¶
func (b *Buffer) DeleteWordLeft()
DeleteWordLeft deletes the word before the cursor.
func (*Buffer) HistoryDown ¶
HistoryDown navigates down in history (newer entries).
func (*Buffer) MoveLeft ¶
func (b *Buffer) MoveLeft()
MoveLeft moves the cursor left by one character.
func (*Buffer) MoveRight ¶
func (b *Buffer) MoveRight()
MoveRight moves the cursor right by one character.
func (*Buffer) MoveToEnd ¶
func (b *Buffer) MoveToEnd()
MoveToEnd moves the cursor to the end of the line.
func (*Buffer) MoveToEndOfText ¶
func (b *Buffer) MoveToEndOfText()
MoveToEndOfText moves the cursor to the end of the text.
func (*Buffer) MoveToStart ¶
func (b *Buffer) MoveToStart()
MoveToStart moves the cursor to the start of the line.
func (*Buffer) MoveToStartOfText ¶
func (b *Buffer) MoveToStartOfText()
MoveToStartOfText moves the cursor to the start of the text.
func (*Buffer) MoveWordLeft ¶
func (b *Buffer) MoveWordLeft()
MoveWordLeft moves the cursor left by one word.
func (*Buffer) MoveWordRight ¶
func (b *Buffer) MoveWordRight()
MoveWordRight moves the cursor right by one word.
func (*Buffer) NewLine ¶
func (b *Buffer) NewLine()
NewLine inserts a newline at the cursor position.
func (*Buffer) SetCursorOffset ¶
SetCursorOffset sets the cursor from an offset.
func (*Buffer) SetViewport ¶
SetViewport sets the viewport dimensions.
func (*Buffer) VisualLines ¶
func (b *Buffer) VisualLines() []VisualLine
VisualLines returns the visible lines for rendering.
type EditAction ¶
type EditAction struct {
Type ActionType
Row, Col int
Text string
PrevText string
}
EditAction represents an edit operation for undo/redo.