* Add vi W motion
This moves forward by WORD which is a sequence of non-blank characters
separated by whitespace.
* Add vi B motion
Support deleting backward for word (db) and WORD (dB)
* Add vi E motion
Makes the history querying structs and enums pub as it seems reasonable
for now. Useful to create nushells `history` command.
Might make sense to change that API to something simpler cleaner later.
Changes the history API to support different storage backends and more rich information to be used as metadata/filtering criterions.
Includes a SQLite backed history with additional fields and ports the simple `FileBackedHistory` format consistent.
Includes a `HistoryCursor` to abstract the internal interactive browsing.
Updates `History` trait to cover the API to load and store to the storage backend.
Commits
* basic sqlite history
* fix test compilation
* final touches for MVP
* better documentation
* fix for empty history
* partial change to non-generic history
* mostly working
* fix tests and ci
* fixes, format
* move history item to new file
* fix some comments, fix test compile errors
todo: fix tests
* ci features matrix
* fix index creation
* fix file-based tests
* move logic for not saving empty entries to engine
* fix update last command on empty, set up application_id and check version
* add specific error variants
* format
* fix compile errors
* fix fmt
* sqlite with bashisms
* hide with features
* cargo fmt
* improve performance of bashisms selectors
* Style: Remove commented out code
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Fernando Herrera <fernando.j.herrera@gmail.com>
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
* Fix clippy lints that will become warnings
clippy from the nightly future
* Revent false positive `.to_string()` removal
This [lint](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned) is nasty as `ansi_term` and thus `nu_ansi_term` on their `AnsiGenericString` implement `Display` to apply the styling and `Deref` to just return the underlying `&str`.
As [`ToString` is implemented for any `T: Display + ?Sized` ](https://doc.rust-lang.org/std/string/trait.ToString.html#impl-ToString-6) the to_string implementation relies on the `Display` defined for the type alias `AnsiString` and not on the `impl ToString for str` for the `&str` accessible through `Deref`.
Applying the suggested fix will remove syntax highlighting!!!
* don't panic whan parent directory is not exists
* no need to check parent exists
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Group the common keybindings into three functions:
- `add_common_control_bindings`
- `add_common_navigation_bindings`
- `add_common_edit_bindings`
Vi normal uses the first two
Vi insert uses all of them
Emacs extends upon those
Goals:
- Provide pointers to further reading for folks not too familiar with the
problem set on the terminal
- Explain the architecture a bit to get people up to speed
The code didn't account for the index
and the indicator in its calculation for
the number of lines in the list_menu.
Now the unicode_width of the indicator and the
number of digits of the index are accountet for.
Amortized growing of the history based on the amount read from the file
is cheap. Allocating for the capacity is expensive and can cause OOM for
large capacities.
Fix for nushell/nushell#5593
* Fix vi-mode word motions
The 'w' motion goes to the beginning of the next word to the right, not
the end. The 'e' motion, which is introduced here, goes to the end, but
lands on the last character, not after it.
* Add test case for `move_word_right_end`
Ensure Unicode safety as well as that the cursor will move to the next
word end when already at a word end
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
- Fix README and lib.rs code examples
- Add missing doctests
- Fix the completion example in README
- Fix the edit mode example
- Try to run more of the doctests
- They should not block with the IO loop or do file IO as this was failing the CI
Adding a space when accepting a completion avoids rerunning the same already accepted completion when working with a space tokenized language like nushell
* Add append_whitespace choice for suggestion
Signed-off-by: gipsyh <gipsyh.icu@gmail.com>
* Update src/completion/base.rs
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
* Update src/menu/columnar_menu.rs
Signed-off-by: gipsyh <gipsyh.icu@gmail.com>
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
- vim's 'S' binding
- copy char while deleting in vi mode
- Fixes the behavior of `x` so the removed char/grapheme can be pasted with `p`
- vim's 's' binding
- Minor clarifications by @sholderbach
- Fix doccomments and clarify an enum variant's name
Rebased the commits from #406
Co-authored-by: zim0369 <zim@onionmail.org>
Clearing the scrollback did not work on most terminal emulators.
By reordering two ANSI control sequences, this seems to work on Linux
with most terminal emulators.
Due to a missing implementation of the exact details this will probably
not clear the scrollback under the old Windows API.
Related to the discussion in #120 and nushell/nushell#5089
* Change the CI to use caching
This tries to replicate the cargo caching techniques developed by @rgwood on the [nushell](https://github.com/nushell/nushell) repo to save time (and energy) on the CI pipeline.
## Further reading:
[Reilly's blog post](https://www.reillywood.com/blog/rust-faster-ci/)
* Simplify to one job per build matrix combination
This should save some setup time.
And as rebuilds and tests of reedline are fast enough we can just be parallel over the feature
configurations.
- Remove the `Signal::CtrlL` as it requires explicit handling and
cooperation but we offer configurable keybindings already
- Default keybinding of `Ctrl-l` is `ReedlineEvent::ClearScreen` that
directly performs the scrollback buffer preserving clear of the current
screen.
- Add `ReedlineEvent::ClearScrollback` to perform screen clearing with
removal of the scrollback buffer. (Demo will now do that on clear as
seen in bash, zsh etc.)
Fixes#120
Helps with nushell/nushell#5089
Uses the system newline separator
Example in main with `Alt+Enter` (according to @fdncred `cmd-option-enter` or `shift-option-enter` on macOS to get the same key event)
* Implement vi's `I` normal mode binding to start insert mode at the lines start.
* Use `MoveToLineStart/End` instead to correctly work on lines
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Default constructor created a Hinter and Validator.
Disabling those required writing a noop version of the trait (see #392 for an example).
Now they are off by default and can be added or removed via the
"builder" pattern.
Changes the completer trait to take a mutable reference of itself on
calling `Completer::complete`
This enables the `Completer` to do caching or other smart things on the fly.
* generic reedline menus
* change word in description
* correct tests in examples
* corrected menu names
* renamed menu
* option for menus to take full line buffer
* corrected list menu insertion