@@ -19,6 +19,7 @@ type editor struct {
1919 err error
2020 save bool
2121 textarea textarea.Model
22+ title string
2223}
2324
2425type cancelError struct {}
@@ -61,7 +62,7 @@ func (e editor) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6162
6263 case tea.WindowSizeMsg :
6364 e .textarea .SetWidth (msg .Width )
64- e .textarea .SetHeight (msg .Height - 3 ) // Negative height works.
65+ e .textarea .SetHeight (msg .Height - 2 ) // Negative height works.
6566 }
6667
6768 e .textarea , cmd = e .textarea .Update (msg )
@@ -74,11 +75,11 @@ func (e editor) View() string {
7475 banner = bannerSave
7576 }
7677
77- return fmt .Sprintf ("\n % s\n \n %s" , e .textarea .View (), banner )
78+ return fmt .Sprintf ("%q % s\n \n %s" , e .title , banner , e . textarea .View ())
7879}
7980
80- // Edit presents an editor with the given initial content and returns the edited text.
81- func Edit (initial string , save bool ) (string , error ) {
81+ // Edit presents an editor with a given title and initial content and returns the edited text.
82+ func Edit (title , initial string , save bool ) (string , error ) {
8283 if len (initial ) > editorCharLimit {
8384 return "" , fmt .Errorf ("initial text too long" )
8485 }
@@ -99,6 +100,7 @@ func Edit(initial string, save bool) (string, error) {
99100
100101 e := editor {
101102 save : save ,
103+ title : title ,
102104 textarea : ta ,
103105 }
104106
0 commit comments