|
|
@ -21,299 +21,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
|
|
|
pub struct StatusPanel {
|
|
|
|
|
|
|
|
cursor: (usize, usize),
|
|
|
|
|
|
|
|
account_cursor: usize,
|
|
|
|
|
|
|
|
status: Option<AccountStatus>,
|
|
|
|
|
|
|
|
content: CellBuffer,
|
|
|
|
|
|
|
|
dirty: bool,
|
|
|
|
|
|
|
|
theme_default: ThemeAttribute,
|
|
|
|
|
|
|
|
id: ComponentId,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl core::fmt::Display for StatusPanel {
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
|
|
|
|
|
|
|
write!(f, "status")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Component for StatusPanel {
|
|
|
|
|
|
|
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
|
|
|
|
|
|
|
if let Some(ref mut status) = self.status {
|
|
|
|
|
|
|
|
status.draw(grid, area, context);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
self.draw_accounts(context);
|
|
|
|
|
|
|
|
let (width, height) = self.content.size();
|
|
|
|
|
|
|
|
let (cols, rows) = (width!(area), height!(area));
|
|
|
|
|
|
|
|
self.cursor = (
|
|
|
|
|
|
|
|
std::cmp::min(width.saturating_sub(cols), self.cursor.0),
|
|
|
|
|
|
|
|
std::cmp::min(height.saturating_sub(rows), self.cursor.1),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
clear_area(grid, area, self.theme_default);
|
|
|
|
|
|
|
|
copy_area(
|
|
|
|
|
|
|
|
grid,
|
|
|
|
|
|
|
|
&self.content,
|
|
|
|
|
|
|
|
area,
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
std::cmp::min((width - 1).saturating_sub(cols), self.cursor.0),
|
|
|
|
|
|
|
|
std::cmp::min((height - 1).saturating_sub(rows), self.cursor.1),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
std::cmp::min(self.cursor.0 + cols, width - 1),
|
|
|
|
|
|
|
|
std::cmp::min(self.cursor.1 + rows, height - 1),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
context.dirty_areas.push_back(area);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
|
|
|
|
|
|
|
if let Some(ref mut status) = self.status {
|
|
|
|
|
|
|
|
if status.process_event(event, context) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
match *event {
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Char('k')) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.account_cursor = self.account_cursor.saturating_sub(1);
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Char('j')) if self.status.is_none() => {
|
|
|
|
|
|
|
|
if self.account_cursor + 1 < context.accounts.len() {
|
|
|
|
|
|
|
|
self.account_cursor += 1;
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Char('\n')) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.status = Some(AccountStatus::new(self.account_cursor, self.theme_default));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Esc) if self.status.is_some() => {
|
|
|
|
|
|
|
|
self.status = None;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Left) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.cursor.0 = self.cursor.0.saturating_sub(1);
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Right) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.cursor.0 = self.cursor.0 + 1;
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Up) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.cursor.1 = self.cursor.1.saturating_sub(1);
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::Input(Key::Down) if self.status.is_none() => {
|
|
|
|
|
|
|
|
self.cursor.1 = self.cursor.1 + 1;
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::MailboxUpdate(_)
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::NewJob(_))
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::JobFinished(_))
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::JobCanceled(_)) => {
|
|
|
|
|
|
|
|
self.set_dirty(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_dirty(&self) -> bool {
|
|
|
|
|
|
|
|
self.dirty || self.status.as_ref().map(|s| s.is_dirty()).unwrap_or(false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_dirty(&mut self, value: bool) {
|
|
|
|
|
|
|
|
self.dirty = value;
|
|
|
|
|
|
|
|
if let Some(ref mut status) = self.status {
|
|
|
|
|
|
|
|
status.set_dirty(value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn id(&self) -> ComponentId {
|
|
|
|
|
|
|
|
self.id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_id(&mut self, id: ComponentId) {
|
|
|
|
|
|
|
|
self.id = id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl StatusPanel {
|
|
|
|
|
|
|
|
pub fn new(theme_default: ThemeAttribute) -> StatusPanel {
|
|
|
|
|
|
|
|
let default_cell = {
|
|
|
|
|
|
|
|
let mut ret = Cell::with_char(' ');
|
|
|
|
|
|
|
|
ret.set_fg(theme_default.fg)
|
|
|
|
|
|
|
|
.set_bg(theme_default.bg)
|
|
|
|
|
|
|
|
.set_attrs(theme_default.attrs);
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut content = CellBuffer::new(120, 40, default_cell);
|
|
|
|
|
|
|
|
content.set_growable(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StatusPanel {
|
|
|
|
|
|
|
|
cursor: (0, 0),
|
|
|
|
|
|
|
|
account_cursor: 0,
|
|
|
|
|
|
|
|
content,
|
|
|
|
|
|
|
|
status: None,
|
|
|
|
|
|
|
|
dirty: true,
|
|
|
|
|
|
|
|
theme_default,
|
|
|
|
|
|
|
|
id: ComponentId::new_v4(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fn draw_accounts(&mut self, context: &Context) {
|
|
|
|
|
|
|
|
let default_cell = {
|
|
|
|
|
|
|
|
let mut ret = Cell::with_char(' ');
|
|
|
|
|
|
|
|
ret.set_fg(self.theme_default.fg)
|
|
|
|
|
|
|
|
.set_bg(self.theme_default.bg)
|
|
|
|
|
|
|
|
.set_attrs(self.theme_default.attrs);
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
self.content
|
|
|
|
|
|
|
|
.resize(120, 40 + context.accounts.len() * 45, default_cell);
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
"Accounts",
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((2, 2), (120 - 1, 2)),
|
|
|
|
|
|
|
|
Some(2),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i, (_h, a)) in context.accounts.iter().enumerate() {
|
|
|
|
|
|
|
|
for x in 2..(120 - 1) {
|
|
|
|
|
|
|
|
set_and_join_box(&mut self.content, (x, 4 + i * 10), BoxBoundary::Horizontal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//create_box(&mut self.content, ((2, 5 + i * 10), (120 - 1, 15 + i * 10)));
|
|
|
|
|
|
|
|
let (x, y) = write_string_to_grid(
|
|
|
|
|
|
|
|
a.name(),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
Attr::BOLD,
|
|
|
|
|
|
|
|
((3, 4 + i * 10), (120 - 2, 4 + i * 10)),
|
|
|
|
|
|
|
|
Some(3),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
" ▒██▒ ",
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
Color::Byte(32),
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((x, y), (120 - 2, y)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&a.settings.account().identity,
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((4, y + 2), (120 - 2, y + 2)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if i == self.account_cursor {
|
|
|
|
|
|
|
|
for h in 1..8 {
|
|
|
|
|
|
|
|
self.content[(2, h + y + 1)].set_ch('*');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for h in 1..8 {
|
|
|
|
|
|
|
|
self.content[(2, h + y + 1)].set_ch(' ');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let count = a
|
|
|
|
|
|
|
|
.mailbox_entries
|
|
|
|
|
|
|
|
.values()
|
|
|
|
|
|
|
|
.map(|entry| &entry.ref_mailbox)
|
|
|
|
|
|
|
|
.fold((0, 0), |acc, f| {
|
|
|
|
|
|
|
|
let count = f.count().unwrap_or((0, 0));
|
|
|
|
|
|
|
|
(acc.0 + count.0, acc.1 + count.1)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
let (mut column_width, _) = write_string_to_grid(
|
|
|
|
|
|
|
|
&format!("Messages total {}, unseen {}", count.1, count.0),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((5, y + 3), (120 - 2, y + 3)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
column_width = std::cmp::max(
|
|
|
|
|
|
|
|
column_width,
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&format!("Contacts total {}", a.address_book.len()),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((5, y + 4), (120 - 2, y + 4)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
column_width = std::cmp::max(
|
|
|
|
|
|
|
|
column_width,
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&format!("Backend {}", a.settings.account().format()),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((5, y + 5), (120 - 2, y + 5)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if let Err(err) = a.is_online.as_ref() {
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&err.to_string(),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((5, y + 6), (5 + column_width, y + 6)),
|
|
|
|
|
|
|
|
Some(5),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* next column */
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
"Special Mailboxes:",
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
Attr::BOLD,
|
|
|
|
|
|
|
|
((5 + column_width, y + 2), (120 - 2, y + 2)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
for (i, f) in a
|
|
|
|
|
|
|
|
.mailbox_entries
|
|
|
|
|
|
|
|
.values()
|
|
|
|
|
|
|
|
.map(|entry| &entry.ref_mailbox)
|
|
|
|
|
|
|
|
.filter(|f| f.special_usage() != SpecialUsageMailbox::Normal)
|
|
|
|
|
|
|
|
.enumerate()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&format!("{}: {}", f.special_usage(), f.path()),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
self.theme_default.attrs,
|
|
|
|
|
|
|
|
((5 + column_width, y + 3 + i), (120 - 2, y + 2)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct AccountStatus {
|
|
|
|
pub struct AccountStatus {
|
|
|
|
cursor: (usize, usize),
|
|
|
|
cursor: (usize, usize),
|
|
|
@ -359,17 +66,26 @@ impl Component for AccountStatus {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.dirty = false;
|
|
|
|
self.dirty = false;
|
|
|
|
let (mut width, height) = self.content.size();
|
|
|
|
let (mut width, _) = self.content.size();
|
|
|
|
let a = &context.accounts[self.account_pos];
|
|
|
|
let a = &context.accounts[self.account_pos];
|
|
|
|
let (_x, _y) = write_string_to_grid(
|
|
|
|
let (_x, _y) = write_string_to_grid(
|
|
|
|
"(Press Esc to return)",
|
|
|
|
"Account ",
|
|
|
|
&mut self.content,
|
|
|
|
&mut self.content,
|
|
|
|
self.theme_default.fg,
|
|
|
|
self.theme_default.fg,
|
|
|
|
self.theme_default.bg,
|
|
|
|
self.theme_default.bg,
|
|
|
|
Attr::BOLD,
|
|
|
|
self.theme_default.attrs | Attr::UNDERLINE,
|
|
|
|
((1, 0), (width - 1, 0)),
|
|
|
|
((1, 0), (width - 1, 0)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
let (_x, _y) = write_string_to_grid(
|
|
|
|
|
|
|
|
a.name(),
|
|
|
|
|
|
|
|
&mut self.content,
|
|
|
|
|
|
|
|
self.theme_default.fg,
|
|
|
|
|
|
|
|
self.theme_default.bg,
|
|
|
|
|
|
|
|
Attr::BOLD | Attr::UNDERLINE,
|
|
|
|
|
|
|
|
((_x, _y), (width - 1, _y)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
width = self.content.size().0;
|
|
|
|
width = self.content.size().0;
|
|
|
|
let mut line = 2;
|
|
|
|
let mut line = 2;
|
|
|
|
|
|
|
|
|
|
|
@ -447,7 +163,6 @@ impl Component for AccountStatus {
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
width = self.content.size().0;
|
|
|
|
|
|
|
|
for f in a
|
|
|
|
for f in a
|
|
|
|
.mailbox_entries
|
|
|
|
.mailbox_entries
|
|
|
|
.values()
|
|
|
|
.values()
|
|
|
@ -477,7 +192,6 @@ impl Component for AccountStatus {
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
width = self.content.size().0;
|
|
|
|
|
|
|
|
line += 2;
|
|
|
|
line += 2;
|
|
|
|
for mailbox_node in a.list_mailboxes() {
|
|
|
|
for mailbox_node in a.list_mailboxes() {
|
|
|
|
width = self.content.size().0;
|
|
|
|
width = self.content.size().0;
|
|
|
@ -508,7 +222,6 @@ impl Component for AccountStatus {
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
((1, line), (width - 1, line)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
width = self.content.size().0;
|
|
|
|
|
|
|
|
let max_name_width = std::cmp::max(
|
|
|
|
let max_name_width = std::cmp::max(
|
|
|
|
"Server Extensions:".len(),
|
|
|
|
"Server Extensions:".len(),
|
|
|
|
extensions
|
|
|
|
extensions
|
|
|
@ -527,10 +240,9 @@ impl Component for AccountStatus {
|
|
|
|
((max_name_width + 6, line), (width - 1, line)),
|
|
|
|
((max_name_width + 6, line), (width - 1, line)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
width = self.content.size().0;
|
|
|
|
|
|
|
|
line += 1;
|
|
|
|
line += 1;
|
|
|
|
for (name, status) in extensions.into_iter() {
|
|
|
|
for (name, status) in extensions.into_iter() {
|
|
|
|
let (width, height) = self.content.size();
|
|
|
|
width = self.content.size().0;
|
|
|
|
write_string_to_grid(
|
|
|
|
write_string_to_grid(
|
|
|
|
name.trim_at_boundary(30),
|
|
|
|
name.trim_at_boundary(30),
|
|
|
|
&mut self.content,
|
|
|
|
&mut self.content,
|
|
|
@ -541,7 +253,7 @@ impl Component for AccountStatus {
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
let (width, height) = self.content.size();
|
|
|
|
width = self.content.size().0;
|
|
|
|
let (x, y) = match status {
|
|
|
|
let (x, y) = match status {
|
|
|
|
MailBackendExtensionStatus::Unsupported { comment: _ } => write_string_to_grid(
|
|
|
|
MailBackendExtensionStatus::Unsupported { comment: _ } => write_string_to_grid(
|
|
|
|
"not supported",
|
|
|
|
"not supported",
|
|
|
@ -684,13 +396,14 @@ impl Component for AccountStatus {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
context.dirty_areas.push_back(area);
|
|
|
|
context.dirty_areas.push_back(area);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
|
|
|
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
|
|
|
match *event {
|
|
|
|
match *event {
|
|
|
|
UIEvent::Resize => {
|
|
|
|
UIEvent::Resize => {
|
|
|
|
self.dirty = true;
|
|
|
|
self.dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UIEvent::Input(Key::Left) => {
|
|
|
|
UIEvent::Input(Key::Left) if self.cursor.0 != 0 => {
|
|
|
|
self.cursor.0 = self.cursor.0.saturating_sub(1);
|
|
|
|
self.cursor.0 -= 1;
|
|
|
|
self.dirty = true;
|
|
|
|
self.dirty = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -709,13 +422,21 @@ impl Component for AccountStatus {
|
|
|
|
self.dirty = true;
|
|
|
|
self.dirty = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEvent::MailboxUpdate(_)
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::NewJob(_))
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::JobFinished(_))
|
|
|
|
|
|
|
|
| UIEvent::StatusEvent(StatusEvent::JobCanceled(_)) => {
|
|
|
|
|
|
|
|
self.set_dirty(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn is_dirty(&self) -> bool {
|
|
|
|
fn is_dirty(&self) -> bool {
|
|
|
|
self.dirty
|
|
|
|
self.dirty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn set_dirty(&mut self, value: bool) {
|
|
|
|
fn set_dirty(&mut self, value: bool) {
|
|
|
|
self.dirty = value;
|
|
|
|
self.dirty = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -723,6 +444,7 @@ impl Component for AccountStatus {
|
|
|
|
fn id(&self) -> ComponentId {
|
|
|
|
fn id(&self) -> ComponentId {
|
|
|
|
self.id
|
|
|
|
self.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn set_id(&mut self, id: ComponentId) {
|
|
|
|
fn set_id(&mut self, id: ComponentId) {
|
|
|
|
self.id = id;
|
|
|
|
self.id = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|