Expand description
This crate is a part of rat-salsa.
For examples see rat-text GitHub or an extended example mdedit.rs
in
rat-salsa GitHub.
§Text widgets for ratatui
Features for all widgets:
-
Undo/redo
-
Sync another widget
-
Support double-width characters
-
Range based text styling
-
Clipboard trait to link to some clipboard implementation.
There is no general solution for clipboards but this way you can integrate one of the many crates that try to do this.
-
Builtin scrolling. Uses rat-scrolled.
-
Lots of text manipulation functions.
- Line/TextRange/byte indexes supported.
- Glyph iteration (glyph=grapheme+display information)
- Grapheme iterator/cursor
- byte-pos to TextPosition and vice versa.
- Screen position to text position.
§TextInput
Single line text input widget.
§TextArea
Textarea with tendencies to being an editor.
Uses Rope backend for a good editing experience for longer text. Starts lagging a bit if you have more than 10,000 style ranges or so (wip).
- Tab width/Tab expand to space.
- Indent/dedent selection.
- Newline starts at indent.
- Mouse selection can work word-wise.
- Renders this text in ~400µs
- Add Quotes/Braces/Brackets to selection.
There is an extended example mdedit.rs
for TextArea in
rat-salsa
§MaskedInput
Single line text input with a text-mask for allowed input.
- Numeric
- Decimal/Hexadecimal/Octal digits
- Character/Character+Digits
- Text separators
Nice to have for structured text input.
The widgets
- DateInput and
- NumberInput
use this as base.
§DateInput
DateInput with chrono format patterns.
§NumberInput
NumberInput with format_num_pattern backend. A bit similar to javas DecimalFormat.
§LineNumbers
Line numbers widget that can be combined with TextArea.
Modules§
- clipboard
- There are too many clipboard crates.
- core
- Core structs for text-editing. Used to implement the widgets.
- date_
input - Date-input widget using chrono
- event
- Event-handler traits and Keybindings.
- line_
number - Line numbers widget.
- number_
input - Number input widget
- text_
area - A text-area widget with text-styling abilities. And undo + clipboard support.
- text_
input - Text input widget.
- text_
input_ mask - Text input widget with an input mask.
- undo_
buffer - Undo functionality.
Macros§
- impl_
screen_ cursor - Create the implementation of HasScreenCursor for the given list of struct members.
Structs§
- Glyph
- Data for rendering/mapping graphemes to screen coordinates.
- Grapheme
- One grapheme.
- Text
Position - Text position.
- Text
Range - Exclusive range for text ranges.
- Text
Style - Combined style for the widget.
Enums§
- Locale
- Locales matching the locales in
glibc
. - Text
Error - Text
Focus Gained - Behavior modifiers.
- Text
Focus Lost - Behaviour modifiers.
Traits§
- Cursor
- Trait for a cursor (akin to an Iterator, not the blinking thing).
- HasScreen
Cursor - Trait for accessing the screen-cursor.
Functions§
- screen_
cursor - Returns the screen_cursor for the first widget that returns one.