mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 10:46:12 +00:00
feat: show @recipient as 'To: nick' bar in fullscreen message view
When a message starts with @nick, the fullscreen view expands the header to show a second row 'To: nick' below the sender name, and displays the message body without the @nick prefix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9b61bc3028
commit
8f566732ed
@@ -42,35 +42,59 @@ struct FullscreenMsgView {
|
|||||||
int render(DisplayDriver& display, const char* sender, const char* text,
|
int render(DisplayDriver& display, const char* sender, const char* text,
|
||||||
bool has_prev, bool has_next) {
|
bool has_prev, bool has_next) {
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
|
|
||||||
|
// detect @recipient at start of message
|
||||||
|
char to_nick[32] = "";
|
||||||
|
const char* body = text;
|
||||||
|
if (text[0] == '@') {
|
||||||
|
const char* sp = strchr(text, ' ');
|
||||||
|
if (sp && sp[1]) {
|
||||||
|
int len = (int)(sp - text) - 1;
|
||||||
|
if (len >= (int)sizeof(to_nick)) len = sizeof(to_nick) - 1;
|
||||||
|
memcpy(to_nick, text + 1, len);
|
||||||
|
to_nick[len] = '\0';
|
||||||
|
body = sp + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int header_h = to_nick[0] ? 20 : 10;
|
||||||
|
const int startY = header_h + 2;
|
||||||
|
const int visible = (display.height() - startY - FS_LINE_H) / FS_LINE_H;
|
||||||
|
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.fillRect(0, 0, display.width(), 10);
|
display.fillRect(0, 0, display.width(), header_h);
|
||||||
display.setColor(DisplayDriver::DARK);
|
display.setColor(DisplayDriver::DARK);
|
||||||
display.drawTextEllipsized(2, 1, display.width() - 4, sender);
|
display.drawTextEllipsized(2, 1, display.width() - 4, sender);
|
||||||
|
if (to_nick[0]) {
|
||||||
|
char to_label[36];
|
||||||
|
snprintf(to_label, sizeof(to_label), "To: %s", to_nick);
|
||||||
|
display.drawTextEllipsized(2, 11, display.width() - 4, to_label);
|
||||||
|
}
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
|
|
||||||
char trans_text[512];
|
char trans_text[512];
|
||||||
display.translateUTF8ToBlocks(trans_text, text, sizeof(trans_text));
|
display.translateUTF8ToBlocks(trans_text, body, sizeof(trans_text));
|
||||||
char lines[12][FS_CHARS + 1];
|
char lines[12][FS_CHARS + 1];
|
||||||
int lcount = wrapLines(trans_text, lines, 12);
|
int lcount = wrapLines(trans_text, lines, 12);
|
||||||
int max_scroll = lcount > FS_VISIBLE ? lcount - FS_VISIBLE : 0;
|
int max_scroll = lcount > visible ? lcount - visible : 0;
|
||||||
if (scroll > max_scroll) scroll = max_scroll;
|
if (scroll > max_scroll) scroll = max_scroll;
|
||||||
|
|
||||||
for (int i = 0; i < FS_VISIBLE && (scroll + i) < lcount; i++) {
|
for (int i = 0; i < visible && (scroll + i) < lcount; i++) {
|
||||||
display.setCursor(0, FS_START_Y + i * FS_LINE_H);
|
display.setCursor(0, startY + i * FS_LINE_H);
|
||||||
display.print(lines[scroll + i]);
|
display.print(lines[scroll + i]);
|
||||||
}
|
}
|
||||||
if (scroll > 0) {
|
if (scroll > 0) {
|
||||||
display.setColor(DisplayDriver::DARK);
|
display.setColor(DisplayDriver::DARK);
|
||||||
display.fillRect(display.width() - 6, FS_START_Y, 6, FS_LINE_H);
|
display.fillRect(display.width() - 6, startY, 6, FS_LINE_H);
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.setCursor(display.width() - 6, FS_START_Y);
|
display.setCursor(display.width() - 6, startY);
|
||||||
display.print("^");
|
display.print("^");
|
||||||
}
|
}
|
||||||
if (scroll < max_scroll) {
|
if (scroll < max_scroll) {
|
||||||
display.setColor(DisplayDriver::DARK);
|
display.setColor(DisplayDriver::DARK);
|
||||||
display.fillRect(display.width() - 6, FS_START_Y + (FS_VISIBLE - 1) * FS_LINE_H, 6, FS_LINE_H);
|
display.fillRect(display.width() - 6, startY + (visible - 1) * FS_LINE_H, 6, FS_LINE_H);
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.setCursor(display.width() - 6, FS_START_Y + (FS_VISIBLE - 1) * FS_LINE_H);
|
display.setCursor(display.width() - 6, startY + (visible - 1) * FS_LINE_H);
|
||||||
display.print("v");
|
display.print("v");
|
||||||
}
|
}
|
||||||
if (has_next) {
|
if (has_next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user