feat(textarea): add ScrollYOffset and ScrollPosition methods

Signed-off-by: Liam Stanley <liam@liam.sh>
This commit is contained in:
Liam Stanley
2025-09-01 09:36:08 -04:00
committed by Christian Rocha
parent 601216f68e
commit c690ea5e0f
+13 -1
View File
@@ -591,11 +591,23 @@ func (m *Model) LineCount() int {
return len(m.value)
}
// Line returns the line position.
// Line returns the row position of the cursor.
func (m Model) Line() int {
return m.row
}
// ScrollYOffset returns the Y offset (top row) index of the current view, which
// can be used to calculate the current scroll position.
func (m Model) ScrollYOffset() int {
return m.viewport.YOffset()
}
// ScrollPercent returns the amount of the textarea that is currently scrolled
// through, clamped between 0 and 1.
func (m Model) ScrollPercent() float64 {
return m.viewport.ScrollPercent()
}
// CursorDown moves the cursor down by one line.
// Returns whether or not the cursor blink should be reset.
func (m *Model) CursorDown() {