Commit Graph

540 Commits

Author SHA1 Message Date
Stefan Holderbach
d2e0d320a9
Start developer documentation (#424)
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
2022-05-23 23:14:17 +02:00
Dhruv Dhamani
4fedec4ad0
Support non-compliant terms with default size (#402)
if reported size is 0, 0 -
use a default size to avoid divide by 0 panics


Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2022-05-23 23:13:45 +02:00
petrisch
28514478e3
Typo (#429)
Reedline has now... instead of Nushell has now...
2022-05-23 15:25:03 +02:00
ahkrr
c49845e3e0
fix: list_menu not accounting for index + indicator (#428)
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.
2022-05-23 12:58:07 +02:00
Stefan Holderbach
85daf4e4fc
Do not allocate eagerly for full history capacity (#427)
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
2022-05-20 17:09:19 +02:00
Casey Dahlin
9b5d033dce
Fix vi-mode word motions (#425)
* 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>
2022-05-11 08:04:51 +02:00
Stefan Holderbach
ef6499202a
Prepare the 0.5.0 release (#421)
`Cargo.toml` version bump
2022-05-03 21:16:00 +02:00
Stefan Holderbach
33a91e53a2
Change keybinding for external editor (#422)
Current `Ctrl-i` is overloaded as `Tab` in the ASCII/ANSI world.

Use `Ctrl-o` (mnenomic "o"pen in editor) currently not bound to anything
2022-05-03 21:06:44 +02:00
Stefan Holderbach
3aaa776858
Fix README and lib.rs code examples (#419)
- 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
2022-05-02 14:23:01 +02:00
Yuheng Su
29f30a8f79
Append whitespace after selecting menu (#410)
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>
2022-05-02 11:13:38 +02:00
Stefan Holderbach
60b9b91e13
Add doctests back to the CI (#418)
`cargo nextest` currently doesn't support running the doctests.

Thus, add an additional job for them with cargo's default test runner.
2022-05-02 11:10:52 +02:00
Stefan Holderbach
2947a94fef
Vi additions and fixes by @zim0369 (#417)
- 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>
2022-05-02 00:15:35 +02:00
Stefan Holderbach
0311da5e83
Attempt fix of ClearScrollback (#416)
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
2022-05-02 00:13:52 +02:00
Stefan Holderbach
23cbd8a74b
Fix the ci badge (#415) 2022-05-01 20:04:16 +02:00
Stefan Holderbach
e5c2709202
Change the CI to use caching (#414)
* 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.
2022-05-01 19:52:10 +02:00
Richard
43c495818f
Only partial complete suggestions when input is a prefix (#412)
* Add unit tests for can_partially_complete

* Add partial-completion-tests for fuzzy matches

* Partially complete only if the input is extended
2022-05-01 07:48:14 -05:00
Fernando Herrera
ed0e420083
change keybinding (#413) 2022-05-01 08:35:12 +01:00
Fernando Herrera
39c70136bb
line buffer editor (#411)
* line buffer editor

* corrected message in docstring

* formated example

* allow file extension for buffer

* change editor command
2022-04-30 15:09:43 +01:00
Invader Zim
229c729898
Add vim's C binding (#405)
`C` to change the content from the cursor to the end of the current line.
2022-04-20 14:05:26 +02:00
Stefan Holderbach
2e2bdc5462
Add better options for screen clearing (#400)
- 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
2022-04-20 10:10:58 +02:00
Stefan Holderbach
77344ebafb
Add explicit EditCommand::InsertNewline (#399)
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)
2022-04-20 09:58:10 +02:00
Invader Zim
b8c7efc907
Implements vim's I prepend to start binding (#403)
* 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>
2022-04-20 09:53:06 +02:00
sholderbach
2176424cec
Finalize v0.4.0 2022-04-12 11:39:54 +02:00
Stefan Holderbach
7aca406f13
Use better word definition (#396)
Follow UAX29: http://www.unicode.org/reports/tr29/#Word_Boundaries

This behavior is closer to VIs definition respecting identifiers and
respects special characters like fish

Fixes #346

Fixes #377
2022-04-12 11:33:37 +02:00
Darren Schroeder
77d28e3956
change dark orange in prompt to purple (#395) 2022-04-11 15:01:13 -05:00
Stefan Holderbach
1bf273d6e5
Clean up some stuff found by pedantic clippy (#394)
e.g.

- make modifying, non-returning functions more obvious by `;`
termination.
- merge match arms where it improves legibility
2022-04-11 17:58:36 +02:00
Stefan Holderbach
e906c008c1
Remove Hinter and Validator from the default (#393)
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.
2022-04-11 12:43:28 +02:00
Stefan Holderbach
7ce8b674e0
Allow the removal of keybindings (#391)
This was previously impossible, existing defaults could only be overridden.
2022-04-10 21:01:54 +02:00
Darren Schroeder
e3c75c1cd2
change up prompt with traditional nushell colors (#388)
* change up prompt with traditional nushell colors

* removed the changing of backslashes to slashes
2022-04-08 15:19:47 -05:00
Fernando Herrera
922fab18e0
Short description (#390)
* short descriptions

* remove new line
2022-04-08 07:14:08 +01:00
Fernando Herrera
860b110490
short descriptions (#389) 2022-04-08 06:49:04 +01:00
Stefan Holderbach
446a60ffa9
Add Ctrl-Delete/Backspace as default keybindings (#386)
Used to delete words
Shared between vi and emacs

Fixes #383
2022-04-07 19:02:30 +02:00
Michael Angerman
ad6015a19a
fix example in readme (#387) 2022-04-06 12:35:41 -07:00
Darren Schroeder
2f59d803a8
clean up query output so that it's closer to matching what key bindings want (#381)
* clean up query output so that it's closer to matching what keybindings need

* sort keybindings
2022-04-06 07:49:45 -05:00
Stefan Holderbach
51cc0cc020
Escape Ctrl-R history search with ESC (#385)
Fixes #384
2022-04-06 13:45:52 +02:00
Stefan Holderbach
6332747730
[API] Allow the Completer impl to be stateful (#379)
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.
2022-04-04 23:21:13 +02:00
Fernando Herrera
698190c534
generic reedline menus (#378)
* 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
2022-04-04 11:04:57 +01:00
Fernando Herrera
accce4af7f
bashisms feature for reedline (#374)
* bashisms feature for reedline

* cargo fmt
2022-04-01 18:27:51 +01:00
Fernando Herrera
246706c971
format descriptions to the left (#375) 2022-04-01 18:27:41 +01:00
Stefan Holderbach
60386ac610
API break: remove unnecessary fallibility (#367)
The fallible std::io::Results were originally introduced for the history
file but the critical points are completely separated from the builder
pattern now.

Makes the public API nicer
2022-03-31 23:32:31 +02:00
Stefan Holderbach
0f92985c69
Expose the history as syncable and readable (#373)
Useful for nushell repl loop lifting
2022-03-30 22:11:49 +02:00
Sherub Thakur
5240130c9f
Edit stack (#368)
* Add edit stack

* Use edit stack in the core editor

* Edit stack is just a struct

* Test undo-redo behaviour instead of implementation details
2022-03-29 18:17:51 +02:00
Waleed Dahshan
0216c84aa2
Fix the first example so it can be run (#371)
The example in the read me doesn't actually run until you add a return value for propagating io results.
2022-03-29 13:21:54 +02:00
Fernando Herrera
bc18ba3260
corrects menu selection (#369) 2022-03-28 07:37:48 +01:00
Tomoki Aonuma
7b5e761c8e
Fix menu::menu_functions::string_difference (#364) 2022-03-27 13:34:11 +01:00
Fernando Herrera
072f961107
Vim normal keybingings (#365)
* corrected normal keybindings and caps

* insert checks first for mode

* vi parser test
2022-03-27 13:24:17 +01:00
Tomoki Aonuma
7c594b16ba
Fix menu::menu_functions::find_common_string (#363)
* Fix `menu::menu_functions::find_common_string`

* Add test for `DefaultCompleter`

* Add test strings
2022-03-27 11:46:57 +01:00
Fernando Herrera
e982abf7e2
update history menu (#362) 2022-03-27 08:47:40 +01:00
Fernando Herrera
69fad67b90
Descriptions for completion suggestions (#358)
* add description to completion suggestions

* completion menu with help

* corrected doc tests

* moved menu functions to module

* menu type with its own completer

* corrected doc tests

* function for menus to quick complete
2022-03-27 08:30:08 +01:00
Darren Schroeder
bc528de132
bump to 0.3.1 and nu-ansi-term to 0.45.1 (#361) 2022-03-27 15:42:39 +13:00