зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
Merge pull request #62 from cestef/main
Add serde feature to Scrolling, CursorMove and Input enums
Этот коммит содержится в:
@@ -2,14 +2,17 @@ use crate::widget::Viewport;
|
||||
use crate::word::{find_word_start_backward, find_word_start_forward};
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::Arbitrary;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp;
|
||||
|
||||
/// Specify how to move the cursor.
|
||||
///
|
||||
/// This type is marked as `#[non_exhaustive]` since more variations may be supported in the future.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum CursorMove {
|
||||
/// Move cursor forward by one character. When the cursor is at the end of line, it moves to the head of next line.
|
||||
/// ```
|
||||
|
||||
@@ -7,13 +7,16 @@ mod termwiz;
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::Arbitrary;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Backend-agnostic key input kind.
|
||||
///
|
||||
/// This type is marked as `#[non_exhaustive]` since more keys may be supported in the future.
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Hash, Eq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum Key {
|
||||
/// Normal letter key input
|
||||
Char(char),
|
||||
@@ -100,8 +103,9 @@ impl Default for Key {
|
||||
/// shift: false,
|
||||
/// });
|
||||
/// ```
|
||||
#[derive(Debug, Clone, Default, PartialEq, Hash)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Hash, Eq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Input {
|
||||
/// Typed key.
|
||||
pub key: Key,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::widget::Viewport;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
/// Specify how to scroll the textarea.
|
||||
///
|
||||
/// This type is marked as `#[non_exhaustive]` since more variations may be supported in the future. Note that the cursor will
|
||||
@@ -7,6 +8,8 @@ use crate::widget::Viewport;
|
||||
///
|
||||
/// [`TextArea::scroll`]: https://docs.rs/tui-textarea/latest/tui_textarea/struct.TextArea.html#method.scroll
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub enum Scrolling {
|
||||
/// Scroll the textarea by rows (vertically) and columns (horizontally). Passing positive scroll amounts to `rows` and `cols`
|
||||
/// scolls it to down and right. Negative integers means the opposite directions. `(i16, i16)` pair can be converted into
|
||||
|
||||
Ссылка в новой задаче
Block a user