4 releases (2 breaking)

0.12.1 Sep 11, 2024
0.12.0 Sep 9, 2024
0.11.0 Aug 29, 2024
0.10.0 Aug 25, 2024

#908 in Command-line interface

Download history 109/week @ 2024-08-22 168/week @ 2024-08-29 306/week @ 2024-09-05 204/week @ 2024-09-12 13/week @ 2024-09-19

695 downloads per month
Used in 3 crates (via rat-widget)

MIT/Apache

480KB
11K SLoC

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-scroll.

  • Lot's 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
  • Quote/Brace/Bracket selection.

There is an extended example mdedit.rs for TextArea in https://github.com/thscharler/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.

Dependencies

~13–23MB
~315K SLoC