34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package motion
|
|
|
|
import (
|
|
"git.gophernest.net/azpect/TextEditor/internal/action"
|
|
"git.gophernest.net/azpect/TextEditor/internal/core"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
)
|
|
|
|
// MoveCommandLeft implements Motion - moves cursor left in command line.
|
|
type MoveCommandLeft struct{}
|
|
|
|
// MoveCommandLeft.Execute: Moves the command line cursor one position to the left.
|
|
func (a MoveCommandLeft) Execute(m action.Model) tea.Cmd {
|
|
// The set function handles bounds
|
|
m.SetCommandCursor(m.CommandCursor() - 1)
|
|
return nil
|
|
}
|
|
|
|
// MoveCommandLeft.Type: Returns CharwiseExclusive for command line motion.
|
|
func (a MoveCommandLeft) Type() core.MotionType { return core.CharwiseExclusive }
|
|
|
|
// MoveCommandRight implements Motion - moves cursor right in command line.
|
|
type MoveCommandRight struct{}
|
|
|
|
// MoveCommandRight.Execute: Moves the command line cursor one position to the right.
|
|
func (a MoveCommandRight) Execute(m action.Model) tea.Cmd {
|
|
// The set function handles bounds
|
|
m.SetCommandCursor(m.CommandCursor() + 1)
|
|
return nil
|
|
}
|
|
|
|
// MoveCommandRight.Type: Returns CharwiseExclusive for command line motion.
|
|
func (a MoveCommandRight) Type() core.MotionType { return core.CharwiseExclusive }
|