pub struct Viewport {
pub width: usize,
pub height: usize,
pub key_map: KeyMap,
pub mouse_wheel_enabled: bool,
pub mouse_wheel_delta: usize,
pub style: Style,
/* private fields */
}Expand description
Viewport model for scrollable content.
Fields§
§width: usizeWidth of the viewport.
height: usizeHeight of the viewport.
key_map: KeyMapKey bindings for navigation.
mouse_wheel_enabled: boolWhether mouse wheel scrolling is enabled.
mouse_wheel_delta: usizeNumber of lines to scroll per mouse wheel tick.
style: StyleStyle for rendering the viewport.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(width: usize, height: usize) -> Self
pub fn new(width: usize, height: usize) -> Self
Creates a new viewport with the given dimensions.
Sourcepub fn set_content(&mut self, content: &str)
pub fn set_content(&mut self, content: &str)
Sets the content of the viewport.
Sourcepub fn set_y_offset(&mut self, n: usize)
pub fn set_y_offset(&mut self, n: usize)
Sets the vertical scroll offset.
Sourcepub fn set_x_offset(&mut self, n: usize)
pub fn set_x_offset(&mut self, n: usize)
Sets the horizontal scroll offset.
Sourcepub fn set_horizontal_step(&mut self, n: usize)
pub fn set_horizontal_step(&mut self, n: usize)
Sets the horizontal scroll step size.
Sourcepub fn past_bottom(&self) -> bool
pub fn past_bottom(&self) -> bool
Returns whether the viewport is past the bottom.
Sourcepub fn scroll_percent(&self) -> f64
pub fn scroll_percent(&self) -> f64
Returns the scroll percentage (0.0 to 1.0).
Sourcepub fn horizontal_scroll_percent(&self) -> f64
pub fn horizontal_scroll_percent(&self) -> f64
Returns the horizontal scroll percentage (0.0 to 1.0).
Sourcepub fn total_line_count(&self) -> usize
pub fn total_line_count(&self) -> usize
Returns the total number of lines.
Sourcepub fn visible_line_count(&self) -> usize
pub fn visible_line_count(&self) -> usize
Returns the number of visible lines.
Sourcepub fn scroll_down(&mut self, n: usize)
pub fn scroll_down(&mut self, n: usize)
Scrolls down by the given number of lines.
Sourcepub fn scroll_left(&mut self, n: usize)
pub fn scroll_left(&mut self, n: usize)
Scrolls left by the given number of columns.
Sourcepub fn scroll_right(&mut self, n: usize)
pub fn scroll_right(&mut self, n: usize)
Scrolls right by the given number of columns.
Sourcepub fn half_page_down(&mut self)
pub fn half_page_down(&mut self)
Moves down half a page.
Sourcepub fn half_page_up(&mut self)
pub fn half_page_up(&mut self)
Moves up half a page.
Sourcepub fn goto_bottom(&mut self)
pub fn goto_bottom(&mut self)
Goes to the bottom.