mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
fix(cli): keys pages counted as they are printed
A page break counted a space before every key, printing put none before the first, so the skipped pages broke one key early and the next page began with the previous page's last key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -98,14 +98,15 @@ static bool handle(UiCore& core, const char* cmd, char* reply, int n) {
|
||||
reply[0] = 0;
|
||||
for (int k = 0; k < KEY_COUNT; k++) {
|
||||
if (row(KEYS[k]) < 0) continue;
|
||||
int len = (int)strlen(KEYS[k].key) + 1;
|
||||
int len = (o ? 1 : 0) + (int)strlen(KEYS[k].key); // as printed: a space before all but the first
|
||||
if (o + len > n - 20) { // room left for " (more: keys N)"
|
||||
if (pg == page) { more = true; break; }
|
||||
pg++;
|
||||
o = 0;
|
||||
len--; // first on its page: no space
|
||||
}
|
||||
if (pg == page) o += snprintf(reply + o, n - o, "%s%s", o ? " " : "", KEYS[k].key);
|
||||
else o += len;
|
||||
if (pg == page) snprintf(reply + o, n - o, "%s%s", o ? " " : "", KEYS[k].key);
|
||||
o += len;
|
||||
}
|
||||
if (more) snprintf(reply + o, n - o, " (more: keys %d)", page + 1);
|
||||
else if (pg < page || page < 1) snprintf(reply, n, "No more keys");
|
||||
|
||||
Reference in New Issue
Block a user