# tui-realm-textarea
~ Textarea component for tui-realm ~
tui-textarea · tui-realm · Documentation
Developed by @veeso
Current version: 2.0.0 (13/10/2024)
--- - [tui-realm-textarea](#tui-realm-textarea) - [About tui-realm-textarea ✏️](#about-tui-realm-textarea-️) - [Get started 🏁](#get-started-) - [Add tui-realm-textarea to your Cargo.toml 🦀](#add-tui-realm-textarea-to-your-cargotoml-) - [Features ⚙️](#features-️) - [Examples 📋](#examples-) - [Component API](#component-api) - [Footer and status format](#footer-and-status-format) - [Documentation 📚](#documentation-) - [Contributing and issues 🤝🏻](#contributing-and-issues-) - [Changelog ⏳](#changelog-) - [Support the developer ☕](#support-the-developer-) - [License 📃](#license-) --- ## About tui-realm-textarea ✏️ tui-realm-textarea is an implementation of a **textarea component** for [tui-realm](https://github.com/veeso/tui-realm). It is based on the [tui-textarea](https://github.com/rhysd/tui-textarea) component by [rhysd](https://github.com/rhysd). ![Demo](docs/images/demo.gif) --- ## Get started 🏁 ### Add tui-realm-textarea to your Cargo.toml 🦀 ```toml tui-realm-textarea = "2" ``` Or if you don't use **Crossterm**, define the backend as you do with tui-realm: ```toml tui-realm-textarea = { version = "2", default-features = false, features = [ "termion" ] } ``` #### Features ⚙️ These features can be enabled in tui-realm-textarea: - `clipboard` enables system clipboard support - `search` enables the string search in the textarea ### Examples 📋 View how to use the textarea component in the [example](examples/demo.rs). The example contains a simple text editor. ```sh 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 component - `Custom($TREE_IDENT_SIZE, Size)`: Set space to render for each each depth level - `Custom($TEXTAREA_MAX_HISTORY, Payload(One(Usize)))`: Set the history steps to record - `Custom($TEXTAREA_CURSOR_STYLE, Style)`: Set the cursor style - `Custom($TEXTAREA_CURSOR_LINE_STYLE, Style)`: Set the current line style - `Custom($TEXTAREA_FOOTER_FMT, Payload(Tup2(Str, Style)))`: Set the format and the style for the footer bar - `Custom($TEXTAREA_LINE_NUMBER_STYLE, Style)`: set the style for the line number - `Custom($TEXTAREA_STATUS_FMT, Payload(Tup2(Str, Style)))`: Set the format and the style for the status bar - `Custom($TEXTAREA_SEARCH_PATTERN, String`: Set search pattern - `Custom($TEXTAREA_SEARCH_STYLE, Style`: Set search style - `Style(Style)`: Set the general style for the textarea - `Custom($TEXTAREA_TAB_SIZE, Size)`: Set the tab size to display - `FocusStyle(Style)`: inactive style - `ScrollStep(Length)`: Defines the maximum amount of rows to scroll - `Title(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