1
0
зеркало из 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
Этот коммит содержится в:
Linda_pp
2024-07-12 23:11:34 +09:00
коммит произвёл GitHub
родитель b2f805bbe5 dff2694010
Коммит fcd44bb7d9
5 изменённых файлов: 17 добавлений и 4 удалений

1
.github/workflows/ci.yml поставляемый
Просмотреть файл

@@ -45,6 +45,7 @@ jobs:
- run: cargo fmt -- --check
- run: cargo clippy --examples --tests -- -D warnings
- run: cargo clippy --examples --tests --features search -- -D warnings
- run: cargo clippy --examples --tests --features serde -- -D warnings
- run: cargo clippy --examples --tests --no-default-features --features termion -- -D warnings
- run: cargo clippy --examples --tests --no-default-features --features termion,search -- -D warnings
- run: cargo clippy --examples --tests --no-default-features --features termwiz -- -D warnings

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

@@ -31,6 +31,7 @@ tuirs-termion = ["tuirs", "dep:termion", "tui/termion"]
tuirs-no-backend = ["tuirs"]
# Other optional features
search = ["dep:regex"]
serde = ["dep:serde"]
[dependencies]
arbitrary = { version = "1", features = ["derive"], optional = true }
@@ -42,6 +43,7 @@ termion = { version = "4.0", optional = true }
termwiz = { version = "0.22.0", optional = true }
tui = { version = "0.19", default-features = false, optional = true }
unicode-width = "0.1.11"
serde = { version = "1", optional = true , features = ["derive"] }
[[example]]
name = "minimal"

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

@@ -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