mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-26 19:28:38 +00:00
feat: implement max scrollback in debug view
This commit is contained in:
parent
afaed79a2f
commit
cdf3c2fa13
1 changed files with 8 additions and 0 deletions
|
@ -48,6 +48,8 @@ pub struct DebugView {
|
||||||
|
|
||||||
pub struct DebugViewInit {}
|
pub struct DebugViewInit {}
|
||||||
|
|
||||||
|
const MAX_SCROLLBACK: i32 = 2000;
|
||||||
|
|
||||||
#[relm4::component(pub)]
|
#[relm4::component(pub)]
|
||||||
impl SimpleComponent for DebugView {
|
impl SimpleComponent for DebugView {
|
||||||
type Init = DebugViewInit;
|
type Init = DebugViewInit;
|
||||||
|
@ -209,6 +211,12 @@ impl SimpleComponent for DebugView {
|
||||||
textview.scroll_mark_onscreen(&end_mark);
|
textview.scroll_mark_onscreen(&end_mark);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
while self.textbuf.line_count() > MAX_SCROLLBACK {
|
||||||
|
let mut start = self.textbuf.start_iter();
|
||||||
|
let mut end = self.textbuf.start_iter();
|
||||||
|
end.forward_line();
|
||||||
|
self.textbuf.delete(&mut start, &mut end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Self::Input::ClearLog => {
|
Self::Input::ClearLog => {
|
||||||
self.textbuf.set_text("");
|
self.textbuf.set_text("");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue