diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2018-08-08 11:50:51 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:27 +0300 |
commit | 2932dd0dc086410fcee54fa15f468ea623924ce3 (patch) | |
tree | becbab82aa572f9b3d7305bbdd2eacbfd69e5be5 /ui | |
parent | a8fed3a042fbf8510a46908eb3c7fecf1a643544 (diff) |
Fix some drawing bugs
Diffstat (limited to 'ui')
-rw-r--r-- | ui/src/components/mail/mod.rs | 2 | ||||
-rw-r--r-- | ui/src/types/cells.rs | 11 | ||||
-rw-r--r-- | ui/src/types/mod.rs | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/ui/src/components/mail/mod.rs b/ui/src/components/mail/mod.rs index b15b069a..e04e44c4 100644 --- a/ui/src/components/mail/mod.rs +++ b/ui/src/components/mail/mod.rs @@ -189,7 +189,7 @@ impl AccountMenu { if highlight && idx > 1 && self.cursor.unwrap().1 == idx - 2 { change_colors( grid, - ((x, y), (get_x(bottom_right) + 1, y)), + ((x, y), (get_x(bottom_right), y)), color_fg, color_bg, ); diff --git a/ui/src/types/cells.rs b/ui/src/types/cells.rs index 1e1c0169..6f3bd9a6 100644 --- a/ui/src/types/cells.rs +++ b/ui/src/types/cells.rs @@ -187,10 +187,17 @@ impl Default for CellBuffer { impl<'a> From<&'a String> for CellBuffer { fn from(s: &'a String) -> Self { + let lines: Vec<&str> = s.lines().map(|l| l.trim_right()).collect(); let len = s.len(); let mut buf = CellBuffer::new(len, 1, Cell::default()); - for (idx, c) in s.chars().enumerate() { - buf[(idx, 0)].set_ch(c); + let mut x = 0; + for l in lines.iter() { + for (idx, c) in l.chars().enumerate() { + buf[(x + idx, 0)].set_ch(c); + } + x += l.chars().count(); + buf[(x, 0)].set_ch('\n'); + x += 1; } buf } diff --git a/ui/src/types/mod.rs b/ui/src/types/mod.rs index 0dd55a83..4f704871 100644 --- a/ui/src/types/mod.rs +++ b/ui/src/types/mod.rs @@ -20,13 +20,13 @@ */ #[macro_use] +mod position; +#[macro_use] mod cells; #[macro_use] mod helpers; #[macro_use] mod keys; -#[macro_use] -mod position; pub use self::cells::*; pub use self::helpers::*; pub use self::keys::*; |