Commit Graph

454 Commits

Author SHA1 Message Date
JT
ae7e930119
Complete to the latest history (#204) 2021-12-22 20:18:47 +11:00
JT
c810d65a9d
Add a history-specific completer (#203)
* Add a history-specific completer

* Document api
2021-12-22 19:38:24 +11:00
JT
349f66b7b3
Apply history on tab (#202) 2021-12-22 19:12:45 +11:00
Stefan Holderbach
0f0a557479
Disable raw mode with Drop for panics (#201)
Panicking inside reedline (or bubbling up an Err inside reedline's
critical sections that gets unwrapped/expected by the hosting
application) leaves the terminal in a bad state. Workaround that should
also work without cooperation by the consumer would be to include a call
to `disable_raw_mode` in the `Drop` trait. With standard stack-unwinding
panics will call the drop.

Calling `crossterm::terminal::disable_raw_mode` twice seems to be fine
if the program started in non-raw mode (under linux)
2021-12-20 21:16:28 +11:00
Stefan Holderbach
44826d2f6d
Remove additional line on line clear via Ctrl-C (#200)
Additional line was a crutch introduced to counteract misbehavior fixed
in #77

Similar behavior was already sneaked into engine-q with https://github.com/nushell/engine-q/pull/508
2021-12-19 22:34:32 +01:00
JT
e512512dd4
Crlf fixes (#199)
* Add some wrapping estimate when adjusting prompt

* Add some crlf fixes for Windows multiline
2021-12-15 06:47:53 +11:00
JT
4da6a82ae6
Add some wrapping estimate when adjusting prompt (#198) 2021-12-14 06:34:29 +11:00
Darren Schroeder
6884ec4062
add the ability to optionally turn off ansi coloring (#197)
* add the ability to optionally turn off ansi coloring

* also strip from the hinter
2021-12-09 21:48:08 +01:00
Stefan Holderbach
a44a590b25
Fix clippy style and remove unecessary stuff (#192)
- remove unused members, found after update to Rust 1.57
- semicolon termination in void blocks
- other clippy pedantic prompted fixes (e.g. docstrings, unnecessary borrows)
2021-12-02 23:22:12 +01:00
Stefan Holderbach
2d34d100bd
Improve undo of EditCommands (#191)
* Improve undo of EditCommands

Address #190

Formalize the undo role of different edit commands via exhaustive
matching

Will track every move, but won't cause inconsistent cursor jumps while
undoing
2021-12-02 23:21:09 +01:00
Antonio Natilla
82bc3acb64
Forwarding Prompt's multiline indicator (#185)
* Multiline continuation prompt introduced

* Hardcoded multiline continuation prompt styling

A way to convert `crossterm::style::Color` in `nu_ansi_term::Color` must
be found/implemented. This enables creating a Style from it.
Otherwise, it is necessary that the Style of the prompt is accessible
from everywhere.

* Forward Prompt's multline prompt to rendering func

* Finish #185

Co-authored-by: Antonio Natilla <antonio.natilla@studenti.unimi.it>
Co-authored-by: sholderbach <ho.steve@web.de>
2021-12-01 12:18:49 +01:00
Stefan Holderbach
2bc7046066
Fix busy polling when animation is disabled (#188)
Addresses https://github.com/nushell/engine-q/issues/386

Breaks the API for variable refresh times, standardizes on one second
and simply optionally disables the automatic repaint.
2021-11-30 16:25:06 +01:00
Stefan Holderbach
b19ea8d9b4
Fix cursor flickering for full repaint (#187)
Avoids jumping cursor to the prompt on full repaints of the standard
buffer. Does not completely remove a perceptable flicker at the fixed
position if animation is active.

Partially addresses #174 as other cases still need to be checked for
cursor updates
2021-11-29 23:00:58 +01:00
Antonio Natilla
75d9b4b52d
Simple multiline continuation prompt (#184)
* Multiline continuation prompt introduced

* Hardcoded multiline continuation prompt styling

A way to convert `crossterm::style::Color` in `nu_ansi_term::Color` must
be found/implemented. This enables creating a Style from it.
Otherwise, it is necessary that the Style of the prompt is accessible
from everywhere.

Co-authored-by: Antonio Natilla <antonio.natilla@studenti.unimi.it>
2021-11-24 20:10:55 +13:00
JT
c11aef2d9b
Handle the bottom resize a little better (#182) 2021-11-11 19:00:17 +13:00
JT
730147167c
Handle the bottom resize a little better (#181) 2021-11-11 16:55:38 +13:00
Josh
a16f96863d
fn queue_buffer probably didn't mean to flush; Simplified engine->insert_char and removed the need to create a String at each insert. (#180)
* `fn queue_buffer` probably didn't mean to flush :)

* Simplified insert_char, and removed the need to create a String at each insert

* rust fmt
2021-11-11 08:19:10 +13:00
Stefan Holderbach
1b24499298
Improvements to handling of incoming events (#179)
* Drain crossterm events, prioritize last resize

This attempts to address #166, some slowness is still observed

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>

* Fix timing of repaint with drained events

* Initial code to coalesce edit commands

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2021-11-10 13:59:17 +13:00
Stefan Holderbach
550ce9b486
Bump dependency versions (#177) 2021-11-08 10:49:30 +13:00
Antonio Natilla
9218158903
Curly braces fix in vim events (#173)
Support for Shift-AltGr is required for several European keyboards (e.g. italian) #169 #136 #139 #171

* Curly braces fix

* Curly braces fix for vim events

Co-authored-by: Antonio Natilla <antonio.natilla@studenti.unimi.it>
2021-11-06 14:20:18 +01:00
Stefan Holderbach
ee0c274600
Fix printing in #170 (#172)
Small printing bug introduced due to raw mode had to be fixed
2021-11-05 23:19:07 +01:00
Antonio Natilla
e159f3fd0d
Curly braces fix (#171)
Co-authored-by: Antonio Natilla <antonio.natilla@studenti.unimi.it>
2021-11-05 22:56:20 +01:00
Stefan Holderbach
d832449a51
Provide more details in the keyevent debugger (#170)
Inform about the character code and the bit pattern of the modifier to
debug more subtle problems with key events
2021-11-06 10:22:42 +13:00
Josh
75a2ca0761
Builder to customize and disable idle animations (#168)
* Introduced 'repaint' flag on struct ReedLine, and associated builder function

* Added builder to configure and disable idle animations

* Ran `cargo fmt` and `cargo clippy`
2021-11-06 07:17:32 +13:00
JT
68a6ab4e5b
Expose line buffer (#165)
* Add list style completions

* Expose the LineBuffer struct
2021-10-16 07:28:53 +13:00
JT
6fedafffb7
Update LICENSE (#163) 2021-10-07 06:49:16 +13:00
JT
88bded3417
Add list style completions (#162) 2021-10-05 10:32:21 +13:00
Marco Zanrosso
de0f399650
[BugFix] undo function (#143)
* [BugFix] undo function

This commit solves the problem that when the undo function is performed,
for some reason the buffer remained with 1 character.

The FIX consists in correcting the logic of the current implementation
by bringing it to the initial design state; Where the vector of the
buffer had been initialized with an empty entry so that when performing
many times the undo brought you back to an initial condition with
the blank buffer rather than show you the first character.

* [Add] doc-test for set_previous_lines

This test was created specifically to check that the insertion
of characters and words in the Editor.edits vector works properly.

* Replace doctest with unittest

This does not require exposing private functionality as pub

* Fix naming according to #160

Co-authored-by: sholderbach <ho.steve@web.de>
2021-10-03 23:01:01 +02:00
Stefan Holderbach
f03c036ba4
Fix links in lib.rs 2021-10-03 22:16:42 +02:00
Stefan Holderbach
8a09f75dee
Clarify method names for undo-interface (#160)
Minimal change to make undo machinery of `Editor` more explicit.
2021-10-04 09:11:59 +13:00
Stefan Holderbach
2ecda6e681
Fix README badges (#161)
Account for the move to the nushell org
2021-10-04 09:07:03 +13:00
Stefan Holderbach
38bf8e469c
Simplify and document history trait (#159)
Inspired by #158
2021-10-04 09:05:58 +13:00
Stefan Holderbach
87ce437d89
Fix CtrlD/CtrlC and reverse-history-search + stuff (#155)
* Fix CtrlD/CtrlC and reverse-history-search + stuff

- `Ctrl+C` and `Ctrl+D` did not work after the changes in #138 and #146
  - Fixed by only registering the `ReedlineEvent` and defering
potentially necessary edits to the `handle_event` stage
  - Defined their behavior for the reverse history search
  - Corrected interactions with undo (as best as I could understand it)
- Reverse history search did not allow for browsing through its results
  - Fixed `handle_history_search_event` and simplified the cases
- Register undo steps for the reverse history search (when entering and
leaving via enter)
- Added comments to similar sounding methods and variants (UPDATE IF
NECESSARY!)
- Moved the repaint stuff closer together in engine.rs for better
readability
- Noncritical stuff that caught my eye

* Test first/last line detection
2021-10-03 19:44:23 +02:00
Sherub Thakur
bfddc5870c
Add tests line buffer (and fix methods) (#150)
* Ignore tarpaulin coverage build folder and html report

* Add tests for line buffer

* Capitalize char only moves a character to right

* Uppercasing and lowercasing words works

* Fix the swap grapheme function

I have made this to be close to what I inferred the intent to be. I
really think we should probably have two functions which do this:
`swap_grapheme_left` and `swap_grapheme_right` which work in the
mentioned direction.

* Fix swap words

Swap words only swap words and there is no change in position.
2021-09-27 14:37:57 +13:00
JT
93c2146fcf
Bump version (#152)
* Bump to 0.2

* Add to README

* Improve top docs

* Clear to the end of each newline to remove any leftovers
2021-09-24 07:40:32 +12:00
Fernando Herrera
5048cc50e7
Incomplete brackets (#149)
* incomplete brackets

* check type of brackets

* comment and tests
2021-09-24 07:01:42 +12:00
JT
a6ad37ced9
Improve rendering of multiline (#151) 2021-09-24 06:58:40 +12:00
JT
30ad477832
Multiline improvements (#148)
* Multiline overlow in navigation fix

* Remove line from insertion point

* Finish adding scrolling to the adjustment

* fix test
2021-09-23 12:21:31 +12:00
JT
22fc31c68d
Add simple validation to check for multiline completion (#147)
* Add simple validation to check for multiline completion

* fix test
2021-09-22 17:12:26 +12:00
Sherub Thakur
30f9d419f3
Add tests to emacs and vi edit mode (#146)
* Add equality derive for EditCommand and ReedlineEvent

* Move matches to keybinds for emacs edit mode

* Simplify event matching in emacs edit mode

* Bugfix: All matches happening at same point

* Add failing test to check keybinding override

* Bugfix: Inserting capital character works

* Unknown requirement: test to be to capture currently unknown requirement

* Add rstest

The reason is to easily write parameterized tests

* Add test: for emoji input to emacs

* Add tests and fixes for vi edit mode

* Reedline None event and vi keybinds

* Keybindings are overridable

* Vi Reedline::None
2021-09-22 16:37:19 +12:00
JT
cd87851ad9
Cleanup some deps and improve build times (#144) 2021-09-06 05:39:19 +12:00
Fernando Herrera
1233b450b9
Modifier for altgr (#139)
* modifier for altgr

* change reedline event
2021-09-05 09:48:01 +12:00
JT
ab3666a0ac
Fix update to TODO (#142)
* Fix update to TODO

* Fix tests

* remove test ci
2021-09-05 07:57:23 +12:00
JT
ccce8d5fa1
Fix double chars (#140)
* Fix double chars

* Fix double chars

* Updates

* doctest fixes

* see if it's paying attention

* see if it's paying attention
2021-09-05 07:32:02 +12:00
JT
2d4a579f0b
Create rust.yml (#141) 2021-09-05 07:15:54 +12:00
JT
1bd9e9fe01 Fix clippy 2021-09-05 06:09:39 +12:00
JT
e3f8b59f86
Update ci.yml 2021-09-05 06:08:53 +12:00
Sherub Thakur
8c6fe225ab
Pull some events from EditCommand to ReedlineEvent (#138)
* Extract hinter and highlighter out of Painter

* Cleanup unused variables, add comments

* Remove AppendToHistory Event

* Keybindings talk in terms of ReedlineEvent

* Add placeholder docs

* Push History handling one-level up

* Modify Enter handling to match others

* Extract Previous and Next History commands from EditCommand to ReedlineEvent

* Remove reduncant EditCommand -> ViFragment

* Pull Up/Down from EditCommand to ReedlineEvent

* Pull SearchHistory from EditCommand to ReedlineEvent

* Refactor insertion wrapping code

* Push History handling one more level up

* Fix doc test: keybind interface change

* Remove redundant indirections

* Reorganize methods in engine

* Update vi binds from history to up/down operations

* Remove the hacky EditInsert brach from ReedlineEvent
2021-09-05 06:04:58 +12:00
Sherub Thakur
aebbc24188
Modularization of the main struct (#134)
* Remove vagueness from position method

* Pull terminal size into the main struct

* WIP: prompt widget

* Remove a bunch of stuff

- clock
- vi stuff
- requirement to do full repaint state management

* Remove edit mode from event matcher

* Extract out event handling into a function

* Add reedline specific enum

* Rebase fixes

* Update docs

* Re-add clock functionality

* Add event-parser

* Pull out Input Parsing out of the main struct

* Move input parsing stuff into a directory

* Move vi stuff into input parsing

* Re-introduce Vi-Mode

* Remove EditMode enum

* Emacs mode uses non-default keybindings

* Basic hygine for edit_mode

- Rename: input_parsing to edit_mode
- Rename: EmacsInputParser to Emacs
- Rename: ViInputParser to Vi
- Rename: InputParser to EditMode
- Add docs: EditMode
- Add docs: Vi
- Add docs: Emacs

* Remove update_keybindings interface

* Vi sends Repaint events on mode switch

* Rename new to create
2021-08-29 06:10:16 +12:00
Sherub Thakur
12ba36f8be
Less intrusive tab completion (#133)
* Organise tab handling into files

* Concretise assumptions as manul tests

* Add expectation (failing test)

* Store one-level history for tab handler

* Remove reset index from the public interface of TabCompletion

* Update note on cycling though the tab-completions
2021-08-15 08:14:10 +12:00