ui/Component: change set_dirty() to set_dirty(value)

Next commit will need to set a child component as not dirty so we need
set_dirty(value) instead of set_dirty() that always sets is to true.
async
Manos Pitsidianakis 2019-12-14 18:50:05 +02:00
parent 2e38ea11e2
commit ab3e01359a
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
19 changed files with 168 additions and 169 deletions

View File

@ -93,7 +93,7 @@ pub trait Component: Display + Debug + Send {
fn can_quit_cleanly(&mut self, _context: &Context) -> bool { fn can_quit_cleanly(&mut self, _context: &Context) -> bool {
true true
} }
fn set_dirty(&mut self); fn set_dirty(&mut self, value: bool);
fn kill(&mut self, _id: ComponentId, _context: &mut Context) {} fn kill(&mut self, _id: ComponentId, _context: &mut Context) {}
fn set_id(&mut self, _id: ComponentId) {} fn set_id(&mut self, _id: ComponentId) {}
fn id(&self) -> ComponentId; fn id(&self) -> ComponentId;

View File

@ -194,7 +194,7 @@ impl Component for ContactManager {
_ => {} _ => {}
} }
} }
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
} }
@ -240,7 +240,7 @@ impl Component for ContactManager {
context.replies.push_back(UIEvent::ComponentKill(self.id)); context.replies.push_back(UIEvent::ComponentKill(self.id));
} }
} }
self.set_dirty(); self.set_dirty(true);
if let UIEvent::InsertInput(_) = event { if let UIEvent::InsertInput(_) = event {
self.has_changes = true; self.has_changes = true;
} }
@ -269,11 +269,11 @@ impl Component for ContactManager {
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.form.set_dirty(); self.form.set_dirty(value);
if let ViewMode::Discard(ref mut selector) = self.mode { if let ViewMode::Discard(ref mut selector) = self.mode {
selector.set_dirty(); selector.set_dirty(value);
} }
} }
@ -301,7 +301,7 @@ impl Component for ContactManager {
true, true,
context, context,
)); ));
self.set_dirty(); self.set_dirty(true);
false false
} }
} }

View File

@ -656,7 +656,7 @@ impl Component for ContactList {
} }
if self.account_pos + amount < self.accounts.len() { if self.account_pos + amount < self.accounts.len() {
self.account_pos += amount; self.account_pos += amount;
self.set_dirty(); self.set_dirty(true);
self.initialized = false; self.initialized = false;
self.cursor_pos = 0; self.cursor_pos = 0;
self.new_cursor_pos = 0; self.new_cursor_pos = 0;
@ -693,7 +693,7 @@ impl Component for ContactList {
} }
if self.account_pos >= amount { if self.account_pos >= amount {
self.account_pos -= amount; self.account_pos -= amount;
self.set_dirty(); self.set_dirty(true);
self.cursor_pos = 0; self.cursor_pos = 0;
self.new_cursor_pos = 0; self.new_cursor_pos = 0;
self.length = 0; self.length = 0;
@ -710,7 +710,7 @@ impl Component for ContactList {
if shortcut!(k == shortcuts[Self::DESCRIPTION]["toggle_menu_visibility"]) => if shortcut!(k == shortcuts[Self::DESCRIPTION]["toggle_menu_visibility"]) =>
{ {
self.menu_visibility = !self.menu_visibility; self.menu_visibility = !self.menu_visibility;
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => { UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => {
self.cmd_buf.clear(); self.cmd_buf.clear();
@ -747,7 +747,7 @@ impl Component for ContactList {
return true; return true;
}; };
self.movement = Some(PageMovement::Up(amount)); self.movement = Some(PageMovement::Up(amount));
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -769,7 +769,7 @@ impl Component for ContactList {
.push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); .push_back(UIEvent::StatusEvent(StatusEvent::BufClear));
return true; return true;
}; };
self.set_dirty(); self.set_dirty(true);
self.movement = Some(PageMovement::Down(amount)); self.movement = Some(PageMovement::Down(amount));
return true; return true;
} }
@ -789,7 +789,7 @@ impl Component for ContactList {
.push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); .push_back(UIEvent::StatusEvent(StatusEvent::BufClear));
return true; return true;
}; };
self.set_dirty(); self.set_dirty(true);
self.movement = Some(PageMovement::PageUp(mult)); self.movement = Some(PageMovement::PageUp(mult));
return true; return true;
} }
@ -809,17 +809,17 @@ impl Component for ContactList {
.push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); .push_back(UIEvent::StatusEvent(StatusEvent::BufClear));
return true; return true;
}; };
self.set_dirty(); self.set_dirty(true);
self.movement = Some(PageMovement::PageDown(mult)); self.movement = Some(PageMovement::PageDown(mult));
return true; return true;
} }
UIEvent::Input(ref key) if *key == Key::Home => { UIEvent::Input(ref key) if *key == Key::Home => {
self.set_dirty(); self.set_dirty(true);
self.movement = Some(PageMovement::Home); self.movement = Some(PageMovement::Home);
return true; return true;
} }
UIEvent::Input(ref key) if *key == Key::End => { UIEvent::Input(ref key) if *key == Key::End => {
self.set_dirty(); self.set_dirty(true);
self.movement = Some(PageMovement::End); self.movement = Some(PageMovement::End);
return true; return true;
} }
@ -830,14 +830,14 @@ impl Component for ContactList {
UIEvent::ComponentKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => { UIEvent::ComponentKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => {
self.mode = ViewMode::List; self.mode = ViewMode::List;
self.view.take(); self.view.take();
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::ChangeMode(UIMode::Normal) => { UIEvent::ChangeMode(UIMode::Normal) => {
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::Resize => { UIEvent::Resize => {
self.set_dirty(); self.set_dirty(true);
} }
_ => {} _ => {}
} }
@ -849,11 +849,11 @@ impl Component for ContactList {
self.dirty || self.view.as_ref().map(|v| v.is_dirty()).unwrap_or(false) self.dirty || self.view.as_ref().map(|v| v.is_dirty()).unwrap_or(false)
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
if let Some(p) = self.view.as_mut() { if let Some(p) = self.view.as_mut() {
p.set_dirty(); p.set_dirty(value);
}; };
self.dirty = true; self.dirty = value;
} }
fn kill(&mut self, uuid: Uuid, context: &mut Context) { fn kill(&mut self, uuid: Uuid, context: &mut Context) {

View File

@ -124,8 +124,8 @@ impl Component for Indexer {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -131,32 +131,32 @@ impl Component for Index {
UIEvent::Input(Key::Up) => { UIEvent::Input(Key::Up) => {
if self.cursor_pos > 0 { if self.cursor_pos > 0 {
self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1); self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1);
self.set_dirty(); self.set_dirty(true);
} }
return true; return true;
} }
UIEvent::Input(Key::Down) => { UIEvent::Input(Key::Down) => {
if self.length > 0 && self.new_cursor_pos < self.length - 1 { if self.length > 0 && self.new_cursor_pos < self.length - 1 {
self.new_cursor_pos += 1; self.new_cursor_pos += 1;
self.set_dirty(); self.set_dirty(true);
} }
return true; return true;
} }
UIEvent::Input(Key::Char('\n')) if self.state == IndexState::Listing => { UIEvent::Input(Key::Char('\n')) if self.state == IndexState::Listing => {
self.state = IndexState::Unfocused; self.state = IndexState::Unfocused;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(Key::Char('i')) if self.state == IndexState::Unfocused => { UIEvent::Input(Key::Char('i')) if self.state == IndexState::Unfocused => {
self.state = IndexState::Listing; self.state = IndexState::Listing;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::ChangeMode(UIMode::Normal) => { UIEvent::ChangeMode(UIMode::Normal) => {
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::Resize => { UIEvent::Resize => {
self.set_dirty(); self.set_dirty(true);
} }
_ => {} _ => {}
} }
@ -166,8 +166,8 @@ impl Component for Index {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.content.is_dirty() self.dirty || self.content.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -507,7 +507,7 @@ impl Component for Composer {
} }
} else { } else {
self.embed_area = (upper_left!(header_area), bottom_right!(body_area)); self.embed_area = (upper_left!(header_area), bottom_right!(body_area));
self.pager.set_dirty(); self.pager.set_dirty(true);
self.pager.draw(grid, body_area, context); self.pager.draw(grid, body_area, context);
} }
@ -642,7 +642,7 @@ impl Component for Composer {
} }
_ => {} _ => {}
} }
self.set_dirty(); self.set_dirty(true);
} }
return true; return true;
} }
@ -661,7 +661,7 @@ impl Component for Composer {
match *event { match *event {
UIEvent::Resize => { UIEvent::Resize => {
self.set_dirty(); self.set_dirty(true);
} }
/* /*
/* Switch e-mail From: field to the `left` configured account. */ /* Switch e-mail From: field to the `left` configured account. */
@ -812,7 +812,7 @@ impl Component for Composer {
} }
} }
} }
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -830,7 +830,7 @@ impl Component for Composer {
context context
.replies .replies
.push_back(UIEvent::ChangeMode(UIMode::Embed)); .push_back(UIEvent::ChangeMode(UIMode::Embed));
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -997,10 +997,10 @@ impl Component for Composer {
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.pager.set_dirty(); self.pager.set_dirty(value);
self.form.set_dirty(); self.form.set_dirty(value);
} }
fn kill(&mut self, uuid: Uuid, context: &mut Context) { fn kill(&mut self, uuid: Uuid, context: &mut Context) {
@ -1063,7 +1063,7 @@ impl Component for Composer {
context, context,
), ),
); );
self.set_dirty(); self.set_dirty(true);
false false
} }
} }

View File

@ -387,7 +387,7 @@ impl Component for Listing {
self.cursor_pos.1 += amount; self.cursor_pos.1 += amount;
self.component self.component
.set_coordinates((self.cursor_pos.0, self.cursor_pos.1)); .set_coordinates((self.cursor_pos.0, self.cursor_pos.1));
self.set_dirty(); self.set_dirty(true);
} else { } else {
return true; return true;
} }
@ -397,7 +397,7 @@ impl Component for Listing {
self.cursor_pos.1 -= amount; self.cursor_pos.1 -= amount;
self.component self.component
.set_coordinates((self.cursor_pos.0, self.cursor_pos.1)); .set_coordinates((self.cursor_pos.0, self.cursor_pos.1));
self.set_dirty(); self.set_dirty(true);
} else { } else {
return true; return true;
} }
@ -451,7 +451,7 @@ impl Component for Listing {
if self.cursor_pos.0 + amount < self.accounts.len() { if self.cursor_pos.0 + amount < self.accounts.len() {
self.cursor_pos = (self.cursor_pos.0 + amount, 0); self.cursor_pos = (self.cursor_pos.0 + amount, 0);
self.component.set_coordinates((self.cursor_pos.0, 0)); self.component.set_coordinates((self.cursor_pos.0, 0));
self.set_dirty(); self.set_dirty(true);
} else { } else {
return true; return true;
} }
@ -460,7 +460,7 @@ impl Component for Listing {
if self.cursor_pos.0 >= amount { if self.cursor_pos.0 >= amount {
self.cursor_pos = (self.cursor_pos.0 - amount, 0); self.cursor_pos = (self.cursor_pos.0 - amount, 0);
self.component.set_coordinates((self.cursor_pos.0, 0)); self.component.set_coordinates((self.cursor_pos.0, 0));
self.set_dirty(); self.set_dirty(true);
} else { } else {
return true; return true;
} }
@ -520,7 +520,7 @@ impl Component for Listing {
for i in focused { for i in focused {
self.component.perform_action(context, i, a); self.component.perform_action(context, i, a);
} }
self.component.set_dirty(); self.component.set_dirty(true);
return true; return true;
} }
_ => {} _ => {}
@ -545,7 +545,7 @@ impl Component for Listing {
self.dirty = true; self.dirty = true;
} }
UIEvent::Resize => { UIEvent::Resize => {
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
if shortcut!(key == shortcuts[Listing::DESCRIPTION]["scroll_up"]) => if shortcut!(key == shortcuts[Listing::DESCRIPTION]["scroll_up"]) =>
@ -643,7 +643,7 @@ impl Component for Listing {
if shortcut!(k == shortcuts[Listing::DESCRIPTION]["toggle_menu_visibility"]) => if shortcut!(k == shortcuts[Listing::DESCRIPTION]["toggle_menu_visibility"]) =>
{ {
self.menu_visibility = !self.menu_visibility; self.menu_visibility = !self.menu_visibility;
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::Input(ref k) UIEvent::Input(ref k)
if shortcut!(k == shortcuts[Listing::DESCRIPTION]["new_mail"]) => if shortcut!(k == shortcuts[Listing::DESCRIPTION]["new_mail"]) =>
@ -711,9 +711,9 @@ impl Component for Listing {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.component.is_dirty() self.dirty || self.component.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.component.set_dirty(); self.component.set_dirty(value);
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {

View File

@ -499,7 +499,7 @@ impl ListingTrait for CompactListing {
fn set_movement(&mut self, mvm: PageMovement) { fn set_movement(&mut self, mvm: PageMovement) {
self.movement = Some(mvm); self.movement = Some(mvm);
self.set_dirty(); self.set_dirty(true);
} }
} }
@ -1335,14 +1335,14 @@ impl Component for CompactListing {
) => ) =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::StartupCheck(ref f) UIEvent::StartupCheck(ref f)
if *f if *f
== context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
let account = &context.accounts[self.cursor_pos.0]; let account = &context.accounts[self.cursor_pos.0];
@ -1398,7 +1398,7 @@ impl Component for CompactListing {
UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => { UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => {
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Action(ref action) => match action { UIEvent::Action(ref action) => match action {
@ -1433,11 +1433,11 @@ impl Component for CompactListing {
false false
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = value;
if self.unfocused { if self.unfocused {
self.view.set_dirty(); self.view.set_dirty(value);
} }
self.dirty = true;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {

View File

@ -469,7 +469,7 @@ impl ListingTrait for ConversationsListing {
fn set_movement(&mut self, mvm: PageMovement) { fn set_movement(&mut self, mvm: PageMovement) {
self.movement = Some(mvm); self.movement = Some(mvm);
self.set_dirty(); self.set_dirty(true);
} }
} }
@ -1353,14 +1353,14 @@ impl Component for ConversationsListing {
) => ) =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::StartupCheck(ref f) UIEvent::StartupCheck(ref f)
if *f if *f
== context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::ChangeMode(UIMode::Normal) => { UIEvent::ChangeMode(UIMode::Normal) => {
self.dirty = true; self.dirty = true;
@ -1395,7 +1395,7 @@ impl Component for ConversationsListing {
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.force_draw = false; self.force_draw = false;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
_ => {} _ => {}
@ -1411,11 +1411,11 @@ impl Component for ConversationsListing {
false false
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
if self.unfocused { if self.unfocused {
self.view.set_dirty(); self.view.set_dirty(value);
} }
self.dirty = true; self.dirty = value;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {

View File

@ -451,7 +451,7 @@ impl ListingTrait for PlainListing {
fn set_movement(&mut self, mvm: PageMovement) { fn set_movement(&mut self, mvm: PageMovement) {
self.movement = Some(mvm); self.movement = Some(mvm);
self.set_dirty(); self.set_dirty(true);
} }
} }
@ -1112,14 +1112,14 @@ impl Component for PlainListing {
) => ) =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::StartupCheck(ref f) UIEvent::StartupCheck(ref f)
if *f if *f
== context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] => == context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
let account = &context.accounts[self.cursor_pos.0]; let account = &context.accounts[self.cursor_pos.0];
@ -1156,7 +1156,7 @@ impl Component for PlainListing {
} }
UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => { UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => {
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1)); self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
self.set_dirty(); self.set_dirty(true);
self.refresh_mailbox(context); self.refresh_mailbox(context);
return true; return true;
} }
@ -1192,11 +1192,11 @@ impl Component for PlainListing {
false false
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = value;
if self.unfocused { if self.unfocused {
self.view.set_dirty(); self.view.set_dirty(value);
} }
self.dirty = true;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {

View File

@ -216,7 +216,7 @@ impl ListingTrait for ThreadListing {
fn set_movement(&mut self, mvm: PageMovement) { fn set_movement(&mut self, mvm: PageMovement) {
self.movement = Some(mvm); self.movement = Some(mvm);
self.set_dirty(); self.set_dirty(true);
} }
} }
@ -628,7 +628,7 @@ impl Component for ThreadListing {
) => ) =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::StartupCheck(ref f) UIEvent::StartupCheck(ref f)
if *f if *f
@ -636,7 +636,7 @@ impl Component for ThreadListing {
[self.new_cursor_pos.1] => [self.new_cursor_pos.1] =>
{ {
self.refresh_mailbox(context); self.refresh_mailbox(context);
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::ChangeMode(UIMode::Normal) => { UIEvent::ChangeMode(UIMode::Normal) => {
self.dirty = true; self.dirty = true;
@ -674,11 +674,11 @@ impl Component for ThreadListing {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.view.as_ref().map(|p| p.is_dirty()).unwrap_or(false) self.dirty || self.view.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
if let Some(p) = self.view.as_mut() { if let Some(p) = self.view.as_mut() {
p.set_dirty(); p.set_dirty(value);
}; };
self.dirty = true; self.dirty = value;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
self.view self.view

View File

@ -208,10 +208,10 @@ impl Component for StatusPanel {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.status.as_ref().map(|s| s.is_dirty()).unwrap_or(false) self.dirty || self.status.as_ref().map(|s| s.is_dirty()).unwrap_or(false)
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
if let Some(ref mut status) = self.status { if let Some(ref mut status) = self.status {
status.set_dirty(); status.set_dirty(value);
} }
} }
@ -575,8 +575,8 @@ impl Component for AccountStatus {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -269,7 +269,7 @@ impl MailView {
pub fn update(&mut self, new_coordinates: (usize, usize, EnvelopeHash)) { pub fn update(&mut self, new_coordinates: (usize, usize, EnvelopeHash)) {
self.coordinates = new_coordinates; self.coordinates = new_coordinates;
self.mode = ViewMode::Normal; self.mode = ViewMode::Normal;
self.set_dirty(); self.set_dirty(true);
} }
} }
@ -615,7 +615,7 @@ impl Component for MailView {
} }
} }
} }
self.set_dirty(); self.set_dirty(true);
} }
return true; return true;
} }
@ -637,7 +637,7 @@ impl Component for MailView {
return true; return true;
} }
} }
self.pager.set_dirty(); self.pager.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -647,7 +647,7 @@ impl Component for MailView {
{ {
self.force_draw_headers = true; self.force_draw_headers = true;
self.headers_cursor += 1; self.headers_cursor += 1;
self.pager.set_dirty(); self.pager.set_dirty(true);
return true; return true;
} }
_ => { _ => {
@ -718,7 +718,7 @@ impl Component for MailView {
if self.mode.is_contact_selector() => if self.mode.is_contact_selector() =>
{ {
self.mode = ViewMode::Normal; self.mode = ViewMode::Normal;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => { UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => {
@ -742,7 +742,7 @@ impl Component for MailView {
&& shortcut!(key == shortcuts[MailView::DESCRIPTION]["view_raw_source"]) => && shortcut!(key == shortcuts[MailView::DESCRIPTION]["view_raw_source"]) =>
{ {
self.mode = ViewMode::Raw; self.mode = ViewMode::Raw;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -755,7 +755,7 @@ impl Component for MailView {
) => ) =>
{ {
self.mode = ViewMode::Normal; self.mode = ViewMode::Normal;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -797,7 +797,7 @@ impl Component for MailView {
drop(account); drop(account);
if let Some(u) = attachments.get(lidx) { if let Some(u) = attachments.get(lidx) {
if let Ok(()) = crate::mailcap::MailcapEntry::execute(u, context) { if let Ok(()) = crate::mailcap::MailcapEntry::execute(u, context) {
self.set_dirty(); self.set_dirty(true);
} else { } else {
context.replies.push_back(UIEvent::StatusEvent( context.replies.push_back(UIEvent::StatusEvent(
StatusEvent::DisplayMessage(format!( StatusEvent::DisplayMessage(format!(
@ -1270,15 +1270,15 @@ impl Component for MailView {
false false
} }
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
match self.mode { match self.mode {
ViewMode::Normal => { ViewMode::Normal => {
self.pager.set_dirty(); self.pager.set_dirty(value);
} }
ViewMode::Subview => { ViewMode::Subview => {
if let Some(s) = self.subview.as_mut() { if let Some(s) = self.subview.as_mut() {
s.set_dirty(); s.set_dirty(value);
} }
} }
_ => {} _ => {}

View File

@ -541,8 +541,8 @@ impl Component for EnvelopeView {
|| self.pager.as_ref().map(|p| p.is_dirty()).unwrap_or(false) || self.pager.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
|| self.subview.as_ref().map(|p| p.is_dirty()).unwrap_or(false) || self.subview.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -160,8 +160,8 @@ impl Component for HtmlView {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.pager.is_dirty() self.pager.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.pager.set_dirty(); self.pager.set_dirty(value);
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -155,7 +155,7 @@ impl ThreadView {
self.expanded_pos = new_entry_idx; self.expanded_pos = new_entry_idx;
} }
} }
self.set_dirty(); self.set_dirty(true);
} }
fn initiate(&mut self, expanded_hash: Option<ThreadHash>, context: &Context) { fn initiate(&mut self, expanded_hash: Option<ThreadHash>, context: &Context) {
/* stack to push thread messages in order in order to pop and print them later */ /* stack to push thread messages in order in order to pop and print them later */
@ -1014,7 +1014,7 @@ impl Component for ThreadView {
self.new_expanded_pos = self.current_pos(); self.new_expanded_pos = self.current_pos();
self.show_mailview = true; self.show_mailview = true;
//self.initiated = false; //self.initiated = false;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -1022,7 +1022,7 @@ impl Component for ThreadView {
{ {
self.show_mailview = !self.show_mailview; self.show_mailview = !self.show_mailview;
self.initiated = false; self.initiated = false;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -1030,7 +1030,7 @@ impl Component for ThreadView {
{ {
self.show_thread = !self.show_thread; self.show_thread = !self.show_thread;
self.initiated = false; self.initiated = false;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)
@ -1076,7 +1076,7 @@ impl Component for ThreadView {
return true; return true;
} }
UIEvent::Resize => { UIEvent::Resize => {
self.set_dirty(); self.set_dirty(true);
} }
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => { UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
let account = &context.accounts[self.coordinates.0]; let account = &context.accounts[self.coordinates.0];
@ -1104,9 +1104,9 @@ impl Component for ThreadView {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || (self.show_mailview && self.mailview.is_dirty()) self.dirty || (self.show_mailview && self.mailview.is_dirty())
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.mailview.set_dirty(); self.mailview.set_dirty(value);
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let mut map = self.mailview.get_shortcuts(context); let mut map = self.mailview.get_shortcuts(context);

View File

@ -72,7 +72,8 @@ impl Component for XDGNotifications {
} }
false false
} }
fn set_dirty(&mut self) {} fn set_dirty(&mut self, _value: bool) {}
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
false false
} }
@ -153,10 +154,7 @@ impl Component for NotificationFilter {
.spawn() .spawn()
{ {
log( log(
format!( format!("Could not run notification script: {}.", err.to_string()),
"Could not run notification script: {}.",
err.to_string()
),
ERROR, ERROR,
); );
debug!("{:?}", err); debug!("{:?}", err);
@ -187,6 +185,6 @@ impl Component for NotificationFilter {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
false false
} }
fn set_dirty(&mut self) {} fn set_dirty(&mut self, _value: bool) {}
fn set_id(&mut self, _id: ComponentId) {} fn set_id(&mut self, _id: ComponentId) {}
} }

View File

@ -105,9 +105,9 @@ impl Component for HSplit {
self.top.is_dirty() || self.bottom.is_dirty() self.top.is_dirty() || self.bottom.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.top.set_dirty(); self.top.set_dirty(value);
self.bottom.set_dirty(); self.bottom.set_dirty(value);
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
@ -171,7 +171,7 @@ impl Component for VSplit {
let total_cols = get_x(bottom_right) - get_x(upper_left); let total_cols = get_x(bottom_right) - get_x(upper_left);
let visibility = (self.left.is_visible(), self.right.is_visible()); let visibility = (self.left.is_visible(), self.right.is_visible());
if visibility != self.prev_visibility { if visibility != self.prev_visibility {
self.set_dirty(); self.set_dirty(true);
self.prev_visibility = visibility; self.prev_visibility = visibility;
} }
let right_component_width = match visibility { let right_component_width = match visibility {
@ -245,9 +245,9 @@ impl Component for VSplit {
self.left.is_dirty() || self.right.is_dirty() self.left.is_dirty() || self.right.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.left.set_dirty(); self.left.set_dirty(value);
self.right.set_dirty(); self.right.set_dirty(value);
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
@ -676,8 +676,8 @@ impl Component for Pager {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let config_map: FnvHashMap<&'static str, Key> = let config_map: FnvHashMap<&'static str, Key> =
@ -901,19 +901,19 @@ impl Component for StatusBar {
self.auto_complete.set_suggestions(suggestions); self.auto_complete.set_suggestions(suggestions);
/* redraw self.container because we have got ridden of an autocomplete /* redraw self.container because we have got ridden of an autocomplete
* box, and it must be drawn over */ * box, and it must be drawn over */
self.container.set_dirty(); self.container.set_dirty(true);
return; return;
} }
/* redraw self.container because we have less suggestions than before */ /* redraw self.container because we have less suggestions than before */
if suggestions.len() < self.auto_complete.suggestions().len() { if suggestions.len() < self.auto_complete.suggestions().len() {
self.container.set_dirty(); self.container.set_dirty(true);
} }
if self.auto_complete.set_suggestions(suggestions) { if self.auto_complete.set_suggestions(suggestions) {
let len = self.auto_complete.suggestions().len() - 1; let len = self.auto_complete.suggestions().len() - 1;
self.auto_complete.set_cursor(len); self.auto_complete.set_cursor(len);
self.container.set_dirty(); self.container.set_dirty(true);
} }
let hist_height = std::cmp::min(15, self.auto_complete.suggestions().len()); let hist_height = std::cmp::min(15, self.auto_complete.suggestions().len());
let hist_area = if height < self.auto_complete.suggestions().len() { let hist_area = if height < self.auto_complete.suggestions().len() {
@ -1064,8 +1064,8 @@ impl Component for StatusBar {
UIEvent::ChangeMode(m) => { UIEvent::ChangeMode(m) => {
let offset = self.status.find('|').unwrap_or_else(|| self.status.len()); let offset = self.status.find('|').unwrap_or_else(|| self.status.len());
self.status.replace_range(..offset, &format!("{} ", m)); self.status.replace_range(..offset, &format!("{} ", m));
self.set_dirty(); self.set_dirty(true);
self.container.set_dirty(); self.container.set_dirty(true);
self.mode = *m; self.mode = *m;
match m { match m {
UIMode::Normal => { UIMode::Normal => {
@ -1098,8 +1098,8 @@ impl Component for StatusBar {
let mut utext = UText::new(suggestion); let mut utext = UText::new(suggestion);
let len = utext.as_str().len(); let len = utext.as_str().len();
utext.set_cursor(len); utext.set_cursor(len);
self.container.set_dirty(); self.container.set_dirty(true);
self.set_dirty(); self.set_dirty(true);
self.ex_buffer = Field::Text(utext, None); self.ex_buffer = Field::Text(utext, None);
} }
} }
@ -1145,8 +1145,8 @@ impl Component for StatusBar {
); );
let len = utext.as_str().len(); let len = utext.as_str().len();
utext.set_cursor(len); utext.set_cursor(len);
self.container.set_dirty(); self.container.set_dirty(true);
self.set_dirty(); self.set_dirty(true);
self.ex_buffer = Field::Text(utext, None); self.ex_buffer = Field::Text(utext, None);
self.ex_buffer_cmd_history_pos = pos; self.ex_buffer_cmd_history_pos = pos;
self.dirty = true; self.dirty = true;
@ -1167,8 +1167,8 @@ impl Component for StatusBar {
); );
let len = utext.as_str().len(); let len = utext.as_str().len();
utext.set_cursor(len); utext.set_cursor(len);
self.container.set_dirty(); self.container.set_dirty(true);
self.set_dirty(); self.set_dirty(true);
self.ex_buffer = Field::Text(utext, None); self.ex_buffer = Field::Text(utext, None);
self.ex_buffer_cmd_history_pos = pos; self.ex_buffer_cmd_history_pos = pos;
self.dirty = true; self.dirty = true;
@ -1202,8 +1202,8 @@ impl Component for StatusBar {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.container.is_dirty() self.dirty || self.container.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
@ -1274,7 +1274,8 @@ impl Component for Progress {
fn process_event(&mut self, _event: &mut UIEvent, _context: &mut Context) -> bool { fn process_event(&mut self, _event: &mut UIEvent, _context: &mut Context) -> bool {
false false
} }
fn set_dirty(&mut self) {} fn set_dirty(&mut self, _value: bool) {}
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
false false
} }
@ -1585,7 +1586,7 @@ impl Component for Tabbed {
.get_status(context) .get_status(context)
.unwrap_or_default(), .unwrap_or_default(),
))); )));
self.set_dirty(); self.set_dirty(true);
} }
return true; return true;
} }
@ -1598,13 +1599,13 @@ impl Component for Tabbed {
.get_status(context) .get_status(context)
.unwrap_or_default(), .unwrap_or_default(),
))); )));
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Input(Key::Char('?')) => { UIEvent::Input(Key::Char('?')) => {
if self.show_shortcuts { if self.show_shortcuts {
/* children below the shortcut overlay must be redrawn */ /* children below the shortcut overlay must be redrawn */
self.set_dirty(); self.set_dirty(true);
} }
self.show_shortcuts = !self.show_shortcuts; self.show_shortcuts = !self.show_shortcuts;
self.dirty = true; self.dirty = true;
@ -1617,13 +1618,13 @@ impl Component for Tabbed {
} }
self.add_component(Box::new(composer)); self.add_component(Box::new(composer));
self.cursor_pos = self.children.len() - 1; self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty(); self.children[self.cursor_pos].set_dirty(true);
return true; return true;
} }
UIEvent::Action(Tab(Reply(coordinates, msg))) => { UIEvent::Action(Tab(Reply(coordinates, msg))) => {
self.add_component(Box::new(Composer::with_context(coordinates, msg, context))); self.add_component(Box::new(Composer::with_context(coordinates, msg, context)));
self.cursor_pos = self.children.len() - 1; self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty(); self.children[self.cursor_pos].set_dirty(true);
return true; return true;
} }
UIEvent::Action(Tab(Edit(account_pos, msg))) => { UIEvent::Action(Tab(Edit(account_pos, msg))) => {
@ -1651,13 +1652,13 @@ impl Component for Tabbed {
}; };
self.add_component(Box::new(composer)); self.add_component(Box::new(composer));
self.cursor_pos = self.children.len() - 1; self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty(); self.children[self.cursor_pos].set_dirty(true);
return true; return true;
} }
UIEvent::Action(Tab(New(ref mut e))) if e.is_some() => { UIEvent::Action(Tab(New(ref mut e))) if e.is_some() => {
self.add_component(e.take().unwrap()); self.add_component(e.take().unwrap());
self.cursor_pos = self.children.len() - 1; self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty(); self.children[self.cursor_pos].set_dirty(true);
return true; return true;
} }
UIEvent::Action(Tab(Close)) => { UIEvent::Action(Tab(Close)) => {
@ -1666,7 +1667,7 @@ impl Component for Tabbed {
} }
let id = self.children[self.cursor_pos].id(); let id = self.children[self.cursor_pos].id();
self.children[self.cursor_pos].kill(id, context); self.children[self.cursor_pos].kill(id, context);
self.set_dirty(); self.set_dirty(true);
return true; return true;
} }
UIEvent::Action(Tab(Kill(id))) => { UIEvent::Action(Tab(Kill(id))) => {
@ -1676,7 +1677,7 @@ impl Component for Tabbed {
if let Some(c_idx) = self.children.iter().position(|x| x.id() == id) { if let Some(c_idx) = self.children.iter().position(|x| x.id() == id) {
self.children.remove(c_idx); self.children.remove(c_idx);
self.cursor_pos = 0; self.cursor_pos = 0;
self.set_dirty(); self.set_dirty(true);
return true; return true;
} else { } else {
debug!( debug!(
@ -1717,9 +1718,9 @@ impl Component for Tabbed {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.children[self.cursor_pos].is_dirty() self.dirty || self.children[self.cursor_pos].is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.children[self.cursor_pos].set_dirty(); self.children[self.cursor_pos].set_dirty(value);
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
@ -1739,7 +1740,7 @@ impl Component for Tabbed {
for (i, c) in self.children.iter_mut().enumerate() { for (i, c) in self.children.iter_mut().enumerate() {
if !c.can_quit_cleanly(context) { if !c.can_quit_cleanly(context) {
self.cursor_pos = i; self.cursor_pos = i;
self.set_dirty(); self.set_dirty(true);
return false; return false;
} }
} }
@ -2038,8 +2039,8 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Component for Selector<T> {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
@ -2318,8 +2319,8 @@ impl Component for RawBuffer {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {

View File

@ -246,13 +246,13 @@ impl Component for Field {
return false; return false;
} }
} }
self.set_dirty(); self.set_dirty(true);
true true
} }
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
false false
} }
fn set_dirty(&mut self) {} fn set_dirty(&mut self, _value: bool) {}
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
ComponentId::nil() ComponentId::nil()
@ -490,7 +490,7 @@ impl Component for FormWidget {
self.focus = FormFocus::Buttons; self.focus = FormFocus::Buttons;
self.buttons.set_focus(true); self.buttons.set_focus(true);
if self.hide_buttons { if self.hide_buttons {
self.set_dirty(); self.set_dirty(true);
return false; return false;
} }
} }
@ -532,15 +532,15 @@ impl Component for FormWidget {
return false; return false;
} }
} }
self.set_dirty(); self.set_dirty(true);
true true
} }
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty || self.buttons.is_dirty() self.dirty || self.buttons.is_dirty()
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
self.buttons.set_dirty(); self.buttons.set_dirty(value);
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
@ -658,14 +658,14 @@ where
return false; return false;
} }
} }
self.set_dirty(); self.set_dirty(true);
true true
} }
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
@ -766,8 +766,8 @@ impl Component for AutoComplete {
fn is_dirty(&self) -> bool { fn is_dirty(&self) -> bool {
self.dirty self.dirty
} }
fn set_dirty(&mut self) { fn set_dirty(&mut self, value: bool) {
self.dirty = true; self.dirty = value;
} }
fn id(&self) -> ComponentId { fn id(&self) -> ComponentId {
@ -845,12 +845,12 @@ impl AutoComplete {
pub fn inc_cursor(&mut self) { pub fn inc_cursor(&mut self) {
if self.cursor < self.entries.len().saturating_sub(1) { if self.cursor < self.entries.len().saturating_sub(1) {
self.cursor += 1; self.cursor += 1;
self.set_dirty(); self.set_dirty(true);
} }
} }
pub fn dec_cursor(&mut self) { pub fn dec_cursor(&mut self) {
self.cursor = self.cursor.saturating_sub(1); self.cursor = self.cursor.saturating_sub(1);
self.set_dirty(); self.set_dirty(true);
} }
pub fn cursor(&self) -> usize { pub fn cursor(&self) -> usize {