Commit Graph

515 Commits

Author SHA1 Message Date
Fernando Herrera
0d6e26276a
menu partial completions to menu function (#335) 2022-03-06 16:34:56 +00:00
Fernando Herrera
7c5f20d252
History improved (#334)
* undo for history replace

* history improvements

* replaced history comment
2022-03-05 19:27:50 -05:00
Fernando Herrera
3209848ddb
history bang (#333) 2022-03-05 08:53:54 +00:00
Fernando Herrera
e75a3c340a
update values after common string (#332) 2022-03-04 17:24:19 +00:00
Fernando Herrera
75489c02b4
Partial completions (#331)
* partial completions

* cargo fmt

* avoid extra partial completion
2022-03-03 09:48:05 +00:00
Fernando Herrera
e9c1e37d7c
partial completions for menu (#330)
* partial completions

* cargo fmt
2022-03-03 08:43:11 +00:00
JT
3d933d52ce
Better crossterm fix (#329)
* Move to crossterm on git

* Better fix for crossterm
2022-03-01 06:32:14 -05:00
JT
470b20129d
Move to crossterm on git (#328) 2022-03-01 05:41:23 -05:00
Stefan Holderbach
e314e8491e
Revert crossterm: key modifier issue on win (#326)
crossterm 0.23 seems to have introduce a regression on windows for
decoding keybindings with `ctrl` that uppercases the char.

Tracking issue crossterm-rs/crossterm#636

Might be fixed by crossterm-rs/crossterm#629
2022-02-26 14:51:38 +01:00
Stefan Holderbach
97230d73bc
Provide cursor position for highlighting (#324)
Changes the `Highlighter` trait to include the position of the cursor in
the buffer. This allows it to make cursor aware highlighting such as
highlighting matching braces or code blocks

Prerequisite to address nushell/nushell#4325
2022-02-26 14:51:16 +01:00
Stefan Holderbach
bb7179cd9c
Use chars in str::replace where applicable (#327)
Fixes ci fail due to new clippy lint in rust 1.59
2022-02-26 14:17:30 +01:00
Stefan Holderbach
de97702cea
Add event to keybind a command in the hosting app (#323)
Instead of affecting the editor this lets `Reedline::read_line` return
with `Ok(Signal::Success)` containing a predefined command to be executed or
consumed by the app using `reedline` as a line editor.
The state of the editor is preserved. After the command execution in a
REPL the host would call `Reedline::read_line` again and the line editor
would be redrawn on the next free line.
Command will not be added to the history in this config.

Open for debate if this should not expect printed output from the
command and try to redraw on top or reset some state.

Addresses #312
2022-02-26 12:16:33 +01:00
Stefan Holderbach
8a8dd44aad
Small fix to document need to configure completion (#325)
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
2022-02-24 20:41:45 +01:00
Stefan Holderbach
65cfd6bcbd
Bump dependencies and edition to 2021 (#310) 2022-02-24 00:09:58 +01:00
Fernando Herrera
2db0ffd1c4
extra row for empty menu (#322)
* extra row for empty menu

* simple syntax
2022-02-21 19:38:53 +00:00
Fernando Herrera
e87e9d1fd3
corrected padding for menu (#319) 2022-02-19 15:33:39 +00:00
Fernando Herrera
42ec23f083
edit mode for quick completions (#318) 2022-02-18 18:47:37 +00:00
JT
8c565e4f1d
Make up/down be one-press-per-history (#306) 2022-02-09 10:40:46 -05:00
Fernando Herrera
da21703840
Revising quick completions (#305)
* increase default page size

* revising quick completions

* not default quick completions
2022-02-07 18:36:44 +00:00
JT
ca727ff4a7
Fix one item completions (#304) 2022-02-07 07:06:09 -05:00
Fernando Herrera
805daea8b6
Vi menus (#303)
* increase default page size

* navigation in normal mode
2022-02-06 17:24:14 +00:00
Fernando Herrera
7a232a1f0e
Menu events (#302)
* increase default page size

* menu events

* removed empty space variable

* removed width variable
2022-02-06 14:15:50 +00:00
Stefan Holderbach
92b299916e
Make appending and truncating history file thread safe (#299)
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
2022-02-06 00:20:44 +01:00
Fernando Herrera
18f5383612
Keybindings functions (#297)
* increase default page size

* keybinding functions
2022-02-04 22:23:53 +00:00
JT
e4cec99526
Add support for quick completions (#296) 2022-02-04 10:01:54 -05:00
sholderbach
375c779e36 Avoid repaint on line validation for paste
This does not trigger if the line is shorter than EventThreshold
2022-02-03 22:35:53 +01:00
sholderbach
0714e901a1 Allow sequential pasting of multiple expressions
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
2022-02-03 22:35:53 +01:00
sholderbach
b385d3a215 Clean engine by coalesced painting and abstraction
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.
2022-02-03 22:35:53 +01:00
Stefan Holderbach
43788def68
Improve default keybindings slightly for vi (#293)
* 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
2022-02-02 23:56:19 +01:00
Stefan Holderbach
e633499335
Polishing in the painter (#292)
* 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
2022-02-02 21:31:33 +01:00
Darren Schroeder
8a22413d52
Merge pull request #285 from nushell/list_things
list things with `reedline --list`
2022-02-02 08:35:41 -06:00
Darren Schroeder
4b4e16f29a move get_all_keybinding_info() to main 2022-02-02 07:25:48 -06:00
Darren Schroeder
a00b61fb65 updated get_reedline_default_keybindings to return vec of tuple 2022-02-01 15:12:24 -06:00
Darren Schroeder
606a537bd2 tweaked output 2022-02-01 05:12:41 -06:00
Darren Schroeder
03c197ffbc print/get default keybindings 2022-02-01 05:03:18 -06:00
Fernando Herrera
054b04cebb
Continous history index (#290)
* increase default page size

* countinous history index
2022-02-01 07:12:20 +00:00
Fernando Herrera
1ac359694b
increase default page size (#289)
* increase default page size

* respect full page
2022-01-31 21:44:33 +00:00
Fernando Herrera
c5003d81e3
continue history (#288) 2022-01-31 20:41:00 +00:00
Darren Schroeder
a9b8fe4af3 moved some thing around 2022-01-30 19:48:09 -06:00
Stefan Holderbach
c8e3ea270c
Init prompt without superfluous line at the bottom (#287)
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
2022-01-30 20:20:15 -05:00
Darren Schroeder
abf710b53b cleanup a few more uses 2022-01-30 13:40:37 -06:00
Darren Schroeder
23ad1d02a7 cleanup uses 2022-01-30 13:35:31 -06:00
Darren Schroeder
9a9697436e quite complaining already, clippy 2022-01-30 13:29:07 -06:00
Darren Schroeder
30f4dc0e7a add functions to get items 2022-01-30 13:21:19 -06:00
Fernando Herrera
3305799947
growing menu (#286) 2022-01-30 17:35:39 +00:00
Darren Schroeder
bb942dcd47 clippy 2022-01-30 07:38:01 -06:00
Darren Schroeder
4020a99dc1 add impl Disply prototype 2022-01-30 07:20:25 -06:00
Darren Schroeder
a55884390e list things 2022-01-29 15:50:05 -06:00
Fernando Herrera
4b50d29959
dynamic menu (#284)
* 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
2022-01-29 14:31:13 +00:00
Stefan Holderbach
998ddd5452
Coerce LF to CRLF lazily for lines and prompt (#281)
* 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
2022-01-28 20:26:11 +01:00