Commit Graph

128 Commits

Author SHA1 Message Date
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
Sherub Thakur
ade4172046
Cleanup (#130)
* Cleanup: Remove un-necessary indirections from engine to editor functions

* Cleanup: Remove dead code - partial_command

* Cleanup: Make undo/redo interface consistent with other editor functions

* Cleanup: abstract up/down command logic to appropriate units
2021-08-13 07:29:44 +12:00
Sherub Thakur
d8684f50af
Pull undo redo to editor (#129)
* Pull undo/redo functionality out from line_buffer to editor

* Update editor.rs

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2021-08-13 06:29:46 +12:00
Sherub Thakur
f490dd4f93
Core editor (#128)
* Add a core-editor folder

* Add editor

Currently this is more of less line_buffer the integration with engine
has a few hacky edges that need to taken care off.

* Pull cut buffer operations into editor
2021-08-13 05:28:28 +12:00
JT
289188eee7 Allow the read_line to fail in the demo 2021-08-07 10:10:00 +12:00
JT
5822306504
Exposed the styled text struct (#127) 2021-07-27 14:58:30 +12:00
JT
28dbd03953
Fix enter during history traversal (#126) 2021-07-27 14:38:56 +12:00
JT
1caf34339d
Add more rustdoc comments (#124)
* Add more rustdoc comments

* Add more rustdoc comments
2021-07-26 16:24:02 +12:00
JT
d8d8947735
Update README.md 2021-07-26 08:43:01 +12:00
JT
a69f95b47b
Update README.md 2021-07-26 08:42:10 +12:00
JT
2023222d6b
Add clippy to ci (#123) 2021-07-26 08:36:15 +12:00
JT
e36fff2d86
Update ci.yml (#122)
* Update ci.yml

* Update ci.yml
2021-07-26 08:23:29 +12:00
Marco Zanrosso
df7c24b651
[StyleFix] compact engine.rs match arms (#121) 2021-07-26 08:12:08 +12:00
JT
79ae22ed50
Fix the build (#118) 2021-07-25 20:50:06 +12:00
Sherub Thakur
858eabf940
Outside world does not know about insertion point (#111) 2021-07-25 20:37:41 +12:00
Marco Zanrosso
d251df31ac
[Add] CtrlZ (undo) and CtrlG (redo) features (#107)
* [Add] CtrlZ and CtrlY features

* [Update] undo and redo features to work with words

* [StyleFix] resolved cargo clippy warnings in lib.rs

* [BugFix] change redo keybinding

* [BugFix] reset stored linebuffer when reedline return

* [StyleFix] de-duplicate lines

* [StyleFix] simplify EditCommand enum

* [Improve] set_previous_line logic

* [StyleFix] avoid glob imports
2021-07-25 20:36:21 +12:00
Marco Zanrosso
29db18292f
[Improve] gitignore file adding MacOS ds_store (#114) 2021-07-23 10:33:27 +12:00
Stefan Holderbach
653223f595
Change cursor pos in prefix search to the end (#115)
* Change cursor pos in prefix search to the end

Approach discussed in #113

* Shrink mem footprint of test

Just sneaking in a commit
2021-07-22 16:53:12 +12:00
Stefan Holderbach
3dae21fe34
Fix the history behavior (#94) (#110)
* [WIP] Fixing the history behavior

* Repaint mode switching after the 1sec case
* Back to history cursor with len for not used -> fixes the skipping the
most recent
* unit tests not yet adapted
* None logic not yet smart to be able to leave history traversal

* Rewriting history with JT

Fixing the basic traversal as well as the prefix based search.

Ctrl-R search still dysfunctional. Missing the duplicate detection, thus
not passing tests. Missing test coverage for moving forward in a search.

* Complete basic history test suite

* Test the forward behavior in prefix search
* Skip consecutive equal matches

* Fix Ctrl-R search

* Update file_backed.rs

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2021-07-21 06:11:26 +12:00
Sherub Thakur
b4748acfb5
History fix cursor update (#97)
* Cursor updates with the appropriate history command

* History command inserts after the end

we will most likely store multiline commands in history as `String`s so
I have opted for a converstion of this string to a vector separated by
newlines in `set_buffer`.

* History Traversal paining rules

- On normal up down we update the cursor to the end of the line
- On prefix based up and down we do not update the cursor

Rationale for this is that when we are doing prefix search a user might
want to add more to his query so as to get better prefix matching and
having to delete through all the chars we would otherwise fill in might
be annoying.

* Fix prefix search not updating properly

* Normal traversal sets history string at cursor to line buffer

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2021-07-20 05:59:49 +12:00
JT
4056abe4c2
Add multiline support (#108) 2021-07-19 11:08:29 +12:00
Stefan Holderbach
db9722e5f3
Fix eclectic docs (#106)
* Fix eclectic docs

* Make `cargo doc` happy again
* Let the `lib.rs` doc test a few constructor examples.
* Fix badges and repo links in the README

* Make the badges linkout

* Fix typo
2021-07-19 06:05:54 +12:00
Stefan Holderbach
ea717d81bb
Manual checklist to test the UX (#105)
As some bugs are hard to find with automated tests, we should regularly
test the core behavior of reedline, to catch those bugs that might creep
in, when changing the I/O, frontend or core code.

I am looking for suggestions on how we make this manual checklist
comprehensive enough to cover most problems but not too tedious to do
manually. (Ideally we find a way to integration test most of it)
2021-07-17 23:51:58 +02:00
Marco Zanrosso
6f2344271e
[StyleFix][Update] Documentation (#104)
* [Update] lib.rs with latest improvements

* [Update] readme.md with latest improvements
2021-07-17 01:40:38 +02:00
Marco Zanrosso
e47191650e
[StyleFix] remove clippy warnings (#102) 2021-07-16 21:58:40 +02:00
Marco Zanrosso
b934c8a3ef
[Add] in-line hints (#101)
* [Add] in-line hints

Other features:
 - inside line hints
 - customizable hints style
 - hints from completer
Todo:
 - hints from history

* [Improve] in-line hints adding support for history

* [Improve] in-line hints adding dynamic support for inside-line hints

* [StyleFix] main.rs with better comment for DefaultHinter

Comment out exclusivity between use of with_completer and with_history.

* [BugFix] use only one instance of history
2021-07-17 06:56:16 +12:00
Stefan Holderbach
e95d8465b7
Remove some unnecessary stuff from the engine (#95)
* tool for event tracking is only relevant for testing -> main
* unnecessary enable_raw_mode call
* we don't enable mouse mode yet
* clippy suggested removals of overspecified type and clone
2021-07-13 15:42:45 +02:00