From eaf792faf32eaea2d9a53fdc2507c138f4b71fc3 Mon Sep 17 00:00:00 2001 From: "Rich O." Date: Sun, 8 Nov 2026 18:35:53 -0500 Subject: [PATCH] palm-client: Radio Stats' and SB-LoRa Test's messages wrap onto the next line instead of being cut off at the screen's edge (new DrawWrap) --- palm-client/src/sb_test.c | 6 +++--- palm-client/src/stats_form.c | 4 ++-- palm-client/src/ui/draw.c | 15 +++++++++++++++ palm-client/src/ui/draw.h | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/palm-client/src/sb_test.c b/palm-client/src/sb_test.c index 24f6d40..2a42e6f 100644 --- a/palm-client/src/sb_test.c +++ b/palm-client/src/sb_test.c @@ -245,9 +245,9 @@ static void Draw(void) RctSetRectangle(&r, 0, 16, 160, 128); WinEraseRectangle(&r, 0); if (gCount == 0) - DrawCut("Testing...", 3, y, 154); - for (i = 0; i < gCount; i++, y += VM_ROW_H) - DrawCut(gLines[i], 3, y, 154); + DrawWrap("Testing...", 3, y, 154); + for (i = 0; i < gCount; i++) + y = DrawWrap(gLines[i], 3, y, 154); FntSetFont(old); } diff --git a/palm-client/src/stats_form.c b/palm-client/src/stats_form.c index 4a1cc49..e5489cf 100644 --- a/palm-client/src/stats_form.c +++ b/palm-client/src/stats_form.c @@ -126,7 +126,7 @@ static void Draw(void) RctSetRectangle(&r, 0, 16, 160, 127); WinEraseRectangle(&r, 0); if (gErr == serErrNotOpen) { - DrawText(y, "Connect to the radio first (Node)."); + DrawWrap("Connect to the radio first (Node).", 3, y, 154); FntSetFont(old); return; } @@ -171,7 +171,7 @@ static void Draw(void) y += step; } if (!gStats.hasCore && !gStats.hasRadio && !gStats.hasPackets) { - DrawText(y, gErr == vmErrRadio ? "This firmware doesn't report stats." : "The radio didn't answer."); + DrawWrap(gErr == vmErrRadio ? "This firmware doesn't report stats." : "The radio didn't answer.", 3, y, 154); FntSetFont(old); return; } diff --git a/palm-client/src/ui/draw.c b/palm-client/src/ui/draw.c index 7a63df0..42f8cd1 100644 --- a/palm-client/src/ui/draw.c +++ b/palm-client/src/ui/draw.c @@ -106,6 +106,21 @@ Coord DrawCut(const Char *text, Coord x, Coord y, Coord maxW) return w + FntCharWidth(ell); } +Coord DrawWrap(const Char *text, Coord x, Coord y, Coord maxW) +{ + UInt16 n; + + while (*text) { + n = FntWordWrap(text, maxW); + if (n == 0) + break; + WinDrawChars(text, n, x, y); + text += n; + y += VM_ROW_H; + } + return y; +} + Coord DrawRight(const Char *text, Coord xRight, Coord y) { UInt16 len = StrLen(text); diff --git a/palm-client/src/ui/draw.h b/palm-client/src/ui/draw.h index 4818d6c..2ef9061 100644 --- a/palm-client/src/ui/draw.h +++ b/palm-client/src/ui/draw.h @@ -33,6 +33,9 @@ Coord ChipWidth(const Char *text) VM_SECT2; /* Draws text in the current font, cut with an ellipsis to fit maxW. Returns the width drawn. */ Coord DrawCut(const Char *text, Coord x, Coord y, Coord maxW) VM_SECT2; +/* Draws text word-wrapped to maxW, a line per VM_ROW_H. Returns the y below the last line. */ +Coord DrawWrap(const Char *text, Coord x, Coord y, Coord maxW) VM_SECT2; + /* Draws text right-aligned so it ends at xRight. Returns its left edge. */ Coord DrawRight(const Char *text, Coord xRight, Coord y) VM_SECT2;