Keybindings are currently configured to require the completion menu. To
use the completions you have to manually add it.
Undocumented: Changing the keybindings to use the old bash style
completions with `CircularCompletionHandler`
Track #307
Add safe `sync` method to `History`
This method both reads from the file and writes local additions. Is safe
when multiple `History` instances try to truncate the history file on
disk.
To avoid race conditions on the file uses the `fd_lock` crate for file
advisory locks. (Inspiration for that thanks to rustyline: https://github.com/kkawakam/rustyline/blob/master/src/history.rs)
Fixes#221
- Cover history file ops with tests
- Add test for conflicting writes that should truncate
- Add safe `sync` method to `History`
- Test `FileBackedHistory` for threadsafety
To allow the automatic execution of multiple new line separated lines
only take events up until enter and execute to check if complete valide
expression. Remaining events present in crossterms event queue will be executed on next invocation.
Removes the need for the explicit Paste event, which in it's current
implementation did not provide a performance benefit over the existing
machinery (From the current state, it seems that the performance
improvement of that patch relies on the change in inner loop poll
timeout)
Introduces a minimal performance regression for pasting large text
containing many newlines which is a single valid entry as after the
validation step a repaint is triggered
Fixes#282
All `repaint`/`buffer_paint` calls are removed from the event handling,
instead the `EventStatus` determines if a repaint is necessary:
- `Handled` -> repaint
- `Inapplicable` -> no action was taken, thus no need to repaint
Additionally some conditions to check and repeatedly used patterns
abstracted as methods.
* Make cntrl-arrow keys available with vi insert
Move the key bindings based on cntrl arrow keys to the shared defaults
and place the emacs only alt-special keys to emacs
* Move emacs keybindings to eponymous file
* Correct allocation behavior of `coerce_crlf`
Empty string optimization of Cow<str> has to be avoided when trying to
use pre-sized buffers
* Consolidate names to `screen_width/height`
* Simplify the `PromptCoordinate` down to the row
Column of the prompt origin is never different from 0, can thus be
elided.
* Encapsulate the large buffer state readonly
* Consolidate line requirement calculion
Currently several places exists that try to estimate the number of lines
required for a given content
Extract for obvious places in the painter
Rename 'estimated_wrapped_line_count` due to misleading name to
`estimate_single_line_wraps`
* Unify painter initialization step
Prevents misuse of the painter that would cause overflows in position
calculations due to size and prompt positions being out of lockstep
* Fix painter debug output
The prompt initialization was still hardcoded for the two line prompt.
Now all adaptation to account for the number of prompt lines is done
during repaint
* dynamic menu
* corrected string
* no hints when a menu is active
* status bar style
* changed default page size
* cargo clippy
* status bar for empty list
* Coerce to CRLF lazily
Will only introduce a CR if LF is not part of CRLF.
Only allocates if necessary
* Coerce CRLF for prompt as well
In this case handled right before painting as lifetime construct would
be tricky otherwise.
Hopeful fix for nushell/engine-q#575
Now take into account that the new cursor position might have to be at
the last line of the screen that is already used. (Was hidden when on
the last line of a multiline buffer due to superfluous `CRLF` in the
event handler)
Fixes#261
* Doc and integerify `estimated_wrapped_line_count`
Avoid unnecessary float conversion and use usize properties
* Correct and doc `line_width`
- Fix the unlikely failure case for strip_ansi_escapes (Fallibility seems
to be driven mostly by the std::io::Write implementation of that crate)
to also compute a correct width.
- Remove unnecessary type conversions
* Single alloc strip_ansi
* Collapse ANSI handling in wrapping
* Remove superfluous fluff from painter
* Remove outdated ListCompletionActionHandler
The implementation is incompatible with the line estimation of the
painter and superseded by the selection supporting menu.
* Internalize Completer and the related UI
- Remove the `CompletionActionHandler` trait
- Make a single `Completer` member of the `Reedline` engine
- Provide a `CircularCompletionHandler` in the engine
Open question: How to manage configuration, whether circular completions
or the interactive completion menu are preferred
* Rename `ContextMenu` to `CompletionMenu`
Clarifies the exact purpose
* Remove noop as hints are completed only at the end
* Clarify names for hint completion
* Support "token by token"-hint completion
Hints can now be completed partially
Keybindings: `Alt-right` `Alt-f` `Ctrl-right`
Uses whitespace as token/word boundary for now
* Fix event dispatch for history search mode
* Support Ctrl-Right in vi insert as well
Hint partial completion for vi
Also move word in insert mode like vim (Ctrl supported Alt unsupported)
Changes initiated by @elferherrera in #266 to enable flexibility in the keymapping and simplify the individual event handlers in `handle_editor_events`
To make complex keybindings that behave differently based on context use the `ReedlineEvent::UntilFound(Vec<ReedlineEvent>)` start with the most special case that will fail to handle if conditions are not met and end with the most general handler.
TODO: Check how this interacts with vi normal mode
* multiple options for keybindings
* corrected tests and keybindings
* with handled flag
* Fix repaint usage
Don't repaint on inapplicable cases
Repaint for the ctrl-d Delete action
* Use enum to indicate the handling status of event
* Revert to explicit event keybinding method
Makes the unique situation with UntilFound more prominent
* Fix ordering of Arrow events
* Make emacs arrow commands fully compatible
Co-authored-by: Fernando Herrera <fernando.j.herrera@gmail.com>
* Show content after cursor when completing
Currently the content after the cursor was completely omitted when
entering the completion menu
Addresses it for the simple case of everything fitting on the screen
Question what should take priority if the entry and menu together exceed
the hight of the screen remains open!
* Place the hint obligatory behind the line content
In line with the behavior in fish and zsh autosuggestions hints are
displayed after the line.
Next step would be to make the DefaultHinter/Hinter trait conformant to
this behavior and also allow history hint suggestions based on the whole
line content, while editing inside the line.
* Simplify hinter internals/capabilities
DefaultHinter now only supports history
Requires no copies of the whole history anymore
* Remove `HistoryCompleter` (was never pub)
* Fix doctest `Reedline::with_hinter`
* Add configurable character threshold for Hinter
Only hint if a certain number of characters has been typed
Default: 1