Commit Graph

553 Commits

Author SHA1 Message Date
WindSoilder
2aaa58f93a
fix double bang (#444) 2022-06-17 10:57:42 -05:00
Darren Schroeder
680bc7a162
add impl Display to HistoryItemId and HistorySessionId (#443) 2022-06-17 08:38:32 -05:00
Eric Hodel
0680bb584a
Add vi WORD motions B, E, W (#441)
* 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
2022-06-16 11:58:19 +02:00
Stefan Holderbach
f14583526a
Prepare 0.7.0 release (#440)
Includes the new History API and their backends
2022-06-14 22:46:04 +02:00
Stefan Holderbach
12dc30ce0a
Expose the History query functionality (#439)
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.
2022-06-14 16:16:54 +02:00
phiresky
4f25ce5633
SQLite History and replaceable History backends (#401)
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>
2022-06-06 18:11:02 +02:00
Stefan Holderbach
09bbb24bfd
Update nu-ansi-term and crate patches (#437)
- Update `nu-ansi-term` to remove `Deref` impl
- General `cargo update`
2022-06-03 21:11:59 +02:00
Stefan Holderbach
265e59966c
Fix clippy lints that will become warnings (#435)
* 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!!!
2022-06-03 10:47:43 +02:00
WindSoilder
59379bf5b4
Don't panic when parent directory does not exist (#436)
* 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>
2022-06-03 10:46:27 +02:00
Artturi
a3dbc6232b
Move ctrl+a & ctrl+e to common navigation binds (#434)
* Move ctrl+a & ctrl+e to common navigation binds

* ctrl+w DeleteWord -> BackspaceWord

See fe795caabc (r74631178)
2022-05-29 17:00:35 +02:00
Stefan Holderbach
fe795caabc
Organize the common keybindings (#433)
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
2022-05-26 23:17:50 +02:00
Artturi
e7f1dab8f4
Move some commonly used keybinds to common keybinds (#432)
* Move ctrl+d keybinding from emacs to common keybinds
* Move ctrl+w keybinding from emacs to common keybinds
2022-05-26 22:00:10 +02:00
Stefan Holderbach
d8ff270f94
Prepare the v0.6.0 release (#430) 2022-05-23 23:59:07 +02:00
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