3 ms·
Glad to see this using http://github.com/peterh/liner http://github.com/peterh/liner for interactive line editing. I used that package in an interpreter of my
by frou_dh 9y ago
Glad to see this using http://github.com/peterh/liner http://github.com/peterh/liner for interactive line editing.
I used that package in an interpreter of my own and it works wonderfully to provide `readline` style keyboard interaction in a pure Go program.
- crawshaw 9y agoIt really is an excellent package. Does exactly what it says on the box. I fear I may hit a wall with it eventually. For example, several interesting approaches to https://github.com/neugram/ng/issues/49 https://github.com/neugram/ng/issues/49 would step outside what liner can do. But I'm going to use it as long as I can.
- frou_dh 9y agoAmong other things, I actually modified liner to stop using/swallowing all control codes, and to instead surface some of them to the client program to decide how to respond. e.g. liner stops doing anything with Ctrl-X (0x18 ?) and instead ng could respond to Ctrl-X by writing a docstring to stderr for an identifier under the caret in the input buffer. https://github.com/frou/liner/blob/master/common.go#L208 https://github.com/frou/liner/blob/master/common.go#L208