@@ -109,6 +109,7 @@ type Style struct {
109
109
LineNumber lipgloss.Style
110
110
Placeholder lipgloss.Style
111
111
Prompt lipgloss.Style
112
+ NextPrompt lipgloss.Style
112
113
Text lipgloss.Style
113
114
}
114
115
@@ -123,6 +124,10 @@ type Model struct {
123
124
EndOfBufferCharacter rune
124
125
KeyMap KeyMap
125
126
127
+ // NextPrompt, if set, is used for all lines
128
+ // except the first.
129
+ NextPrompt string
130
+
126
131
// Styling. FocusedStyle and BlurredStyle are used to style the textarea in
127
132
// focused and blurred states.
128
133
FocusedStyle Style
@@ -219,6 +224,7 @@ func DefaultStyles() (Style, Style) {
219
224
LineNumber : lipgloss .NewStyle ().Foreground (lipgloss.AdaptiveColor {Light : "249" , Dark : "7" }),
220
225
Placeholder : lipgloss .NewStyle ().Foreground (lipgloss .Color ("240" )),
221
226
Prompt : lipgloss .NewStyle ().Foreground (lipgloss .Color ("7" )),
227
+ NextPrompt : lipgloss .NewStyle ().Foreground (lipgloss .Color ("7" )),
222
228
Text : lipgloss .NewStyle (),
223
229
}
224
230
blurred := Style {
@@ -229,6 +235,7 @@ func DefaultStyles() (Style, Style) {
229
235
LineNumber : lipgloss .NewStyle ().Foreground (lipgloss.AdaptiveColor {Light : "249" , Dark : "7" }),
230
236
Placeholder : lipgloss .NewStyle ().Foreground (lipgloss .Color ("240" )),
231
237
Prompt : lipgloss .NewStyle ().Foreground (lipgloss .Color ("7" )),
238
+ NextPrompt : lipgloss .NewStyle ().Foreground (lipgloss .Color ("7" )),
232
239
Text : lipgloss .NewStyle ().Foreground (lipgloss.AdaptiveColor {Light : "245" , Dark : "7" }),
233
240
}
234
241
@@ -682,7 +689,7 @@ func (m *Model) SetWidth(w int) {
682
689
// Account for base style borders and padding.
683
690
inputWidth -= m .style .Base .GetHorizontalFrameSize ()
684
691
685
- inputWidth -= rw .StringWidth (m .Prompt )
692
+ inputWidth -= max ( rw .StringWidth (m .Prompt ), rw . StringWidth ( m . NextPrompt ) )
686
693
m .width = clamp (inputWidth , minWidth , maxWidth )
687
694
}
688
695
@@ -848,6 +855,11 @@ func (m Model) View() string {
848
855
849
856
var newLines int
850
857
858
+ prompt , nextPrompt := m .getPromptStrings ()
859
+ prompt = m .style .Prompt .Render (prompt )
860
+ nextPrompt = m .style .NextPrompt .Render (nextPrompt )
861
+
862
+ firstDisplayLine := true
851
863
for l , line := range m .value {
852
864
wrappedLines := wrap (line , m .width )
853
865
@@ -858,7 +870,12 @@ func (m Model) View() string {
858
870
}
859
871
860
872
for wl , wrappedLine := range wrappedLines {
861
- s .WriteString (style .Render (m .style .Prompt .Render (m .Prompt )))
873
+ selectedPrompt := nextPrompt
874
+ if firstDisplayLine {
875
+ selectedPrompt = prompt
876
+ firstDisplayLine = false
877
+ }
878
+ s .WriteString (style .Render (selectedPrompt ))
862
879
863
880
if m .ShowLineNumbers {
864
881
if wl == 0 {
@@ -907,7 +924,7 @@ func (m Model) View() string {
907
924
// Always show at least `m.Height` lines at all times.
908
925
// To do this we can simply pad out a few extra new lines in the view.
909
926
for i := 0 ; i < m .height ; i ++ {
910
- s .WriteString (m . style . Prompt . Render ( m . Prompt ) )
927
+ s .WriteString (nextPrompt )
911
928
912
929
if m .ShowLineNumbers {
913
930
lineNumber := m .style .EndOfBuffer .Render ((fmt .Sprintf (m .lineNumberFormat , string (m .EndOfBufferCharacter ))))
@@ -920,6 +937,22 @@ func (m Model) View() string {
920
937
return m .style .Base .Render (m .viewport .View ())
921
938
}
922
939
940
+ func (m Model ) getPromptStrings () (prompt , nextPrompt string ) {
941
+ prompt = m .Prompt
942
+ nextPrompt = m .NextPrompt
943
+ if nextPrompt == "" {
944
+ return prompt , prompt
945
+ }
946
+ pl := rw .StringWidth (prompt )
947
+ npl := rw .StringWidth (nextPrompt )
948
+ if pl > npl {
949
+ nextPrompt = fmt .Sprintf ("%*s" , pl - npl , "" ) + nextPrompt
950
+ } else if npl > pl {
951
+ prompt = fmt .Sprintf ("%*s" , npl - pl , "" ) + prompt
952
+ }
953
+ return prompt , nextPrompt
954
+ }
955
+
923
956
// placeholderView returns the prompt and placeholder view, if any.
924
957
func (m Model ) placeholderView () string {
925
958
var (
@@ -928,7 +961,9 @@ func (m Model) placeholderView() string {
928
961
style = m .style .Placeholder .Inline (true )
929
962
)
930
963
931
- prompt := m .style .Prompt .Render (m .Prompt )
964
+ prompt , nextPrompt := m .getPromptStrings ()
965
+
966
+ prompt = m .style .Prompt .Render (prompt )
932
967
s .WriteString (m .style .CursorLine .Render (prompt ))
933
968
934
969
if m .ShowLineNumbers {
@@ -943,9 +978,10 @@ func (m Model) placeholderView() string {
943
978
s .WriteString (m .style .CursorLine .Render (style .Render (p [1 :] + strings .Repeat (" " , max (0 , m .width - rw .StringWidth (p ))))))
944
979
945
980
// The rest of the new lines
981
+ nextPrompt = m .style .NextPrompt .Render (nextPrompt )
946
982
for i := 1 ; i < m .height ; i ++ {
947
983
s .WriteRune ('\n' )
948
- s .WriteString (prompt )
984
+ s .WriteString (nextPrompt )
949
985
950
986
if m .ShowLineNumbers {
951
987
eob := m .style .EndOfBuffer .Render ((fmt .Sprintf (m .lineNumberFormat , string (m .EndOfBufferCharacter ))))
0 commit comments