@@ -133,6 +133,13 @@ type LineInfo struct {
133 CharOffset int
133 CharOffset int
136+// PromptInfo is a struct that can be used to store information about the
138+type PromptInfo struct {
136// CursorStyle is the style for real and virtual cursors.
143// CursorStyle is the style for real and virtual cursors.
137type CursorStyle struct {
144type CursorStyle struct {
138 // Style styles the cursor block.
145 // Style styles the cursor block.
@@ -287,7 +294,7 @@ type Model struct {
288 // If promptFunc is set, it replaces Prompt as a generator for
295 // If promptFunc is set, it replaces Prompt as a generator for
289 // prompt strings at the beginning of each line.
296 // prompt strings at the beginning of each line.
290− promptFunc func(line int, focused bool) string
297+ promptFunc func(PromptInfo) string
292 // promptWidth is the width of the prompt.
299 // promptWidth is the width of the prompt.
293 promptWidth int
300 promptWidth int
@@ -983,14 +990,14 @@ func (m Model) Width() int {
983 return m.width
990 return m.width
986−// moveToBegin moves the cursor to the beginning of the input.
993+// MoveToBegin moves the cursor to the beginning of the input.
987−func (m *Model) moveToBegin() {
994+func (m *Model) MoveToBegin() {
988 m.row = 0
995 m.row = 0
989 m.SetCursorColumn(0)
996 m.SetCursorColumn(0)
992−// moveToEnd moves the cursor to the end of the input.
999+// MoveToEnd moves the cursor to the end of the input.
993−func (m *Model) moveToEnd() {
1000+func (m *Model) MoveToEnd() {
994 m.row = len(m.value) - 1
1001 m.row = len(m.value) - 1
995 m.SetCursorColumn(len(m.value[m.row]))
1002 m.SetCursorColumn(len(m.value[m.row]))
@@ -1052,7 +1059,7 @@ func (m *Model) SetWidth(w int) {
1052// promptWidth, it will be padded to the left. If it returns a prompt that is
1059// promptWidth, it will be padded to the left. If it returns a prompt that is
1053// longer, display artifacts may occur; the caller is responsible for computing
1060// longer, display artifacts may occur; the caller is responsible for computing
1054// an adequate promptWidth.
1061// 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) {
1056 m.promptFunc = fn
1063 m.promptFunc = fn
1057 m.promptWidth = promptWidth
1064 m.promptWidth = promptWidth
@@ -1170,9 +1177,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
1170 case key.Matches(msg, m.KeyMap.WordBackward):
1177 case key.Matches(msg, m.KeyMap.WordBackward):
1171 m.wordLeft()
1178 m.wordLeft()
1172 case key.Matches(msg, m.KeyMap.InputBegin):
1179 case key.Matches(msg, m.KeyMap.InputBegin):
1173− m.moveToBegin()
1180+ m.MoveToBegin()
1174 case key.Matches(msg, m.KeyMap.InputEnd):
1181 case key.Matches(msg, m.KeyMap.InputEnd):
1175− m.moveToEnd()
1182+ m.MoveToEnd()
1176 case key.Matches(msg, m.KeyMap.LowercaseWordForward):
1183 case key.Matches(msg, m.KeyMap.LowercaseWordForward):
1177 m.lowercaseRight()
1184 m.lowercaseRight()
1178 case key.Matches(msg, m.KeyMap.UppercaseWordForward):
1185 case key.Matches(msg, m.KeyMap.UppercaseWordForward):
@@ -1320,7 +1327,10 @@ func (m Model) promptView(displayLine int) (prompt string) {
1320 if m.promptFunc == nil {
1327 if m.promptFunc == nil {
1321 return prompt
1328 return prompt
1323− prompt = m.promptFunc(displayLine, m.focus)
1330+ prompt = m.promptFunc(PromptInfo{
1331+ LineNumber: displayLine,
1324 width := lipgloss.Width(prompt)
1334 width := lipgloss.Width(prompt)
1325 if width < m.promptWidth {
1335 if width < m.promptWidth {
1326 prompt = fmt.Sprintf("%*s%s", m.promptWidth-width, "", prompt)
1336 prompt = fmt.Sprintf("%*s%s", m.promptWidth-width, "", prompt)