pub struct TextBuffer { /* private fields */ }Expand description
Text, selection and read-only boundary for one editable region.
Implementations§
Source§impl TextBuffer
impl TextBuffer
pub fn new() -> Self
pub fn content(&self) -> &str
Sourcepub fn read_only_len(&self) -> usize
pub fn read_only_len(&self) -> usize
The byte offset where the editable region begins. Everything before it is read-only (console output). Zero for a plain field.
pub fn selected_range(&self) -> &Range<usize> ⓘ
pub fn selection_reversed(&self) -> bool
pub fn marked_range(&self) -> Option<&Range<usize>>
pub fn cursor_offset(&self) -> usize
pub fn move_to(&mut self, offset: usize)
pub fn select_to(&mut self, offset: usize)
pub fn select_all(&mut self)
pub fn set_selection(&mut self, range: Range<usize>, reversed: bool)
pub fn set_marked_range(&mut self, range: Option<Range<usize>>)
pub fn previous_boundary(&self, offset: usize) -> usize
pub fn next_boundary(&self, offset: usize) -> usize
Sourcepub fn line_range(&self, offset: usize) -> Range<usize> ⓘ
pub fn line_range(&self, offset: usize) -> Range<usize> ⓘ
Byte range of the line containing offset (excluding the newline).
Sourcepub fn replace_range(&mut self, range: Range<usize>, text: &str)
pub fn replace_range(&mut self, range: Range<usize>, text: &str)
Replace range with text, clamped to the editable region, and put the
caret after the inserted text.
Sourcepub fn replace_and_mark(
&mut self,
range: Range<usize>,
text: &str,
selection: Option<Range<usize>>,
)
pub fn replace_and_mark( &mut self, range: Range<usize>, text: &str, selection: Option<Range<usize>>, )
Replace range with text for the IME path, marking the inserted text
as composing and placing the selection relative to the insertion point.
Sourcepub fn backspace(&mut self) -> bool
pub fn backspace(&mut self) -> bool
Delete the selection, or the grapheme before the caret. Returns whether anything changed (false at the read-only boundary, where the caller may play the system bell).
Sourcepub fn set_content(&mut self, text: impl Into<SharedString>)
pub fn set_content(&mut self, text: impl Into<SharedString>)
Replace the whole content. The read-only boundary is clamped to the new length and the caret moves to the end.
pub fn set_read_only_len(&mut self, len: usize)
Sourcepub fn push_read_only(&mut self, text: &str)
pub fn push_read_only(&mut self, text: &str)
Append text to the read-only prefix (console output) and move the caret to the end of the now-empty editable region.
Sourcepub fn take_editable(&mut self) -> String
pub fn take_editable(&mut self) -> String
Remove and return the editable text, leaving the read-only prefix.
pub fn offset_from_utf16(&self, offset: usize) -> usize
pub fn offset_to_utf16(&self, offset: usize) -> usize
pub fn range_to_utf16(&self, range: &Range<usize>) -> Range<usize> ⓘ
pub fn range_from_utf16(&self, range_utf16: &Range<usize>) -> Range<usize> ⓘ
Trait Implementations§
Source§impl Clone for TextBuffer
impl Clone for TextBuffer
Source§impl Debug for TextBuffer
impl Debug for TextBuffer
Auto Trait Implementations§
impl Freeze for TextBuffer
impl RefUnwindSafe for TextBuffer
impl Send for TextBuffer
impl Sync for TextBuffer
impl Unpin for TextBuffer
impl UnsafeUnpin for TextBuffer
impl UnwindSafe for TextBuffer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().