Closed MaxGyver83 closed 2 months ago
Hi! Thanks for the contribution! In general, these edit libraries are "best effort" and I'm happy to add a new one. I'm curious if there is any automated testing that could be included with this PR. I'm happy to merge without, but I wonder how you tested the library integration.
Yes, I have written some unit tests. They depend on mity/acutest: Simple header-only C/C++ unit testing facility. I guess you don't want to include acutest.h
in the rc
repository. I could omit this file and leave it to future developers/testers to download it themselves. Or I could remove this dependency and use assert
's instead. (No report in this case.) In any case, I need to clean up the tests to make them work everywhere. (For example the command completion depends on the commands available on my laptop.)
I have fixed a bug in edit-bestline.c
that showed up when I cleaned-up the unit tests.
And I have added the unit tests in a separate commit. They can be executed via make run-test-bestline
. This will download the lastest version of acutest.h
.
That's great, thank you!
Support bestline for line editing
bestline is a small line editing library (roughly 3000 lines of code) based on linenoise.
Installation
First, install a patched version of bestline as dynamic library:
This patch adds a position argument to bestline's
completion
function. The cursor position is necessary to decide which part of the current command is to be completed. The cursor position is updated for completion that don't happen at the end of a line. It also adds amake
target for building a dynamic library. (In integrate Antirez's linenoise single file zero conf line editing by rlonstein · Pull Request #5 · rakitzis/rc, it was suggested to provide linenoise as a standalone library.) I'll open a pull request with these changes to bestline.Then, build rc with bestline support:
Features
Bestline states to be "nearly as good as gnu readline".
Some differences compared to readline:
Alt+.
in readline).history-search-backward
). UseCtrl+r
instead.Ctrl+w w
,Ctrl+y
inserts only the first word (with readline it inserts both words).Bonus in this integration:
~/dir
to$HOME/dir
.