pub struct TextEditorArgs {
pub width: Option<DimensionValue>,
pub height: Option<DimensionValue>,
pub min_width: Option<Dp>,
pub min_height: Option<Dp>,
pub background_color: Option<Color>,
pub border_width: f32,
pub border_color: Option<Color>,
pub shape: Shape,
pub padding: Dp,
pub focus_border_color: Option<Color>,
pub focus_background_color: Option<Color>,
pub selection_color: Option<Color>,
}Expand description
Arguments for the text_editor component.
§Example
use tessera_ui_basic_components::text_editor::{TextEditorArgs, TextEditorArgsBuilder, TextEditorState};
use tessera_ui::{Dp, DimensionValue, Px};
use std::sync::Arc;
use parking_lot::RwLock;
// Create a text editor with a fixed width and height.
let editor_args_fixed = TextEditorArgsBuilder::default()
.width(Some(DimensionValue::Fixed(Px(200)))) // pixels
.height(Some(DimensionValue::Fixed(Px(100)))) // pixels
.build()
.unwrap();
// Create a text editor that fills available width up to 500px, with a min width of 50px
let editor_args_fill_wrap = TextEditorArgsBuilder::default()
.width(Some(DimensionValue::Fill { min: Some(Px(50)), max: Some(Px(500)) })) // pixels
.height(Some(DimensionValue::Wrap { min: None, max: None }))
.build()
.unwrap();
// Create the editor state
let editor_state = Arc::new(RwLock::new(TextEditorState::new(Dp(10.0), None)));
// text_editor(editor_args_fixed, editor_state.clone());
// text_editor(editor_args_fill_wrap, editor_state.clone());Fields§
§width: Option<DimensionValue>Optional width constraint for the text editor. Values are in logical pixels.
height: Option<DimensionValue>Optional height constraint for the text editor. Values are in logical pixels.
min_width: Option<Dp>Minimum width in density-independent pixels. Defaults to 120dp if not specified.
min_height: Option<Dp>Minimum height in density-independent pixels. Defaults to line height + padding if not specified.
background_color: Option<Color>Background color of the text editor (RGBA). Defaults to light gray.
border_width: f32Border width in pixels. Defaults to 1.0.
border_color: Option<Color>Border color (RGBA). Defaults to gray.
shape: ShapeThe shape of the text editor.
padding: DpPadding inside the text editor. Defaults to 5.0.
focus_border_color: Option<Color>Border color when focused (RGBA). Defaults to blue.
focus_background_color: Option<Color>Background color when focused (RGBA). Defaults to white.
selection_color: Option<Color>Color for text selection highlight (RGBA). Defaults to light blue with transparency.
Implementations§
Source§impl TextEditorArgs
Convenience constructors for common use cases
impl TextEditorArgs
Convenience constructors for common use cases
Source§impl TextEditorArgs
Builder methods for fluent API
impl TextEditorArgs
Builder methods for fluent API
pub fn with_width(self, width: DimensionValue) -> Self
pub fn with_height(self, height: DimensionValue) -> Self
pub fn with_min_width(self, min_width: Dp) -> Self
pub fn with_min_height(self, min_height: Dp) -> Self
pub fn with_background_color(self, color: Color) -> Self
pub fn with_border_width(self, width: f32) -> Self
pub fn with_border_color(self, color: Color) -> Self
pub fn with_shape(self, shape: Shape) -> Self
pub fn with_padding(self, padding: Dp) -> Self
pub fn with_focus_border_color(self, color: Color) -> Self
pub fn with_focus_background_color(self, color: Color) -> Self
pub fn with_selection_color(self, color: Color) -> Self
Trait Implementations§
Source§impl Clone for TextEditorArgs
impl Clone for TextEditorArgs
Source§fn clone(&self) -> TextEditorArgs
fn clone(&self) -> TextEditorArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TextEditorArgs
impl Debug for TextEditorArgs
Source§impl Default for TextEditorArgs
impl Default for TextEditorArgs
Source§fn default() -> TextEditorArgs
fn default() -> TextEditorArgs
Auto Trait Implementations§
impl Freeze for TextEditorArgs
impl RefUnwindSafe for TextEditorArgs
impl Send for TextEditorArgs
impl Sync for TextEditorArgs
impl Unpin for TextEditorArgs
impl UnwindSafe for TextEditorArgs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more