Add indexes to account menu

embed
Manos Pitsidianakis 2018-07-14 22:40:44 +03:00
parent 5fcacc80b8
commit dc348dde6d
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 27 additions and 15 deletions

View File

@ -144,11 +144,11 @@ fn main() {
let mut idxa = 0;
let mut idxm = 0;
let account_length = state.context.accounts.len();
'main: loop {
state.refresh_mailbox(idxa,idxm);
let folder_length = state.context.accounts[idxa].len();
state.render();
state.redraw();
'inner: loop {
match receiver.recv().unwrap() {
@ -183,7 +183,19 @@ fn main() {
idxm -= 1;
break 'inner;
},
Key::Char(k @ 'g') => {
Key::Char('l') => if idxa + 1 < account_length {
idxa += 1;
idxm = 0;
break 'inner;
},
Key::Char('h') => if idxa > 0 {
idxa -= 1;
idxm = 0;
break 'inner;
},
Key::Char('r') => {
state.update_size();
state.render();
},
Key::Char(v) if v > '/' && v < ':' => {
},

View File

@ -285,7 +285,11 @@ impl Component for MailListing {
grid[(x, mid+5)].set_fg(Color::Default);
}
}
context.dirty_areas.push_back((set_y(upper_left, mid), set_y(bottom_right, mid+5)));
clear_area(grid,
(set_y(upper_left, mid+headers_rows), set_y(bottom_right, mid+headers_rows)));
context.dirty_areas.push_back((set_y(upper_left, mid), set_y(bottom_right, mid+headers_rows)));
/* Draw body */
self.draw_mail_view(grid,
@ -398,37 +402,33 @@ impl AccountMenu {
}
}
let mut ind = 0;
let mut depth = String::from(" ");
let mut inc = 0;
let mut depth = String::from("");
let mut s = String::from(format!("\n\n {}\n", a.name));
fn pop(depth: &mut String) {
depth.pop();
depth.pop();
depth.pop();
depth.pop();
}
fn push(depth: &mut String, c: char) {
depth.push(' ');
depth.push(c);
depth.push(' ');
depth.push(' ');
}
fn print(root: usize, parents: &Vec<Option<usize>>, depth: &mut String, entries: &Vec<(usize, Folder)>, s: &mut String) -> () {
fn print(root: usize, parents: &Vec<Option<usize>>, depth: &mut String, entries: &Vec<(usize, Folder)>, s: &mut String, inc: &mut usize) -> () {
let len = s.len();
s.insert_str(len, &format!("{}: {}\n ", entries[root].0, &entries[root].1.get_name()));
s.insert_str(len, &format!("{} {}\n ", *inc, &entries[root].1.get_name()));
*inc += 1;
let children_no = entries[root].1.get_children().len();
for (idx, child) in entries[root].1.get_children().iter().enumerate() {
let len = s.len();
s.insert_str(len, &format!("{}├─", depth));
push(depth, if idx == children_no - 1 {'│'} else { ' ' });
print(*child, parents, depth, entries, s);
print(*child, parents, depth, entries, s, inc);
pop(depth);
}
}
for r in roots {
print(r, &parents, &mut depth, &a.entries, &mut s);
print(r, &parents, &mut depth, &a.entries, &mut s, &mut inc);
}

View File

@ -168,7 +168,7 @@ impl<W: Write> State<W> {
s.stdout.flush().unwrap();
s
}
fn update_size(&mut self) {
pub fn update_size(&mut self) {
/* update dimensions. TODO: Only do that in size change events. ie SIGWINCH */
let termsize = termion::terminal_size().ok();
let termcols = termsize.map(|(w,_)| w);