Skip to content

Commit

Permalink
Implement multi-line prompt for text templates
Browse files Browse the repository at this point in the history
Resolves #444
  • Loading branch information
martinhpedersen committed Dec 13, 2024
1 parent 98e36ad commit 855c867
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions internal/forms/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/la5nta/wl2k-go/fbb"

"github.com/la5nta/pat/internal/debug"
"github.com/la5nta/pat/internal/editor"
)

// Message represents a concrete message compiled from a template
Expand Down Expand Up @@ -193,9 +194,19 @@ func (b messageBuilder) scanAndBuild(path string) (Message, error) {
// Prompts (mostly found in text templates)
if b.Interactive {
lineTmpl = promptAsks(lineTmpl, func(a Ask) string {
// TODO: Handle a.Multiline as we do message body
fmt.Printf(a.Prompt + " ")
ans := b.FormsMgr.config.LineReader()
var ans string
if a.Multiline {
fmt.Println(a.Prompt + " (Press ENTER to start external editor)")
b.FormsMgr.config.LineReader()
var err error
ans, err = editor.EditText("")
if err != nil {
log.Fatalf("Failed to start text editor: %v", err)
}
} else {
fmt.Printf(a.Prompt + " ")
ans = b.FormsMgr.config.LineReader()
}
if a.Uppercase {
ans = strings.ToUpper(ans)
}
Expand Down

0 comments on commit 855c867

Please sign in to comment.