Move out of Box<dyn Prompt> by using `&dyn Prompt`.
Also use `Cow<str>` instead of `String` for the
`Prompt` return types. Both of this changes permit
the use of reference but most importantly,
it avoids unnecessary clones.
* Revamp Prompt states
The idea here is that what we want to display on the screen which can
impact the prompt should be available as part of the prompt's interface.
So here are the things that can impact what we show with our prompt
- The line-editor can either be in Emacs mode or VI mode (for now)
[These are exclusive to one another]
- The line-editor can be either in editing a command or searching
history mode [These two states are also exclusive]
- Lastly the command can be either single-line or multi-line.
Now all these variables can happen togeter (i.e. they for a cross
prodcut)
- example 1: You can be in vi-normal mode and be editing history search
term and that particular term earlier resulted in a multi-line
command. (So, we need to showcase all these three variations together)
one way to do this is using a struct. I found that it was making the
more frequent case (of being in edit mode) overly complex so I chose to
expose the functionality as separate methonds.
* Cleanup custom strings from engine
* Kickoff testing
* Change interface for insert_char and insert_str
- Renamed insert_char -> insert_char_at
- Renamed insert_str -> insert_str_at, Modified the interface to use
insertion_point instead of insertion_point.offset
- Added insert_char: this also modifies the insertion_point in addition
to chaning the buffer
- Added insert_str: this also modifies the insertion_point in addition
to chaning the buffer
Question: Do we really need insert_char_at and insert_str_at?
* Move backspace and delete to line_buffer
- Rename backspace -> delete_grapheme_left
- Rename delete -> delete_grapheme_right
* Move backspace_word and delete_word to line_buffer
* Move upcasing and lowercasing to line_buffer
* Move swaping operation to line_buffer
* Remove `current_line` and use `get_buffer` instead
* Replace use of `insert_char_at` with `insert_char`
* Replace use of `insert_str_at` with `insert_str`
* Remove redundant setting insertion point to 0
* Doctests for History
* Improve the general documentation of History.
* Doc tests to understand the API.
* Includes regression test to read back correctly from file.
* Run doctests in CI
* Minimal doc comments for Clipboard
* Basic API docs for the most important components
Still work in progress
* Add README and lib.rs docs
* Document more internals to help new contributors
* Doctest linebuffer
* Revert "Doctest linebuffer" for now
This reverts commit 08ff9c152c.
* Format run
The clipboard crate breaks the CI in a non GUI context. Make use of it
optional by feature flag `system_clipboard`.
Clipboard could be changed during runtime based on trait.
Additional fix: read back from system clipboard
* Support history file
History has a new constructor to remember a file to read from/ write to.
Writing is deferred to the Drop.
Binary supports history file via `REEDLINE_HISTFILE` env variable
Additional changes:
Inverted the ordering of the history VecDeque to simplify file IO and
history internals. This makes the search code slightly more brittle.
* Clarify history API
* Harmonize return type of iterators
* Extract history management into struct
* Encapsulates the up/down arrow browsing
* Still fully in-memory but easy to add file based constructors and
flushing
* No further integration with the statefulness of the Ctrl-R search
(yet)
* Add tests to history
* Basic clear
Addresses #28
Succeeds in providing a clear new screen for both the line editing and
reverse search mode.
Solution is conservative and prints more newlines than strictly
necessary as solutions with scrolling didn't seem to work as expected.
* Command based clear
* Redraw prompt indicator after history search
The prompt indicator gets drawn over when searching the history so we
need to restore it when done searching.
Co-authored-by: Jason Rodney Hansen <jasonrodneyhansen@gmail.com>
* Minimal enum to address #18
Reuse outer Result for error handling only pass the special case
signals.
* Restore behavior of shell
* support exit via `exit` or `logout`
* Clear buffer on pressing Ctrl-c
* move one line down on Ctrl-c
* Handling by main maybe suboptimal
* Fix whitespace awareness regression
* Rename special Ctrl key signals