Skip to content

v0.4.0

Latest
Compare
Choose a tag to compare
@rhysd rhysd released this 19 Nov 14:35
· 2 commits to main since this release

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