diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-06 15:17:49 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-06 15:17:49 -0800 |
| commit | fb6c02e033196cdc8d2a3642ea8e869d18b37fed (patch) | |
| tree | bafe64869f0fb98c55965976a3048a732bb8d3fc /src/main.rs | |
| parent | 9ac429aa26529af2f753d01fe6e4fe5046bdf30f (diff) | |
| download | editor-fb6c02e033196cdc8d2a3642ea8e869d18b37fed.tar.zst | |
Fix some bugs with long lines.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 139b4c3..6251ace 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,12 +59,9 @@ impl State { if i > self.buf.lines() { break; } - let mut line = self.buf.line(i); + let line = self.buf.line(i); let max_len = line.char(usize::from(size.ws_col-1)); - if max_len < line.len() { - line = line.slice(0, max_len); - } - line.print(&mut stdout)?; + line.slice(0, max_len).print(&mut stdout)?; if max_len < line.len() { write!(stdout, "\x1b[30m\x1b[47m>\x1b[m")?; } @@ -103,6 +100,11 @@ impl State { if col == self.cursor_col { // One codepoint per column, like God intended. self.line_offset = offset_guess; + line.slice(offset_guess, line.len()).print(&mut stdout)?; + if truncated { + write!(stdout, "\x1b[30m\x1b[47m>\x1b[m")?; + } + write!(stdout, "\x1b[{}G", self.cursor_col+1)?; return Ok(()); } |
