Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for emacs-like line editing. #201

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

s10e-g
Copy link

@s10e-g s10e-g commented May 1, 2023

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

  • C-a move cursor to the beginning of the line
  • C-e move cursor to the end of the line
  • C-b move cursor backward
  • C-f move cursor forward
  • C-n get the next history
  • C-p get the previous history
  • C-t transpose chars
  • C-u unix line discard
  • C-k kill line
  • C-w unix word rubout
  • C-y yank (only one buffer. kill ring is not needed for now since M-y cannot be captured by read().)
  • 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
Copy link
Author

s10e-g commented May 1, 2023

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?

@daniele77
Copy link
Owner

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.

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