pub struct TextView { /* private fields */ }Expand description
A scrollable, wrapped view over a text buffer.
Implementations§
Source§impl TextView
impl TextView
Sourcepub fn new(text: impl Into<Rope>, width: usize, wrap: WrapMode) -> Self
pub fn new(text: impl Into<Rope>, width: usize, wrap: WrapMode) -> Self
Build a view from raw text, wrap mode, and viewport width.
Sourcepub const fn source_line_count(&self) -> usize
pub const fn source_line_count(&self) -> usize
Number of logical (source) lines in the text.
Sourcepub fn virtual_line_count(&self) -> usize
pub fn virtual_line_count(&self) -> usize
Number of virtual (wrapped) lines.
Sourcepub fn source_to_virtual(&self, source_line: usize) -> Option<usize>
pub fn source_to_virtual(&self, source_line: usize) -> Option<usize>
Map a source line index to its first virtual line index.
Sourcepub fn virtual_to_source(&self, virtual_line: usize) -> Option<usize>
pub fn virtual_to_source(&self, virtual_line: usize) -> Option<usize>
Map a virtual line index to its source line index.
Sourcepub fn clamp_scroll(&self, scroll_y: usize, viewport_height: usize) -> usize
pub fn clamp_scroll(&self, scroll_y: usize, viewport_height: usize) -> usize
Clamp scroll position to a valid range for the given viewport height.
Sourcepub fn max_scroll(&self, viewport_height: usize) -> usize
pub fn max_scroll(&self, viewport_height: usize) -> usize
Maximum scroll offset for the given viewport height.
Sourcepub fn visible_range(
&self,
scroll_y: usize,
viewport_height: usize,
) -> Range<usize>
pub fn visible_range( &self, scroll_y: usize, viewport_height: usize, ) -> Range<usize>
Compute the visible virtual line range for a scroll offset + viewport height.
Sourcepub fn visible_lines(
&self,
scroll_y: usize,
viewport_height: usize,
) -> &[ViewLine]
pub fn visible_lines( &self, scroll_y: usize, viewport_height: usize, ) -> &[ViewLine]
Get the visible virtual lines for a scroll offset + viewport height.
Sourcepub fn scroll_to_line(
&self,
source_line: usize,
viewport_height: usize,
) -> Option<usize>
pub fn scroll_to_line( &self, source_line: usize, viewport_height: usize, ) -> Option<usize>
Scroll so the given source line is at the top of the viewport.
Returns None if the source line doesn’t exist.
Sourcepub fn scroll_to_top(&self) -> usize
pub fn scroll_to_top(&self) -> usize
Scroll to the top of the view.
Sourcepub fn scroll_to_bottom(&self, viewport_height: usize) -> usize
pub fn scroll_to_bottom(&self, viewport_height: usize) -> usize
Scroll to the bottom of the view.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextView
impl RefUnwindSafe for TextView
impl Send for TextView
impl Sync for TextView
impl Unpin for TextView
impl UnwindSafe for TextView
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