mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-22 12:34:49 +00:00
feat: always scroll to bottom in logs
This commit is contained in:
parent
abb283b206
commit
55d20b2b61
2 changed files with 7 additions and 18 deletions
|
@ -140,11 +140,6 @@ impl SimpleComponent for BuildWindow {
|
|||
}
|
||||
Self::Input::UpdateContent(c) => {
|
||||
if !c.is_empty() {
|
||||
let is_at_bottom = {
|
||||
let adj = self.scrolledwin.as_ref().unwrap().vadjustment();
|
||||
(adj.upper() - adj.page_size() - adj.value()) <= 15.0
|
||||
};
|
||||
|
||||
let n_lines = c.concat();
|
||||
let mut n_content = self.content.clone();
|
||||
n_content.push_str(n_lines.as_str());
|
||||
|
@ -153,12 +148,10 @@ impl SimpleComponent for BuildWindow {
|
|||
.insert(&mut self.textbuf.end_iter(), n_lines.as_str());
|
||||
let textbuf = self.textbuf.clone();
|
||||
let textview = self.textview.as_ref().unwrap().clone();
|
||||
if is_at_bottom {
|
||||
gtk::glib::idle_add_local_once(move || {
|
||||
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
||||
textview.scroll_mark_onscreen(&end_mark);
|
||||
});
|
||||
}
|
||||
gtk::glib::idle_add_local_once(move || {
|
||||
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
||||
textview.scroll_mark_onscreen(&end_mark);
|
||||
});
|
||||
}
|
||||
}
|
||||
Self::Input::UpdateBuildStatus(status) => {
|
||||
|
|
|
@ -194,10 +194,6 @@ impl SimpleComponent for DebugView {
|
|||
}
|
||||
}
|
||||
Self::Input::LogUpdated(n_log) => {
|
||||
let is_at_bottom = {
|
||||
let adj = self.scrolledwin.as_ref().unwrap().vadjustment();
|
||||
(adj.upper() - adj.page_size() - adj.value()) <= 15.0
|
||||
};
|
||||
self.log.extend(n_log.clone());
|
||||
for row in n_log {
|
||||
let txt = match MonadoLog::new_from_str(row.as_str()) {
|
||||
|
@ -218,9 +214,9 @@ impl SimpleComponent for DebugView {
|
|||
.insert(&mut self.textbuf.end_iter(), t.as_str());
|
||||
}
|
||||
}
|
||||
let textbuf = self.textbuf.clone();
|
||||
let textview = self.textview.as_ref().unwrap().clone();
|
||||
if is_at_bottom && !self.searchbar.as_ref().unwrap().is_search_mode() {
|
||||
if !self.searchbar.as_ref().unwrap().is_search_mode() {
|
||||
let textbuf = self.textbuf.clone();
|
||||
let textview = self.textview.as_ref().unwrap().clone();
|
||||
gtk::glib::idle_add_local_once(move || {
|
||||
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
||||
textview.scroll_mark_onscreen(&end_mark);
|
||||
|
|
Loading…
Add table
Reference in a new issue