@@ -133,6 +133,13 @@ type LineInfo struct {
133133 CharOffset int
134134}
135135
136+// PromptInfo is a struct that can be used to store information about the
137+// prompt.
138+type PromptInfo struct {
139+ LineNumber int
140+ Focused bool
141+}
142+
136143// CursorStyle is the style for real and virtual cursors.
137144type CursorStyle struct {
138145 // Style styles the cursor block.
@@ -287,7 +294,7 @@ type Model struct {
287294
288295 // If promptFunc is set, it replaces Prompt as a generator for
289296 // prompt strings at the beginning of each line.
290− promptFunc func(line int, focused bool) string
297+ promptFunc func(PromptInfo) string
291298
292299 // promptWidth is the width of the prompt.
293300 promptWidth int
@@ -983,14 +990,14 @@ func (m Model) Width() int {
983990 return m.width
984991}
985992
986−// moveToBegin moves the cursor to the beginning of the input.
987−func (m *Model) moveToBegin() {
993+// MoveToBegin moves the cursor to the beginning of the input.
994+func (m *Model) MoveToBegin() {
988995 m.row = 0
989996 m.SetCursorColumn(0)
990997}
991998
992−// moveToEnd moves the cursor to the end of the input.
993−func (m *Model) moveToEnd() {
999+// MoveToEnd moves the cursor to the end of the input.
1000+func (m *Model) MoveToEnd() {
9941001 m.row = len(m.value) - 1
9951002 m.SetCursorColumn(len(m.value[m.row]))
9961003}
@@ -1052,7 +1059,7 @@ func (m *Model) SetWidth(w int) {
10521059// promptWidth, it will be padded to the left. If it returns a prompt that is
10531060// longer, display artifacts may occur; the caller is responsible for computing
10541061// an adequate promptWidth.
1055−func (m *Model) SetPromptFunc(promptWidth int, fn func(lineIndex int, focused bool) string) {
1062+func (m *Model) SetPromptFunc(promptWidth int, fn func(PromptInfo) string) {
10561063 m.promptFunc = fn
10571064 m.promptWidth = promptWidth
10581065}
@@ -1170,9 +1177,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
11701177 case key.Matches(msg, m.KeyMap.WordBackward):
11711178 m.wordLeft()
11721179 case key.Matches(msg, m.KeyMap.InputBegin):
1173− m.moveToBegin()
1180+ m.MoveToBegin()
11741181 case key.Matches(msg, m.KeyMap.InputEnd):
1175− m.moveToEnd()
1182+ m.MoveToEnd()
11761183 case key.Matches(msg, m.KeyMap.LowercaseWordForward):
11771184 m.lowercaseRight()
11781185 case key.Matches(msg, m.KeyMap.UppercaseWordForward):
@@ -1320,7 +1327,10 @@ func (m Model) promptView(displayLine int) (prompt string) {
13201327 if m.promptFunc == nil {
13211328 return prompt
13221329 }
1323− prompt = m.promptFunc(displayLine, m.focus)
1330+ prompt = m.promptFunc(PromptInfo{
1331+ LineNumber: displayLine,
1332+ Focused: m.focus,
1333+ })
13241334 width := lipgloss.Width(prompt)
13251335 if width < m.promptWidth {
13261336 prompt = fmt.Sprintf("%*s%s", m.promptWidth-width, "", prompt)