1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-08-28 11:36:17 +03:00

implement Scrolling enum to specify scrolling more flexibly

this is a breaking change. next release should be v0.2.0.
Этот коммит содержится в:
rhysd
2022-10-03 20:59:26 +09:00
родитель 2f300b9dfa
Коммит 4e1a99988f
5 изменённых файлов: 73 добавлений и 20 удалений

Просмотреть файл

@@ -415,7 +415,7 @@ notify how to move the cursor.
| `textarea.set_search_pattern(pattern)` | Set a pattern for text search |
| `textarea.search_forward(match_cursor)` | Move cursor to next match of text search |
| `textarea.search_back(match_cursor)` | Move cursor to previous match of text search |
| `textarea.scroll(rows, cols)` | Scroll the viewport |
| `textarea.scroll(scrolling)` | Scroll the viewport |
To define your own key mappings, simply call the above methods in your code instead of `TextArea::input()` method. The
following example defines modal key mappings like Vim.
@@ -468,8 +468,8 @@ loop {
Input { key: Key::Esc, .. } => textarea.set_search_pattern("").unwrap(),
Input { key: Key::Char('n'), .. } => textarea.search_forward(),
Input { key: Key::Char('N'), .. } => textarea.search_back(),
Input { key: Key::Char('e'), ctrl: true .. } => textarea.scroll(1, 0),
Input { key: Key::Char('y'), ctrl: true .. } => textarea.scroll(-1, 0),
Input { key: Key::Char('e'), ctrl: true .. } => textarea.scroll((1, 0)),
Input { key: Key::Char('y'), ctrl: true .. } => textarea.scroll((-1, 0)),
_ => {},
},
Mode::Insert => match read()?.into() {