[Bugfix] lua splash_scroller line formatting

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Thu, 18 Jun 2026 22:22:19 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 7a32c8b5e3ecaf7933c74075ff61b4958203b31f
Author: William Wilgus <[email protected]>
Date:   Thu Jun 18 22:17:47 2026 -0400

    [Bugfix] lua splash_scroller line formatting
    
    I accidentally added an extra character wittthe last patch by changing
    < to <= in the process of testing this I realized spaces were sometimes
    being included at the beginning of the line and also that sometime
    sentences were being cut short even though they fit on the screen
    
    Change-Id: Iee0ed64e18defad2acb3c107d334ea2a49bd5b6f

diff --git a/apps/plugins/lua/rockaux.c b/apps/plugins/lua/rockaux.c
index 1cfd31805c..86abf5c456 100644
--- a/apps/plugins/lua/rockaux.c
+++ b/apps/plugins/lua/rockaux.c
@@ -77,7 +77,7 @@ int splash_scroller(int timeout, const char* str)
     const int max_lines = LCD_HEIGHT / ch_h - 1;
     const int wrap_thresh = (LCD_WIDTH / 4);
 
-    const int max_ch = (LCD_WIDTH / ch_w - 1) * 2;
+    const int max_ch = (LCD_WIDTH / ch_w - 1) * 3;
     char line[max_ch + 2]; /* display buffer +2 incase of tab chars */
     const char break_chars[] = "/\\ \r\n\f\v";
     const char *ch, *brk;
@@ -99,8 +99,10 @@ int splash_scroller(int timeout, const char* str)
         {
             linepos = 0;
             brk = NULL;
+
             maxl = rb->font_measurestring(ch, max_ch, max_w, &w, NULL, fontnum);
-            for (; *ch && linepos <= maxl; ch++)
+
+            for (; *ch && linepos < maxl; ch++)
             {
                 if (strpbrk_n(ch, 1, break_chars))
                 {
@@ -134,9 +136,9 @@ int splash_scroller(int timeout, const char* str)
                     continue;
                 }
                 else
-                    line[linepos] = ch[0];
-
-                linepos++;
+                {
+                    line[linepos++] = ch[0];
+                }
             }
             line[linepos] = '\0';
 
@@ -157,7 +159,8 @@ int splash_scroller(int timeout, const char* str)
                 linesdisp++;
                 last_break = 0;
             }
-
+            if (linepos == maxl && isspace(*ch)) /* we would have split at this space if we could see it */
+                ch++;
             curline++;
         }
 
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs