mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Apply shortening to longNames in Select Destination
This commit is contained in:
parent
3cb4e0e195
commit
2c05baa1b4
@ -1693,19 +1693,37 @@ void CannedMessageModule::drawDestinationSelectionScreen(OLEDDisplay *display, O
|
||||
int nodeIndex = itemIndex - numActiveChannels;
|
||||
if (nodeIndex >= 0 && nodeIndex < static_cast<int>(this->filteredNodes.size())) {
|
||||
meshtastic_NodeInfoLite *node = this->filteredNodes[nodeIndex].node;
|
||||
if (node && node->user.long_name) {
|
||||
strncpy(entryText, node->user.long_name, sizeof(entryText) - 1);
|
||||
entryText[sizeof(entryText) - 1] = '\0';
|
||||
}
|
||||
int availWidth = display->getWidth() - (graphics::isHighResolution ? 40 : 20) - ((node->is_favorite) ? 10 : 0);
|
||||
if (availWidth < 0)
|
||||
availWidth = 0;
|
||||
|
||||
size_t origLen = strlen(entryText);
|
||||
while (entryText[0] && display->getStringWidth(entryText) > availWidth) {
|
||||
entryText[strlen(entryText) - 1] = '\0';
|
||||
}
|
||||
if (strlen(entryText) < origLen) {
|
||||
strcat(entryText, "...");
|
||||
}
|
||||
|
||||
// Prepend "* " if this is a favorite
|
||||
if (node && node->is_favorite) {
|
||||
size_t len = strlen(entryText);
|
||||
if (len + 2 < sizeof(entryText)) {
|
||||
memmove(entryText + 2, entryText, len + 1);
|
||||
entryText[0] = '*';
|
||||
entryText[1] = ' ';
|
||||
}
|
||||
}
|
||||
if (node) {
|
||||
if (node->is_favorite) {
|
||||
#if defined(M5STACK_UNITC6L)
|
||||
snprintf(entryText, sizeof(entryText), "* %s", node->user.short_name);
|
||||
if (display->getWidth() <= 64) {
|
||||
snprintf(node->user.short_name, sizeof(node->user.short_name), "%s", node->user.short_name);
|
||||
} else {
|
||||
snprintf(entryText, sizeof(entryText), "%s", node->user.short_name);
|
||||
snprintf(entryText, sizeof(entryText), "%s", entryText);
|
||||
}
|
||||
#else
|
||||
snprintf(entryText, sizeof(entryText), "* %s", node->user.long_name);
|
||||
} else {
|
||||
snprintf(entryText, sizeof(entryText), "%s", node->user.long_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1725,6 +1743,7 @@ void CannedMessageModule::drawDestinationSelectionScreen(OLEDDisplay *display, O
|
||||
display->setColor(WHITE);
|
||||
|
||||
// Draw key icon (after highlight)
|
||||
/*
|
||||
if (itemIndex >= numActiveChannels) {
|
||||
int nodeIndex = itemIndex - numActiveChannels;
|
||||
if (nodeIndex >= 0 && nodeIndex < static_cast<int>(this->filteredNodes.size())) {
|
||||
@ -1742,6 +1761,7 @@ void CannedMessageModule::drawDestinationSelectionScreen(OLEDDisplay *display, O
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Scrollbar
|
||||
|
||||
Loading…
Reference in New Issue
Block a user