1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-08 00:15:50 +03:00

implement Clone for TextArea and its dependencies

Этот коммит содержится в:
rhysd
2022-07-12 22:56:06 +09:00
родитель 9032320a7e
Коммит 421691d602
4 изменённых файлов: 11 добавлений и 0 удалений

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

@@ -54,6 +54,7 @@ impl EditKind {
} }
} }
#[derive(Clone)]
pub struct Edit { pub struct Edit {
kind: EditKind, kind: EditKind,
cursor_before: (usize, usize), cursor_before: (usize, usize),
@@ -92,6 +93,7 @@ impl Edit {
} }
} }
#[derive(Clone)]
pub struct History { pub struct History {
index: usize, index: usize,
max_items: usize, max_items: usize,

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

@@ -1,6 +1,7 @@
use regex::Regex; use regex::Regex;
use tui::style::{Color, Style}; use tui::style::{Color, Style};
#[derive(Clone)]
pub struct Search { pub struct Search {
pub pat: Option<Regex>, pub pat: Option<Regex>,
pub style: Style, pub style: Style,

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

@@ -31,6 +31,7 @@ use tui::widgets::{Block, Widget};
/// // Get lines as String. /// // Get lines as String.
/// println!("Lines: {:?}", textarea.lines()); /// println!("Lines: {:?}", textarea.lines());
/// ``` /// ```
#[derive(Clone)]
pub struct TextArea<'a> { pub struct TextArea<'a> {
lines: Vec<String>, lines: Vec<String>,
block: Option<Block<'a>>, block: Option<Block<'a>>,

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

@@ -17,6 +17,13 @@ use tui::widgets::{Block, Paragraph, Widget};
#[derive(Default)] #[derive(Default)]
pub struct ScrollTop(AtomicU32); pub struct ScrollTop(AtomicU32);
impl Clone for ScrollTop {
fn clone(&self) -> Self {
let u = self.0.load(Ordering::Relaxed);
ScrollTop(AtomicU32::new(u))
}
}
impl ScrollTop { impl ScrollTop {
fn load(&self) -> (u16, u16) { fn load(&self) -> (u16, u16) {
let u = self.0.load(Ordering::Relaxed); let u = self.0.load(Ordering::Relaxed);