mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-02 22:29:01 +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) => {
|
Self::Input::UpdateContent(c) => {
|
||||||
if !c.is_empty() {
|
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 n_lines = c.concat();
|
||||||
let mut n_content = self.content.clone();
|
let mut n_content = self.content.clone();
|
||||||
n_content.push_str(n_lines.as_str());
|
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());
|
.insert(&mut self.textbuf.end_iter(), n_lines.as_str());
|
||||||
let textbuf = self.textbuf.clone();
|
let textbuf = self.textbuf.clone();
|
||||||
let textview = self.textview.as_ref().unwrap().clone();
|
let textview = self.textview.as_ref().unwrap().clone();
|
||||||
if is_at_bottom {
|
gtk::glib::idle_add_local_once(move || {
|
||||||
gtk::glib::idle_add_local_once(move || {
|
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
||||||
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
textview.scroll_mark_onscreen(&end_mark);
|
||||||
textview.scroll_mark_onscreen(&end_mark);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::UpdateBuildStatus(status) => {
|
Self::Input::UpdateBuildStatus(status) => {
|
||||||
|
|
|
@ -194,10 +194,6 @@ impl SimpleComponent for DebugView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::LogUpdated(n_log) => {
|
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());
|
self.log.extend(n_log.clone());
|
||||||
for row in n_log {
|
for row in n_log {
|
||||||
let txt = match MonadoLog::new_from_str(row.as_str()) {
|
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());
|
.insert(&mut self.textbuf.end_iter(), t.as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let textbuf = self.textbuf.clone();
|
if !self.searchbar.as_ref().unwrap().is_search_mode() {
|
||||||
let textview = self.textview.as_ref().unwrap().clone();
|
let textbuf = self.textbuf.clone();
|
||||||
if is_at_bottom && !self.searchbar.as_ref().unwrap().is_search_mode() {
|
let textview = self.textview.as_ref().unwrap().clone();
|
||||||
gtk::glib::idle_add_local_once(move || {
|
gtk::glib::idle_add_local_once(move || {
|
||||||
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
let end_mark = textbuf.create_mark(None, &textbuf.end_iter(), false);
|
||||||
textview.scroll_mark_onscreen(&end_mark);
|
textview.scroll_mark_onscreen(&end_mark);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue