43 lines
856 B
Go
43 lines
856 B
Go
package motion
|
|
|
|
import (
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"git.gophernest.net/azpect/TextEditor/internal/action"
|
|
)
|
|
|
|
// MoveToTop implements Motion (gg)
|
|
type MoveToTop struct{}
|
|
|
|
func (a MoveToTop) Execute(m action.Model) tea.Cmd {
|
|
m.SetCursorY(0)
|
|
m.ClampCursorX()
|
|
return nil
|
|
}
|
|
|
|
// MoveToBottom implements Motion (G)
|
|
type MoveToBottom struct{}
|
|
|
|
func (a MoveToBottom) Execute(m action.Model) tea.Cmd {
|
|
m.SetCursorY(m.LineCount() - 1)
|
|
m.ClampCursorX()
|
|
return nil
|
|
}
|
|
|
|
// MoveToLineStart implements Motion (0)
|
|
type MoveToLineStart struct{}
|
|
|
|
func (a MoveToLineStart) Execute(m action.Model) tea.Cmd {
|
|
m.SetCursorX(0)
|
|
m.ClampCursorX()
|
|
return nil
|
|
}
|
|
|
|
// MoveToLineEnd implements Motion ($)
|
|
type MoveToLineEnd struct{}
|
|
|
|
func (a MoveToLineEnd) Execute(m action.Model) tea.Cmd {
|
|
m.SetCursorX(len(m.Line(m.CursorY())))
|
|
m.ClampCursorX()
|
|
return nil
|
|
}
|