pub struct State<T> {
pub cursor: usize,
pub anchor: usize,
pub offset: Point<T>,
pub preferred_x: Option<T>,
pub upstream: bool,
pub max_undos: usize,
/* private fields */
}Expand description
the edited text with its selection, scroll offset, and undo history
Fields§
§cursor: usize§anchor: usize§offset: Point<T>§preferred_x: Option<T>§upstream: boolkeeps a cursor at a soft wrap on the line it ends until the next edit
max_undos: usizeImplementations§
Source§impl<T: Scalar> State<T>
impl<T: Scalar> State<T>
pub fn new() -> Self
pub fn max_undos(self, max_undos: usize) -> Self
pub fn value(&self) -> &str
pub fn selected_text(&self) -> &str
Sourcepub fn set_value(&mut self, value: impl Into<String>)
pub fn set_value(&mut self, value: impl Into<String>)
replaces the text and clears the undo history it no longer matches
pub fn clear_history(&mut self)
Source§impl<T: Scalar> State<T>
impl<T: Scalar> State<T>
Sourcepub fn update(
&mut self,
edit: Option<Edit>,
text: &str,
multiline: bool,
now: Duration,
) -> Response
pub fn update( &mut self, edit: Option<Edit>, text: &str, multiline: bool, now: Duration, ) -> Response
applies an edit that needs no layout
vertical and visual line moves are left to drive
pub fn paste(&mut self, text: &str, multiline: bool, now: Duration) -> bool
pub fn move_to(&mut self, offset: usize, extend: bool)
Trait Implementations§
impl<T: PartialEq> StructuralPartialEq for State<T>
Auto Trait Implementations§
impl<T> Forget for State<T>
impl<T> Freeze for State<T>
impl<T> Move for State<T>
impl<T> RefUnwindSafe for State<T>where
T: RefUnwindSafe,
impl<T> Send for State<T>
impl<T> Sync for State<T>
impl<T> Unpin for State<T>
impl<T> UnsafeUnpin for State<T>where
T: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Change>: UnsafeUnpin,
impl<T> UnwindSafe for State<T>where
T: UnwindSafe,
RawVecInner: UnwindSafe,
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