Fix extraneous white cell at top left when loading ANSI files

This commit is contained in:
Isaiah Odhner 2023-04-25 18:43:28 -04:00
parent ba7f8e6a0a
commit 1ab1dfb037
2 changed files with 5 additions and 2 deletions

View File

@ -137,7 +137,6 @@ cat file.ans
- Some languages don't display correctly.
- Large files can make the program very slow, as can magnifying the canvas.
- The program sometimes crashes or freezes randomly, and there's no auto-save feature.
- Saving/loading an ANSI file ends up with a white cell at the top left, which pushes the top row to the right. The top right cell gets pushed off and deleted.
- Saved ANSI files are unnecessarily large, because they include escape sequences for every cell, even if the colors match the previous cell.
- When finalizing a selection that is partially outside the document bounds to the top or to the left, it gets cut off.

View File

@ -551,7 +551,11 @@ class AnsiArtDocument:
# TODO: use Rich API to render ANSI to a virtual screen,
# and remove dependency on stransi
ansi = stransi.Ansi(text)
document = AnsiArtDocument(1, 1)
# Initial document is zero wide to avoid an extraneous character at (0,0),
# but needs one row to avoid IndexError.
document = AnsiArtDocument(0, 1)
# Ultimately, the minimum size is 1x1.
width = 1
height = 1