1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-08 08:25:51 +03:00

describe termwiz support in documents

Этот коммит содержится в:
rhysd
2023-10-21 02:38:18 +09:00
родитель 257c8bcbf0
Коммит 1e781950d6
3 изменённых файлов: 31 добавлений и 14 удалений

Просмотреть файл

@@ -17,7 +17,7 @@ Multi-line text editor can be easily put as part of your TUI application.
- Search with regular expressions - Search with regular expressions
- Mouse scrolling - Mouse scrolling
- Yank support. Paste text deleted with `C-k`, `C-j`, ... - Yank support. Paste text deleted with `C-k`, `C-j`, ...
- Backend agnostic. [crossterm][], [termion][], and your own backend are all supported - Backend agnostic. [crossterm][], [termion][], [termwiz][], and your own backend are all supported
- Multiple textarea widgets in the same screen - Multiple textarea widgets in the same screen
- Support both [tui-rs][] (the original) and [ratatui][] (the fork by community) - Support both [tui-rs][] (the original) and [ratatui][] (the fork by community)
@@ -130,6 +130,14 @@ cargo run --example ratatui_termion --no-default-features --features=ratatui-ter
cargo run --example ratatui_popup_placeholder --no-default-features --features=ratatui-crossterm cargo run --example ratatui_popup_placeholder --no-default-features --features=ratatui-crossterm
``` ```
### [`termwiz`](./examples/termwiz.rs)
```sh
cargo run --example termwiz --no-default-features --features=ratatui-termwiz
```
Minimal usage with [termwiz][] support.
## Installation ## Installation
Add `tui-textarea` crate to dependencies in your `Cargo.toml`. This enables crossterm backend support by default. Add `tui-textarea` crate to dependencies in your `Cargo.toml`. This enables crossterm backend support by default.
@@ -160,10 +168,10 @@ tui-textarea = { version = "*", default-features = false, features = ["termion"]
If you're using [ratatui][] instead of [tui-rs][], you need to enable features for using ratatui crate. The following table If you're using [ratatui][] instead of [tui-rs][], you need to enable features for using ratatui crate. The following table
shows feature names corresponding to the dependencies. shows feature names corresponding to the dependencies.
| | crossterm | termion | Your own backend | | | crossterm | termion | termwiz | Your own backend |
|---------|----------------------------------|-------------------|------------------------| |---------|----------------------------------|-------------------|-------------------|------------------------|
| tui-rs | `crossterm` (enabled by default) | `termion` | `your-backend` | | tui-rs | `crossterm` (enabled by default) | `termion` | N/A | `your-backend` |
| ratatui | `ratatui-crossterm` | `ratatui-termion` | `ratatui-your-backend` | | ratatui | `ratatui-crossterm` | `ratatui-termion` | `ratatui-termwiz` | `ratatui-your-backend` |
For example, when you want to use the combination of [ratatui][] and [crossterm][], For example, when you want to use the combination of [ratatui][] and [crossterm][],
@@ -176,9 +184,9 @@ tui-textarea = { version = "*", features = ["ratatui-crossterm"], default-featur
Note that [tui-rs][] support and [ratatui][] support are exclusive. When you use [ratatui][] support, you must disable Note that [tui-rs][] support and [ratatui][] support are exclusive. When you use [ratatui][] support, you must disable
[tui-rs][] support by `default-features = false`. [tui-rs][] support by `default-features = false`.
In addition to above dependencies, you also need to install [crossterm][] or [termion][] to initialize your application In addition to above dependencies, you also need to install [crossterm][] or [termion][] or [termwiz][] to initialize
and to receive key inputs. Note that version of [crossterm][] crate is different between [tui-rs][] and [ratatui][]. your application and to receive key inputs. Note that version of [crossterm][] crate is different between [tui-rs][]
Please select the correct version. and [ratatui][]. Please select the correct version.
## Minimal Usage ## Minimal Usage
@@ -553,7 +561,7 @@ match read()?.into() {
tui-rs allows to make your own backend by implementing [`tui::backend::Backend`][tui-backend] trait. tui-textarea also tui-rs allows to make your own backend by implementing [`tui::backend::Backend`][tui-backend] trait. tui-textarea also
supports it. In this case, please use `your-backend` feature for [tui-rs][] or `ratatui-your-backend` feature for supports it. In this case, please use `your-backend` feature for [tui-rs][] or `ratatui-your-backend` feature for
[ratatui][]. They avoid adding backend crates (crossterm and termion) since you're using your own backend. [ratatui][]. They avoid adding backend crates (crossterm, termion, and termwiz) since you're using your own backend.
```toml ```toml
[dependencies] [dependencies]
@@ -696,9 +704,10 @@ tui-textarea is distributed under [The MIT License](./LICENSE.txt).
[ci-badge]: https://github.com/rhysd/tui-textarea/actions/workflows/ci.yml/badge.svg?event=push [ci-badge]: https://github.com/rhysd/tui-textarea/actions/workflows/ci.yml/badge.svg?event=push
[ci]: https://github.com/rhysd/tui-textarea/actions/workflows/ci.yml [ci]: https://github.com/rhysd/tui-textarea/actions/workflows/ci.yml
[tui-rs]: https://github.com/fdehau/tui-rs [tui-rs]: https://github.com/fdehau/tui-rs
[ratatui]: https://github.com/tui-rs-revival/ratatui [ratatui]: https://github.com/ratatui-org/ratatui
[termion]: https://docs.rs/termion/latest/termion/
[crossterm]: https://docs.rs/crossterm/latest/crossterm/ [crossterm]: https://docs.rs/crossterm/latest/crossterm/
[termion]: https://docs.rs/termion/latest/termion/
[termwiz]: https://docs.rs/termwiz/latest/termwiz/
[tui-backend]: https://docs.rs/tui/latest/tui/backend/trait.Backend.html [tui-backend]: https://docs.rs/tui/latest/tui/backend/trait.Backend.html
[repo]: https://github.com/rhysd/tui-textarea [repo]: https://github.com/rhysd/tui-textarea
[new-issue]: https://github.com/rhysd/tui-textarea/issues/new [new-issue]: https://github.com/rhysd/tui-textarea/issues/new

Просмотреть файл

@@ -47,7 +47,8 @@ pub enum Key {
/// Backend-agnostic key input type. /// Backend-agnostic key input type.
/// ///
/// When `crossterm` and/or `termion` features are enabled, converting their key input types into this `Input` type is defined. /// When `crossterm`, `termion`, `ratatui-termwiz` features are enabled, converting respective key input types into this
/// `Input` type is defined.
/// ```no_run /// ```no_run
/// use tui_textarea::{TextArea, Input, Key}; /// use tui_textarea::{TextArea, Input, Key};
/// use crossterm::event::{Event, read}; /// use crossterm::event::{Event, read};

Просмотреть файл

@@ -172,8 +172,8 @@ impl<'a> TextArea<'a> {
/// Handle a key input with default key mappings. For default key mappings, see the table in /// Handle a key input with default key mappings. For default key mappings, see the table in
/// [the module document](./index.html). /// [the module document](./index.html).
/// `crossterm` and `termion` features enable conversion from their own key event types into [`Input`] so this /// `crossterm`, `termion`, and `ratatui-termwiz` features enable conversion from their own key event types into
/// method can take the event values directly. /// [`Input`] so this method can take the event values directly.
/// This method returns if the input modified text contents or not in the textarea. /// This method returns if the input modified text contents or not in the textarea.
/// ```ignore /// ```ignore
/// use tui_textarea::{TextArea, Key, Input}; /// use tui_textarea::{TextArea, Key, Input};
@@ -194,6 +194,13 @@ impl<'a> TextArea<'a> {
/// textarea.input(key); /// textarea.input(key);
/// } /// }
/// ///
/// // Handle termwiz key events
/// let event: termwiz::input::InputEvent = ...;
/// textarea.input(event);
/// if let termwiz::input::InputEvent::Key(key) = event {
/// textarea.input(key);
/// }
///
/// // Handle backend-agnostic key input /// // Handle backend-agnostic key input
/// let input = Input { key: Key::Char('a'), ctrl: false, alt: false }; /// let input = Input { key: Key::Char('a'), ctrl: false, alt: false };
/// let modified = textarea.input(input); /// let modified = textarea.input(input);