-
Notifications
You must be signed in to change notification settings - Fork 358
Show multiline's answer in new line #336
Comments
And it just needs to add a |
So, any idea? |
Thanks for the ping @AielloChan! It's been hard to wrangle all of the different notifications I get so I appreciate your patience. At the moment, a change like this would be considered a break in the API. I know its not the answer you or the others want to hear but I dont think we can change this at the moment. I will leave the issue open and tag it for future consideration though! |
Okay, this would be the best choice for now. 😄 |
I agree with @AielloChan the current behavior bugged me as-well. I am just staring with Go so am I far from being one which could provide any implementation advice nor I fully understand how survey is internally working. Given the templating engine of Go and an extension of PromptConfig it should be possible to flag this feature. So no integration test on larger companies will break |
After checking the source code I guess From fee69eed1c232b6f3d6f84ac6a5a8f3ceea52f49 Mon Sep 17 00:00:00 2001
From: Christian Ege <[email protected]>
Date: Mon, 11 Apr 2022 18:20:25 +0000
Subject: [PATCH] Proposal for adding a newline after Inputs
Signed-off-by: Christian Ege <[email protected]>
---
input.go | 2 ++
multiline.go | 9 +++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/input.go b/input.go
index dbc7c08..453c6c8 100644
--- a/input.go
+++ b/input.go
@@ -26,6 +26,7 @@ type Input struct {
options []core.OptionAnswer
selectedIndex int
showingHelp bool
+ PrintNewline bool
}
// data available to the templates when processing
@@ -60,6 +61,7 @@ var InputQuestionTemplate = `
{{- if and .Suggest }}{{color "cyan"}}{{ print .Config.SuggestInput }} for suggestions{{end -}}
]{{color "reset"}} {{end}}
{{- if .Default}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}}
+ {{- if .PrintNewline}}{{"\n"}}{{end}}
{{- end}}`
func (i *Input) onRune(config *PromptConfig) terminal.OnRuneFn {
diff --git a/multiline.go b/multiline.go
index bff9622..a4c4d5a 100644
--- a/multiline.go
+++ b/multiline.go
@@ -8,9 +8,10 @@ import (
type Multiline struct {
Renderer
- Message string
- Default string
- Help string
+ Message string
+ Default string
+ Help string
+ PrintNewline bool
}
// data available to the templates when processing
@@ -32,7 +33,7 @@ var MultilineQuestionTemplate = `
{{- if .Answer }}{{ "\n" }}{{ end }}
{{- else }}
{{- if .Default}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}}
- {{- color "cyan"}}[Enter 2 empty lines to finish]{{color "reset"}}
+ {{- color "cyan"}}[Enter 2 empty lines to fonish]{{color "reset"}}{{- if .PrintNewline}}{{"\n"}}{{end}}
{{- end}}`
func (i *Multiline) Prompt(config *PromptConfig) (interface{}, error) {
--
2.30.2 Of course the tests are missing. But would that be something acceptable? |
I'm running into this styling issue myself as well currently. The solution proposed by @graugans seems like a good option to me. What do you think @AlecAivazis? |
+1 |
@AlecAivazis would a PR just adding that missing line break to the go template be acceptable? I don't mind submitting that. I noticed pterm input and some other tools do this so it's only the survey library that I've noticed the multiline editing on the same line happen in. It's a minor "nit" but it's sufficiently jarring to users that I figured I'd see if I could help get this through. |
Now, it looks wired:
How about showing the answer in a new line, just like below:
The text was updated successfully, but these errors were encountered: