Skip to content

Commit 784858c

Browse files
committed
Fix rendering of multicharacter backgrounds
1 parent 47694e4 commit 784858c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎charcoal.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,16 +601,15 @@ def __str__(self):
601601
left = min(self.indices)
602602
right = max(self.right_indices)
603603
string = ""
604-
bg_start = None
605604
if self.bg_lines:
606605
for i in range(len(self.lines)):
607606
top = self.top + i
608607
index = self.indices[i]
609608
line = self.lines[i]
610-
j = -1
609+
bg_start = None
610+
j = 0
611611
if self.background_inside:
612612
for character in line:
613-
j += 1
614613
if character == "\000":
615614
if bg_start is None:
616615
bg_start = j
@@ -623,6 +622,7 @@ def __str__(self):
623622
line[j:]
624623
)
625624
bg_start = None
625+
j += 1
626626
if bg_start is not None:
627627
line = (
628628
line[:bg_start] +

‎test.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ def test_background(self):
289289
*#-#*
290290
*****""")
291291
self.assertEqual(Run("F⁶«M→_»UB| "), "_|_|_|_|_|_")
292+
self.assertEqual(Run("UB#@↗³⟲"), "/@#\n#/#\n#@/")
292293
# TODO: weird, why does Charcoal escape asterisks???
293294
self.assertEqual(
294295
Run("Multiprint(:+, 'abc');SetBackground('*')", verbose=True),

0 commit comments

Comments
 (0)