Struct TextEditorArgs

Source
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());

Arguments for configuring the text_editor component.

TextEditorArgs provides flexible options for layout, appearance, and interaction of the text editor. All fields are optional and have sensible defaults. Use the builder pattern or convenience methods for construction.

§Fields

  • width, height: Optional constraints for the editor’s size (logical pixels or fill/wrap).
  • min_width, min_height: Minimum size in density-independent pixels (Dp).
  • background_color, focus_background_color: Editor background color (normal/focused).
  • border_width, border_color, focus_border_color: Border styling (width and color, normal/focused).
  • shape: Shape of the editor container (e.g., rounded rectangle).
  • padding: Inner padding (Dp).
  • selection_color: Highlight color for selected text.

§Example

use tessera_ui_basic_components::text_editor::{TextEditorArgs, TextEditorArgsBuilder};
use tessera_ui::{Dp, DimensionValue, Px};

let args = TextEditorArgsBuilder::default()
    .width(Some(DimensionValue::Fixed(Px(300))))
    .height(Some(DimensionValue::Fill { min: Some(Px(50)), max: Some(Px(500)) }))
    .background_color(Some(tessera_ui::Color::WHITE))
    .padding(Dp(8.0))
    .build()
    .unwrap();

Fields§

§width: Option<DimensionValue>

Optional width constraint for the text editor. Values are in logical pixels or fill/wrap.

§height: Option<DimensionValue>

Optional height constraint for the text editor. Values are in logical pixels or fill/wrap.

§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: f32

Border width in pixels. Defaults to 1.0.

§border_color: Option<Color>

Border color (RGBA). Defaults to gray.

§shape: Shape

The shape of the text editor container.

§padding: Dp

Padding inside the text editor. Defaults to 5.0 Dp.

§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

Source

pub fn simple() -> Self

Creates a simple text editor with default styling.

  • Minimum width: 120dp
  • Background: white
  • Border: 1px gray, rounded rectangle
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple();
Source

pub fn outlined() -> Self

Creates a text editor with an emphasized border for better visibility.

  • Border: 2px, blue focus border
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::outlined();
Source

pub fn minimal() -> Self

Creates a text editor with no border (minimal style).

  • Border: 0px, square corners
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::minimal();
Source§

impl TextEditorArgs

Builder methods for fluent API

Source

pub fn with_width(self, width: DimensionValue) -> Self

Sets the width constraint for the editor.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_width(DimensionValue::Fixed(Px(200)));
Source

pub fn with_height(self, height: DimensionValue) -> Self

Sets the height constraint for the editor.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_height(DimensionValue::Fixed(Px(100)));
Source

pub fn with_min_width(self, min_width: Dp) -> Self

Sets the minimum width in Dp.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_width(Dp(80.0));
Source

pub fn with_min_height(self, min_height: Dp) -> Self

Sets the minimum height in Dp.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_height(Dp(40.0));
Source

pub fn with_background_color(self, color: Color) -> Self

Sets the background color.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_background_color(Color::WHITE);
Source

pub fn with_border_width(self, width: f32) -> Self

Sets the border width in pixels.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple().with_border_width(2.0);
Source

pub fn with_border_color(self, color: Color) -> Self

Sets the border color.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_border_color(Color::BLACK);
Source

pub fn with_shape(self, shape: Shape) -> Self

Sets the shape of the editor container.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui_basic_components::shape_def::Shape;
let args = TextEditorArgs::simple().with_shape(Shape::RoundedRectangle { corner_radius: 8.0, g2_k_value: 3.0 });
Source

pub fn with_padding(self, padding: Dp) -> Self

Sets the inner padding in Dp.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_padding(Dp(12.0));
Source

pub fn with_focus_border_color(self, color: Color) -> Self

Sets the border color when focused.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_border_color(Color::new(0.0, 0.5, 1.0, 1.0));
Source

pub fn with_focus_background_color(self, color: Color) -> Self

Sets the background color when focused.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_background_color(Color::WHITE);
Source

pub fn with_selection_color(self, color: Color) -> Self

Sets the selection highlight color.

§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_selection_color(Color::new(0.5, 0.7, 1.0, 0.4));

Trait Implementations§

Source§

impl Clone for TextEditorArgs

Source§

fn clone(&self) -> TextEditorArgs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextEditorArgs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TextEditorArgs

Source§

fn default() -> TextEditorArgs

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the concrete type as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,