Awesome
tui-realm-textarea
<p align="center">~ Textarea component for tui-realm ~</p> <p align="center"> <a href="https://github.com/rhysd/tui-textarea" target="_blank">tui-textarea</a> ยท <a href="https://github.com/veeso/tui-realm" target="_blank">tui-realm</a> ยท <a href="https://docs.rs/tui-realm-textarea" target="_blank">Documentation</a> </p> <p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p> <p align="center">Current version: 1.1.2 (29/08/2023)</p> <p align="center"> <a href="https://opensource.org/licenses/MIT" ><img src="https://img.shields.io/badge/License-MIT-teal.svg" alt="License-MIT" /></a> <a href="https://github.com/veeso/tui-realm-textarea/stargazers" ><img src="https://img.shields.io/github/stars/veeso/tui-realm-textarea.svg" alt="Repo stars" /></a> <a href="https://crates.io/crates/tui-realm-textarea" ><img src="https://img.shields.io/crates/d/tui-realm-textarea.svg" alt="Downloads counter" /></a> <a href="https://crates.io/crates/tui-realm-textarea" ><img src="https://img.shields.io/crates/v/tui-realm-textarea.svg" alt="Latest version" /></a> <a href="https://ko-fi.com/veeso"> <img src="https://img.shields.io/badge/donate-ko--fi-red" alt="Ko-fi" /></a> </p> <p align="center"> <a href="https://github.com/veeso/tui-realm-textarea/actions" ><img src="https://github.com/veeso/tui-realm-textarea/workflows/Build/badge.svg" alt="CI" /></a> <a href="https://docs.rs/tui-realm-textarea" ><img src="https://docs.rs/tui-realm-textarea/badge.svg" alt="Docs" /></a> </p>About tui-realm-textarea โ๏ธ
tui-realm-textarea is an implementation of a textarea component for tui-realm. It is based on the tui-textarea component by rhysd.
Get started ๐
Add tui-realm-textarea to your Cargo.toml ๐ฆ
tui-realm-textarea = "^1.1.0"
Or if you don't use Crossterm, define the backend as you do with tui-realm:
tui-realm-textarea = { version = "^1.1.0", default-features = false, features = [ "with-termion" ] }
Features โ๏ธ
These features can be enabled in tui-realm-textarea:
clipboard
enables system clipboard supportsearch
enables the string search in the textarea
Examples ๐
View how to use the textarea component in the example. The example contains a simple text editor.
cargo run --example demo --features clipboard,search
Press ESC
to quit
Component API
Commands:
Cmd | Result | Behaviour |
---|---|---|
Custom($TEXTAREA_CMD_NEWLINE) | None | Insert newline |
Custom($TEXTAREA_CMD_DEL_LINE_BY_END) | None | Delete line by end to current position |
Custom($TEXTAREA_CMD_DEL_LINE_BY_HEAD) | None | Delete line by head to current position |
Custom($TEXTAREA_CMD_DEL_WORD) | None | Delete the current word |
Custom($TEXTAREA_CMD_DEL_NEXT_WORD) | None | Delete the next word |
Custom($TEXTAREA_CMD_MOVE_WORD_FORWARD) | None | Move to the next word |
Custom($TEXTAREA_CMD_MOVE_WORD_BACK) | None | Move to the previous word |
Custom($TEXTAREA_CMD_MOVE_PARAGRAPH_BACK) | None | Move to the previous paragraph |
Custom($TEXTAREA_CMD_MOVE_PARAGRAPH_FORWARD) | None | Move to the next paragraph |
Custom($TEXTAREA_CMD_MOVE_TOP) | None | Move to the beginning of the file |
Custom($TEXTAREA_CMD_MOVE_BOTTOM) | None | Move to the end of the file |
Custom($TEXTAREA_CMD_UNDO) | None | Undo last change |
Custom($TEXTAREA_CMD_REDO) | None | Redo last change |
Custom($TEXTAREA_CMD_PASTE) | None | Paste the current content of the buffer |
Custom($TEXTAREA_CMD_SEARCH_BACK) | None | Go to the previous search match |
Custom($TEXTAREA_CMD_SEARCH_FORWARD) | None | Go to the next search match |
Cancel | None | Delete next char |
Delete | None | Delete previous char |
GoTo(Begin) | None | Go to the head of the line |
GoTo(End) | None | Go to the end of the line |
Move(Down) | None | Move to the line below |
Move(Up) | None | Move to the line above |
Move(Left) | None | Move cursor to the left |
Move(Right) | None | Move cursor to the right |
Scroll(Up) | None | Move by scroll_step lines up |
Scroll(Down) | None | Move by scroll_step lines down |
Type(ch) | None | Type a char in the editor |
Submit | Submit | Get current lines |
โ Paste command is supported only if the
clipboard
feature is enabled
State: the state returned is a Vec(String)
containing the lines in the text area.
Properties:
Borders(Borders)
: set borders properties for componentCustom($TREE_IDENT_SIZE, Size)
: Set space to render for each each depth levelCustom($TEXTAREA_MAX_HISTORY, Payload(One(Usize)))
: Set the history steps to recordCustom($TEXTAREA_CURSOR_STYLE, Style)
: Set the cursor styleCustom($TEXTAREA_CURSOR_LINE_STYLE, Style)
: Set the current line styleCustom($TEXTAREA_FOOTER_FMT, Payload(Tup2(Str, Style)))
: Set the format and the style for the footer barCustom($TEXTAREA_LINE_NUMBER_STYLE, Style)
: set the style for the line numberCustom($TEXTAREA_STATUS_FMT, Payload(Tup2(Str, Style)))
: Set the format and the style for the status barCustom($TEXTAREA_SEARCH_PATTERN, String
: Set search patternCustom($TEXTAREA_SEARCH_STYLE, Style
: Set search styleStyle(Style)
: Set the general style for the textareaCustom($TEXTAREA_TAB_SIZE, Size)
: Set the tab size to displayFocusStyle(Style)
: inactive styleScrollStep(Length)
: Defines the maximum amount of rows to scrollTitle(Title)
: Set box title
Footer and status format
The status and footer bars support a special syntax. The following keys can be inserted into the string:
{ROW}
: current row{COL}
: current column
Documentation ๐
The developer documentation can be found on Rust Docs at https://docs.rs/tui-realm-textarea
Contributing and issues ๐ค๐ป
Contributions, bug reports, new features and questions are welcome! ๐ If you have any question or concern, or you want to suggest a new feature, or you want just want to improve tui-realm, feel free to open an issue or a PR.
Please follow our contributing guidelines
Changelog โณ
View tui-realm-textarea's changelog HERE
Support the developer โ
If you like tui-realm and you're grateful for the work I've done, please consider a little donation ๐ฅณ
You can make a donation with one of these platforms:
License ๐
tui-realm-textarea is licensed under the MIT license.
You can read the entire license HERE