Commit Graph

28 Commits

Author SHA1 Message Date
maxomatic458
34af84ebe0
Typed text style (#730)
* add match style to MenuTextStyle

* cargo fmt

* fix external style
2024-01-28 21:36:58 -08:00
maxomatic458
c8a52a85f1
menu refactor (#723)
* get correct cursor pos when menu indicator contains newline

* add tests

* fix cursor pos in multiline prompt

* make description mode enum public

* add doc comment

* respect windows newline in update_values

* Revert "respect windows newline in update_values"

This reverts commit 070d600545.

* add complete_with_base_ranges to Completer

* add builder for correct_cursor_pos

* add config options to completion examples

* add style to ide menu

* run fmt

* start menu refactor

* Revert "start menu refactor"

This reverts commit 62726f29be.

* start menu refactor

* fix ci

* use MenuSettings struct

* add test case for unix newline

* more tests

* fix newline replace

* add explicit panic to stay backwards compatible

* fix ci

* Update columnar_menu.rs

Co-authored-by: Yash Thakur <45539777+ysthakur@users.noreply.github.com>

---------

Co-authored-by: Yash Thakur <45539777+ysthakur@users.noreply.github.com>
2024-01-28 08:01:16 -08:00
nibon7
7069448050
Don't panic when creating FileBackedHistory with usize::MAX capacity (#701) 2024-01-25 09:53:18 -08:00
Michael Angerman
ede2defbfe
update the ide_completions example with more cases to explore (#718) 2024-01-22 14:09:59 -08:00
maxomatic458
cbb56e25d0
get back the ranges of the strings from the completer used for generating completions (#713)
* get correct cursor pos when menu indicator contains newline

* add tests

* fix cursor pos in multiline prompt

* make description mode enum public

* add doc comment

* respect windows newline in update_values

* Revert "respect windows newline in update_values"

This reverts commit 070d600545.

* add complete_with_base_ranges to Completer

* add builder for correct_cursor_pos

* add config options to completion examples
2024-01-22 13:08:52 -08:00
maxomatic458
31eaeeb231
ide style completions (#696)
* ide style completions

* descriptions

* truncate suggestion & description

* border width

* clippy & typos

* run cargo fmt

* add with_description_offset to builder

* fix empty description

* minimize description padding

* rework working details handling + fix CI

* add tests + change split function

* fix multiline prompt cursor pos
2024-01-18 10:37:06 -06:00
Stefan Holderbach
879272643f
Properly handle optional event modes (#659)
* Properly handle optional event modes

Both bracketed paste and the kitty keyboard enhancement flag are not
always supported.
This goes both for terminals that may not emit events according to their
spec and also applications that will run in the terminal independent of
reedline.

Make sure we enter the mode when starting to take control and exit the
mode when leaving the mode or being dropped.
The settings exposed to the user will just internally enable a setting
(in the case of the kitty keyboard enhancement flags crossterm provides
and easy way to check for support that we take into account with that)

* Adjust demo to sane bracketed paste API

* cargo fmt

* Add a static helper `kitty_protocol_available`

Public as `reedline::kitty_protocol_available`

Replace the method `Reedline::can_use_kitty_protocol` that doesn't
depend on `Reedline` in the future

Rewrite `KittyProtocolGuard` in terms of it.

* Remove `Reedline::can_use_kitty_protocol`

* Add builder style setters for terminal enhancement

* Switch demo to bracketed paste via builder

* Expand `use_kitty_keyboard_enhancement` doccomment

* Remove old terminal enhancement APIs

* Use `use_kitty_keyboard_enhancement(true)` in demo

As we internally check whether it is available, this should be fine in
nearly all terminals (if they can safely be probed)

* Fix typo
2023-11-14 19:53:13 +01:00
Hofer-Julian
63c43a9a6b
Also run clippy on examples (#666)
* Also run clippy on examples

This PR also fixes existing clippy lints

* Update .github/workflows/ci.yml

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-11-14 11:40:28 +01:00
Darren Schroeder
7ca3c388b9
don't allow certain examples to compile without their features (#658) 2023-11-05 14:31:24 -06:00
Chinmay Dalal
973dbb5f5f
add cwd aware hinter (#647)
* add cwd aware hinter

towards https://github.com/nushell/nushell/issues/8883

* handle the case where get_current_dir returns Err

* WIP cwd aware hinter

 - guard CwdAwareHinter with feature flag
 - remove references to fish from DefaultHinter as fish is cwd aware
 - add example

* document that CwdAwareHinter is only compatible with sqlite history

* handle non-sqlite history

* handle no sqlite feature in example

* fix warnings
2023-10-19 22:41:09 +02:00
Horasal
b1344f6a65
Accept Command with args for BufferEditor (#630)
`.with_buffer_editor()` now expects a `std::process::Command` that can be provided with additional arguments and a tempfile that is unique.

---------

Co-authored-by: Horasal <horsal@horsal.dev>
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-09-28 16:42:05 +02:00
Hofer-Julian
f993939690
Improve history isolation (#634)
* Improve history isolation

After this change we will get rows:
- that have the same session_id, or
- have a lower id than the first command with our session_id, or
- if there's no command with our session_id, take the whole history.

* Enforce history_isolation also for hints

* Store the session_timestamp in `SqliteBackedHistory`
2023-09-17 15:45:38 -05:00
ysthakur
33828e5821
Add support for a different prompt after submission (#627)
adds a separate `transient_prompt` to be displayed after submitting.
2023-09-12 22:36:01 +02:00
Stefan Holderbach
31257a4c54
Bump crossterm to 0.27.0 (#625)
* Bump `crossterm` to 0.27.0

Waiting for nushell as ratatui (used in nu-explore) is still on 0.26

* Cargo fmt

* Fix examples
2023-08-28 21:08:10 +02:00
WMR
79778f7b85
Update to make work with new lines embedded in sent string. (#588)
* Update to make work with new lines embedded in sent string.

* Appease fmt
2023-05-30 17:20:20 -05:00
samlich
97f754425a
History filter (#566)
* add `HistoryFilter` and use it in engine, to allow not storing items with a given prefix

* use `with_history_exclusion_prefix` in demo

* review

* impl history filter on engine

* keep 1 filterered history item

* don't impl History on Box<T: History>
2023-05-03 23:25:42 +02:00
WindSoilder
3b60811f57
support bracketed paste (#571)
* support bracketed paste

* update demo

* fix clippy

* no need to enable bracketed paste, leave the behavior to user
2023-04-24 20:07:56 +02:00
Darren Schroeder
61c6409fb7
Allow history searching via session id (#562)
* add the ability to search history with session id

* clippy
2023-04-18 07:13:49 -05:00
WindSoilder
27f4417191
Update crossterm to version 0.26.1 (#560)
* update crossterm to 0.26.1

* add event_listener_kitty_proto example

* add comment

* remove trait
2023-04-13 19:24:17 +02:00
Darren Schroeder
572a391211
add history-clear to demo (#537) 2023-02-10 18:34:30 +01:00
Doug Kelkhoff
e1366260c1
Allow configuration of multiline prompt color (#531)
* make multiline prompt color configurable

* remove unnused use statements

* minor comment update

* Clippy fix

new lints from rust 1.67

* Cargo fmt

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-01-27 15:58:25 +01:00
Carl Schierig
475495d785
Make reedline handling cursor shapes more configurable (#515)
Adds a struct to configure the cursor shape

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
resolve https://github.com/nushell/reedline/issues/514
2022-12-21 12:15:46 +01:00
Jonathan Moore
de8fc988df
Make DefaultPrompt configurable (#519)
* Add default prompt configuration
2022-12-01 13:58:01 +01:00
perlindgren
cd2d263eb4
Custom validator and prompt code examples (#500)
* custom validator and prompt

* Split prompt and validator demo into two files

Also add info text when running

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2022-11-07 20:33:54 +01:00
Stefan Holderbach
307df231e1
Split the main example binary into examples (#506)
* Split the main example binary into examples

Separate fully featured demo from keybinding listing and event listener

Allows to make `gethostname` dev-dependency

* Clippy fix in examples
2022-10-30 21:41:13 +01:00
Stefan Holderbach
5061d2288c
Fix completion example in README/lib.rs (#497)
Adapted from examples added in #493
2022-10-16 23:41:57 +02:00
perlindgren
835d2e9f25
examples updated (#493)
Puts the minimal examples from the documentation as separate example executables to play around with
2022-10-16 22:13:55 +02:00
Gregor
70118f732c
Basic external printer (#467)
Addresses #320, #236

* Adding External printer

* Made ExternalPrinter as an optional feature. Clippy is happy, test pass, docs added.

* ExternalPrinter: prints multiple messages if available, more on error-handling.

* Bug(s) fixed. Prints messages. Working example in examples folder. Code formatted, clippyed, tests pass.

* Generic ExternalPrinter<T> where T: Display.

* Fixed: Works with buffers larger than a line.

* Fixed: Works with buffers larger than a line, refactored.

* Different approach, seems to look like what is expected. Gives the "illusion" of one line being entered. Needs more testing, could have some off by one errors ;)

Co-authored-by: Gregor Engberding <gregor@meinkopter.de>
2022-09-14 21:58:45 +02:00