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
impl TextBox
pub fn new<S: Into<String>>(init_ctx: &Context, text: S) -> Self
pub fn post_hook_for_set_selectability(&self)
pub fn set_dirty(&self)
pub fn with_scrollbars(self, init_ctx: &Context) -> Self
pub fn with_left_scrollbar(self, init_ctx: &Context) -> Self
pub fn with_right_scrollbar(self, init_ctx: &Context) -> Self
pub fn with_top_scrollbar(self, init_ctx: &Context) -> Self
pub fn with_bottom_scrollbar(self, init_ctx: &Context) -> Self
pub fn reset_sb_sizes(&self, _init_ctx: &Context)
pub fn with_line_numbers(self, init_ctx: &Context) -> Self
pub fn reset_line_numbers(&self, init_ctx: &Context)
pub fn set_line_numbers(&self, init_ctx: &Context)
pub fn set_corner_decor(&self, init_ctx: &Context)
pub fn with_text_when_empty<S: Into<String>>(self, text: S) -> Self
pub fn set_text_when_empty(&self, text: String)
pub fn with_text_when_empty_fg(self, fg: Color) -> Self
pub fn with_styles(self, styles: SelStyles) -> Self
pub fn with_dyn_width(self, width: DynVal) -> Self
pub fn with_dyn_height(self, height: DynVal) -> Self
pub fn at<D: Into<DynVal>, D2: Into<DynVal>>(self, loc_x: D, loc_y: D2) -> Self
pub fn set_at(&self, loc_x: DynVal, loc_y: DynVal)
pub fn with_ch_cursor(self) -> Self
pub fn with_no_ch_cursor(self) -> Self
pub fn editable(self, init_ctx: &Context) -> Self
pub fn non_editable(self, init_ctx: &Context) -> Self
pub fn with_wordwrap(self, init_ctx: &Context) -> Self
pub fn with_no_wordwrap(self, init_ctx: &Context) -> Self
pub fn with_position_style_hook( self, hook: Box<dyn FnMut(Context, usize, Style) -> Style>, ) -> Self
pub fn set_position_style_hook( &mut self, hook: Box<dyn FnMut(Context, usize, Style) -> Style>, )
pub fn with_cursor_changed_hook(self, hook: CursorChangedHook) -> Self
pub fn set_cursor_changed_hook(&mut self, hook: CursorChangedHook)
pub fn with_text_changed_hook( self, hook: Box<dyn FnMut(Context, String) -> EventResponses>, ) -> Self
pub fn set_text_changed_hook( &mut self, hook: Box<dyn FnMut(Context, String) -> EventResponses>, )
pub fn with_cursor_style(self, style: Style) -> Self
pub fn with_corner_decor(self, decor: DrawCh) -> Self
pub fn get_text(&self) -> String
pub fn set_text(&self, text: String)
pub fn set_cursor_pos(&self, pos: usize)
pub fn with_focused(self, focused: bool) -> TextBox
pub fn with_kind(self, kind: &'static str) -> TextBox
pub fn with_overflow(self) -> TextBox
pub fn with_z(self, z: ZIndex) -> TextBox
pub fn with_start_x<D: Into<DynVal>>(self, x: D) -> TextBox
pub fn with_start_y<D: Into<DynVal>>(self, y: D) -> TextBox
pub fn with_end_x<D: Into<DynVal>>(self, x: D) -> TextBox
pub fn with_end_y<D: Into<DynVal>>(self, y: D) -> TextBox
pub fn with_dyn_location(self, l: DynLocation) -> TextBox
pub fn with_content(self, content: DrawChs2D) -> TextBox
pub fn with_default_ch(self, ch: DrawCh) -> TextBox
pub fn with_transparent(self) -> TextBox
pub fn with_style(self, style: Style) -> TextBox
pub fn with_bg(self, bg: Color) -> TextBox
pub fn with_fg(self, fg: Color) -> TextBox
pub fn with_focused_receivable_events(self, evs: ReceivableEvents) -> TextBox
pub fn with_always_receivable_events(self, evs: ReceivableEvents) -> TextBox
pub fn set_kind(&self, kind: &'static str)
pub fn set_overflow(&self)
pub fn set_start_x<D: Into<DynVal>>(&self, x: D)
pub fn set_start_y<D: Into<DynVal>>(&self, y: D)
pub fn set_end_x<D: Into<DynVal>>(&self, x: D)
pub fn set_end_y<D: Into<DynVal>>(&self, y: D)
pub fn get_start_x(&self, dr: &DrawRegion) -> i32
pub fn get_start_y(&self, dr: &DrawRegion) -> i32
pub fn get_end_x(&self, dr: &DrawRegion) -> i32
pub fn get_end_y(&self, dr: &DrawRegion) -> i32
pub fn get_dyn_start_x(&self) -> DynVal
pub fn get_dyn_start_y(&self) -> DynVal
pub fn get_dyn_end_x(&self) -> DynVal
pub fn get_dyn_end_y(&self) -> DynVal
pub fn get_height(&self, dr: &DrawRegion) -> usize
pub fn get_width(&self, dr: &DrawRegion) -> usize
pub fn set_dyn_height<D: Into<DynVal>>(&self, h: D)
pub fn set_dyn_width<D: Into<DynVal>>(&self, w: D)
pub fn get_dyn_height(&self) -> DynVal
pub fn get_dyn_width(&self) -> DynVal
pub fn set_z(&self, z: ZIndex)
pub fn get_dyn_location(&self) -> DynLocation
pub fn set_dyn_location(&self, l: DynLocation)
pub fn get_last_size(&self) -> Ref<'_, Size>
pub fn set_content(&self, content: DrawChs2D)
pub fn get_content(&self) -> Ref<'_, DrawChs2D>
pub fn get_content_mut(&self) -> RefMut<'_, DrawChs2D>
pub fn set_content_from_string<S: Into<String>>(&self, s: S)
pub fn set_content_from_string_with_style( &self, dr: &DrawRegion, s: &str, sty: Style, )
pub fn set_content_style(&self, sty: Style)
pub fn content_width(&self) -> usize
pub fn content_height(&self) -> usize
pub fn content_size(&self) -> Size
pub fn scroll_up(&self, dr: Option<&DrawRegion>)
pub fn scroll_down(&self, dr: Option<&DrawRegion>)
pub fn scroll_left(&self, dr: Option<&DrawRegion>)
pub fn scroll_right(&self, dr: Option<&DrawRegion>)
pub fn set_style(&self, style: Style)
pub fn get_style(&self) -> Style
pub fn set_bg(&self, bg: Color)
pub fn set_fg(&self, fg: Color)
pub fn set_default_ch(&self, ch: DrawCh)
pub fn set_transparent(&self)
pub fn set_focused_receivable_events(&self, evs: ReceivableEvents)
pub fn set_always_receivable_events(&self, evs: ReceivableEvents)
pub fn send_responses_upward(&self, ctx: &Context, resps: EventResponses)
pub fn has_parent(&self) -> bool
pub fn set_focused(&self, focused: bool)
pub fn correct_offsets_to_view_position( &self, dr: &DrawRegion, x: usize, y: usize, )
Trait Implementations§
Source§impl Element for TextBox
impl Element for TextBox
Source§fn receive_event(&self, ctx: &Context, ev: Event) -> (bool, EventResponses)
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 can_receive(&self, ev: &Event) -> bool
fn can_receive(&self, ev: &Event) -> bool
can the element receive the event provided
Source§fn receivable(&self) -> Vec<Rc<RefCell<ReceivableEvents>>>
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.
fn set_focused(&self, focused: bool)
fn get_focused(&self) -> bool
Source§fn drawing(
&self,
ctx: &Context,
dr: &DrawRegion,
force_update: bool,
) -> Vec<DrawUpdate>
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>>
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
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>)>,
)
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
fn remove_hook(&self, kind: &str, el_id: ElementID)
Source§fn clear_hooks_by_id(&self, el_id: ElementID)
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)
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>)
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>
fn get_dyn_location_set(&self) -> Ref<'_, DynLocationSet>
get/set the scalable location of the widget
fn get_visible(&self) -> bool
Source§fn get_ref_cell_dyn_location_set(&self) -> Rc<RefCell<DynLocationSet>>
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.
fn get_ref_cell_visible(&self) -> Rc<RefCell<bool>>
fn get_ref_cell_overflow(&self) -> Rc<RefCell<bool>>
Source§fn set_content_x_offset(&self, dr: Option<&DrawRegion>, x: usize)
fn set_content_x_offset(&self, dr: Option<&DrawRegion>, x: usize)
used by scrollbars
fn set_content_y_offset(&self, dr: Option<&DrawRegion>, y: usize)
fn get_content_x_offset(&self) -> usize
fn get_content_y_offset(&self) -> usize
fn get_content_width(&self, dr: Option<&DrawRegion>) -> usize
fn get_content_height(&self, dr: Option<&DrawRegion>) -> usize
fn set_attribute(&self, key: &str, value: Vec<u8>)
fn get_z(&self) -> ZIndex
fn set_dyn_location_set(&self, l: DynLocationSet)
fn set_dyn_location(&self, l: DynLocation)
fn set_dyn_location_extra(&self, extra: Vec<DynLocation>)
fn set_visible(&self, v: bool)
fn with_description(self, desc: String) -> Selfwhere
Self: Sized,
fn get_description(&self) -> Option<String>
fn set_description(&self, desc: String)
fn label_above_right(&self, ctx: &Context, label: &str) -> Label
fn label_above(&self, ctx: &Context, label: &str) -> Label
fn label_above_left(&self, ctx: &Context, label: &str) -> Label
fn label_below_right(&self, ctx: &Context, label: &str) -> Label
fn label_below_left(&self, ctx: &Context, label: &str) -> Label
fn label_below(&self, ctx: &Context, label: &str) -> Label
fn label_left(&self, ctx: &Context, label: &str) -> Label
fn label_left_top(&self, ctx: &Context, label: &str) -> Label
fn label_left_bottom(&self, ctx: &Context, label: &str) -> Label
fn label_right_top(&self, ctx: &Context, label: &str) -> Label
fn label_right(&self, ctx: &Context, label: &str) -> Label
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> 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
Mutably borrows from an owned value. Read more
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>
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>
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)
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)
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> 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>
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 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>
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