Skip to content

Releases: rhysd/tui-textarea

v0.2.4

21 Oct 16:23
Compare
Choose a tag to compare
  • Support the ratatui's termwiz backend. ratatui-termwiz feature was newly added for this.
    • Add the following dependencies in your Cargo.toml to use termwiz support.
      termwiz = "0.20"
      ratatui = { version = "0.23", default-features = false, features = ["termwiz"] }
      tui-textarea = { version = "0.2.4", default-features = false, features = ["ratatui-termwiz"] }
    • Read and run the termwiz example to know the API usage.
      cargo run --example termwiz --no-default-features --features=ratatui-termwiz
  • Fix calculating the length of tab character when the line contains wide characters. Now the length of wide characters like あ are calculated as 2 correctly.

v0.2.3

20 Oct 13:24
Compare
Choose a tag to compare
  • Add APIs to mask text with a character (#32, thanks @pm100).
    • TextArea::set_mask_char, TextArea::clear_mask_char, TextArea::mask_char are added. See the documentation for more details.
    • The password example was added to show the usage.
      password example
  • Fix the length of displayed hard tab in text (#33, thanks @pm100).

v0.2.2

01 Oct 17:26
Compare
Choose a tag to compare

Very small patch release only for fixing the build failure on docs.rs. No implementation has been changed.

v0.2.1

01 Oct 17:09
Compare
Choose a tag to compare
  • Add the support for ratatui crate in addition to tui-rs. The ratatui crate is a community fork of inactive tui-rs crate. (#12)
    • The latest version of ratatui v0.23 is supported.
    • tui-textarea still uses tui-rs by default to keep the compatibility at this moment. ratatui users explicitly need to set features for it. See the installation document for the features matrix. For example, when you want to use ratatui and crossterm, write the following in your Cargo.toml:
      [dependencies]
      ratatui = "*"
      tui-textarea = { version = "*", features = ["ratatui-crossterm"], default-features = false }
    • tui-rs is no longer maintained and the repository was archived. At the next minor version bump, tui-textarea will switch the default features from tui-rs to ratatui. If you use tui-rs, I recommend to switch your dependency to ratatui.
    • Examples with ratatui are added to the examples directory. For example, the following command runs ratatui version of editor example:
      cargo run --example ratatui_editor --no-default-features --features=ratatui-crossterm,search file.txt
  • Add support for the placeholder text which is rendered when no text is input in the textarea. (#16, thanks @pm100)
    • Use TextArea::set_placeholder_text to set the text. To change the text style, use TextArea::set_placeholder_style. See the API documentation for more details.
    • popup_placeholder example was added to show the usage.
      cargo run --example popup_placeholder
  • Derive Debug trait for TextArea struct. (#23)
  • Fix a key input is received twice on Windows. (#17, thanks @pm100)

v0.2.0

18 Oct 10:57
Compare
Choose a tag to compare
  • Add Scrolling enum to provide more flexible scrolling via TextArea::scroll method. It has the following enum variants.
    • BREAKING Scrolling::Delta scrolls the textarea by given rows and cols. This variant can be converted from (i16, i16) so migrating from v0.1.6 is very easy.
      let rows: i16 = ...;
      let cols: i16 = ...;
      
      // Until v0.1.6
      textarea.scroll(rows, cols);
      
      // Since v0.2.0
      textarea.scroll((rows, cols));
    • Scrolling::PageDown and Scrolling::PageUp scroll the textarea by page.
    • Scrolling::HalfPageDown and Scrolling::HalfPageUp scroll the textarea by half-page.
  • Update default key mappings handled by TextArea::input method.
    • BREAKING Change PageDown and PageUp keys to scroll down/up the textarea by page since v0.2.0. Until v0.1.6, it moved the cursor down/up by one paragraph.
    • Add Ctrl+V and Alt+V keys to scroll down/up the textarea by page as Emacs-like key mappings.
    • Add Alt+] and Alt+[ keys to move the cursor down/up by one paragraph as Emacs-like key mappings.
  • BREAKING Add #[non_exhaustive] attribute to CursorMove enum. This is because more cursor move variations may be added in the future.
  • Fix panic when the max history size is zero (which means the edit history is disabled). (#4)

v0.1.6

28 Sep 14:25
Compare
Choose a tag to compare
  • Support mouse scroll. (#2)
    • Handle mouse events for both crossterm and termion backends.
    • TextArea::scroll method was added.
    • Key::MouseScrollUp and Key::MouseScrollDown virtual keys are added to Key enum so that custom backends can support mouse scrolling.
    • CursorMove::InViewport variant was added to CursorMove enum, which ensures the cursor to be within the viewport.
  • Add TextArea::alignment and TextArea::set_alignment to set the text alignment of textarea. Note that right and center alignments don't work well with line number so calling TextArea::set_alignment with them automatically disables it. (#3, thanks @Volkalex28)
  • Set rust-version to 1.56.1 in Cargo.toml to show MSRV explicitly.

v0.1.5

18 Jul 11:21
Compare
Choose a tag to compare
  • Improve performance to render a textarea widget. When number of lines increases, now rendering lines is about 2~8x faster according to our benchmark suites. See the commit for more details of the benchmark results. This was archived by managing a vertical scroll position by ourselves instead of scroll handling by Paragraph. Previously, a cost of rendering lines was O(n) where n was number of all lines. Now the cost is O(1).
  • Implement Clone for TextArea so that textarea instances can be copied easily. It is useful when you create multiple textarea instances with the same configuration. Create a first TextArea instance with configuring blocks and styles, then simply clone it.
  • Add arbitrary feature which is disabled by default. By enabling it, Input, Key and CursorMove can be randomly generated via arbitrary crate. This feature aims to be used by fuzzing tests.
  • Add many benchmark suites to track performance; insert/delete lines/characters, text search, moving a cursor.
  • Improve fuzzing tests to include rendering a textarea to a dummy terminal backend and moving a cursor randomly.
  • Refactor TextArea implementation. The implementation of text search was separated to src/search.rs. The implementation of highlighting was separated to src/highlight.rs. And the implementation of widget rendered by tui-rs was separated to src/widget.rs. These refactorings changed no public API.

v0.1.4

10 Jul 16:07
Compare
Choose a tag to compare
  • Fix the cursor line style was not applied when a cursor is at the end of line.
  • Fix the cursor position after undoing the modification by 'delete until head of line' (^J by default).

v0.1.3

08 Jul 09:29
Compare
Choose a tag to compare
  • Text search was implemented. Text search is gated behind search feature flag to avoid depending on regex crate until it is necessary. See the usage document, the API document, and the working example for more details.
    • TextArea::set_search_pattern sets a search pattern in regular expression. This updates highlights at matches in textarea, but does not move the cursor.
    • TextArea::search_forward moves cursor to the next match of the text search based on current cursor position.
    • TextArea::search_back moves cursor to the previous match of the text search based on current cursor position.
    • TextArea::set_search_style sets the text style for highlighting matches of text search.
    search in editor example

v0.1.2

25 Jun 02:53
Compare
Choose a tag to compare
  • Indent with hard tab is now supported. TextArea::set_hard_tab_indent method enables indentation with a hard tab on hitting a tab key.
    let mut textarea = TextArea::default();
    
    textarea.set_hard_tab_indent(true);
    textarea.insert_tab();
    assert_eq!(textarea.lines(), ["\t"]);
    Demo with cargo run --example editor:
    screencast
  • Add TextArea::indent method to get an indent string of textarea.
    let mut textarea = TextArea::default();
    
    assert_eq!(textarea.indent(), "    ");
    textarea.set_tab_length(2);
    assert_eq!(textarea.indent(), "  ");
    textarea.set_hard_tab_indent(true);
    assert_eq!(textarea.indent(), "\t");