Commit Graph

404 Commits

Author SHA1 Message Date
Stefan Holderbach
52675664d2
Distill DefaultHinter down to history suggestions (#265)
* 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
2022-01-21 05:25:40 +11:00
Stefan Holderbach
2a20ca6e87
Remove Reedline::print_line from the API (#263)
As this function can only be called outside running
`Reedline::read_line` it is not relevant for raw mode reasons and can be
replaced by standard `println!()`
2022-01-20 11:06:51 +01:00
Stefan Holderbach
86712ed485
Remove superfluous insertion of carriage return (#262)
In the hinter logic `LF` was always replaced by `CRLF` thus inserting unnecessary `CR`'s into the linebuffer that accumulate if a multiline entry is recalled via hint autosuggestion from history multiple times.

Carriage returns, that are not introduced at the end of the line as part of the painter or the OS convention, break the painting of multilines, as the cursor position might jump to the start of the multiline continuation prompt and start painting from there!
2022-01-20 00:09:47 +01:00
Fernando Herrera
caebe19742
action and complete events (#260) 2022-01-18 18:54:09 +00:00
Fernando Herrera
b0ff0eb4d1
Parsing keybindings (#257)
* reduce string print

* menu input struct

* exposing keybindings
2022-01-17 21:36:21 +00:00
Fernando Herrera
32338dc18a
Tab backwards (#255)
* reduce string print

* menu input struct

* back tab

* spelling correction
2022-01-16 08:25:13 +00:00
Fernando Herrera
c0fbcf0ed1
Tab correction (#254)
* reduce string print

* menu input struct

* corrected tab movement
2022-01-15 18:56:15 +00:00
Fernando Herrera
4c3c23c959
Menu config (#253)
* reduce string print

* menu input struct

* context menu options

* removed pub from structs
2022-01-15 16:41:07 +00:00
Darren Schroeder
56025adb65
Merge pull request #252 from fdncred/fix_windows_typeo
fix windows type-o
2022-01-14 15:32:06 -06:00
Darren Schroeder
b1c5c8c60a fix windows type-o 2022-01-14 15:27:27 -06:00
Stefan Holderbach
c0e3dd791e
Move running of EditCommands to the editor (#251)
* Move running of EditCommands to the editor

- Moves the big match statement for `EditCommand`s into `Editor`
- Removes the need for many `pub` wrappers around the `LineBuffer`
- Make `Left` a `ReedlineEvent` as well
- Fix left, right, up, down for vi mode

* Fix left move in vi insert mode
2022-01-14 17:23:17 +11:00
Stefan Holderbach
b6f47f020a
Hide hint when finishing line entry (#250)
Fixes #239
2022-01-13 22:39:03 +01:00
Fernando Herrera
9ec02cb738
menu improvements (#249) 2022-01-14 02:48:26 +11:00
Fernando Herrera
63aeeb62e4
menu with tab (#248) 2022-01-12 09:53:15 +00:00
Fernando Herrera
2cb2e40195
Context menu with completer (#247)
* menu filler builder

* context menu with completer
2022-01-11 21:17:15 +00:00
Fernando Herrera
4c75c36e4d
menu filler builder (#246) 2022-01-10 20:39:09 +00:00
Fernando Herrera
af19a7bfc6
Context menu (#243)
* vi keybinding events

* context menu for reedline

* corrected tests

* text style for menu
2022-01-10 20:17:31 +00:00
JT
a5b6cc079b
Right arrow is full hint completion (#244) 2022-01-10 11:06:45 +11:00
Fernando Herrera
eed17392cb
remove position function (#242) 2022-01-07 18:33:18 +11:00
JT
373c76a383
Double prompt (#241)
* support double prompt

* clippy warning

* better cursor position

* Move to estimating the right prompt cutoff

* refactor to use line_width

* refactor to use line_width

Co-authored-by: Fernando Herrera <fernando.j.herrera@gmail.com>
2022-01-06 22:01:47 +11:00
Fernando Herrera
811dde6d03
corrected extra line (#238)
* corrected extra line

* corrected extra line

* calculating remainig lines
2022-01-03 13:30:29 +00:00
Fernando Herrera
4b6055dccf
corrected extra line (#237) 2022-01-03 10:24:23 +00:00
Fernando Herrera
dcf8ff3f7a
Big buffer (#230)
* test big buffer

* clippy error

* more clippy corrections

* extra else for position

* debug cursor

* moving to debug section

* hints in big buffer

* case for prompt one line

* corrected extra line
2022-01-03 10:13:08 +00:00
Stefan Holderbach
a2682b50f9
Improve and highlight history search (#234)
Fixes `history_search_paint`:
- Fix unnecessary clear of single line
- Ensure LF to CRLF in search results

Fixes `Painter`:
- Make sure that Color is cleared after prompt (Currently depends on
Highlighter to provide a new color)
- Remove unnecessary fn

Introduce simple highlighting of the search term in the search result:
- Introduce `SingleMatchHighlighter` that will highlight all matches of
the search string
- Rename `DefaultHighlighter` to `ExampleHightlighter` as the behavior
seems not very useful for default use.
- Extract styling operations into styled text
2022-01-02 20:26:30 +01:00
Stefan Holderbach
aefc2965d1
Add issue templates (#235)
* Add issue templates

As we often have to consider certain platform/terminal editor specific things as potential sources of bugs, let's nudge people to provide this info

* Delete githubs default form
2022-01-02 20:24:47 +01:00
Stefan Holderbach
1da1e848bf
Insert strings directly (#233)
There are latent concerns about unicode correctness, but as long as
crossterm/hints are providing correct chars/strs this is neither a security risk
(no unchecked/unsafe string ops on our side) nor
a DoS risk.
2022-01-02 20:24:17 +01:00
Stefan Holderbach
2c24ff6140
Bump dependency versions (#232)
Make sure we are up to date on unicode crates et al.
2022-01-02 20:19:11 +01:00
Stefan Holderbach
c1021f6f35
Improve correctness of move operations (#231)
- Made move up and move down unicode safe
- Added the option to constrict the char search (vi `f` `F` `t` `T`) to
the current line as usual in vi
- Improved test coverage
2022-01-02 20:17:57 +01:00
JT
07696fe06d
strip ansi before estimate (#229) 2022-01-01 15:50:06 +11:00
JT
b82b6ebd35
Estimate wrapping (#228)
* Add wrap estimates to line counting

* Remove adjust_prompt_position
2022-01-01 11:25:32 +11:00
JT
3292aaa2b4
Let anims handle resize (#227) 2022-01-01 08:33:19 +11:00
Fernando Herrera
5401b4ec58
adjust position to insert in middle (#226) 2021-12-31 21:42:29 +11:00
Fernando Herrera
913e58d4a9
prompt moves based on hint (#217)
* prompt moves based on hint

* checked sub for the prompt

* checked sub for the prompt

* using promplines

* clean flush

* split lines before print

* test with full print

* test with full print

* removed flush

* no split

* drawing function with prompt

* replacing space return to string

* history search in repaint buffer

* using last row

* removed extra required lines
2021-12-31 10:34:11 +11:00
Stefan Holderbach
1553c77e40
Test and fix line buffer utils (#224)
- current line detection was off on the first position of a following
line
- find_current_line_end was not correctly aware of CRLF platforms
- Increase of coverage for some old functions
2021-12-31 08:25:14 +11:00
JT
a8153cf69a
Make StyledText easier to work with (#225)
* Make StyledText easier to work with

Make the contents of StyledText pub to make it easier to work with

* Update styled_text.rs
2021-12-30 22:25:07 +01:00
Leo Kettmeir
b3eec539b8
fix: make traits Send (#223)
* send sync

* fmt

* only Send

* add test
2021-12-31 08:23:22 +11:00
Stefan Holderbach
b242a030aa
Make the editing operations aware of multiline (#219)
- Moves to start and beginning of the line
- Make start and end of buffer available for move via `Ctrl-Home` and
`Ctrl-End`
- Support vi style cutting of whole lines in the cut buffer.
- add vi style `p` after paste in addition to before cursor paste with
`P` or in emacs mode
- Enables vi style `dd` and paste
- Make sure the line to end cut and clear operations work only on the
line
2021-12-29 18:07:27 +11:00
David Lattimore
02e13f1e17
Cargo.toml: Add repository link (#216) 2021-12-28 12:19:00 +01:00
Stefan Holderbach
afa83d9e70
Disable hints during history traversal (#215)
* Disable hints during history traversal

Additional autosuggestion (history) hints are confusing while
navigating through the history.

Example history:
```
hello test
hello
something else
hello world
whatever
```

- Type `h`
- Press up arrow
- Prefix based history search will return `hello world`
- Press up arrow again
- Previously `hello <hint>world</hint>` now just `hello`

* Reduce code duplication before painting
2021-12-27 19:21:18 +01:00
Fernando Herrera
7c75ed6c62
vi insert mode kept after enter (#214) 2021-12-27 12:16:37 +01:00
Fernando Herrera
f9a6806e01
vi insert mode default (#213) 2021-12-27 11:28:07 +01:00
Stefan Holderbach
8895756054
Improve history internals (#212)
* Move history newline escape to the file IO

Avoids potential interference with history search, makes
`History::iter_chronologic` nice again, simplifies it regarding hints
and should address the `history` command in a better way.
+ Extract escape
+ Remove unwrap

* Remove unnecessary optional history allocation

No need to clone if entry is duplicate or empty
2021-12-27 00:05:50 +01:00
Fernando Herrera
fbd7b20e8c
vi mode commands (#211)
* vi mode commands

* added search to left

* reordered files

* clippy corrections

* utf8 character offsets

* check valid input

* test has garbage

* Fix `f<char>` move starting on multibyte char

* Fix formatting

* added append command

* correcting failing tests

* append command doesnt require repaint

* Pedantic fixes

- Terminate statements with ;
- Make char references copies for performance

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2021-12-26 18:13:44 +00:00
JT
3acf7da71a
Minor history fix (#210) 2021-12-23 12:35:39 +11:00
JT
5d0e803b9d
Another multiline decode (#209) 2021-12-23 10:58:20 +11:00
JT
328c86e38d
improve multiline paste (#208) 2021-12-23 09:32:07 +11:00
Stefan Holderbach
adc6b1f649
Attempt at consolidating offset calculations and streamlining the painting (#164)
* Offset setting changes

* Rename `PromptWidget` to `PromptCoordinates`
* Explicit setters
* Set offset implicitly on `full_repaint`

* Rename origin and offset

As suggested by JT

origin -> prompt_start

offset -> input_start

* Move tracking of offsets and size into painter

Relatively basic refactor of all tracking of prompt/input offsets as
well as the terminal size into the painter.

Some cooperative behavior in the engine is still required

Wrapping handler is currently still a crutch in the engine as it is not
`InsertChar` specific and should be handled for every buffer change
instead

* Simplify restore from history stearch

Prompt is simply updated via full repaint

* Fix ansi coloring for history prompt

also ignore reset color in non ansi colored mode

* Make pedantic clippy happier

* Ensure prompt creation is tight and not wrapping

Fix additional line that is created upon prompt creation if the previous
output was printing a new line. Also ensures that line clearing and
regular prompt creation at the bottom of the screen doesn't cause
scrolling issues (Currently a hardcoded solution for the two line
prompt)

Also reduces the API surface for tools only necessary to deal within raw
mode.

* Fix doctests for internals removal

`print_crlf()` was removed from the public API as it should only be used
in raw mode for internal stuff.
As soon as we leave `Reedline.read_line()` raw mode should be disabled
and the regular print macros should work as expected
2021-12-22 23:14:58 +01:00
JT
2ddeb76ff4
Simple multiline history (#207) 2021-12-23 06:59:55 +11:00
JT
fb152af5f4
Adjust prompt position after paste (#206) 2021-12-23 06:27:09 +11:00
Fernando Herrera
792ee12344
defining paste event (#205) 2021-12-23 06:17:18 +11:00