use crate::command_log::{self, CommandLogEntry};
#[derive(Debug, Default)]
pub struct CommandLogs {
pub entries: Vec<CommandLogEntry>,
pub scroll: u16,
pub max_scroll: u16,
pub x_scroll: u16,
pub max_x_scroll: u16,
}
impl CommandLogs {
pub fn new() -> Self {
Self::default()
}
pub fn sync(&mut self) {
self.entries = command_log::snapshot();
}
pub fn scroll_down(&mut self) {
self.scroll = (self.scroll + 1).min(self.max_scroll);
}
pub fn scroll_up(&mut self) {
self.scroll = self.scroll.saturating_sub(1);
}
pub fn scroll_right(&mut self) {
self.x_scroll = (self.x_scroll + 1).min(self.max_x_scroll);
}
pub fn scroll_left(&mut self) {
self.x_scroll = self.x_scroll.saturating_sub(1);
}
pub fn scroll_to_top(&mut self) {
self.scroll = 0;
}
pub fn scroll_to_bottom(&mut self) {
self.scroll = self.max_scroll;
}
pub fn reset(&mut self) {
self.scroll = 0;
self.x_scroll = 0;
}
}