зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-08 16:35:49 +03:00
describe ratatui crate support in readme
Этот коммит содержится в:
@@ -5,7 +5,7 @@ edition = "2021"
|
|||||||
rust-version = "1.56.1"
|
rust-version = "1.56.1"
|
||||||
authors = ["rhysd <lin90162@yahoo.co.jp>"]
|
authors = ["rhysd <lin90162@yahoo.co.jp>"]
|
||||||
description = """
|
description = """
|
||||||
tui-textarea is a simple yet powerful text editor widget for tui-rs. Multi-line
|
tui-textarea is a simple yet powerful text editor widget for tui-rs and ratatui. Multi-line
|
||||||
text editor can be easily put as part of your TUI application.
|
text editor can be easily put as part of your TUI application.
|
||||||
"""
|
"""
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -13,7 +13,7 @@ homepage = "https://github.com/rhysd/tui-textarea#readme"
|
|||||||
repository = "https://github.com/rhysd/tui-textarea"
|
repository = "https://github.com/rhysd/tui-textarea"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
categories = ["text-editors", "text-processing"]
|
categories = ["text-editors", "text-processing"]
|
||||||
keywords = ["tui", "textarea", "editor", "input", "edit"]
|
keywords = ["tui", "textarea", "editor", "input", "edit", "ratatui"]
|
||||||
include = [
|
include = [
|
||||||
"/src",
|
"/src",
|
||||||
"/examples",
|
"/examples",
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -4,8 +4,8 @@ tui-textarea
|
|||||||
[![docs][doc-badge]][doc]
|
[![docs][doc-badge]][doc]
|
||||||
[![CI][ci-badge]][ci]
|
[![CI][ci-badge]][ci]
|
||||||
|
|
||||||
[tui-textarea][crate] is a simple yet powerful text editor widget like `<textarea>` in HTML for [tui-rs][]. Multi-line
|
[tui-textarea][crate] is a simple yet powerful text editor widget like `<textarea>` in HTML for [tui-rs][] and [ratatui][].
|
||||||
text editor can be easily put as part of your TUI application.
|
Multi-line text editor can be easily put as part of your TUI application.
|
||||||
|
|
||||||
**Features:**
|
**Features:**
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ text editor can be easily put as part of your TUI application.
|
|||||||
- 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][], 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)
|
||||||
|
|
||||||
[Documentation][doc]
|
[Documentation][doc]
|
||||||
|
|
||||||
@@ -90,6 +91,22 @@ cargo run --example modal
|
|||||||
|
|
||||||
Simple modal text editor like `vi`.
|
Simple modal text editor like `vi`.
|
||||||
|
|
||||||
|
### Examples for [ratatui][] support
|
||||||
|
|
||||||
|
All above examples uses [tui-rs][], but some examples provide [ratatui][] version. Try `ratatui_` prefix. In these cases,
|
||||||
|
you need to specify features to use `ratatui` and `--no-default-features` flag explicltly.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# ratatui version of `minimal` example
|
||||||
|
cargo run --example ratatui_minimal --no-default-features --features=ratatui-crossterm
|
||||||
|
|
||||||
|
# ratatui version of `editor` example
|
||||||
|
cargo run --example ratatui_editor --no-default-features --features=ratatui-crossterm,search file.txt
|
||||||
|
|
||||||
|
# ratatui version of `termion` example
|
||||||
|
cargo run --example ratatui_termion --no-default-features --features=ratatui-termion
|
||||||
|
```
|
||||||
|
|
||||||
## 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.
|
||||||
@@ -117,6 +134,28 @@ tui = { version = "*", default-features = false, features = ["termion"] }
|
|||||||
tui-textarea = { version = "*", default-features = false, features = ["termion"] }
|
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
|
||||||
|
shows feature names corresponding to the dependencies.
|
||||||
|
|
||||||
|
| | crossterm | termion |
|
||||||
|
|---------|----------------------------------|-------------------|
|
||||||
|
| tui-rs | `crossterm` (enabled by default) | `termion` |
|
||||||
|
| ratatui | `ratatui-crossterm` | `ratatui-termion` |
|
||||||
|
|
||||||
|
For example, when you want to use [ratatui][] and [crossterm][],
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[dependencies]
|
||||||
|
ratatui = "*"
|
||||||
|
tui-textarea = { version = "*", features = ["ratatui-crossterm"] default-features=false }
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** [tui-rs][] support and [ratatui][] support are exclusive. When you use [ratatui][] support, you must disable
|
||||||
|
[tui-rs][] support by `default-features=false`.
|
||||||
|
|
||||||
|
**Note:** Versions of [crossterm][] crate are different between [tui-rs][] and [ratatui][]. Please choose correct version
|
||||||
|
of the crate as dependency of your project.
|
||||||
|
|
||||||
## Minimal Usage
|
## Minimal Usage
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
@@ -629,6 +668,7 @@ 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
|
||||||
[termion]: https://docs.rs/termion/latest/termion/
|
[termion]: https://docs.rs/termion/latest/termion/
|
||||||
[crossterm]: https://docs.rs/crossterm/latest/crossterm/
|
[crossterm]: https://docs.rs/crossterm/latest/crossterm/
|
||||||
[tui-backend]: https://docs.rs/tui/latest/tui/backend/trait.Backend.html
|
[tui-backend]: https://docs.rs/tui/latest/tui/backend/trait.Backend.html
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user