pub struct ContentWindow {
pub top: usize,
pub bottom: usize,
pub len: usize,
pub height: usize,
}Expand description
Holds the information about the displayed window of lines.
When there’s too much lines to display in one screen, we can scroll
and this struct is responsible for that.
Scrolling is done with scroll_to, scroll_up_one, scroll_down_one
methods.
Fields§
§top: usizeThe index of the first displayed element.
bottom: usizeThe index of the last displayed element + 1.
len: usizeThe number of displayble elements.
height: usizeThe height of the rect containing the elements.
Implementations§
Source§impl ContentWindow
impl ContentWindow
Sourcepub const WINDOW_PADDING: usize = 4usize
pub const WINDOW_PADDING: usize = 4usize
The padding around the last displayed filename
pub const WINDOW_PADDING_FUZZY: u32 = 3u32
Sourcepub const WINDOW_MARGIN_TOP_U16: u16 = 2u16
pub const WINDOW_MARGIN_TOP_U16: u16 = 2u16
The space of the top element as an u16 for convenience
Sourcepub const WINDOW_MARGIN_BOTTOM: usize = 1usize
pub const WINDOW_MARGIN_BOTTOM: usize = 1usize
The space for the bottom row
Sourcepub const HEADER_ROWS: usize = 3usize
pub const HEADER_ROWS: usize = 3usize
How many rows are reserved for the header ?
Sourcepub fn new(len: usize, rect_height: usize) -> Self
pub fn new(len: usize, rect_height: usize) -> Self
Returns a new ContentWindow instance with values depending of
number of displayable elements and height of the terminal screen.
Sourcepub fn set_height(&mut self, terminal_height: usize)
pub fn set_height(&mut self, terminal_height: usize)
Set the height of file window.
pub fn set_len(&mut self, len: usize)
Sourcepub fn scroll_up_one(&mut self, index: usize)
pub fn scroll_up_one(&mut self, index: usize)
Move the window one line up if possible. Does nothing if the index can’t be reached.
Sourcepub fn scroll_down_one(&mut self, index: usize)
pub fn scroll_down_one(&mut self, index: usize)
Move the window one line down if possible. Does nothing if the index can’t be reached.
Sourcepub fn scroll_to(&mut self, index: usize)
pub fn scroll_to(&mut self, index: usize)
Scroll the window to this index if possible. Does nothing if the index can’t be reached.
pub fn is_row_in_header(row: u16) -> bool
pub fn preview_page_up(&mut self, skip: usize)
pub fn preview_page_down(&mut self, skip: usize, preview_len: usize)
Trait Implementations§
Source§impl Clone for ContentWindow
impl Clone for ContentWindow
Source§fn clone(&self) -> ContentWindow
fn clone(&self) -> ContentWindow
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentWindow
impl Debug for ContentWindow
Auto Trait Implementations§
impl Freeze for ContentWindow
impl RefUnwindSafe for ContentWindow
impl Send for ContentWindow
impl Sync for ContentWindow
impl Unpin for ContentWindow
impl UnwindSafe for ContentWindow
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> 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 more