package action import ( "git.gophernest.net/azpect/TextEditor/internal/core" tea "github.com/charmbracelet/bubbletea" ) // Quit implements Action (ctrl+c) type Quit struct{} // Quit.Execute: Quits the editor (Ctrl+C). func (a Quit) Execute(m Model) tea.Cmd { return tea.Quit } // EnterComandMode implements Action (:) - enters command mode. type EnterComandMode struct{} // EnterComandMode.Execute: Enters command mode (: key). func (a EnterComandMode) Execute(m Model) tea.Cmd { m.SetMode(core.CommandMode) m.SetCommand("") m.SetCommandOutput(&core.CommandOutput{}) m.SetCommandCursor(0) return nil } // EnterVisualMode implements Action (v) - enters visual character mode. type EnterVisualMode struct{} // EnterVisualMode.Execute: Enters visual character mode (v key). func (a EnterVisualMode) Execute(m Model) tea.Cmd { win := m.ActiveWindow() win.SetAnchorCol(win.Cursor.Col) win.SetAnchorLine(win.Cursor.Line) m.SetMode(core.VisualMode) return nil } // EnterVisualLineMode implements Action (V) - enters visual line mode. type EnterVisualLineMode struct{} // EnterVisualLineMode.Execute: Enters visual line mode (V key). func (a EnterVisualLineMode) Execute(m Model) tea.Cmd { win := m.ActiveWindow() win.SetAnchorCol(win.Cursor.Col) win.SetAnchorLine(win.Cursor.Line) m.SetMode(core.VisualLineMode) return nil } // EnterVisualBlockMode implements Action (Ctrl+V) - enters visual block mode. type EnterVisualBlockMode struct{} // EnterVisualBlockMode.Execute: Enters visual block mode (Ctrl+V). func (a EnterVisualBlockMode) Execute(m Model) tea.Cmd { win := m.ActiveWindow() win.SetAnchorCol(win.Cursor.Col) win.SetAnchorLine(win.Cursor.Line) m.SetMode(core.VisualBlockMode) return nil } // TODO: Implement count? type Undo struct{} func (a Undo) Execute(m Model) tea.Cmd { win := m.ActiveWindow() buf := m.ActiveBuffer() if buf.UndoStack.CanUndo() { buf.Undo(win) } return nil } // TODO: Implement count? type Redo struct{} func (a Redo) Execute(m Model) tea.Cmd { win := m.ActiveWindow() buf := m.ActiveBuffer() if buf.UndoStack.CanRedo() { buf.Redo(win) } return nil }