Commit Graph

521 Commits

Author SHA1 Message Date
JT
5421556895
Fix up merge (#83)
* WIP

* WIP

* Finish fixing up merge

* Finish fixing up merge

* Update engine.rs
2021-07-01 19:38:42 +12:00
Marco Zanrosso
50febca8c6
[Improve] add buffer highlight if command is recognized (#82)
Co-Authored-By: JT <jonathandturner@users.noreply.github.com>

Co-authored-by: JT <jonathandturner@users.noreply.github.com>
2021-07-01 18:47:53 +12:00
Sherub Thakur
8c19d610c1
Extract screen painting stuff into a separate struct (#80) 2021-07-01 18:24:04 +12:00
Marco Zanrosso
fab60e80a6
Bugfix after recent changes in prompt module (#81)
* [BugFix] add use with recent implemented prompt function

* [BugFix] add public scope to PromptHistorySearch struct fields
2021-07-01 07:55:39 +12:00
Urgau
1b9247dc16
Improve Prompt trait and it's handling (#79)
Move out of Box<dyn Prompt> by using `&dyn Prompt`.
Also use `Cow<str>` instead of `String` for the
`Prompt` return types. Both of this changes permit
the use of reference but most importantly,
it avoids unnecessary clones.
2021-06-26 10:57:06 +12:00
ahkrr
30bede6646
fix: overwriting of line #76 (#77)
* fix: overwriting of line #76

* fix: overwriting_line

Co-authored-by: ahkrr <alexhk@protonmail.com>
2021-06-26 10:56:22 +12:00
Sherub Thakur
ca445820ae
Extending PromptMode (#74)
* Revamp Prompt states

The idea here is that what we want to display on the screen which can
impact the prompt should be available as part of the prompt's interface.

So here are the things that can impact what we show with our prompt
- The line-editor can either be in Emacs mode or VI mode (for now)
  [These are exclusive to one another]
- The line-editor can be either in editing a command or searching
  history mode [These two states are also exclusive]
- Lastly the command can be either single-line or multi-line.

Now all these variables can happen togeter (i.e. they for a cross
prodcut)
- example 1: You can be in vi-normal mode and be editing history search
  term and that particular term earlier resulted in a multi-line
  command. (So, we need to showcase all these three variations together)

one way to do this is using a struct. I found that it was making the
more frequent case (of being in edit mode) overly complex so I chose to
expose the functionality as separate methonds.

* Cleanup custom strings from engine
2021-06-26 05:52:56 +12:00
JT
1ad2fcc46a
Add vi parser (#78) 2021-06-24 10:41:27 +12:00
JT
4d786e0118
Fix Windows full repaint (#75) 2021-06-24 06:40:23 +12:00
Sherub Thakur
83ab5ddd6a
Add pretty_assertions lib (#73) 2021-06-24 06:07:58 +12:00
ahkrr
6a7cea6e00
fix: prompt_origin and prompt_offset issues (#72)
Co-authored-by: ahkrr <alexhk@protonmail.com>
2021-06-22 14:54:54 +12:00
Sherub Thakur
dd66dd71aa
Extract operations on buffer into line buffer (#71)
* Kickoff testing

* Change interface for insert_char and insert_str

- Renamed insert_char -> insert_char_at
- Renamed insert_str -> insert_str_at, Modified the interface to use
  insertion_point instead of insertion_point.offset
- Added insert_char: this also modifies the insertion_point in addition
  to chaning the buffer
- Added insert_str: this also modifies the insertion_point in addition
  to chaning the buffer

Question: Do we really need insert_char_at and insert_str_at?

* Move backspace and delete to line_buffer

- Rename backspace -> delete_grapheme_left
- Rename delete -> delete_grapheme_right

* Move backspace_word and delete_word to line_buffer

* Move upcasing and lowercasing to line_buffer

* Move swaping operation to line_buffer

* Remove `current_line` and use `get_buffer` instead

* Replace use of `insert_char_at` with `insert_char`

* Replace use of `insert_str_at` with `insert_str`

* Remove redundant setting insertion point to 0
2021-06-21 17:53:00 +02:00
JT
4433bfc309
Update README.md 2021-06-17 14:29:10 +12:00
JT
ad33d8e0f3
Add more support for vi (#59)
* Add more support for vi

* Fix doctests
2021-06-17 11:27:12 +12:00
Darren Schroeder
0a224bef05
syntax highlighting fileio (#56)
* syntax highlighting fileio

* add an example syntax json file

* complied with jt's wishes because reasons :)
2021-06-16 08:02:29 +12:00
JT
df0fba8ec5
Fix Windows prompt (#58) 2021-06-16 07:07:04 +12:00
JT
c8d00d1acd
Add vi mode (#57) 2021-06-15 11:03:57 +12:00
Stefan Holderbach
725779728c
Various proposed refactors (#54)
* Small refactors, doctest for History search walk

* Reset History cursor on append() automatically

* Split off the enums from engine.rs
2021-06-14 18:35:40 +12:00
mzanrosso
4cd9733c1b
Fix SHIFT KeyModifier (#53)
Co-authored-by: Marco Zanrosso <mzanrosso@storvix.eu>
2021-06-12 20:44:44 +12:00
JT
e0714819e4
Add configurable keybindings (#51) 2021-06-11 12:08:09 +12:00
Stefan Holderbach
ceb894f5c9
Skip duplication in History prefix search (#50) 2021-06-11 12:00:33 +12:00
JT
43e300dc5d
Add delete and backspace word (#52) 2021-06-11 11:59:47 +12:00
mzanrosso
ceedca2404
Add dynamic prompt color (#49)
Co-authored-by: Marco Zanrosso <mzanrosso@storvix.eu>
2021-06-10 19:06:05 +02:00
JT
14d051c950
Add resize logic and history prefix (#48) 2021-06-10 16:30:20 +12:00
Stefan Holderbach
afd2c9526e
Basic API docs to give an overview of the current state (#47)
* Doctests for History

* Improve the general documentation of History.
* Doc tests to understand the API.
* Includes regression test to read back correctly from file.

* Run doctests in CI

* Minimal doc comments for Clipboard

* Basic API docs for the most important components

Still work in progress

* Add README and lib.rs docs

* Document more internals to help new contributors

* Doctest linebuffer

* Revert "Doctest linebuffer" for now

This reverts commit 08ff9c152c.

* Format run
2021-05-04 12:12:08 +02:00
JT
f00f08567e
Add Prompt trait and make current prompt the default (#46) 2021-04-30 12:26:52 +12:00
Stefan Holderbach
7b2ec8a073
Refactor Clipboard behind feature flag (#45)
The clipboard crate breaks the CI in a non GUI context. Make use of it
optional by feature flag `system_clipboard`.
Clipboard could be changed during runtime based on trait.

Additional fix: read back from system clipboard
2021-04-30 10:46:42 +12:00
Stefan Holderbach
32c9ac0c25
Support history file (#44)
* Support history file

History has a new constructor to remember a file to read from/ write to.
Writing is deferred to the Drop.
Binary supports history file via `REEDLINE_HISTFILE` env variable

Additional changes:

Inverted the ordering of the history VecDeque to simplify file IO and
history internals. This makes the search code slightly more brittle.

* Clarify history API

* Harmonize return type of iterators
2021-04-30 10:45:12 +12:00
Guillermo Lella
6c8ca05b4c
added OS's clipboard (#43)
Should work in Linux, macOS and Windows
2021-04-26 18:55:49 +12:00
Stefan Holderbach
e7f2b4cdc5
Simplify prints and newline after read_line() (#39)
Make the return after a succesful entry part of `Reedline.read_line`'s
contract
2021-04-11 06:27:19 +12:00
Stefan Holderbach
2b1897e3a9
Extract history management into struct (#38)
* Extract history management into struct

* Encapsulates the up/down arrow browsing
* Still fully in-memory but easy to add file based constructors and
flushing
* No further integration with the statefulness of the Ctrl-R search
(yet)

* Add tests to history
2021-04-10 17:43:53 +12:00
Jonathan Turner
1a61030be5
Update Cargo.toml 2021-04-10 09:24:10 +12:00
Jonathan Turner
8ae6b58ae1
Split lib from main (#37)
* Split the library from the main

* Finish with lib refactor
2021-04-10 09:21:37 +12:00
Jason Hansen
bcf894076a
Remove Deref implementation and other refactorings (#36)
`Deref` no longer makes sense for `LineBuffer` since it can have
multiple lines.
2021-03-23 06:30:00 +13:00
Jonathan Turner
c376cefd3e
Begin multiline editing (#35) 2021-03-21 11:01:28 +13:00
Stefan Holderbach
d465afe536
Only append unique new lines to history (#34) 2021-03-21 08:01:11 +13:00
Stefan Holderbach
14aa0cd00c
Add history command for debugging (#33) 2021-03-21 08:00:23 +13:00
Jason Hansen
d8e7b65fba
Simplify prompt code and handle narrow terminals (#32)
When there isn't enough room for both the left and right prompts, only
show the left one. Also truncate the left prompt if it's too wide.
2021-03-20 11:17:42 +13:00
Stefan Holderbach
43092998d3
Basic clear (#30)
* Basic clear

Addresses #28

Succeeds in providing a clear new screen for both the line editing and
reverse search mode.
Solution is conservative and prints more newlines than strictly
necessary as solutions with scrolling didn't seem to work as expected.

* Command based clear

* Redraw prompt indicator after history search

The prompt indicator gets drawn over when searching the history so we
need to restore it when done searching.

Co-authored-by: Jason Rodney Hansen <jasonrodneyhansen@gmail.com>
2021-03-20 08:27:42 +13:00
Darren Schroeder
6ec4f86068
added a slightly-fancy prompt (#29) 2021-03-19 06:39:23 +13:00
Basile Henry
073bdde3c8
Implement basic history search (#27) 2021-03-18 15:04:51 +13:00
Darren Schroeder
5e924ba896
small refactor (#25) 2021-03-18 06:53:22 +13:00
Stefan Holderbach
7f9cbe02db
Minimal enum to address #18 (#22)
* Minimal enum to address #18

Reuse outer Result for error handling only pass the special case
signals.

* Restore behavior of shell

* support exit via `exit` or `logout`
* Clear buffer on pressing Ctrl-c
* move one line down on Ctrl-c
  * Handling by main maybe suboptimal

* Fix whitespace awareness regression

* Rename special Ctrl key signals
2021-03-18 00:01:50 +13:00
Jason Hansen
4ae019c6a5
Implement Deref for LineBuffer (#23)
This removes the need for `get_buffer()` everywhere.
2021-03-17 14:04:27 +13:00
Jonathan Turner
90aca707d0
Let's try adding a ci (#24) 2021-03-17 14:03:17 +13:00
Jason Hansen
2123d1d874
Add more commands and simplify some existing ones (#21) 2021-03-17 12:10:38 +13:00
Jason Hansen
073a62393a
Fix backspace and delete to use grapheme clusters (#20) 2021-03-16 18:17:07 +13:00
Jason Hansen
3896346444
Remove the need to allocate new Strings (#19) 2021-03-16 16:11:27 +13:00
crozbo
8683e8d2ae
Add binding for Ctrl+n and Ctrl+p (#17)
Co-authored-by: crozbo <crozbo@users.noreply.github.com>
2021-03-16 13:37:09 +13:00
Jonathan Turner
92459ce185
Allow the engine to read lines (#16) 2021-03-16 13:10:33 +13:00