Skip to content

Releases: rhysd/tui-textarea

v0.4.0

19 Nov 14:35
Compare
Choose a tag to compare

This release introduces text selection feature. The internal implementation was largely refactored to handle multi-line text for this feature. As the side effect, several APIs now can handle a multi-line string (string contains newlines) correctly.

  • Text selection has been implemented. (#6, #45, thanks @pm100 for the first implementation)
    minimal example
    • Default key shortcuts now support text selection. When moving the cursor with pressing a shift key, a textarea starts to select the text under the cursor. The selected text can be copied/cut by the following key shortcuts. Modifying some text while text selection deletes the selected text. Doing undo/redo cancels the ongoing text selection.
      Mappings Description
      Ctrl+C, Copy Copy selected text
      Ctrl+X, Cut Cut selected text
    • The following APIs are added
      • TextArea::copy keeps the selected text as a yanked text
      • TextArea::cut deletes the selected text and keeps it as a yanked text
      • TextArea::start_selection starts text selection
      • TextArea::cancel_selection cancels text selection
      • TextArea::select_all selects the entire text
      • TextArea::set_selection_style sets the style of selected text
      • TextArea::selection_style returns the current style for selected text
  • BREAKING CHANGE: col argument of TextArea::delete_str was removed. Instead, current cursor position is used. This change is for aligninig the API signature with TextArea::insert_str.
    • Before: fn delete_str(&mut self, col: usize, chars: usize) -> bool
    • After: fn delete_str(&mut self, chars: usize) -> bool
  • BREAKING CHANGE: TextArea::yank_text now returns String instead of &str. This change was caused to handle yanking multiple-line text correctly.
    • Before: fn yank_text<'a>(&'a self) -> &'a str
    • After: fn yank_text(&self) -> String
  • BREAKING CHANGE: shift field was added to Input to support the Shift modifier key.
  • Add Key::Paste, Key::Copy, and Key::Cut. They are only supported by termwiz crate.
  • Fix TextArea::insert_char didn't handle newline ('\n') correctly.
  • Allow passing multi-line string to TextArea::insert_str. A string joined with newlines is inserted as multiple lines correctly.
  • Allow TextArea::delete_str to delete multiple lines (#42).
  • Fix TextArea::set_yank_text didn't handle multiple lines correctly.
  • Fix editor example didn't handle terminal raw mode on Windows (#44).
  • modal example was rebuilt as vim example. It implements Vim emulation to some level as a state machine. It adds the support for very basic visual mode and operator-pending mode. This example aims to show how to implement complicated and stateful key shortcuts.
  • Add many unit test cases. Several edge cases found by them were fixed. The code coverage of this crate reached 90%.

v0.3.1

04 Nov 16:08
Compare
Choose a tag to compare
  • Fix the width of rendered tab character (\t) is wrong in some cases when hard tab is enabled by TextArea::set_hard_tab_indent (#43).
  • Fix key inputs are doubled on Windows when converting from crossterm::event::KeyEvent into tui_textarea::Input. Note that the conversion from crossterm::event::Event into tui_textarea::Input does not have this issue.
  • Support converting the following type instances into tui_textarea::Input.
    • crossterm::event::KeyCode
    • crossterm::event::KeyEvent
    • crossterm::event::MouseEvent
    • crossterm::event::MouseKind
    • termwiz::input::KeyCode
    • termwiz::input::KeyEvent
    • termion::event::MouseButton
  • Fix typos in API document and error message (#40, thanks @fritzrehde).

v0.3.0

24 Oct 15:09
Compare
Choose a tag to compare
  • BREAKING CHANGE: Enable ratatui support by default instead of inactive tui-rs.
    • ratatui- prefix is removed from all ratatui-* features. crossterm, termion, and termwiz features are for ratatui:
      # ratatui with crossterm backend
      tui-textarea = "0.3"
      # ratatui with termwiz backend
      tui-textarea = { version = "0.3", features = ["termwiz"], default-features = false }
      # ratatui with termion backend
      tui-textarea = { version = "0.3", features = ["termion"], default-features = false }
    • Instead, features for tui-rs support are now prefixed with tuirs-:
      # tui-rs with crossterm backend
      tui-textarea = { version = "0.3", features = ["tuirs-crossterm"], default-features = false }
      # Use proper version of crossterm
      crossterm = "0.2.5"
    • Examples and documents are now implemented and described with ratatui by default
  • BREAKING CHANGE: Rename your-backend features to no-backend. You need to update the feature names if you're using tui-textarea with your own backend.
  • Relax the restriction of ratatui crate dependency from 0.23.0 to >=0.23.0, <1, which means 'v0.23.0 or later and earlier than v1'. The latest version of ratatui (v0.24.0) now works with tui-textarea (#36).
  • Enable termwiz and termion features on generating the API document. APIs to convert from input events of termwiz/termion to tui_textarea::Input are now listed in the document.

Previous Backend features table (v0.2.4):

crossterm termion termwiz Your own backend
tui-rs crossterm (enabled by default) termion N/A your-backend
ratatui ratatui-crossterm ratatui-termion ratatui-termwiz ratatui-your-backend

New backend features table (v0.3.0):

crossterm termion termwiz Your own backend
tui-rs tuirs-crossterm tuirs-termion N/A tuirs-no-backend
ratatui crossterm (enabled by default) termion termwiz no-backend

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.