Restore ellipsis to end of long names

This commit is contained in:
Jason P 2025-10-15 10:56:13 -05:00
parent caff68f2f3
commit 3e3f03c78d

View File

@ -517,20 +517,19 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
strcpy(senderBuf, "Me"); strcpy(senderBuf, "Me");
} }
const char *sender = senderBuf;
// If sender width too wide → truncate manually
int availWidth = SCREEN_WIDTH - display->getStringWidth(timeBuf) - display->getStringWidth(chanType) - int availWidth = SCREEN_WIDTH - display->getStringWidth(timeBuf) - display->getStringWidth(chanType) -
display->getStringWidth(" @") - display->getStringWidth("... ") - 10; display->getStringWidth(" @...") - 10;
if (availWidth < 0)
availWidth = 0;
while (strlen(senderBuf) > 0 && display->getStringWidth(senderBuf) > availWidth) { size_t origLen = strlen(senderBuf);
while (senderBuf[0] && display->getStringWidth(senderBuf) > availWidth) {
senderBuf[strlen(senderBuf) - 1] = '\0'; senderBuf[strlen(senderBuf) - 1] = '\0';
} }
// Add ellipsis if needed // If we actually truncated, append "..."
if (display->getStringWidth(senderBuf) > availWidth && strlen(senderBuf) >= 3) { if (strlen(senderBuf) < origLen) {
size_t len = strlen(senderBuf); strcat(senderBuf, "...");
strcpy(&senderBuf[len - 3], "...");
} }
// Final header line // Final header line
@ -538,7 +537,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
if (mine) { if (mine) {
snprintf(headerStr, sizeof(headerStr), "%s %s", timeBuf, chanType); snprintf(headerStr, sizeof(headerStr), "%s %s", timeBuf, chanType);
} else { } else {
snprintf(headerStr, sizeof(headerStr), "%s @%s %s", timeBuf, sender, chanType); snprintf(headerStr, sizeof(headerStr), "%s @%s %s", timeBuf, senderBuf, chanType);
} }
// Push header line // Push header line