pub struct Viewport { /* private fields */ }Expand description
The visible part of a text pane, including any rendered gutter columns.
top is a zero-based logical line. left, width, gutter, and the
retained desired column are terminal display cells, not UTF-8 byte columns.
The viewport does not own wrapping or rendered text: callers supply the
same logical line snapshot to apply that they display.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(
top: usize,
left: usize,
height: usize,
width: usize,
gutter: usize,
) -> Self
pub fn new( top: usize, left: usize, height: usize, width: usize, gutter: usize, ) -> Self
Creates a viewport in terminal display cells.
Zero height or width is normalized to one so reveal calculations
remain total. top and left may initially be beyond the supplied
text; motion application clamps or adjusts them as needed.
Sourcepub fn with_desired_column(self, desired_column: Option<usize>) -> Self
pub fn with_desired_column(self, desired_column: Option<usize>) -> Self
Restores the desired display column retained by vertical motions.
None derives the first desired column from the current cursor. After
each motion, apply stores the column needed for a later j or k;
callers preserving a viewport between calls normally do not need to set
this themselves.
Sourcepub const fn left(&self) -> usize
pub const fn left(&self) -> usize
Returns the first visible terminal column, including the gutter.
Sourcepub const fn height(&self) -> usize
pub const fn height(&self) -> usize
Returns the viewport height in logical lines (always at least one).
Sourcepub const fn width(&self) -> usize
pub const fn width(&self) -> usize
Returns the viewport width in terminal display cells (always at least one).
Sourcepub const fn gutter(&self) -> usize
pub const fn gutter(&self) -> usize
Returns the rendered gutter width in terminal display cells.
Sourcepub const fn desired_column(&self) -> Option<usize>
pub const fn desired_column(&self) -> Option<usize>
Returns the retained source-text display column used by vertical motions.