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)

This commit is contained in:
rich committed 2026-11-08 18:35:53 -05:00
1 parent bd9d9ce951
commit eaf792faf3
4 files changed
+23 -5

No files matched your search

+3 -3
View File
@@ -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);
}
+2 -2
View File
@@ -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;
}
+15
View File
@@ -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);
+3
View File
@@ -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;