Support bestline for line editing #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
git clone -b lib https://github.com/MaxGyver83/bestline.git cd bestline make libbestline.so sudo cp libbestline.so /usr/local/lib/ sudo cp bestline.h /usr/local/include/UPDATE (for people finding this page): Since these changes (jart/bestline#33 and jart/bestline#34) have been merged into bestline's
masterbranch, you don't need my patched version anymore. Just clone https://github.com/jart/bestline.git instead.This patch adds a position argument to bestline's
completionfunction. 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 amaketarget 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:
cd /path/to/rc make EDIT=bestlineFeatures
Bestline states to be "nearly as good as gnu readline".
Some differences compared to readline:
Alt+.in readline).history-search-backward). UseCtrl+rinstead.Ctrl+w w,Ctrl+yinserts only the first word (with readline it inserts both words).Bonus in this integration:
~/dirto$HOME/dir.