Skip to content

Conversation

@pdmccormick
Copy link

I've made some modifications to linenoise to allow it to be used with an asynchronous event loop (like poll or select), by refactoring input handling into a state machine to avoid blocking read() calls. I've written a complete example demonstrating the possibilities and usage of the new API.

A downside is the increased size of linenoise.c (now over 1100 lines), and additional API functions to handle the interactions.

If you find this useful or have any feedback, I'd love to hear it! Many thanks for all your work on this very useful library.

Peter

Includes a complete example using poll(2) showing the effect of other
asynchronous activity intermixed with line editing.
@sheerun
Copy link

sheerun commented Sep 9, 2013

Thank you for this code. I get "linenoise_example_nonblock(43530,0x7fff73f6b310) malloc: *** error for object 0x7faa00000000: pointer being freed was not allocated" though when typing + enter fast.

@pdmccormick
Copy link
Author

Multiple consecutive enters on empty lines also triggers a crash on linenoise.c:638 (when history_len becomes negative.) I am investigating further!

@sheerun
Copy link

sheerun commented Sep 10, 2013

Maybe it's worth noticing that it crashed for me even without enabling history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants