Closed lucacervasio closed 10 years ago
Thanks for the pull request.
Unfortunately, I cannot accept it, because it cannot work with TERM=dumb.
(There are also a few bugs, such as []line
not being cleared upon return from Prompt
, and PrintAbovePrompt
showing a phantom prompt even if nothing is actually inside Prompt
. I suspect there is also a race condition if you call PrintAbovePrompt
during a refresh
, but I haven't looked at it too closely)
In my applications, I send messages on a (buffered) channel to the UI goroutine, which drains the channel before calling Prompt. The user won't see messages as they happen, but generally the messages are shown "soon enough" in a truly interactive session.
It occurs to me that if you wanted, you could expose a chan string
in State
that is drained upon entry and exit to Prompt
, and optionally added to the select in input.go (where it would clear the line, output the string, and then return winch
) for immediate output on some platforms. The application would still be responsible for draining messages whenever it is not inside Prompt
, however, so I'm not sure it's worth the extra complexity.
I submitted #119, anyone here interested to review?
Hi, I'm using your package to implement a CLI. While writing on the prompt line, I dump logs on the screen (using
fmt.Println
) and they overwrite the prompt, which is annoying to me.So I tried to improve the package adding a
line.PrintAbovePrompt
func. Hope I didn't mess up the code. Let me know what you think and in case I'll try to correct.Thanks Luca
Here a working example (I'm importing
github.com/lucacervasio/liner
just because I forked your repo for the PR).