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)
- 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 textTextArea::cut
deletes the selected text and keeps it as a yanked textTextArea::start_selection
starts text selectionTextArea::cancel_selection
cancels text selectionTextArea::select_all
selects the entire textTextArea::set_selection_style
sets the style of selected textTextArea::selection_style
returns the current style for selected text
- 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.
- BREAKING CHANGE:
col
argument ofTextArea::delete_str
was removed. Instead, current cursor position is used. This change is for aligninig the API signature withTextArea::insert_str
.- Before:
fn delete_str(&mut self, col: usize, chars: usize) -> bool
- After:
fn delete_str(&mut self, chars: usize) -> bool
- Before:
- BREAKING CHANGE:
TextArea::yank_text
now returnsString
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
- Before:
- BREAKING CHANGE:
shift
field was added toInput
to support the Shift modifier key. - Add
Key::Paste
,Key::Copy
, andKey::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 asvim
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%.