cli icon indicating copy to clipboard operation
cli copied to clipboard

Add basic support for emacs-like line editing.

Open s10e-g opened this issue 2 years ago • 2 comments

Fix part of #152 by implementing some of the readline emacs mode line editing shortcuts on Linux local session and VT100 compatible terminal.

  • [x] C-a move cursor to the beginning of the line
  • [x] C-e move cursor to the end of the line
  • [x] C-b move cursor backward
  • [x] C-f move cursor forward
  • [x] C-n get the next history
  • [x] C-p get the previous history
  • [x] C-t transpose chars
  • [x] C-u unix line discard
  • [x] C-k kill line
  • [x] C-w unix word rubout
  • [x] C-y yank (only one buffer. kill ring is not needed for now since M-y cannot be captured by read().)
  • [x] C-l clear screen (only on VT100 compatible terminal)

TODO:

  • [ ] C-r reverse search history
  • [ ] Shortcuts with alt (cannot be captured by read())

s10e-g avatar May 01 '23 11:05 s10e-g

Ultimately this function should be implemented using GNU readline or curses / unibilium. I fully understand that you want this library to remain independent of third-party libraries, but since C++ itself doesn't have any knowledge about the terminal, even a simple task like clear screen is not possible without reinventing ncurses.

Maybe it's ok to leave the user an option in the future?

s10e-g avatar May 01 '23 11:05 s10e-g

Thank you for your contribution. I'm against making the cli library dependent on other libraries. The library started with a strong dependency on boost, and I had much pressure to remove that dependency, and it cost me hard work. Now, I definitely do not want to add another dependency.

daniele77 avatar Jun 29 '23 13:06 daniele77