diff options
author | rabite <rabite@posteo.de> | 2019-02-05 21:15:07 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-02-05 21:25:10 +0100 |
commit | 09b50562ece43e6b8dc202def224b521268ad875 (patch) | |
tree | a717576edccb791f5b1d054d697cd94d8e6d3bd8 /src/textview.rs | |
parent | 1826fced28630d5b3d7db6db49198549fe45e168 (diff) |
more robust handling of cjk characters
Diffstat (limited to 'src/textview.rs')
-rw-r--r-- | src/textview.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/textview.rs b/src/textview.rs index 694ab5a..ad76ca8 100644 --- a/src/textview.rs +++ b/src/textview.rs @@ -18,8 +18,10 @@ impl TextView { pub fn new_from_file(file: &File) -> TextView { let file = std::fs::File::open(&file.path).unwrap(); let file = std::io::BufReader::new(file); - let lines = file.lines().map(|line| line.unwrap()).collect(); - + let lines = file.lines().map(|line| + line.unwrap() + .replace("\t", " ")).collect(); + TextView { lines: lines, buffer: String::new(), @@ -63,12 +65,10 @@ impl Widget for TextView { .enumerate() .map(|(i, line)| { format!( - "{}{}{:xsize$}", + "{}{}{}", crate::term::goto_xy(xpos, i as u16 + ypos), crate::term::reset(), - sized_string(&line, xsize), - xsize = xsize as usize - ) + sized_string(&line, xsize)) }) .collect::<String>(); } |