From 6b33bd9b6657c988f7b816c69f8daefb3ebf6bbc Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Thu, 6 Jul 2023 16:35:25 +0200 Subject: [PATCH] Add scrollable textarea widget --- Cargo.toml | 1 + src/ui/widget/common/label.rs | 118 ++++++++++++++++++++++++++++++++-- 2 files changed, 115 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73467214..03657114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ anyhow = { version = "1" } lexopt = { version = "0.2" } radicle-surf = { version = "0.14.0" } timeago = { version = "0.4.1" } +textwrap = { version = "0.16.0" } tuirealm = { version = "1.8.0", default-features = false, features = [ "with-termion" ] } tui-realm-stdlib = { version = "1.2.0", default-features = false, features = [ "with-termion" ] } diff --git a/src/ui/widget/common/label.rs b/src/ui/widget/common/label.rs index dcfecda5..c495ecc8 100644 --- a/src/ui/widget/common/label.rs +++ b/src/ui/widget/common/label.rs @@ -1,9 +1,10 @@ use tuirealm::command::{Cmd, CmdResult}; -use tuirealm::props::{AttrValue, Attribute, Color, Props, Style}; -use tuirealm::tui::layout::Rect; -use tuirealm::tui::text::{Span, Text}; -use tuirealm::{Frame, MockComponent, State}; +use tuirealm::props::{Alignment, AttrValue, Attribute, Color, Props, Style}; +use tuirealm::tui::layout::{Constraint, Direction, Layout, Rect}; +use tuirealm::tui::text::{Span, Spans, Text}; +use tuirealm::{Frame, MockComponent, State, StateValue}; +use crate::ui::theme::Theme; use crate::ui::widget::{Widget, WidgetComponent}; /// A label that can be styled using a foreground color and text modifiers. @@ -79,3 +80,112 @@ impl From<&Widget