diff options
| author | Mroik <mroik@delayed.space> | 2025-01-31 05:07:55 +0100 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2025-02-01 19:35:25 +0100 |
| commit | b9950e29d1586d652682e8908075d64abf786433 (patch) | |
| tree | 7f96cd8d68774359873df8e5f6c9a542c58d2687 | |
| parent | 77fc9bc81904fb865dcf9d47cd423cd60c62b83f (diff) | |
Fix margin offset
| -rw-r--r-- | src/app.rs | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -253,8 +253,14 @@ impl App<'_> { return Ok(()); } }; - let margin = - (cols - lines.iter().map(|line| line.join(" ").len()).max().unwrap() as u16) / 2; + let margin = (cols + - lines + .iter() + .map(|line| line.join(" ").chars().count()) + .max() + .unwrap() as u16) + / 2 + + 1; // Terminals index starting with 1 instead of 0 let current_line = lines .iter() .enumerate() @@ -350,7 +356,11 @@ impl App<'_> { // Next line if lines.len() > 1 && current_line < lines.len() - 1 { - let last_rendered = if current_line == 0 && lines.len() > 2 { 2 } else { 1 }; + let last_rendered = if current_line == 0 && lines.len() > 2 { + 2 + } else { + 1 + }; for line in &lines[current_line + 1..current_line + 1 + last_rendered] { self.stdout .queue(SetForegroundColor(Color::Reset))? |
