From 696244a1d00760bbf1df8606ab71905b366f03bb Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 10 Jul 2025 09:34:24 -0400 Subject: [PATCH] feat(textarea): expose MoveToBegin and MoveToEnd methods (#809) This commit exposes the MoveToBegin and MoveToEnd methods in the textarea package, allowing users to programmatically move the cursor to the beginning or end of the input text. --- textarea/textarea.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index 3b37789..f4e0fb3 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -983,14 +983,14 @@ func (m Model) Width() int { return m.width } -// moveToBegin moves the cursor to the beginning of the input. -func (m *Model) moveToBegin() { +// MoveToBegin moves the cursor to the beginning of the input. +func (m *Model) MoveToBegin() { m.row = 0 m.SetCursorColumn(0) } -// moveToEnd moves the cursor to the end of the input. -func (m *Model) moveToEnd() { +// MoveToEnd moves the cursor to the end of the input. +func (m *Model) MoveToEnd() { m.row = len(m.value) - 1 m.SetCursorColumn(len(m.value[m.row])) } @@ -1170,9 +1170,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { case key.Matches(msg, m.KeyMap.WordBackward): m.wordLeft() case key.Matches(msg, m.KeyMap.InputBegin): - m.moveToBegin() + m.MoveToBegin() case key.Matches(msg, m.KeyMap.InputEnd): - m.moveToEnd() + m.MoveToEnd() case key.Matches(msg, m.KeyMap.LowercaseWordForward): m.lowercaseRight() case key.Matches(msg, m.KeyMap.UppercaseWordForward):