TextBox

Struct TextBox 

Source
pub struct TextBox {
    pub pane: SelectablePane,
    pub inner: Rc<RefCell<TextBoxInner>>,
    pub x_scrollbar: Rc<RefCell<Option<HorizontalScrollbar>>>,
    pub y_scrollbar: Rc<RefCell<Option<VerticalScrollbar>>>,
    pub line_number_tb: Rc<RefCell<Option<TextBoxInner>>>,
}

Fields§

§pane: SelectablePane§inner: Rc<RefCell<TextBoxInner>>§x_scrollbar: Rc<RefCell<Option<HorizontalScrollbar>>>§y_scrollbar: Rc<RefCell<Option<VerticalScrollbar>>>§line_number_tb: Rc<RefCell<Option<TextBoxInner>>>

Implementations§

Source§

impl TextBox

Source

pub fn new<S: Into<String>>(init_ctx: &Context, text: S) -> Self

Source

pub fn post_hook_for_set_selectability(&self)

Source

pub fn set_dirty(&self)

Source

pub fn with_scrollbars(self, init_ctx: &Context) -> Self

Source

pub fn with_left_scrollbar(self, init_ctx: &Context) -> Self

Source

pub fn with_right_scrollbar(self, init_ctx: &Context) -> Self

Source

pub fn with_top_scrollbar(self, init_ctx: &Context) -> Self

Source

pub fn with_bottom_scrollbar(self, init_ctx: &Context) -> Self

Source

pub fn reset_sb_sizes(&self, _init_ctx: &Context)

Source

pub fn with_line_numbers(self, init_ctx: &Context) -> Self

Source

pub fn reset_line_numbers(&self, init_ctx: &Context)

Source

pub fn set_line_numbers(&self, init_ctx: &Context)

Source

pub fn set_corner_decor(&self, init_ctx: &Context)

Source

pub fn with_right_click_menu(self, rcm: Option<RightClickMenu>) -> Self

Source

pub fn with_text_when_empty<S: Into<String>>(self, text: S) -> Self

Source

pub fn set_text_when_empty(&self, text: String)

Source

pub fn with_text_when_empty_fg(self, fg: Color) -> Self

Source

pub fn with_styles(self, styles: SelStyles) -> Self

Source

pub fn with_dyn_width(self, width: DynVal) -> Self

Source

pub fn with_dyn_height(self, height: DynVal) -> Self

Source

pub fn at<D: Into<DynVal>, D2: Into<DynVal>>(self, loc_x: D, loc_y: D2) -> Self

Source

pub fn set_at(&self, loc_x: DynVal, loc_y: DynVal)

Source

pub fn with_ch_cursor(self) -> Self

Source

pub fn with_no_ch_cursor(self) -> Self

Source

pub fn editable(self, init_ctx: &Context) -> Self

Source

pub fn non_editable(self, init_ctx: &Context) -> Self

Source

pub fn with_wordwrap(self, init_ctx: &Context) -> Self

Source

pub fn with_no_wordwrap(self, init_ctx: &Context) -> Self

Source

pub fn with_position_style_hook( self, hook: Box<dyn FnMut(Context, usize, Style) -> Style>, ) -> Self

Source

pub fn set_position_style_hook( &mut self, hook: Box<dyn FnMut(Context, usize, Style) -> Style>, )

Source

pub fn with_cursor_changed_hook(self, hook: CursorChangedHook) -> Self

Source

pub fn set_cursor_changed_hook(&mut self, hook: CursorChangedHook)

Source

pub fn with_text_changed_hook( self, hook: Box<dyn FnMut(Context, String) -> EventResponses>, ) -> Self

Source

pub fn set_text_changed_hook( &mut self, hook: Box<dyn FnMut(Context, String) -> EventResponses>, )

Source

pub fn with_cursor_style(self, style: Style) -> Self

Source

pub fn with_corner_decor(self, decor: DrawCh) -> Self

Source

pub fn get_text(&self) -> String

Source

pub fn set_text(&self, text: String)

Source

pub fn set_cursor_pos(&self, pos: usize)

Source

pub fn with_focused(self, focused: bool) -> TextBox

Source

pub fn with_kind(self, kind: &'static str) -> TextBox

Source

pub fn with_overflow(self) -> TextBox

Source

pub fn with_z(self, z: ZIndex) -> TextBox

Source

pub fn with_start_x<D: Into<DynVal>>(self, x: D) -> TextBox

Source

pub fn with_start_y<D: Into<DynVal>>(self, y: D) -> TextBox

Source

pub fn with_end_x<D: Into<DynVal>>(self, x: D) -> TextBox

Source

pub fn with_end_y<D: Into<DynVal>>(self, y: D) -> TextBox

Source

pub fn with_dyn_location(self, l: DynLocation) -> TextBox

Source

pub fn with_content(self, content: DrawChs2D) -> TextBox

Source

pub fn with_default_ch(self, ch: DrawCh) -> TextBox

Source

pub fn with_transparent(self) -> TextBox

Source

pub fn with_style(self, style: Style) -> TextBox

Source

pub fn with_bg(self, bg: Color) -> TextBox

Source

pub fn with_fg(self, fg: Color) -> TextBox

Source

pub fn with_focused_receivable_events(self, evs: ReceivableEvents) -> TextBox

Source

pub fn with_always_receivable_events(self, evs: ReceivableEvents) -> TextBox

Source

pub fn set_kind(&self, kind: &'static str)

Source

pub fn set_overflow(&self)

Source

pub fn set_start_x<D: Into<DynVal>>(&self, x: D)

Source

pub fn set_start_y<D: Into<DynVal>>(&self, y: D)

Source

pub fn set_end_x<D: Into<DynVal>>(&self, x: D)

Source

pub fn set_end_y<D: Into<DynVal>>(&self, y: D)

Source

pub fn get_start_x(&self, dr: &DrawRegion) -> i32

Source

pub fn get_start_y(&self, dr: &DrawRegion) -> i32

Source

pub fn get_end_x(&self, dr: &DrawRegion) -> i32

Source

pub fn get_end_y(&self, dr: &DrawRegion) -> i32

Source

pub fn get_dyn_start_x(&self) -> DynVal

Source

pub fn get_dyn_start_y(&self) -> DynVal

Source

pub fn get_dyn_end_x(&self) -> DynVal

Source

pub fn get_dyn_end_y(&self) -> DynVal

Source

pub fn get_height(&self, dr: &DrawRegion) -> usize

Source

pub fn get_width(&self, dr: &DrawRegion) -> usize

Source

pub fn set_dyn_height<D: Into<DynVal>>(&self, h: D)

Source

pub fn set_dyn_width<D: Into<DynVal>>(&self, w: D)

Source

pub fn get_dyn_height(&self) -> DynVal

Source

pub fn get_dyn_width(&self) -> DynVal

Source

pub fn set_z(&self, z: ZIndex)

Source

pub fn get_dyn_location(&self) -> DynLocation

Source

pub fn set_dyn_location(&self, l: DynLocation)

Source

pub fn get_last_size(&self) -> Ref<'_, Size>

Source

pub fn set_content(&self, content: DrawChs2D)

Source

pub fn get_content(&self) -> Ref<'_, DrawChs2D>

Source

pub fn get_content_mut(&self) -> RefMut<'_, DrawChs2D>

Source

pub fn set_content_from_string<S: Into<String>>(&self, s: S)

Source

pub fn set_content_from_string_with_style( &self, dr: &DrawRegion, s: &str, sty: Style, )

Source

pub fn set_content_style(&self, sty: Style)

Source

pub fn content_width(&self) -> usize

Source

pub fn content_height(&self) -> usize

Source

pub fn content_size(&self) -> Size

Source

pub fn scroll_up(&self, dr: Option<&DrawRegion>)

Source

pub fn scroll_down(&self, dr: Option<&DrawRegion>)

Source

pub fn scroll_left(&self, dr: Option<&DrawRegion>)

Source

pub fn scroll_right(&self, dr: Option<&DrawRegion>)

Source

pub fn set_style(&self, style: Style)

Source

pub fn get_style(&self) -> Style

Source

pub fn set_bg(&self, bg: Color)

Source

pub fn set_fg(&self, fg: Color)

Source

pub fn set_default_ch(&self, ch: DrawCh)

Source

pub fn set_transparent(&self)

Source

pub fn set_focused_receivable_events(&self, evs: ReceivableEvents)

Source

pub fn set_always_receivable_events(&self, evs: ReceivableEvents)

Source

pub fn send_responses_upward(&self, ctx: &Context, resps: EventResponses)

Source

pub fn has_parent(&self) -> bool

Source

pub fn set_focused(&self, focused: bool)

Source

pub fn correct_offsets_to_view_position( &self, dr: &DrawRegion, x: usize, y: usize, )

Trait Implementations§

Source§

impl Clone for TextBox

Source§

fn clone(&self) -> TextBox

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 Element for TextBox

Source§

fn receive_event(&self, ctx: &Context, ev: Event) -> (bool, EventResponses)

Receive an event from a parent. The receiving element may consume the event and/or pass it to a child. The element is expected to return a response to the event, along with any changes receivable events. When the event is captured, the element is expected to returns captured=true.
Source§

fn kind(&self) -> &'static str

TODO consider removing kind a name for the kind of the element
Source§

fn id(&self) -> ElementID

the element id as assigned by the SortingHat
Source§

fn can_receive(&self, ev: &Event) -> bool

can the element receive the event provided
Source§

fn receivable(&self) -> Vec<Rc<RefCell<ReceivableEvents>>>

get the receivable events for the element TODO it’d be nicer to return an iterator here, bit of a pain to make Element clonable then though.
Source§

fn set_focused(&self, focused: bool)

Source§

fn get_focused(&self) -> bool

Source§

fn drawing( &self, ctx: &Context, dr: &DrawRegion, force_update: bool, ) -> Vec<DrawUpdate>

Get the element’s full drawing for the provided context. if force update is set to true then an DrawUpdate should be provided regardless of if the element has changed since the last draw
Source§

fn get_attribute(&self, key: &str) -> Option<Vec<u8>>

Element attributes can be used to store arbitrary values (as encoded bytes) within the element. Typically if you are developing a new Element, you can simply store local values within your struct, only in the situation where you a creating a new sub-class of Elements (such as Widgets) does it make sense to be utilizing the get/set attribute functions. Read more
Source§

fn set_attribute_inner(&self, key: &str, value: Vec<u8>)

Source§

fn set_hook( &self, kind: &str, el_id: ElementID, hook: Box<dyn FnMut(&str, Box<dyn Element>)>, )

sets the hook for the element, the hook is a function that is called when the element is although a developer may implement any custom hook kind, the default hooks are: Read more
Source§

fn remove_hook(&self, kind: &str, el_id: ElementID)

Source§

fn clear_hooks_by_id(&self, el_id: ElementID)

remove all hooks for the element with the given id
Source§

fn call_hooks_of_kind(&self, kind: &str)

calls all the hooks of the provided kind
Source§

fn set_parent(&self, up: Box<dyn Parent>)

Assign a reference to the element’s parent through the Parent trait. This is used to pass ReceivableEventChanges to the parent. (see UpwardPropogator for more context)
Source§

fn get_dyn_location_set(&self) -> Ref<'_, DynLocationSet>

get/set the scalable location of the widget
Source§

fn get_visible(&self) -> bool

Source§

fn get_ref_cell_dyn_location_set(&self) -> Rc<RefCell<DynLocationSet>>

gets the reference to the location set and visible. The intention is so that these can be read without requiring a mutable reference to the element however, the element should not be modified through these references, if this is done then the relevant hooks will not be called when values are set. NOTE these functions should NOT be used to set values, use the set functions below to ensure that hooks are called.
Source§

fn get_ref_cell_visible(&self) -> Rc<RefCell<bool>>

Source§

fn get_ref_cell_overflow(&self) -> Rc<RefCell<bool>>

Source§

fn set_content_x_offset(&self, dr: Option<&DrawRegion>, x: usize)

used by scrollbars
Source§

fn set_content_y_offset(&self, dr: Option<&DrawRegion>, y: usize)

Source§

fn get_content_x_offset(&self) -> usize

Source§

fn get_content_y_offset(&self) -> usize

Source§

fn get_content_width(&self, dr: Option<&DrawRegion>) -> usize

Source§

fn get_content_height(&self, dr: Option<&DrawRegion>) -> usize

Source§

fn set_attribute(&self, key: &str, value: Vec<u8>)

Source§

fn get_z(&self) -> ZIndex

Source§

fn set_dyn_location_set(&self, l: DynLocationSet)

Source§

fn set_dyn_location(&self, l: DynLocation)

Source§

fn set_dyn_location_extra(&self, extra: Vec<DynLocation>)

Source§

fn set_visible(&self, v: bool)

Source§

fn with_description(self, desc: String) -> Self
where Self: Sized,

Source§

fn get_description(&self) -> Option<String>

Source§

fn set_description(&self, desc: String)

Source§

fn label(&self, ctx: &Context, label: &str) -> Label

create a label for this element
Source§

fn label_above_right(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_above(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_above_left(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_below_right(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_below_left(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_below(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_left(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_left_top(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_left_bottom(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_right_top(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_right(&self, ctx: &Context, label: &str) -> Label

Source§

fn label_right_bottom(&self, ctx: &Context, label: &str) -> Label

Auto Trait Implementations§

§

impl Freeze for TextBox

§

impl !RefUnwindSafe for TextBox

§

impl !Send for TextBox

§

impl !Sync for TextBox

§

impl Unpin for TextBox

§

impl !UnwindSafe for TextBox

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

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

Source§

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

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

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

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V