* make multiline prompt color configurable
* remove unnused use statements
* minor comment update
* Clippy fix
new lints from rust 1.67
* Cargo fmt
---------
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
* custom validator and prompt
* Split prompt and validator demo into two files
Also add info text when running
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
* Fix the additional moves of normal mode `hjkl`
Fixesnushell/nushell#6991
Allows using `l` to complete the history hint in normal mode
Support menu navigation with `hjkl` in vi normal mode
Adjusts tests
* Fix clippy
Parameter only used in recursion
* Split the main example binary into examples
Separate fully featured demo from keybinding listing and event listener
Allows to make `gethostname` dev-dependency
* Clippy fix in examples
Alternative to #503
Using `actions-rust-lang` instead of `actions-rs` for
setup. (nushell uses them for setup with integrated caching)
Remove build stage as this should also be covered by test.
clippy --all to see if this checks the examples as well.
7d721a1 introduced the sqlite-dynlib feature, but using it in places
where sqlite is currently used was not possible, because the cfg gates
weren't adjusted yet. This commit replaces each `feature = "sqlite"`
with `any(feature = "sqlite",feature = "sqlite-dynlib")`, meaning that
it doesn't matter which sqlite feature you use, reedline will expose the
same API.
* On backspace, deactivate menu and do not complete
Fixes#5497
* Make Tab insert (partial) completion instead of select next menu item
* Fix history search filtering
* render right prompt on the last line of the left prompt
Closesnushell/nushell#4909
* make rendering the right prompt on the last line configurable
* calculate width of the line where right prompt will be rendered
* `Submit` is used to return data unconditionally. This is useful for
example if you want compiler to show you where the unclosed paren that
doesn't pass validation actually is.
* `SubmitOrNewline` is similar to `Enter` but inserts a new line if the
cursor is not at the end of the buffer. It's useful to insert newlines
in the middle of the text when editing.
This also removes unconditional `KeyCode::Enter` to
`ReedlineEvent::Enter` event mapping and sets it in the keybindings
normally (so you can rebind to `Submit` or `SubmitOrNewline`)
* Remove flicker on external print
Previously each external print was causing a visible flicker on at least
two terminal emulators I've tested (alacritty, xfce4-terminal).
* Make `Painter.print_external_message()` crate local
* Put external_printer Painter members behind flag
* Add `external_printer` feature to CI
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This change truly separates the actions and the motions on the parsing
side. Bare motions are parsed by the motion parser instead of the
command parser. (This requires a separate `ParseResult` to distinguish
valid but incomplete motions like `f` from invalid motions.)
Fixes#449 by making `.` its own command. Also introduces the
possibility of multiplying the `.` repeat and resticts its effect to the
action commands and ignores the bare moves.
Simplify and make the `;` and `,` behavior more correct:
- Place info in the `Vi` state instead of complicated in-band signal
- Support using it with `d;` and `c;`
- Store the character search when combined with an action
- Rename `ViToTill` more explictly to `ViCharSearch`
- **Missing:** the old tests were removed as they tested old quirks
The above change also leads to proper separation of concern between
parsing and translation to emacs commands (and subsequent execution).
Add support for combining `d/c` with `h/l`.
**Note:** `j/k` are still omitted as they require new behavior in the
linebuffer/editor. Also `dj` has to add 1 to the multiplier to achieve
the correct behavior as we do not model line ex-/inclusive behavior.
Rename `ParseResult` to `ParsedViSequence`
Simplify validity checking in `mod.rs` and have explicit check methods
on the types. This fixes problems with `r` and `f/t/T/F` in their
partial and complete state and adds a missing test.
Rename `last_to_till` to `last_char_search`
I discovered a limitation in how we handle character searches with a
multiplier in the case the search character appears in a consecutive
sequence.
Fixing this correctly probably requires performing the search with
knowledge of the multiplier.
Take into account that only the product of the `multiplier` and `count`
are relevant to execute motions.
From 140f6d0eda/runtime/doc/motion.txt (L63-L70)
> If the motion includes a count and the operator also had a count before it,
> the two counts are multiplied. For example: "2d3w" deletes six words.
> When doubling the operator it operates on a line. When using a count, before
> or after the first character, that many lines are operated upon. Thus `3dd`
> deletes three lines. A count before and after the first character is
> multiplied, thus `2y3y` yanks six lines.
Necessary to complete nushell/nushell#6590
(Comment: this whole module feels intricately linked to the nushell
implementation as we do not implement the string parsing in reedline)
* change history session_id to a systematically generated number
* added env var, removed comments
* tweak test
* add public function to get the history session id
* switch from reedline commit date to unix_epoch
* Fix vi character search parsing
Fixes#473
The parser has to consume the items from the iterator to be in a
consistent state!
* Move `ViToTill` logically to `motion.rs`
* Add basic regression test for #473
Addresses #320, #236
* Adding External printer
* Made ExternalPrinter as an optional feature. Clippy is happy, test pass, docs added.
* ExternalPrinter: prints multiple messages if available, more on error-handling.
* Bug(s) fixed. Prints messages. Working example in examples folder. Code formatted, clippyed, tests pass.
* Generic ExternalPrinter<T> where T: Display.
* Fixed: Works with buffers larger than a line.
* Fixed: Works with buffers larger than a line, refactored.
* Different approach, seems to look like what is expected. Gives the "illusion" of one line being entered. Needs more testing, could have some off by one errors ;)
Co-authored-by: Gregor Engberding <gregor@meinkopter.de>
This allows nushell to implement a command similar to fish's `commandline`:
https://fishshell.com/docs/current/cmds/commandline.html
that would allow commands run via `executehostcommand` bindings to do interesting
things to the contents of the input buffer.
This is necessary to avoid the problem with running executehostcommand keybindings in nushell
right after launching it (without having run actual user-input commands yet).
Since the error types are not exposed outside of the crate, we have to use a check instead of
matching on the error.
- Fixed anchor links (some links were not pointing to correct headings).
- Updated headings (some headings in outline didn't match the content).
- Fixed heading level for "Integrate with History" (was 2 should be 3).
* Delete unused code in `CircularCompletionHandler`
I could not find anywhere that the `Reedline::ActionHandler` event is
actually created, except for a bit of deserialization code in nushell
(reedline_config.rs:817). I suspect its functionality is no longer
needed in the current version of reedline.
* Improve word-level undo and completions undo
* Adds completions and history searches to the undo stack
This required changing all the menu interfaces to do their edits through
the `Editor` struct, so it can track undo state
* Improves the system of coalescing word-level edits on the undo stack
This involved expanding the `UndoBehavior` system. Now, every edit gets
tagged with `UndoBehavior`, and by comparing the `UndoBehavior` of the
current and previous edit, we can decide whether these changes should
be grouped together on the undo stack.
Chains of repeated backspace, delete, insertion, or history naviagition
can each be grouped together to form a single undo entry when
appropriate.
* Removing low-usage wrapper methods from editor.rs
Removes LineBuffer wrappers from Editor wherever the wrapper is used
only once, or only internally to the `editor.rs` file.
* Run cargo fmt
* Fixed undo coalescing for backspace/delete with \n
The logic was a bit trickier than I thought. Added some tests
to confirm the intended behavior where adding/deleting newlines creates
additional undo points
* Remove debugging logging code
* Revert "Removing low-usage wrapper methods from editor.rs"
- Also revert reintroduction of `CutFromStart` bug in vi mode
8b5e70fc0e
* Fix undo coalescing for CRLF deletions
* Ensure proper undo tracking in public Editor fns
Delete or make private all Editor functions that modify the line buffer
without tracking UndoBehavior
* Make Editor crate level pub
Added documentation for pub methods on Editor. Kept the public API
smaller by making many convenience methods pub(crate) if they can be
implemented via the pub methods
* Cleanup changes
* word_starts and word_ends functions no longer needed with current
word-level undo tracking algorithm
* `undo` and `redo` don't need to call `update_undo_behavior` because they are
private methods and `run_edit_command` already calls `update_undo_behavior`
* Fix for new clippy warning
* Editor+LineBuffer API updates for nushell merge
* Make `LineBuffer::replace_range` pub rather than pub(crate)
* Make `Editor::set_line_buffer` and `Editor::set_buffer` pub(crate) in
favor of the new `Editor::edit_buffer`.
I believe the `edit_buffer` change is a better API to expose for
`Menu` implementations, as it avoids the need for `clones` while
enforcing proper undo tracking.
Export `crossterm::event::{KeyCode, KeyModifiers}` as our own.
This way users of the library don't have to import crossterm with the
same version explicitly to set their own keybindings.
Closes#456
* Vi mode add support for d0, d^, c0, and c^
Also changes d$ to delete just current line for
multiline inputs
* Make `d0` line aware
* Make `c0` line aware
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
`rstest = 0.12` added support for asynchronous timeouts during testing
thus requiring a larger set of dependencies. Since `rstest = 0.14` this
can be disabled if not used.
Should keep build times for local or CI tests in check.