Skip to content

Releases: rhysd/tui-textarea

v0.7.0

22 Oct 16:28
Compare
Choose a tag to compare

v0.6.1

08 Aug 16:03
Compare
Choose a tag to compare
  • Add TextArea::selection_range method to get the range of the current selection. Please read the document for more details. (#81, thanks @achristmascarl)
    let mut textarea = TextArea::from(["aaa"]);
    
    // It returns `None` when the text selection is not ongoing
    assert_eq!(textarea.selection_range(), None);
    
    textarea.start_selection();
    assert_eq!(textarea.selection_range(), Some(((0, 0), (0, 0))));
    
    textarea.move_cursor(CursorMove::Forward);
    assert_eq!(textarea.selection_range(), Some(((0, 0), (0, 1))));
    
    // The first element of the pair is always smaller than the second one.
    textarea.start_selection();
    textarea.move_cursor(CursorMove::Back);
    assert_eq!(textarea.selection_range(), Some(((0, 0), (0, 1))));
  • Fix depending on the incorrect version of termion crate when tuirs-termion feature is enabled. Since tui crate depends on older version of termion crate v1.5.6, tui-textarea should depend on the same version but actually it depended on the latest version v4.0.0.
    • If you use tui-textarea with tui crate and termion crate, please ensure that your project also depends on termion v1.5. Otherwise your project accidentally depends on multiple versions of termion crate.

v0.6.0

07 Aug 15:32
Compare
Choose a tag to compare
  • BREAKING: Update ratatui crate dependency from v0.27 to v0.28.
  • BREAKING: Update crossterm crate dependency from v0.27 to v0.28 because ratatui crate depends on the new version.
    • Note: If you use tui crate, crossterm crate dependency remains at v0.25.

v0.5.3

03 Aug 14:55
Compare
Choose a tag to compare
  • &TextArea now implements Widget trait. (#78)
    • Now the reference can be passed to ratatui::terminal::Frame::render_widget method call directly.
      // v0.5.2 or earlier
      f.render_widget(textarea.widget(), rect);
      
      // v0.5.3 or later
      f.render_widget(&textarea, rect);
    • This means that TextArea::widget method is no longer necessary. To maintain the compatibility the method is not removed but using it starts to report a deprecation warning from v0.5.3.
  • Fix a cursor can leave the viewport on horizontal scroll when line number is displayed. (#77)
  • Support some key combinations added at termion v4 for termion feature. (#68)
    • termion::event::Key::CtrlLeft
    • termion::event::Key::CtrlRight
    • termion::event::Key::CtrlUp
    • termion::event::Key::CtrlDown
    • termion::event::Key::CtrlHome
    • termion::event::Key::CtrlEnd
    • termion::event::Key::AltLeft
    • termion::event::Key::AltRight
    • termion::event::Key::AltUp
    • termion::event::Key::AltDown
    • termion::event::Key::ShiftLeft
    • termion::event::Key::ShiftRight
    • termion::event::Key::ShiftUp
    • termion::event::Key::ShiftDown
  • Fix the border color is not applied in single_line example. (#79, thanks @fmorroni)
  • Improve vim example's Vim emulation.
    • Fix the range of text selection on e mapping in operator-pending mode. (#76)
    • Fix the text selection on y, d, c mappings in visual mode is not inclusive.

v0.5.2

01 Aug 02:09
Compare
Choose a tag to compare
  • Do not hide a cursor when a placeholder text is printed. (#73, thanks @kyu08)
    • demo
  • Add CursorMove::WordEnd which moves a cursor to the end of the next word inclusively. (#75, thanks @achristmascarl)
    • The behavior is similar to e mapping of Vim in normal mode. vim example implements the mapping for demonstration.

v0.5.1

12 Jul 14:51
Compare
Choose a tag to compare
  • Add serde optional feature. When it is enabled, some types support the serialization/deserialization with serde crate. See the document for more details. (#62, thanks @cestef)
    use tui_textarea::Input;
    
    let json = r#"
        {
            "key": { "Char": "a" },
            "ctrl": true,
            "alt": false,
            "shift": true
        }
    "#;
    
    let input: Input = serde_json::from_str(json).unwrap();
    println!("{input}");
    // Input {
    //     key: Key::Char('a'),
    //     ctrl: true,
    //     alt: false,
    //     shift: true,
    // }

v0.5.0

07 Jul 14:51
Compare
Choose a tag to compare

This is a maintenance release for supporting recent versions of ratatui crate.

  • BREAKING CHANGE: Bump the minimal versions of the following dependencies. If you're depending on the crates older than the following versions, please upgrade them before upgrading this crate. (#69, thanks @joshka)
    • ratatui 0.27.0
    • termion 0.4.0
    • termwiz 0.22.0
  • YankText now implements Display instead of ToString directly. Since ToString is implemented for any types which implement Display, this is not a breaking change.

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