From f2897882426ed193e6cefd4a203775aa3099d982 Mon Sep 17 00:00:00 2001
From: pelgraine <140762863+pelgraine@users.noreply.github.com>
Date: Tue, 24 Feb 2026 00:00:29 +1100
Subject: [PATCH] increase web display max links; fix to encode spaces as %20
in web url entry so you just type a space and it will translate it for you
---
.../companion_radio/ui-new/Webreaderscreen.h | 106 +++++++++++++-----
1 file changed, 80 insertions(+), 26 deletions(-)
diff --git a/examples/companion_radio/ui-new/Webreaderscreen.h b/examples/companion_radio/ui-new/Webreaderscreen.h
index b169411..d42475f 100644
--- a/examples/companion_radio/ui-new/Webreaderscreen.h
+++ b/examples/companion_radio/ui-new/Webreaderscreen.h
@@ -98,9 +98,9 @@ struct IRCMessage {
char text[IRC_MAX_MSG_LEN];
bool isSystem; // true for join/part/server notices
};
-#define WEB_MAX_PAGE_SIZE 32768 // Max HTML download size (32KB)
-#define WEB_MAX_TEXT_SIZE 24576 // Max extracted text size (24KB)
-#define WEB_MAX_LINKS 64 // Max links per page
+#define WEB_MAX_PAGE_SIZE 196608 // Max HTML download size (192KB)
+#define WEB_MAX_TEXT_SIZE 98304 // Max extracted text size (96KB)
+#define WEB_MAX_LINKS 512 // Max links per page
#define WEB_MAX_URL_LEN 256
#define WEB_MAX_BOOKMARKS 20
#define WEB_MAX_HISTORY 30
@@ -155,7 +155,7 @@ static const char* HTML_SKIP_TAGS[] = {
// Tags that produce a paragraph break
static const char* HTML_BLOCK_TAGS[] = {
"p", "div", "br", "h1", "h2", "h3", "h4", "h5", "h6",
- "li", "tr", "blockquote", "article", "section", "figcaption",
+ "tr", "blockquote", "article", "section", "figcaption",
"dt", "dd", nullptr
};
@@ -284,6 +284,31 @@ inline bool extractHref(const char* tagContent, int tagLen, char* hrefOut, int h
return false;
}
+// Encode spaces in URL as %20 (in-place, buffer must have room)
+inline void encodeUrlSpaces(char* url, int maxLen) {
+ int len = strlen(url);
+ // Count spaces to check if result fits
+ int spaces = 0;
+ for (int i = 0; i < len; i++) {
+ if (url[i] == ' ') spaces++;
+ }
+ int newLen = len + spaces * 2; // Each space becomes 3 chars (%20) instead of 1
+ if (newLen >= maxLen) return; // Won't fit, leave as-is
+
+ // Work backwards to encode in-place
+ url[newLen] = '\0';
+ int dst = newLen - 1;
+ for (int src = len - 1; src >= 0; src--) {
+ if (url[src] == ' ') {
+ url[dst--] = '0';
+ url[dst--] = '2';
+ url[dst--] = '%';
+ } else {
+ url[dst--] = url[src];
+ }
+ }
+}
+
// Resolve a relative URL against a base URL
inline void resolveUrl(const char* base, const char* relative, char* out, int outMax) {
if (!relative || !relative[0]) {
@@ -545,7 +570,8 @@ inline ParseResult parseHtml(const char* html, int htmlLen,
if (ti < textMax - 8) {
int n = result.linkCount;
textOut[ti++] = '[';
- if (n >= 10) textOut[ti++] = '0' + (n / 10);
+ if (n >= 100) textOut[ti++] = '0' + (n / 100);
+ if (n >= 10) textOut[ti++] = '0' + ((n / 10) % 10);
textOut[ti++] = '0' + (n % 10);
textOut[ti++] = ']';
lastWasSpace = false;
@@ -556,9 +582,13 @@ inline ParseResult parseHtml(const char* html, int htmlLen,
currentHref[0] = '\0';
}
- // Handle
- add bullet marker
+ // Handle - single newline + bullet marker
if (!isClosing && tagNameLen == 2 && tagName[0] == 'l' && tagName[1] == 'i') {
- if (ti < textMax - 4) {
+ if (ti < textMax - 5) {
+ if (!lastWasBreak && ti > 0) {
+ textOut[ti++] = '\n';
+ lastWasBreak = true;
+ }
textOut[ti++] = ' ';
textOut[ti++] = '*';
textOut[ti++] = ' ';
@@ -722,15 +752,8 @@ inline ParseResult parseHtml(const char* html, int htmlLen,
}
}
- //