parent
d0e6bc24f4
commit
d962da665f
|
@ -172,7 +172,12 @@ impl Component for MailView {
|
|||
let finder = LinkFinder::new();
|
||||
let mut t = envelope.body().text().to_string();
|
||||
let links: Vec<Link> = finder.links(&t).collect();
|
||||
links[lidx].as_str().to_string()
|
||||
if let Some(u) = links.get(lidx) {
|
||||
u.as_str().to_string()
|
||||
} else {
|
||||
context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Link `{}` not found.", lidx)) });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -269,6 +269,7 @@ impl Component for Pager {
|
|||
pub struct StatusBar {
|
||||
container: Entity,
|
||||
status: String,
|
||||
notifications: VecDeque<String>,
|
||||
ex_buffer: String,
|
||||
mode: UIMode,
|
||||
height: usize,
|
||||
|
@ -280,6 +281,7 @@ impl StatusBar {
|
|||
StatusBar {
|
||||
container: container,
|
||||
status: String::with_capacity(256),
|
||||
notifications: VecDeque::new(),
|
||||
ex_buffer: String::with_capacity(256),
|
||||
dirty: true,
|
||||
mode: UIMode::Normal,
|
||||
|
@ -288,11 +290,20 @@ impl StatusBar {
|
|||
}
|
||||
fn draw_status_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
clear_area(grid, area);
|
||||
write_string_to_grid(&self.status,
|
||||
grid,
|
||||
Color::Byte(123),
|
||||
Color::Byte(26),
|
||||
area, false);
|
||||
if let Some(n) = self.notifications.pop_front() {
|
||||
self.dirty = true;
|
||||
write_string_to_grid(&n,
|
||||
grid,
|
||||
Color::Byte(219),
|
||||
Color::Byte(88),
|
||||
area, false);
|
||||
} else {
|
||||
write_string_to_grid(&self.status,
|
||||
grid,
|
||||
Color::Byte(123),
|
||||
Color::Byte(26),
|
||||
area, false);
|
||||
}
|
||||
change_colors(grid, area, Color::Byte(123), Color::Byte(26));
|
||||
context.dirty_areas.push_back(area);
|
||||
}
|
||||
|
@ -377,6 +388,10 @@ impl Component for StatusBar {
|
|||
UIEventType::Resize => {
|
||||
self.dirty = true;
|
||||
},
|
||||
UIEventType::StatusNotification(s) => {
|
||||
self.notifications.push_back(s.clone());
|
||||
self.dirty = true;
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ pub enum UIEventType {
|
|||
Notification(String),
|
||||
EditDraft(std::path::PathBuf),
|
||||
Action(Action),
|
||||
StatusNotification(String),
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue