core

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

Editor coordinates all editing operations

func NewEditor

func NewEditor(buf buffer.Buffer, highlighterService *hl.Highlighter, eventManager *event.Manager) *Editor

NewEditor creates a new Editor instance with a given buffer. eventManager is used by the highlight manager to dispatch TypeHighlightComplete when a background highlighting pass completes; pass nil to disable.

func (*Editor) ClearDirty added in v0.1.3

func (e *Editor) ClearDirty()

ClearDirty resets all dirty-line tracking state after a frame has been drawn.

func (*Editor) ClearHighlights

func (e *Editor) ClearHighlights()

ClearHighlights clears search highlights.

func (*Editor) ClearHistory

func (e *Editor) ClearHistory()

ClearHistory clears the undo/redo stack

func (*Editor) ClearSelection

func (e *Editor) ClearSelection()

ClearSelection resets the selection state.

func (*Editor) CutSelection added in v0.1.3

func (e *Editor) CutSelection() (bool, error)

func (*Editor) DeleteBackward

func (e *Editor) DeleteBackward() error

func (*Editor) DeleteForward

func (e *Editor) DeleteForward() error

func (*Editor) End

func (e *Editor) End()

func (*Editor) FilePath added in v0.1.1

func (e *Editor) FilePath() string

FilePath returns the file path from the buffer. Required by highlight manager.

func (*Editor) Find

func (e *Editor) Find(term string, startPos types.Position, forward bool) (types.Position, bool)

Find operations delegated to findManager

func (*Editor) GetBuffer

func (e *Editor) GetBuffer() buffer.Buffer

GetBuffer returns the editor's buffer.

func (*Editor) GetBufferCol added in v0.1.3

func (e *Editor) GetBufferCol(lineIdx int, visualCol int) int

func (*Editor) GetCurrentSearchHighlights

func (e *Editor) GetCurrentSearchHighlights() []types.HighlightRegion

GetCurrentSearchHighlights delegates to findManager

func (*Editor) GetCurrentTree

func (e *Editor) GetCurrentTree() *sitter.Tree

GetCurrentTree safely gets the current tree from the highlight manager

func (*Editor) GetCursor

func (e *Editor) GetCursor() types.Position

GetCursor returns the current cursor position.

func (*Editor) GetEventManager

func (e *Editor) GetEventManager() *event.Manager

GetEventManager returns the event manager

func (*Editor) GetFindManager

func (e *Editor) GetFindManager() *find.Manager

GetFindManager provides direct access to the find manager

func (*Editor) GetHighlightManager added in v0.1.1

func (e *Editor) GetHighlightManager() *highlight.Manager

GetHighlightManager returns the highlight manager instance. Needed for App to call AccumulateEdit.

func (*Editor) GetHistoryManager

func (e *Editor) GetHistoryManager() *history.Manager

GetHistoryManager returns the history manager for undo/redo

func (*Editor) GetSelecting

func (e *Editor) GetSelecting() bool

GetSelecting returns whether selection is active

func (*Editor) GetSelection

func (e *Editor) GetSelection() (start types.Position, end types.Position, ok bool)

GetSelection returns the normalized selection range (start <= end).

func (*Editor) GetSyntaxHighlightsForLine

func (e *Editor) GetSyntaxHighlightsForLine(lineNum int) []types.StyledRange

GetSyntaxHighlightsForLine returns highlights for a specific line from the manager.

func (*Editor) GetViewport

func (e *Editor) GetViewport() (int, int)

GetViewport returns the viewport position by delegating to the cursor manager

func (*Editor) GetVisualSelectionLines added in v0.1.3

func (e *Editor) GetVisualSelectionLines() (startLine, endLine int)

GetVisualSelectionLines returns the start and end line numbers of the current visual selection. If no selection is active it returns the cursor line for both.

func (*Editor) HardHome added in v0.1.3

func (e *Editor) HardHome()

HardHome moves the cursor to column 0 (Vim '0' behaviour).

func (*Editor) HasHighlights

func (e *Editor) HasHighlights() bool

HasHighlights checks for search highlights.

func (*Editor) HasSelection

func (e *Editor) HasSelection() bool

HasSelection returns whether there's an active selection

func (*Editor) HighlightMatches

func (e *Editor) HighlightMatches(term string) error

func (*Editor) Home

func (e *Editor) Home()

func (*Editor) InsertNewLine

func (e *Editor) InsertNewLine() error

func (*Editor) InsertRune

func (e *Editor) InsertRune(r rune) error

Text operation methods delegated to textOps

func (*Editor) InsertTab

func (e *Editor) InsertTab() error

func (*Editor) IsDirty added in v0.1.3

func (e *Editor) IsDirty(line int) bool

IsDirty reports whether the given buffer line needs to be redrawn. Returns true also when a full redraw has been requested.

func (*Editor) IsLinewise added in v0.1.3

func (e *Editor) IsLinewise() bool

IsLinewise returns true if the current selection is line-wise.

func (*Editor) MarkAllDirty added in v0.1.3

func (e *Editor) MarkAllDirty()

MarkAllDirty signals that every visible line must be redrawn. This is used on viewport scroll, theme change, search highlight update, etc.

func (*Editor) MarkDirty added in v0.1.3

func (e *Editor) MarkDirty(line int)

MarkDirty marks a specific buffer line as needing a redraw.

func (*Editor) MoveCursor

func (e *Editor) MoveCursor(deltaLine, deltaCol int)

Cursor operations delegated to cursorManager

func (*Editor) NeedsFullRedraw added in v0.1.3

func (e *Editor) NeedsFullRedraw() bool

NeedsFullRedraw reports whether the entire viewport should be cleared and redrawn.

func (*Editor) PageMove

func (e *Editor) PageMove(deltaPages int)

func (*Editor) Paste

func (e *Editor) Paste(after bool) (bool, error)

func (*Editor) Redo

func (e *Editor) Redo() (bool, error)

Redo reapplies a previously undone change

func (*Editor) Replace

func (e *Editor) Replace(pattern, replacement string, global bool) (int, error)

Replace performs a find and replace operation using findManager

func (*Editor) ReplaceAll added in v0.1.3

func (e *Editor) ReplaceAll(pattern, replacement string) (int, error)

ReplaceAll replaces all occurrences of pattern across the entire buffer. Wraps the operation in a history transaction for atomic undo.

func (*Editor) ReplaceInRange added in v0.1.3

func (e *Editor) ReplaceInRange(pattern, replacement string, startLine, endLine int) (int, error)

ReplaceInRange replaces all occurrences of pattern in [startLine, endLine]. Wraps the operation in a history transaction for atomic undo.

func (*Editor) SaveBuffer

func (e *Editor) SaveBuffer(filePath ...string) error

SaveBuffer handles buffer saving, accepting an optional override path.

func (*Editor) ScrollOff

func (e *Editor) ScrollOff() int

ScrollOff returns the scrolloff setting

func (*Editor) ScrollToCursor

func (e *Editor) ScrollToCursor()

ScrollToCursor ensures cursor remains visible

func (*Editor) SetCursor

func (e *Editor) SetCursor(pos types.Position)

SetCursor sets the cursor position

func (*Editor) SetEventManager

func (e *Editor) SetEventManager(mgr *event.Manager)

SetEventManager sets the event manager for dispatching events

func (*Editor) SetHighlighter

func (e *Editor) SetHighlighter(h *hl.Highlighter)

SetHighlighter (optional) allows changing the highlighter service later if needed.

func (*Editor) SetLinewise added in v0.1.3

func (e *Editor) SetLinewise(lw bool)

SetLinewise marks the current selection as line-wise (Vim 'V' behaviour).

func (*Editor) SetViewSize

func (e *Editor) SetViewSize(width, height int)

SetViewSize updates the view dimensions

func (*Editor) StartOrUpdateSelection

func (e *Editor) StartOrUpdateSelection()

StartOrUpdateSelection manages selection state during movement.

func (*Editor) Undo

func (e *Editor) Undo() (bool, error)

Undo reverts the last text change

func (*Editor) UpdateSyntaxHighlights

func (e *Editor) UpdateSyntaxHighlights(newHighlights hl.HighlightResult, newTree *sitter.Tree)

UpdateSyntaxHighlights tells the highlight manager to update its internal state. This might be called by the highlight manager's background task.

func (*Editor) WordBackward added in v0.1.3

func (e *Editor) WordBackward()

WordBackward moves the cursor to the start of the current/previous word (Vim 'b').

func (*Editor) WordEnd added in v0.1.3

func (e *Editor) WordEnd()

WordEnd moves the cursor to the end of the current/next word (Vim 'e').

func (*Editor) WordForward added in v0.1.3

func (e *Editor) WordForward()

WordForward moves the cursor to the start of the next word (Vim 'w').

func (*Editor) YankSelection

func (e *Editor) YankSelection() (bool, error)

Clipboard operations delegated to clipboardManager

Directories

Path Synopsis
Package history provides undo/redo functionality via a change history stack.
Package history provides undo/redo functionality via a change history stack.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL