package action import ( "git.gophernest.net/azpect/TextEditor/internal/core" tea "github.com/charmbracelet/bubbletea" ) // Model defines the interface for editor state that actions can modify type Model interface { // ================================================== // Core Data Access // ================================================== Windows() []*core.Window ActiveWindow() *core.Window Buffers() []*core.Buffer ActiveBuffer() *core.Buffer // ================================================== // Insert Mode State // ================================================== InsertKeys() []string SetInsertKeys(keys []string) // Insert recording (for count replay) SetInsertRecording(count int, action Action) // ExitInsertMode handles replay, cursor step-back, and mode transition on esc ExitInsertMode() // ================================================== // Command Mode State // ================================================== Command() string SetCommand(cmd string) CommandCursor() int SetCommandCursor(cur int) CommandError() error SetCommandError(err error) CommandOutput() string SetCommandOutput(out string) // ================================================== // Editor-wide State // ================================================== Mode() core.Mode SetMode(mode core.Mode) Settings() core.EditorSettings SetSettings(s core.EditorSettings) // ================================================== // Registers // ================================================== Registers() map[rune]core.Register GetRegister(name rune) (core.Register, bool) SetRegister(name rune, t core.RegisterType, cnt []string) error UpdateDefaultRegister(t core.RegisterType, cnt []string) } // Action is the base interface - anything executable type Action interface { Execute(m Model) tea.Cmd } // Motion moves the cursor and returns the range covered type Motion interface { Action Type() core.MotionType } // Operator acts on a range (delete, yank, change) type Operator interface { Operate(m Model, start, end core.Position, mtype core.MotionType) tea.Cmd } // DoublePresser is an optional interface for operators that support double-press (dd, yy, cc) type DoublePresser interface { DoublePress(m Model, count int) tea.Cmd } // Repeatable actions track count type Repeatable interface { WithCount(n int) Action }