v0.4.0
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,CopyCopy selected text Ctrl+X,CutCut selected text - The following APIs are added
TextArea::copykeeps the selected text as a yanked textTextArea::cutdeletes the selected text and keeps it as a yanked textTextArea::start_selectionstarts text selectionTextArea::cancel_selectioncancels text selectionTextArea::select_allselects the entire textTextArea::set_selection_stylesets the style of selected textTextArea::selection_stylereturns 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:
colargument ofTextArea::delete_strwas 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_textnow returnsStringinstead 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:
shiftfield was added toInputto support the Shift modifier key. - Add
Key::Paste,Key::Copy, andKey::Cut. They are only supported by termwiz crate. - Fix
TextArea::insert_chardidn'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_strto delete multiple lines (#42). - Fix
TextArea::set_yank_textdidn't handle multiple lines correctly. - Fix
editorexample didn't handle terminal raw mode on Windows (#44). modalexample was rebuilt asvimexample. 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%.