Struct TextBuffer
pub struct TextBuffer { /* private fields */ }
dep_fltk
only.Expand description
Wraps a text buffer, Cloning a text buffer invalidates the underlying pointer, thus the no derive(Clone)
Implementations§
§impl TextBuffer
impl TextBuffer
pub unsafe fn delete(buf: TextBuffer)
pub unsafe fn delete(buf: TextBuffer)
Deletes the TextBuffer
§Safety
The buffer shouldn’t be deleted while the Display widget still needs it
pub unsafe fn delete_buffer(buf: TextBuffer)
pub unsafe fn delete_buffer(buf: TextBuffer)
Deletes the TextBuffer
§Safety
The buffer shouldn’t be deleted while the Display widget still needs it
pub unsafe fn from_ptr(ptr: *mut Fl_Text_Buffer) -> TextBuffer
pub unsafe fn from_ptr(ptr: *mut Fl_Text_Buffer) -> TextBuffer
pub unsafe fn as_ptr(&self) -> *mut Fl_Text_Buffer
pub unsafe fn as_ptr(&self) -> *mut Fl_Text_Buffer
Returns the inner pointer from a text buffer
§Safety
Can return multiple mutable pointers to the same buffer
pub fn append(&mut self, text: &str)
pub fn append(&mut self, text: &str)
Appends to the buffer. To append and scroll to the end of the buffer:
use fltk::{prelude::*, *};
let txt = "Some long text!";
let buf = text::TextBuffer::default();
let mut disp = text::TextDisplay::default();
disp.set_buffer(Some(buf));
disp.buffer().unwrap().append(txt);
disp.set_insert_position(disp.buffer().unwrap().length());
disp.scroll(
disp.count_lines(0, disp.buffer().unwrap().length(), true),
0,
);
pub fn copy_from(
&mut self,
source_buf: &TextBuffer,
start: i32,
end: i32,
to: i32,
)
pub fn copy_from( &mut self, source_buf: &TextBuffer, start: i32, end: i32, to: i32, )
Copies text from a source buffer into the current buffer
pub fn copy(&self) -> TextBuffer
pub fn copy(&self) -> TextBuffer
Copies whole text from a source buffer into a new buffer
pub fn redo(&mut self) -> Result<i32, FltkError> ⓘ
pub fn redo(&mut self) -> Result<i32, FltkError> ⓘ
Performs a redo operation on the buffer. Returns the cursor position.
§Errors
Errors on failure to undo
pub fn get_can_undo(&mut self) -> bool
pub fn get_can_undo(&mut self) -> bool
Gets whether the buffer can undo
pub fn tab_distance(&self) -> i32
pub fn tab_distance(&self) -> i32
Returns the tab distance for the buffer
pub fn set_tab_distance(&mut self, tab_dist: i32)
pub fn set_tab_distance(&mut self, tab_dist: i32)
Sets the tab distance
pub fn unselect(&mut self)
pub fn unselect(&mut self)
Unselects text
pub fn selection_position(&self) -> Option<(i32, i32)> ⓘ
pub fn selection_position(&self) -> Option<(i32, i32)> ⓘ
Returns the selection position
pub fn selection_text(&self) -> String ⓘ
pub fn selection_text(&self) -> String ⓘ
Returns the selection text
pub fn remove_selection(&mut self)
pub fn remove_selection(&mut self)
Removes the selection
pub fn replace_selection(&mut self, text: &str)
pub fn replace_selection(&mut self, text: &str)
Replaces selection
pub fn secondary_select(&mut self, start: i32, end: i32)
pub fn secondary_select(&mut self, start: i32, end: i32)
Secondary selects the text from start to end
pub fn secondary_selected(&self) -> bool
pub fn secondary_selected(&self) -> bool
Returns whether text is secondary selected
pub fn secondary_unselect(&mut self)
pub fn secondary_unselect(&mut self)
Unselects text (secondary selection)
pub fn secondary_selection_position(&self) -> Option<(i32, i32)> ⓘ
pub fn secondary_selection_position(&self) -> Option<(i32, i32)> ⓘ
Returns the secondary selection position
pub fn secondary_selection_text(&self) -> String ⓘ
pub fn secondary_selection_text(&self) -> String ⓘ
Returns the secondary selection text
pub fn remove_secondary_selection(&mut self)
pub fn remove_secondary_selection(&mut self)
Removes the secondary selection
pub fn replace_secondary_selection(&mut self, text: &str)
pub fn replace_secondary_selection(&mut self, text: &str)
Replaces the secondary selection
pub fn is_highlighted(&self) -> bool
pub fn is_highlighted(&self) -> bool
Returns whether text is highlighted
pub fn unhighlight(&mut self)
pub fn unhighlight(&mut self)
Unhighlights text
pub fn highlight_position(&self) -> Option<(i32, i32)> ⓘ
pub fn highlight_position(&self) -> Option<(i32, i32)> ⓘ
Returns the highlight position
pub fn highlight_text(&self) -> String ⓘ
pub fn highlight_text(&self) -> String ⓘ
Returns the highlighted text
pub fn line_start(&self, pos: i32) -> i32
pub fn line_start(&self, pos: i32) -> i32
Returns the index of the line’s start position at pos
pub fn word_start(&self, pos: i32) -> i32
pub fn word_start(&self, pos: i32) -> i32
Returns the index of the first character of a word at pos
pub fn count_lines(&self, start: i32, end: i32) -> i32
pub fn count_lines(&self, start: i32, end: i32) -> i32
Counts the lines from start to end
pub fn call_modify_callbacks(&mut self)
pub fn call_modify_callbacks(&mut self)
Calls the modify callbacks
pub fn add_modify_callback<F>(&mut self, cb: F)
pub fn add_modify_callback<F>(&mut self, cb: F)
Adds a modify callback.
callback args:
pos: i32, inserted items: i32, deleted items: i32, restyled items: i32, deleted_text
pub fn remove_modify_callback<F>(&mut self, cb: F)
pub fn remove_modify_callback<F>(&mut self, cb: F)
Removes a modify callback.
callback args:
pos: i32, inserted items: i32, deleted items: i32, restyled items: i32, deleted_text
pub fn search_forward(
&self,
start_pos: i32,
search_string: &str,
match_case: bool,
) -> Option<i32> ⓘ
pub fn search_forward( &self, start_pos: i32, search_string: &str, match_case: bool, ) -> Option<i32> ⓘ
Forward search for a string
pub fn search_backward(
&self,
start_pos: i32,
search_string: &str,
match_case: bool,
) -> Option<i32> ⓘ
pub fn search_backward( &self, start_pos: i32, search_string: &str, match_case: bool, ) -> Option<i32> ⓘ
Backward search for a string
Trait Implementations§
§impl Clone for TextBuffer
impl Clone for TextBuffer
§fn clone(&self) -> TextBuffer
fn clone(&self) -> TextBuffer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for TextBuffer
impl Debug for TextBuffer
§impl Default for TextBuffer
impl Default for TextBuffer
§fn default() -> TextBuffer
fn default() -> TextBuffer
Initialized a default text buffer
§impl PartialEq for TextBuffer
impl PartialEq for TextBuffer
impl Eq for TextBuffer
impl Send for TextBuffer
impl Sync for TextBuffer
Auto Trait Implementations§
impl Freeze for TextBuffer
impl RefUnwindSafe for TextBuffer
impl Unpin 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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more