Fix some drawing bugs

embed
Manos Pitsidianakis 2018-08-08 11:50:51 +03:00
parent a8fed3a042
commit 2932dd0dc0
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 12 additions and 5 deletions

View File

@ -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,
);

View File

@ -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
}

View File

@ -19,14 +19,14 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
#[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::*;