зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-08 16:35:49 +03:00
invert ratatui-* features with tuirs-*
Этот коммит содержится в:
28
Cargo.toml
28
Cargo.toml
@@ -24,28 +24,28 @@ include = [
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["crossterm"]
|
default = ["crossterm"]
|
||||||
# Features to use tui-rs
|
|
||||||
crossterm = ["dep:crossterm", "tui/crossterm"]
|
|
||||||
termion = ["dep:termion", "tui/termion"]
|
|
||||||
your-backend = ["tui"]
|
|
||||||
# Features to use ratatui
|
# Features to use ratatui
|
||||||
ratatui-crossterm = ["dep:crossterm-027", "ratatui/crossterm"]
|
crossterm = ["dep:crossterm", "ratatui/crossterm"]
|
||||||
ratatui-termion = ["dep:termion", "ratatui/termion"]
|
termion = ["dep:termion", "ratatui/termion"]
|
||||||
ratatui-termwiz = ["dep:termwiz", "ratatui/termwiz"]
|
termwiz = ["dep:termwiz", "ratatui/termwiz"]
|
||||||
ratatui-your-backend = ["ratatui"]
|
your-backend = ["ratatui"]
|
||||||
|
# Features to use tui-rs
|
||||||
|
tuirs-crossterm = ["dep:crossterm-025", "tui/crossterm"]
|
||||||
|
tuirs-termion = ["dep:termion", "tui/termion"]
|
||||||
|
tuirs-your-backend = ["tui"]
|
||||||
# Other optional features
|
# Other optional features
|
||||||
search = ["dep:regex"]
|
search = ["dep:regex"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crossterm = { package = "crossterm", version = "0.25", optional = true }
|
arbitrary = { version = "1", features = ["derive"], optional = true }
|
||||||
|
crossterm = { package = "crossterm", version = "0.27", optional = true }
|
||||||
|
crossterm-025 = { package = "crossterm", version = "0.25", optional = true }
|
||||||
|
ratatui = { version = "0.23.0", default-features = false, optional = true }
|
||||||
regex = { version = "1", optional = true }
|
regex = { version = "1", optional = true }
|
||||||
termion = { version = "2.0", optional = true }
|
termion = { version = "2.0", optional = true }
|
||||||
tui = { version = "0.19", default-features = false, optional = true }
|
|
||||||
arbitrary = { version = "1", features = ["derive"], optional = true }
|
|
||||||
crossterm-027 = { package = "crossterm", version = "0.27", optional = true }
|
|
||||||
ratatui = { version = "0.23.0", default-features = false, optional = true }
|
|
||||||
unicode-width = "0.1.11"
|
|
||||||
termwiz = { version = "0.20.0", optional = true }
|
termwiz = { version = "0.20.0", optional = true }
|
||||||
|
tui = { version = "0.19", default-features = false, optional = true }
|
||||||
|
unicode-width = "0.1.11"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "minimal"
|
name = "minimal"
|
||||||
|
|||||||
@@ -324,12 +324,12 @@ impl CursorMove {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
// Seaparate tests for ratatui support
|
// Seaparate tests for tui-rs support
|
||||||
#[test]
|
#[test]
|
||||||
fn in_viewport() {
|
fn in_viewport() {
|
||||||
use crate::tui::buffer::Buffer;
|
use crate::ratatui::buffer::Buffer;
|
||||||
use crate::tui::layout::Rect;
|
use crate::ratatui::layout::Rect;
|
||||||
use crate::tui::widgets::Widget;
|
use crate::ratatui::widgets::Widget;
|
||||||
use crate::{CursorMove, TextArea};
|
use crate::{CursorMove, TextArea};
|
||||||
|
|
||||||
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
use crate::tui::style::Style;
|
use crate::ratatui::style::Style;
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "ratatui-crossterm",
|
feature = "crossterm",
|
||||||
feature = "ratatui-termion",
|
feature = "termion",
|
||||||
feature = "ratatui-termwiz",
|
feature = "termwiz",
|
||||||
feature = "ratatui-your-backend",
|
feature = "your-backend",
|
||||||
))]
|
))]
|
||||||
use crate::tui::text::Line as Spans;
|
use crate::ratatui::text::Line;
|
||||||
use crate::tui::text::Span;
|
use crate::ratatui::text::Span;
|
||||||
#[cfg(not(any(
|
#[cfg(any(
|
||||||
feature = "ratatui-crossterm",
|
feature = "tuirs-crossterm",
|
||||||
feature = "ratatui-termion",
|
feature = "tuirs-termion",
|
||||||
feature = "ratatui-termwiz",
|
feature = "tuirs-your-backend",
|
||||||
feature = "ratatui-your-backend",
|
))]
|
||||||
)))]
|
use crate::ratatui::text::Spans as Line;
|
||||||
use crate::tui::text::Spans;
|
|
||||||
use crate::util::{num_digits, spaces};
|
use crate::util::{num_digits, spaces};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
@@ -138,7 +137,7 @@ impl<'a> LineHighlighter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_spans(self) -> Spans<'a> {
|
pub fn into_spans(self) -> Line<'a> {
|
||||||
let Self {
|
let Self {
|
||||||
line,
|
line,
|
||||||
mut spans,
|
mut spans,
|
||||||
@@ -158,7 +157,7 @@ impl<'a> LineHighlighter<'a> {
|
|||||||
if cursor_at_end {
|
if cursor_at_end {
|
||||||
spans.push(Span::styled(" ", cursor_style));
|
spans.push(Span::styled(" ", cursor_style));
|
||||||
}
|
}
|
||||||
return Spans::from(spans);
|
return Line::from(spans);
|
||||||
}
|
}
|
||||||
|
|
||||||
boundaries.sort_unstable_by(|(l, i), (r, j)| match i.cmp(j) {
|
boundaries.sort_unstable_by(|(l, i), (r, j)| match i.cmp(j) {
|
||||||
@@ -197,7 +196,7 @@ impl<'a> LineHighlighter<'a> {
|
|||||||
if cursor_at_end {
|
if cursor_at_end {
|
||||||
spans.push(Span::styled(" ", cursor_style));
|
spans.push(Span::styled(" ", cursor_style));
|
||||||
}
|
}
|
||||||
return Spans::from(spans);
|
return Line::from(spans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/input.rs
30
src/input.rs
@@ -1,13 +1,13 @@
|
|||||||
#[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))]
|
#[cfg(any(feature = "crossterm", feature = "tuirs-crossterm"))]
|
||||||
use crate::crossterm::event::{
|
use crate::crossterm::event::{
|
||||||
Event as CrosstermEvent, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent,
|
Event as CrosstermEvent, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent,
|
||||||
MouseEventKind as CrosstermMouseEventKind,
|
MouseEventKind as CrosstermMouseEventKind,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
use arbitrary::Arbitrary;
|
use arbitrary::Arbitrary;
|
||||||
#[cfg(any(feature = "termion", feature = "ratatui-termion"))]
|
#[cfg(any(feature = "termion", feature = "tuirs-termion"))]
|
||||||
use termion::event::{Event as TermionEvent, Key as TermionKey, MouseEvent as TermionMouseEvent};
|
use termion::event::{Event as TermionEvent, Key as TermionKey, MouseEvent as TermionMouseEvent};
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
use termwiz::input::{
|
use termwiz::input::{
|
||||||
InputEvent as TermwizInputEvent, KeyEvent as TermwizKeyEvent,
|
InputEvent as TermwizInputEvent, KeyEvent as TermwizKeyEvent,
|
||||||
MouseButtons as TermwizMouseButtons, MouseEvent as TermwizMouseEvent, PixelMouseEvent,
|
MouseButtons as TermwizMouseButtons, MouseEvent as TermwizMouseEvent, PixelMouseEvent,
|
||||||
@@ -47,7 +47,7 @@ pub enum Key {
|
|||||||
|
|
||||||
/// Backend-agnostic key input type.
|
/// Backend-agnostic key input type.
|
||||||
///
|
///
|
||||||
/// When `crossterm`, `termion`, `ratatui-termwiz` features are enabled, converting respective key input types into this
|
/// When `crossterm`, `termion`, `termwiz` features are enabled, converting respective key input types into this
|
||||||
/// `Input` type is defined.
|
/// `Input` type is defined.
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use tui_textarea::{TextArea, Input, Key};
|
/// use tui_textarea::{TextArea, Input, Key};
|
||||||
@@ -101,7 +101,7 @@ impl Default for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))]
|
#[cfg(any(feature = "crossterm", feature = "tuirs-crossterm"))]
|
||||||
impl From<CrosstermEvent> for Input {
|
impl From<CrosstermEvent> for Input {
|
||||||
/// Convert [`crossterm::event::Event`] to [`Input`].
|
/// Convert [`crossterm::event::Event`] to [`Input`].
|
||||||
fn from(event: CrosstermEvent) -> Self {
|
fn from(event: CrosstermEvent) -> Self {
|
||||||
@@ -113,7 +113,7 @@ impl From<CrosstermEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))]
|
#[cfg(any(feature = "crossterm", feature = "tuirs-crossterm"))]
|
||||||
impl From<KeyEvent> for Input {
|
impl From<KeyEvent> for Input {
|
||||||
/// Convert [`crossterm::event::KeyEvent`] to [`Input`].
|
/// Convert [`crossterm::event::KeyEvent`] to [`Input`].
|
||||||
fn from(key: KeyEvent) -> Self {
|
fn from(key: KeyEvent) -> Self {
|
||||||
@@ -141,7 +141,7 @@ impl From<KeyEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "crossterm", feature = "ratatui-crossterm"))]
|
#[cfg(any(feature = "crossterm", feature = "tuirs-crossterm"))]
|
||||||
impl From<MouseEvent> for Input {
|
impl From<MouseEvent> for Input {
|
||||||
/// Convert [`crossterm::event::MouseEvent`] to [`Input`].
|
/// Convert [`crossterm::event::MouseEvent`] to [`Input`].
|
||||||
fn from(mouse: MouseEvent) -> Self {
|
fn from(mouse: MouseEvent) -> Self {
|
||||||
@@ -156,7 +156,7 @@ impl From<MouseEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "termion", feature = "ratatui-termion"))]
|
#[cfg(any(feature = "termion", feature = "tuirs-termion"))]
|
||||||
impl From<TermionEvent> for Input {
|
impl From<TermionEvent> for Input {
|
||||||
/// Convert [`termion::event::Event`] to [`Input`].
|
/// Convert [`termion::event::Event`] to [`Input`].
|
||||||
fn from(event: TermionEvent) -> Self {
|
fn from(event: TermionEvent) -> Self {
|
||||||
@@ -168,7 +168,7 @@ impl From<TermionEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "termion", feature = "ratatui-termion"))]
|
#[cfg(any(feature = "termion", feature = "tuirs-termion"))]
|
||||||
impl From<TermionKey> for Input {
|
impl From<TermionKey> for Input {
|
||||||
/// Convert [`termion::event::Key`] to [`Input`].
|
/// Convert [`termion::event::Key`] to [`Input`].
|
||||||
fn from(key: TermionKey) -> Self {
|
fn from(key: TermionKey) -> Self {
|
||||||
@@ -207,7 +207,7 @@ impl From<TermionKey> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "termion", feature = "ratatui-termion"))]
|
#[cfg(any(feature = "termion", feature = "tuirs-termion"))]
|
||||||
impl From<TermionMouseEvent> for Input {
|
impl From<TermionMouseEvent> for Input {
|
||||||
/// Convert [`termion::event::MouseEvent`] to [`Input`].
|
/// Convert [`termion::event::MouseEvent`] to [`Input`].
|
||||||
fn from(mouse: TermionMouseEvent) -> Self {
|
fn from(mouse: TermionMouseEvent) -> Self {
|
||||||
@@ -225,7 +225,7 @@ impl From<TermionMouseEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
impl From<TermwizInputEvent> for Input {
|
impl From<TermwizInputEvent> for Input {
|
||||||
/// Convert [`termwiz::input::InputEvent`] to [`Input`].
|
/// Convert [`termwiz::input::InputEvent`] to [`Input`].
|
||||||
fn from(input: TermwizInputEvent) -> Self {
|
fn from(input: TermwizInputEvent) -> Self {
|
||||||
@@ -238,7 +238,7 @@ impl From<TermwizInputEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
impl From<TermwizKeyEvent> for Input {
|
impl From<TermwizKeyEvent> for Input {
|
||||||
/// Convert [`termwiz::input::KeyEvent`] to [`Input`].
|
/// Convert [`termwiz::input::KeyEvent`] to [`Input`].
|
||||||
fn from(key: TermwizKeyEvent) -> Self {
|
fn from(key: TermwizKeyEvent) -> Self {
|
||||||
@@ -270,7 +270,7 @@ impl From<TermwizKeyEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
impl From<TermwizMouseButtons> for Key {
|
impl From<TermwizMouseButtons> for Key {
|
||||||
/// Convert [`termwiz::input::MouseButtons`] to [`Key`].
|
/// Convert [`termwiz::input::MouseButtons`] to [`Key`].
|
||||||
fn from(buttons: TermwizMouseButtons) -> Self {
|
fn from(buttons: TermwizMouseButtons) -> Self {
|
||||||
@@ -286,7 +286,7 @@ impl From<TermwizMouseButtons> for Key {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
impl From<TermwizMouseEvent> for Input {
|
impl From<TermwizMouseEvent> for Input {
|
||||||
/// Convert [`termwiz::input::MouseEvent`] to [`Input`].
|
/// Convert [`termwiz::input::MouseEvent`] to [`Input`].
|
||||||
fn from(mouse: TermwizMouseEvent) -> Self {
|
fn from(mouse: TermwizMouseEvent) -> Self {
|
||||||
@@ -305,7 +305,7 @@ impl From<TermwizMouseEvent> for Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ratatui-termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
impl From<PixelMouseEvent> for Input {
|
impl From<PixelMouseEvent> for Input {
|
||||||
/// Convert [`termwiz::input::PixelMouseEvent`] to [`Input`].
|
/// Convert [`termwiz::input::PixelMouseEvent`] to [`Input`].
|
||||||
fn from(mouse: PixelMouseEvent) -> Self {
|
fn from(mouse: PixelMouseEvent) -> Self {
|
||||||
|
|||||||
41
src/lib.rs
41
src/lib.rs
@@ -5,12 +5,16 @@
|
|||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(feature = "crossterm", feature = "termion", feature = "your-backend"),
|
|
||||||
any(
|
any(
|
||||||
feature = "ratatui-crossterm",
|
feature = "crossterm",
|
||||||
feature = "ratatui-termion",
|
feature = "termion",
|
||||||
feature = "ratatui-termwiz",
|
feature = "termwiz",
|
||||||
feature = "ratatui-your-backend"
|
feature = "your-backend"
|
||||||
|
),
|
||||||
|
any(
|
||||||
|
feature = "tuirs-crossterm",
|
||||||
|
feature = "tuirs-termion",
|
||||||
|
feature = "tuirs-your-backend"
|
||||||
),
|
),
|
||||||
))]
|
))]
|
||||||
compile_error!("tui-rs support and ratatui support are exclussive. only one of them can be enabled at the same time. see https://github.com/rhysd/tui-textarea#installation");
|
compile_error!("tui-rs support and ratatui support are exclussive. only one of them can be enabled at the same time. see https://github.com/rhysd/tui-textarea#installation");
|
||||||
@@ -28,26 +32,25 @@ mod widget;
|
|||||||
mod word;
|
mod word;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "ratatui-crossterm",
|
feature = "crossterm",
|
||||||
feature = "ratatui-termion",
|
feature = "termion",
|
||||||
feature = "ratatui-termwiz",
|
feature = "termwiz",
|
||||||
feature = "ratatui-your-backend",
|
feature = "your-backend",
|
||||||
))]
|
))]
|
||||||
use ratatui as tui;
|
|
||||||
#[cfg(not(any(
|
|
||||||
feature = "ratatui-crossterm",
|
|
||||||
feature = "ratatui-termion",
|
|
||||||
feature = "ratatui-termwiz",
|
|
||||||
feature = "ratatui-your-backend",
|
|
||||||
)))]
|
|
||||||
#[allow(clippy::single_component_path_imports)]
|
#[allow(clippy::single_component_path_imports)]
|
||||||
use tui;
|
use ratatui;
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "tuirs-crossterm",
|
||||||
|
feature = "tuirs-termion",
|
||||||
|
feature = "tuirs-your-backend",
|
||||||
|
))]
|
||||||
|
use tui as ratatui;
|
||||||
|
|
||||||
#[cfg(feature = "crossterm")]
|
#[cfg(feature = "crossterm")]
|
||||||
#[allow(clippy::single_component_path_imports)]
|
#[allow(clippy::single_component_path_imports)]
|
||||||
use crossterm;
|
use crossterm;
|
||||||
#[cfg(feature = "ratatui-crossterm")]
|
#[cfg(feature = "tuirs-crossterm")]
|
||||||
use crossterm_027 as crossterm;
|
use crossterm_025 as crossterm;
|
||||||
|
|
||||||
pub use cursor::CursorMove;
|
pub use cursor::CursorMove;
|
||||||
pub use input::{Input, Key};
|
pub use input::{Input, Key};
|
||||||
|
|||||||
@@ -185,12 +185,12 @@ impl From<(i16, i16)> for Scrolling {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// Seaparate tests for ratatui support
|
// Seaparate tests for tui-rs support
|
||||||
#[test]
|
#[test]
|
||||||
fn delta() {
|
fn delta() {
|
||||||
use crate::tui::buffer::Buffer;
|
use crate::ratatui::buffer::Buffer;
|
||||||
use crate::tui::layout::Rect;
|
use crate::ratatui::layout::Rect;
|
||||||
use crate::tui::widgets::Widget;
|
use crate::ratatui::widgets::Widget;
|
||||||
use crate::TextArea;
|
use crate::TextArea;
|
||||||
|
|
||||||
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::tui::style::{Color, Style};
|
use crate::ratatui::style::{Color, Style};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@@ -2,26 +2,25 @@ use crate::cursor::CursorMove;
|
|||||||
use crate::highlight::LineHighlighter;
|
use crate::highlight::LineHighlighter;
|
||||||
use crate::history::{Edit, EditKind, History};
|
use crate::history::{Edit, EditKind, History};
|
||||||
use crate::input::{Input, Key};
|
use crate::input::{Input, Key};
|
||||||
|
use crate::ratatui::layout::Alignment;
|
||||||
|
use crate::ratatui::style::{Color, Modifier, Style};
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "crossterm",
|
||||||
|
feature = "termion",
|
||||||
|
feature = "termwiz",
|
||||||
|
feature = "your-backend",
|
||||||
|
))]
|
||||||
|
use crate::ratatui::text::Line;
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "tuirs-crossterm",
|
||||||
|
feature = "tuirs-termion",
|
||||||
|
feature = "tuirs-your-backend",
|
||||||
|
))]
|
||||||
|
use crate::ratatui::text::Spans as Line;
|
||||||
|
use crate::ratatui::widgets::{Block, Widget};
|
||||||
use crate::scroll::Scrolling;
|
use crate::scroll::Scrolling;
|
||||||
#[cfg(feature = "search")]
|
#[cfg(feature = "search")]
|
||||||
use crate::search::Search;
|
use crate::search::Search;
|
||||||
use crate::tui::layout::Alignment;
|
|
||||||
use crate::tui::style::{Color, Modifier, Style};
|
|
||||||
#[cfg(any(
|
|
||||||
feature = "ratatui-crossterm",
|
|
||||||
feature = "ratatui-termion",
|
|
||||||
feature = "ratatui-termwiz",
|
|
||||||
feature = "ratatui-your-backend",
|
|
||||||
))]
|
|
||||||
use crate::tui::text::Line as Spans;
|
|
||||||
#[cfg(not(any(
|
|
||||||
feature = "ratatui-crossterm",
|
|
||||||
feature = "ratatui-termion",
|
|
||||||
feature = "ratatui-termwiz",
|
|
||||||
feature = "ratatui-your-backend",
|
|
||||||
)))]
|
|
||||||
use crate::tui::text::Spans;
|
|
||||||
use crate::tui::widgets::{Block, Widget};
|
|
||||||
use crate::util::spaces;
|
use crate::util::spaces;
|
||||||
use crate::widget::{Renderer, Viewport};
|
use crate::widget::{Renderer, Viewport};
|
||||||
use crate::word::{find_word_end_forward, find_word_start_backward};
|
use crate::word::{find_word_end_forward, find_word_start_backward};
|
||||||
@@ -172,7 +171,7 @@ impl<'a> TextArea<'a> {
|
|||||||
|
|
||||||
/// Handle a key input with default key mappings. For default key mappings, see the table in
|
/// Handle a key input with default key mappings. For default key mappings, see the table in
|
||||||
/// [the module document](./index.html).
|
/// [the module document](./index.html).
|
||||||
/// `crossterm`, `termion`, and `ratatui-termwiz` features enable conversion from their own key event types into
|
/// `crossterm`, `termion`, and `termwiz` features enable conversion from their own key event types into
|
||||||
/// [`Input`] so this method can take the event values directly.
|
/// [`Input`] so this method can take the event values directly.
|
||||||
/// This method returns if the input modified text contents or not in the textarea.
|
/// This method returns if the input modified text contents or not in the textarea.
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
@@ -1010,7 +1009,7 @@ impl<'a> TextArea<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn line_spans<'b>(&'b self, line: &'b str, row: usize, lnum_len: u8) -> Spans<'b> {
|
pub(crate) fn line_spans<'b>(&'b self, line: &'b str, row: usize, lnum_len: u8) -> Line<'b> {
|
||||||
let mut hl = LineHighlighter::new(line, self.cursor_style, self.tab_len, self.mask);
|
let mut hl = LineHighlighter::new(line, self.cursor_style, self.tab_len, self.mask);
|
||||||
|
|
||||||
if let Some(style) = self.line_number_style {
|
if let Some(style) = self.line_number_style {
|
||||||
@@ -1749,12 +1748,12 @@ impl<'a> TextArea<'a> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// Seaparate tests for ratatui support
|
// Seaparate tests for tui-rs support
|
||||||
#[test]
|
#[test]
|
||||||
fn scroll() {
|
fn scroll() {
|
||||||
use crate::tui::buffer::Buffer;
|
use crate::ratatui::buffer::Buffer;
|
||||||
use crate::tui::layout::Rect;
|
use crate::ratatui::layout::Rect;
|
||||||
use crate::tui::widgets::Widget;
|
use crate::ratatui::widgets::Widget;
|
||||||
|
|
||||||
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
let mut textarea: TextArea = (0..20).map(|i| i.to_string()).collect();
|
||||||
let r = Rect {
|
let r = Rect {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
use crate::ratatui::buffer::Buffer;
|
||||||
|
use crate::ratatui::layout::Rect;
|
||||||
|
use crate::ratatui::text::Text;
|
||||||
|
use crate::ratatui::widgets::{Paragraph, Widget};
|
||||||
use crate::textarea::TextArea;
|
use crate::textarea::TextArea;
|
||||||
use crate::tui::buffer::Buffer;
|
|
||||||
use crate::tui::layout::Rect;
|
|
||||||
use crate::tui::text::Text;
|
|
||||||
use crate::tui::widgets::{Paragraph, Widget};
|
|
||||||
use crate::util::num_digits;
|
use crate::util::num_digits;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user