From 840f2b5b19c4c266a4bf03e2e3f046f0923d9edf Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Mon, 25 Aug 2025 10:26:24 +0200 Subject: [PATCH] skip padding entirely if not asked --- slic/utils/boxed.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/slic/utils/boxed.py b/slic/utils/boxed.py index ec101b93..34151903 100644 --- a/slic/utils/boxed.py +++ b/slic/utils/boxed.py @@ -65,13 +65,14 @@ def boxed(text, align="left", style="normal", npad=0): lines = aligned(lines, length, align=align) - # factor 3 makes boxes approx. square - nvpad = int(round(npad/3)) - length += 2 * npad + if npad: + # factor 3 makes boxes approx. square + nvpad = int(round(npad/3)) + length += 2 * npad - # this has to be in this order, otherwise vert_padded needs to insert lines of the correct length - lines = vert_padded(lines, nvpad) - lines = hori_padded(lines, length) + # this has to be in this order, otherwise vert_padded needs to insert lines of the correct length + lines = vert_padded(lines, nvpad) + lines = hori_padded(lines, length) style = Style(STYLES[style]) return style.make_box(lines, length)