mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
chore: pre-release cleanup pass (Lemon-era naming, bot sender parsing dedup)
Renamed the vestigial Lemon/default font-switch naming (setLemonFont/ isLemonFont/drawLemonChar/lemonXAdvance/_use_lemon -> setSingleFont/ isSingleFont/drawGlyph/glyphXAdvance/_single_font) across DisplayDriver.h and both concrete drivers -- both have been permanently single-font for several commits, so the old names invited a future reader to think a real switch still existed. Pure identifier rename, no logic changed. Also extracted the byte-identical "SenderName: " prefix-splitting in MyMeshBot.h's tryBotReplyChannel()/tryBotChannelCommand() into a shared botChannelSenderSplit(), mirroring the existing botRoomSenderName(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -328,6 +328,11 @@ private:
|
||||
// Resolves a room post's signed author prefix to a display name for {name};
|
||||
// falls back to a generic label when the poster isn't a known contact.
|
||||
void botRoomSenderName(const uint8_t* sender_prefix, char* out, int out_len);
|
||||
// Splits a channel message's leading "SenderName: " text convention off its
|
||||
// body, for the {name} placeholder and to match triggers/commands against
|
||||
// the body only. `*msg_out` points into `text` (no copy); `sender_name`
|
||||
// defaults to "someone" if there's no ": " separator.
|
||||
void botChannelSenderSplit(const char* text, char* sender_name, int sender_name_len, const char** msg_out);
|
||||
|
||||
void writeOKFrame();
|
||||
void writeErrFrame(uint8_t err_code);
|
||||
|
||||
@@ -54,6 +54,17 @@ void MyMesh::botRoomSenderName(const uint8_t* sender_prefix, char* out, int out_
|
||||
else snprintf(out, out_len, "someone");
|
||||
}
|
||||
|
||||
void MyMesh::botChannelSenderSplit(const char* text, char* sender_name, int sender_name_len, const char** msg_out) {
|
||||
*msg_out = text;
|
||||
snprintf(sender_name, sender_name_len, "someone");
|
||||
const char* sep = strstr(text, ": ");
|
||||
if (sep) {
|
||||
*msg_out = sep + 2;
|
||||
int n = (int)(sep - text);
|
||||
if (n > 0 && n < sender_name_len) { memcpy(sender_name, text, n); sender_name[n] = '\0'; }
|
||||
}
|
||||
}
|
||||
|
||||
// Per-contact DM throttle: true if enough time has passed (or we've never
|
||||
// replied) to this contact. Only the first 4 key bytes are compared — ample to
|
||||
// tell local contacts apart.
|
||||
@@ -142,14 +153,9 @@ void MyMesh::tryBotReplyChannel(uint8_t channel_idx, const char* text, uint8_t h
|
||||
// message body only, and so the name is available for the {name}
|
||||
// placeholder. Unsigned/unverified — channel messages carry no identity
|
||||
// beyond this text convention.
|
||||
const char* msg = text;
|
||||
char sender_name[32] = "someone";
|
||||
const char* sep = strstr(text, ": ");
|
||||
if (sep) {
|
||||
msg = sep + 2;
|
||||
int n = (int)(sep - text);
|
||||
if (n > 0 && n < (int)sizeof(sender_name)) { memcpy(sender_name, text, n); sender_name[n] = '\0'; }
|
||||
}
|
||||
const char* msg;
|
||||
char sender_name[32];
|
||||
botChannelSenderSplit(text, sender_name, sizeof(sender_name), &msg);
|
||||
|
||||
if (!botTriggerMatches(_prefs.bot_trigger_ch, msg, true)) return; // own trigger; "*" = any msg
|
||||
|
||||
@@ -328,14 +334,9 @@ bool MyMesh::tryBotChannelCommand(uint8_t channel_idx, const char* text, uint8_t
|
||||
return false;
|
||||
|
||||
// Skip "sender_name: " prefix so commands are read from the message body only.
|
||||
const char* msg = text;
|
||||
char sender_name[32] = "someone";
|
||||
const char* sep = strstr(text, ": ");
|
||||
if (sep) {
|
||||
msg = sep + 2;
|
||||
int n = (int)(sep - text);
|
||||
if (n > 0 && n < (int)sizeof(sender_name)) { memcpy(sender_name, text, n); sender_name[n] = '\0'; }
|
||||
}
|
||||
const char* msg;
|
||||
char sender_name[32];
|
||||
botChannelSenderSplit(text, sender_name, sizeof(sender_name), &msg);
|
||||
|
||||
uint32_t ts = getRTCClock()->getCurrentTime();
|
||||
char out[BOT_SCRATCH];
|
||||
|
||||
@@ -443,7 +443,7 @@ class HomeScreen : public UIScreen {
|
||||
const int lh = display.getLineHeight();
|
||||
const int cw = display.getCharWidth();
|
||||
const int ind = cw + 2; // single-char indicator width
|
||||
const int ind_h = display.isLemonFont() ? lh - 2 : lh;
|
||||
const int ind_h = display.isSingleFont() ? lh - 2 : lh;
|
||||
const int ind_gap = display.isLandscape() ? 3 : 1; // gap between indicator boxes
|
||||
|
||||
int battLeftX;
|
||||
@@ -2942,7 +2942,7 @@ void UITask::applyBrightness() {
|
||||
|
||||
void UITask::applyFont() {
|
||||
if (_display != NULL && _node_prefs != NULL) {
|
||||
_display->setLemonFont(_node_prefs->use_lemon_font != 0);
|
||||
_display->setSingleFont(_node_prefs->use_lemon_font != 0);
|
||||
_next_refresh = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user