peterh / liner

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

Could this be used to edit a line of text? #74

Closed gammons closed 8 years ago

gammons commented 8 years ago

Hi there,

I am working on a simple terminal-based todolist app, and I'm currently focusing on editing a todo. Ideally for editing I would allow the user to edit the existing todo description by showing it on the screen, something like this:

~ todo edit 56
> have lunch with @frank due tomorrow <cursor here>

The user could backspace, etc or edit text on the screen. I've been looking at a few golang libraries that emulate readline but don't quite do exactly what I need above. I am wondering if this is something that I could use liner to do.

It's almost like I need to prompt the user with the exiting todo text, but obviously liner would not allow the user to backspace or use the left arrow key to edit the todo.

Anyways, I know this isn't an issue with liner. I just figured I'd reach out to see if this is something you might be able to point me in the right direction. Thanks so much!

peterh commented 8 years ago

This has been suggested before, in #38 and #44. It should be relatively straight forward to implement, but nobody has sent a pull request yet.

About the closest you can get with the current code is to seed the history buffer, so the user can find it quickly with up, tab, or Ctrl-R.

Sorry, I'm not familiar with the other libraries that are available. No doubt there exists one more suited to your needs.