summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-05-10 00:54:10 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:48 +0300
commit5a564dee630cfda65f4d2ddb4d9c8a3ed56f49cc (patch)
treebab87e151c09baa2affc67b9843d59f1739cbe96
parentb943941e60f4835c8a76cce2c814a227fa079c6b (diff)
melib: print folder tree in Listing menu properly
Depths weren't calculated correctly, and index (eg 0 Inbox) wasn't colored correctly if the folder's name started with a number (eg 11 2019)
-rw-r--r--ui/src/components/mail/listing.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index dc494f4a..15c16927 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -502,7 +502,6 @@ impl Listing {
let mut s = format!("{}\n", a.name);
fn pop(depth: &mut String) {
depth.pop();
- depth.pop();
}
fn push(depth: &mut String, c: char) {
@@ -546,13 +545,13 @@ impl Listing {
let mut children: Vec<FolderHash> = entries[&folder_idx].children().to_vec();
children
.sort_unstable_by(|a, b| folders_order[a].partial_cmp(&folders_order[b]).unwrap());
+ push(depth, ' ');
for child in children {
let len = s.len();
s.insert_str(len, &format!("{} ", depth));
- push(depth, ' ');
print(child, depth, inc, entries, folders_order, s, index, context);
- pop(depth);
}
+ pop(depth);
}
for f in entries.keys() {
if entries[f].parent().is_none() {
@@ -599,18 +598,25 @@ impl Listing {
false,
);
{
+ enum CellPos {
+ BeforeIndex,
+ Index,
+ //AfterIndex,
+ }
+ let mut pos = CellPos::BeforeIndex;
let mut x = get_x(upper_left);
while let Some(cell) = grid.get_mut(x, y) {
if x == get_x(bottom_right) {
break;
}
- match cell.ch() {
- c if c.is_numeric() => {
+ match (cell.ch(), &pos) {
+ (c, CellPos::Index) | (c, CellPos::BeforeIndex) if c.is_numeric() => {
+ pos = CellPos::Index;
cell.set_fg(Color::Byte(243));
x += 1;
continue;
}
- c if c.is_whitespace() => {
+ (c, CellPos::BeforeIndex) if c.is_whitespace() => {
x += 1;
continue;
}
@@ -620,12 +626,6 @@ impl Listing {
}
}
}
-
- if highlight && idx > 1 && self.cursor_pos.1 == idx - 1 {
- change_colors(grid, ((x, y), (get_x(bottom_right), y)), color_fg, color_bg);
- } else {
- change_colors(grid, ((x, y), set_y(bottom_right, y)), color_fg, color_bg);
- }
idx += 1;
}
if idx == 0 {