mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-14 13:13:08 +00:00
Fix logs demo
This commit is contained in:
parent
e59a2d4dd7
commit
7e4873f5b7
@ -70,8 +70,8 @@ impl BufferView {
|
|||||||
fn update(&mut self) {
|
fn update(&mut self) {
|
||||||
let mut i = self.pos;
|
let mut i = self.pos;
|
||||||
while let Ok(line) = self.rx.try_recv() {
|
while let Ok(line) = self.rx.try_recv() {
|
||||||
i = (i+1) % self.buffer.len();
|
|
||||||
self.buffer[i] = line;
|
self.buffer[i] = line;
|
||||||
|
i = (i+1) % self.buffer.len();
|
||||||
}
|
}
|
||||||
self.pos = i;
|
self.pos = i;
|
||||||
}
|
}
|
||||||
@ -91,17 +91,16 @@ impl View for BufferView {
|
|||||||
// Before drawing, we'll want to update the buffer
|
// Before drawing, we'll want to update the buffer
|
||||||
self.update();
|
self.update();
|
||||||
|
|
||||||
// If the buffer is large enough, we can fill the window
|
// If the buffer is large enough, we'll discard the beginning and keep the end.
|
||||||
if self.buffer.len() > printer.size.y as usize {
|
// If the buffer is too small, only print a part of it with an offset.
|
||||||
// We'll only print the last entries that fit.
|
let (discard,offset) = if self.buffer.len() > printer.size.y as usize {
|
||||||
// So discard entries if there are too many.
|
(self.buffer.len() - printer.size.y as usize, 0)
|
||||||
let discard = self.buffer.len() - printer.size.y as usize;
|
|
||||||
// And we discard the first entries if needed
|
|
||||||
for (i, line) in self.ring().skip(discard).enumerate() {
|
|
||||||
printer.print((0,i as u32), line);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
(0, printer.size.y - self.buffer.len() as u32)
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i, line) in self.ring().skip(discard).enumerate() {
|
||||||
|
printer.print((0,offset + i as u32), line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ impl Cursive {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Regularly redraws everything, even when no input is given.
|
/// Regularly redraws everything, even when no input is given. Between 0 and 1000.
|
||||||
///
|
///
|
||||||
/// Call with fps=0 to disable (default value).
|
/// Call with fps=0 to disable (default value).
|
||||||
pub fn set_fps(&self, fps: u32) {
|
pub fn set_fps(&self, fps: u32) {
|
||||||
|
Loading…
Reference in New Issue
Block a user