feat: don't overwrite the entire build textbuf content on each tick

This commit is contained in:
Gabriele Musco 2023-07-03 18:28:27 +02:00
parent d225b65222
commit ff744853b6
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
2 changed files with 14 additions and 6 deletions

View file

@ -82,8 +82,10 @@ impl RunnerPipeline {
}
}
pub fn get_log(&self) -> String {
self.log.concat()
pub fn get_log(&mut self) -> Vec<String> {
let log = self.log.to_owned();
self.log = vec![];
log
}
pub fn status(&self) -> RunnerStatus {

View file

@ -30,7 +30,7 @@ pub enum BuildWindowMsg {
Present,
UpdateTitle(String),
UpdateBuildStatus(BuildStatus),
UpdateContent(String),
UpdateContent(Vec<String>),
UpdateCanClose(bool),
}
@ -134,9 +134,15 @@ impl SimpleComponent for BuildWindow {
self.set_title(t);
}
Self::Input::UpdateContent(c) => {
if self.content != c {
self.set_content(c);
self.textbuf.set_text(&self.content);
if c.len() > 0 {
let n_lines = c.concat();
let mut n_content = self.content.clone();
n_content.push_str(n_lines.as_str());
self.set_content(n_content);
self.textbuf.insert(
&mut self.textbuf.end_iter(),
n_lines.as_str()
);
let textbuf = self.textbuf.clone();
let textview = self.textview.as_ref().unwrap().clone();
gtk::glib::idle_add_local_once(move || {