Rockbox Technical Forums

Support and General Use => User Interface and Voice => Topic started by: iPodVT on October 24, 2022, 07:35:13 PM

Title: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 24, 2022, 07:35:13 PM
I added 'Use Shortcuts Menu Instead of Quick Screen' to my Shortcuts Menu via the Settings context menu, but the length of the default name for that item in my Shortcuts Menu seemed kind of excessive.  So I edited shortcuts.txt and entered "Shortcuts Instead of Quickscreen" for the item's name (which had been blank indicating the use of a default name).  After rebooting my iPod I found that the displayed name of that menu item was truncated to "Shortcuts Instead of Quickscree", despite the fact that the entire longer default name had previously been fully displayed.  I'm wondering if this is due to a limitation in what Rockbox will recognize for a name field in shortcuts.txt?
Title: Re: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 24, 2022, 08:15:00 PM
I forgot to add that this is on an MA446LL/A iPod 5.5 Gen with Rockbox version 498988d34a-221022.
Title: Re: Shortcuts Menu Oddity(?)
Post by: chris_s on October 24, 2022, 10:17:22 PM
Yeah, the length for the name of shortcuts appears to be purposefully capped (https://github.com/Rockbox/rockbox/blob/498988d34a50bb5fe32cf1092f11e3c10a0ac821/apps/shortcuts.c#L54) at 31 characters currently, if you provide one yourself, whereas if you don't, it is able to display the full name of the setting.
Title: Re: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 24, 2022, 11:37:55 PM
32 byte string, with the first byte specifying the length.  Is that limitation because Rockbox holds the Shortcuts Menu in memory at all times?
Title: Re: Shortcuts Menu Oddity(?)
Post by: chris_s on October 25, 2022, 11:26:58 PM
You may be thinking of Pascal strings instead of null-terminated C strings?

not sure what the reasoning behind the exact number may have been, except that it probably suffices in most cases. It seems to have remain unchanged since jdgordon originally implemented the menu  a decade ago. Memory usage in one way or another must have been a priority like it is almost anywhere else in Rockbox…
Title: Re: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 26, 2022, 12:10:20 AM
Right - Pascal strings - a blast from the past term that I never would have remembered on my own.  I was a Mac applications programmer in the 1980s and 90s, and even though I worked in C, that era's Mac Toolbox as documented in the Inside Macintosh reference books was full of Pascal strings.

Re the Shortcuts Menu:  It's kind of ironically funny that I bumped up against a string length limit while trying to shorten Rockbox's verbose menu item name.
Title: Re: Shortcuts Menu Oddity(?)
Post by: amachronic on October 26, 2022, 11:00:15 AM
Increasing the name length to 64 bytes or more seems reasonable. Most targets aren't that memory constrained.
Title: Re: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 26, 2022, 12:10:29 PM
Would the length have to be a power of 2?  A menu item name that is longer than 48 characters seems excessive to me, especially in the context of shortcuts, though that is just off the top of my head.
Title: Re: Shortcuts Menu Oddity(?)
Post by: amachronic on October 26, 2022, 03:37:24 PM
It doesn't need to be a power of two. But we're talking bytes, not characters. Non-English languages tend to have longer strings than English and use multibyte UTF-8 sequences, so it's worth having some extra wiggle room to accommodate them.
Title: Re: Shortcuts Menu Oddity(?)
Post by: iPodVT on October 26, 2022, 03:46:19 PM
Right, of course.  I was narrowly thinking only of english, and I totally forgot that some languages require multi-byte character sets.