components/mail/view: on draw() set dirty on return

pull/211/head
Manos Pitsidianakis 2023-05-01 16:33:19 +03:00
parent 85d4316a6a
commit 1f1ea30769
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
2 changed files with 17 additions and 28 deletions

View File

@ -1180,7 +1180,6 @@ impl Component for MailView {
if !self.is_dirty() && !self.force_draw_headers {
return;
}
self.dirty = false;
let upper_left = upper_left!(area);
let bottom_right = bottom_right!(area);
@ -1228,7 +1227,7 @@ impl Component for MailView {
(set_y(upper_left, y), bottom_right),
Some(get_x(upper_left)),
);
if let Some(cell) = grid.get_mut(_x,_y) {
if let Some(cell) = grid.get_mut(_x, _y) {
cell.set_ch(' ')
.set_fg(headers_area.fg)
.set_bg(headers_area.bg)
@ -1241,10 +1240,17 @@ impl Component for MailView {
headers.fg,
headers.bg,
headers.attrs,
((_x +1, _y), bottom_right),
((_x + 1, _y), bottom_right),
Some(get_x(upper_left)),
);
clear_area(grid, ((std::cmp::min(_x, get_x(bottom_right)), _y), (get_x(bottom_right), _y)), headers_area);
clear_area(
grid,
(
(std::cmp::min(_x, get_x(bottom_right)), _y),
(get_x(bottom_right), _y),
),
headers_area,
);
y = _y + 1;
}
} else {
@ -1516,7 +1522,6 @@ impl Component for MailView {
return;
};
self.initialised = true;
//let body = AttachmentBuilder::new(bytes).build();
match self.mode {
ViewMode::Attachment(aidx) => {
let mut text = "Viewing attachment. Press `r` to return \n".to_string();
@ -1642,19 +1647,6 @@ impl Component for MailView {
self.pager.filter(filter);
}
}
/*
ViewMode::Ansi(ref buf) => {
write_string_to_grid(
&format!("Viewing `{}`. Press `r` to return", buf.title()),
grid,
Color::Default,
Color::Default,
Attr::DEFAULT,
(set_y(upper_left, y), bottom_right),
Some(get_x(upper_left)),
);
}
*/
ViewMode::Url => {
let mut text = body_text.clone();
if links.is_empty() {
@ -1735,10 +1727,6 @@ impl Component for MailView {
s.draw(grid, (set_y(upper_left, y), bottom_right), context);
}
}
/*
ViewMode::Ansi(ref mut buf) => {
buf.draw(grid, (set_y(upper_left, y + 1), bottom_right), context);
}*/
_ => {
self.pager
.draw(grid, (set_y(upper_left, y), bottom_right), context);
@ -1751,6 +1739,8 @@ impl Component for MailView {
if let ForceCharset::Dialog(ref mut s) = self.force_charset {
s.draw(grid, area, context);
}
self.dirty = false;
}
fn process_event(&mut self, mut event: &mut UIEvent, context: &mut Context) -> bool {

View File

@ -583,7 +583,6 @@ impl ThreadView {
crate::conf::value(context, "theme_default"),
);
}
self.dirty = false;
context.dirty_areas.push_back(area);
} else {
let old_cursor_pos = self.cursor_pos;
@ -735,6 +734,7 @@ impl ThreadView {
}
}
}
fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
let upper_left = upper_left!(area);
let bottom_right = bottom_right!(area);
@ -979,11 +979,7 @@ impl Component for ThreadView {
if self.entries.len() == 1 {
self.mailview.draw(grid, area, context);
self.dirty = false;
return;
}
if total_cols >= self.content.size().0 + 74 {
} else if total_cols >= self.content.size().0 + 74 {
self.draw_vert(grid, area, context);
} else {
self.draw_horz(grid, area, context);
@ -1149,13 +1145,16 @@ impl Component for ThreadView {
}
false
}
fn is_dirty(&self) -> bool {
self.dirty || (self.show_mailview && self.mailview.is_dirty())
}
fn set_dirty(&mut self, value: bool) {
self.dirty = value;
self.mailview.set_dirty(value);
}
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let mut map = self.mailview.get_shortcuts(context);