mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
move destination option to top of canned message screen
This commit is contained in:
parent
4fdc5f094a
commit
7c9ec46d8f
@ -96,35 +96,46 @@ int CannedMessageModule::splitConfiguredMessages()
|
|||||||
// Copy all message parts into the buffer
|
// Copy all message parts into the buffer
|
||||||
strncpy(this->messageStore, canned_messages.c_str(), sizeof(this->messageStore));
|
strncpy(this->messageStore, canned_messages.c_str(), sizeof(this->messageStore));
|
||||||
|
|
||||||
// First message points to start of buffer
|
// Temporary array to allow for insertion
|
||||||
this->messages[messageIndex++] = this->messageStore;
|
const char* tempMessages[CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT + 3] = {0};
|
||||||
|
int tempCount = 0;
|
||||||
|
|
||||||
|
// First message always starts at buffer start
|
||||||
|
tempMessages[tempCount++] = this->messageStore;
|
||||||
int upTo = strlen(this->messageStore) - 1;
|
int upTo = strlen(this->messageStore) - 1;
|
||||||
|
|
||||||
// Walk buffer, splitting on '|'
|
// Walk buffer, splitting on '|'
|
||||||
while (i < upTo) {
|
while (i < upTo) {
|
||||||
if (this->messageStore[i] == '|') {
|
if (this->messageStore[i] == '|') {
|
||||||
this->messageStore[i] = '\0'; // End previous message
|
this->messageStore[i] = '\0'; // End previous message
|
||||||
|
if (tempCount >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT)
|
||||||
// Stop if we've hit max message slots
|
break;
|
||||||
if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT) {
|
tempMessages[tempCount++] = (this->messageStore + i + 1);
|
||||||
this->messagesCount = messageIndex;
|
|
||||||
return this->messagesCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Point to the next message start
|
|
||||||
this->messages[messageIndex++] = (this->messageStore + i + 1);
|
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always add "[Select Destination]" next-to-last
|
// Insert "[Select Destination]" after Free Text if present, otherwise at the top
|
||||||
this->messages[messageIndex++] = (char*)"[Select Destination]";
|
#if defined(USE_VIRTUAL_KEYBOARD)
|
||||||
|
// Insert at position 1 (after Free Text)
|
||||||
|
for (int j = tempCount; j > 1; j--) tempMessages[j] = tempMessages[j - 1];
|
||||||
|
tempMessages[1] = "[Select Destination]";
|
||||||
|
tempCount++;
|
||||||
|
#else
|
||||||
|
// Insert at position 0 (top)
|
||||||
|
for (int j = tempCount; j > 0; j--) tempMessages[j] = tempMessages[j - 1];
|
||||||
|
tempMessages[0] = "[Select Destination]";
|
||||||
|
tempCount++;
|
||||||
|
#endif
|
||||||
|
|
||||||
// === Add [Exit] as the final entry in the list ===
|
// Add [Exit] as the last entry
|
||||||
this->messages[messageIndex++] = (char*)"[Exit]";
|
tempMessages[tempCount++] = "[Exit]";
|
||||||
|
|
||||||
// Record how many messages there are
|
// Copy to the member array
|
||||||
this->messagesCount = messageIndex;
|
for (int k = 0; k < tempCount; ++k) {
|
||||||
|
this->messages[k] = (char*)tempMessages[k];
|
||||||
|
}
|
||||||
|
this->messagesCount = tempCount;
|
||||||
|
|
||||||
return this->messagesCount;
|
return this->messagesCount;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user