Add indexes to account menu
parent
5fcacc80b8
commit
dc348dde6d
16
src/bin.rs
16
src/bin.rs
|
@ -144,11 +144,11 @@ fn main() {
|
||||||
|
|
||||||
let mut idxa = 0;
|
let mut idxa = 0;
|
||||||
let mut idxm = 0;
|
let mut idxm = 0;
|
||||||
|
let account_length = state.context.accounts.len();
|
||||||
'main: loop {
|
'main: loop {
|
||||||
state.refresh_mailbox(idxa,idxm);
|
state.refresh_mailbox(idxa,idxm);
|
||||||
let folder_length = state.context.accounts[idxa].len();
|
let folder_length = state.context.accounts[idxa].len();
|
||||||
state.render();
|
state.render();
|
||||||
state.redraw();
|
|
||||||
|
|
||||||
'inner: loop {
|
'inner: loop {
|
||||||
match receiver.recv().unwrap() {
|
match receiver.recv().unwrap() {
|
||||||
|
@ -183,7 +183,19 @@ fn main() {
|
||||||
idxm -= 1;
|
idxm -= 1;
|
||||||
break 'inner;
|
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 < ':' => {
|
Key::Char(v) if v > '/' && v < ':' => {
|
||||||
},
|
},
|
||||||
|
|
|
@ -285,7 +285,11 @@ impl Component for MailListing {
|
||||||
grid[(x, mid+5)].set_fg(Color::Default);
|
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 */
|
/* Draw body */
|
||||||
self.draw_mail_view(grid,
|
self.draw_mail_view(grid,
|
||||||
|
@ -398,37 +402,33 @@ impl AccountMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ind = 0;
|
let mut inc = 0;
|
||||||
let mut depth = String::from(" ");
|
let mut depth = String::from("");
|
||||||
let mut s = String::from(format!("\n\n {}\n", a.name));
|
let mut s = String::from(format!("\n\n {}\n", a.name));
|
||||||
fn pop(depth: &mut String) {
|
fn pop(depth: &mut String) {
|
||||||
depth.pop();
|
depth.pop();
|
||||||
depth.pop();
|
depth.pop();
|
||||||
depth.pop();
|
|
||||||
depth.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push(depth: &mut String, c: char) {
|
fn push(depth: &mut String, c: char) {
|
||||||
depth.push(' ');
|
|
||||||
depth.push(c);
|
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();
|
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();
|
let children_no = entries[root].1.get_children().len();
|
||||||
for (idx, child) in entries[root].1.get_children().iter().enumerate() {
|
for (idx, child) in entries[root].1.get_children().iter().enumerate() {
|
||||||
let len = s.len();
|
let len = s.len();
|
||||||
s.insert_str(len, &format!("{}ββ", depth));
|
s.insert_str(len, &format!("{}ββ", depth));
|
||||||
push(depth, if idx == children_no - 1 {'β'} else { ' ' });
|
push(depth, if idx == children_no - 1 {'β'} else { ' ' });
|
||||||
print(*child, parents, depth, entries, s);
|
print(*child, parents, depth, entries, s, inc);
|
||||||
pop(depth);
|
pop(depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for r in roots {
|
for r in roots {
|
||||||
print(r, &parents, &mut depth, &a.entries, &mut s);
|
print(r, &parents, &mut depth, &a.entries, &mut s, &mut inc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ impl<W: Write> State<W> {
|
||||||
s.stdout.flush().unwrap();
|
s.stdout.flush().unwrap();
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
fn update_size(&mut self) {
|
pub fn update_size(&mut self) {
|
||||||
/* update dimensions. TODO: Only do that in size change events. ie SIGWINCH */
|
/* update dimensions. TODO: Only do that in size change events. ie SIGWINCH */
|
||||||
let termsize = termion::terminal_size().ok();
|
let termsize = termion::terminal_size().ok();
|
||||||
let termcols = termsize.map(|(w,_)| w);
|
let termcols = termsize.map(|(w,_)| w);
|
||||||
|
|
Loadingβ¦
Reference in New Issue