56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package action
|
|
|
|
import tea "github.com/charmbracelet/bubbletea"
|
|
|
|
// Quit implements Action (ctrl+c)
|
|
type Quit struct{}
|
|
|
|
func (a Quit) Execute(m Model) tea.Cmd {
|
|
return tea.Quit
|
|
}
|
|
|
|
// Quit implements Action (:)
|
|
type EnterComandMode struct{}
|
|
|
|
func (a EnterComandMode) Execute(m Model) tea.Cmd {
|
|
m.SetMode(CommandMode)
|
|
m.SetCommand("")
|
|
m.SetCommandOutput("")
|
|
m.SetCommandError(nil)
|
|
m.SetCommandCursor(0)
|
|
return nil
|
|
}
|
|
|
|
// Quit implements Action (v)
|
|
type EnterVisualMode struct{}
|
|
|
|
func (a EnterVisualMode) Execute(m Model) tea.Cmd {
|
|
win := m.ActiveWindow()
|
|
win.SetAnchorCol(win.Cursor.Col)
|
|
win.SetAnchorLine(win.Cursor.Line)
|
|
m.SetMode(VisualMode)
|
|
return nil
|
|
}
|
|
|
|
// Quit implements Action (V)
|
|
type EnterVisualLineMode struct{}
|
|
|
|
func (a EnterVisualLineMode) Execute(m Model) tea.Cmd {
|
|
win := m.ActiveWindow()
|
|
win.SetAnchorCol(win.Cursor.Col)
|
|
win.SetAnchorLine(win.Cursor.Line)
|
|
m.SetMode(VisualLineMode)
|
|
return nil
|
|
}
|
|
|
|
// Quit implements Action (ctrl+v)
|
|
type EnterVisualBlockMode struct{}
|
|
|
|
func (a EnterVisualBlockMode) Execute(m Model) tea.Cmd {
|
|
win := m.ActiveWindow()
|
|
win.SetAnchorCol(win.Cursor.Col)
|
|
win.SetAnchorLine(win.Cursor.Line)
|
|
m.SetMode(VisualBlockMode)
|
|
return nil
|
|
}
|