peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.04k stars 132 forks source link

Flag to prevent final newline #53

Closed mhagander closed 8 years ago

mhagander commented 8 years ago

It would be great if there was a flag to set either globally or on the call to Prompt to prevent the final newline (that's written on line.go line 515, if I read the code correctly).

I've got an app where I'd really prefer that the whole output didn't shift up by one line once enter is hit after the prompt if it's on the last line.

peterh commented 8 years ago

Thanks for the feature request.

It's not possible when $TERM = dumb, and I'm hesitant to add more options that don't always work.

If the terminal isn't a scrolling list of previous commands (interspersed with the results of those commands), you probably want something based on curses/ncurses instead of liner.

mhagander commented 8 years ago

I definitely see that argument, but I'm not sure why it wouldn't work in a dumb terminal.

As long as the calling process takes care of actually printing the newline it should work.

So I think it would still be a useful feature, but you may also be right in your comment that I should do some more research on ncruses based interfaces. The app started out being much simpler than it is now, which is why I got hooked on liner in the beginning, and it does work very well :)

But thanks for your consideration!

peterh commented 8 years ago

When $TERM=dumb, liner does not echo the user's input, it is echoed by the terminal. Including the newline. There is nothing liner can do to prevent that.