geertjohan / go.linenoise Goto Github PK
View Code? Open in Web Editor NEWLinenoise is a lightweight readline library.
License: BSD 2-Clause "Simplified" License
Linenoise is a lightweight readline library.
License: BSD 2-Clause "Simplified" License
Not sure this is really a bug for go-linenoise, but if one has an uncontrolled panic then stdin
is left in raw mode, messing up the terminal. Maybe simply warn about this possibility?
Note that in the C version of linenoise, the callback can get the cursor position.
This is curcial in order to implement completion correctly.
Thanks BTW for a most useful binding! It would be useful if we could detect that the user has closed stdin with ctrl-D or wants to escape with ctrl-C. Both of these make the original linenoise
function return NULL
. But Go strings are not nil-able; there is no way to tell difference between user pressing empty line and user having cancelled the session with these keys.
Now 1st prize is not breaking the existing API, so I thought one could represent 'end-of-input/session' with a special string. One I tried was "\000" which has length 1 (this is not C ;)) and where s[0]==0
.
Another solution is to extend the API and have a linenoise.LineBytes
(or whatever, I'm not talented at naming things) which returns a []byte
value, which can be easily converted into a string and is nil-able.
Thoughts? Otherwise people are going to be frustrated if they can't get out of a session with the usual keys and have to kill the terminal......
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.