undo/redo
This commit is contained in:
parent
8a4df3307d
commit
8cfe1a0b65
8 changed files with 247 additions and 154 deletions
28
src/tui/log_viewer/view.rs
Normal file
28
src/tui/log_viewer/view.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::tui::{model::LogEntry, processing::LogStream};
|
||||
|
||||
pub struct LogView {
|
||||
pub iter: Box<dyn LogStream>,
|
||||
pub selection_offset: usize,
|
||||
}
|
||||
|
||||
impl LogView {
|
||||
pub fn selected(&self) -> Option<(Rc<LogEntry>, usize)> {
|
||||
let mut temp_iter = self.iter.clone();
|
||||
for _ in 0..self.selection_offset {
|
||||
let _ = temp_iter.next()?;
|
||||
}
|
||||
|
||||
temp_iter.next()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for LogView {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
iter: self.iter.clone(),
|
||||
selection_offset: self.selection_offset.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue