More code cleanup and comments
This commit is contained in:
parent
f4dc64fd69
commit
af93986495
12
src/main.ino
12
src/main.ino
@ -740,13 +740,11 @@ int renderFormattedMessage(String message, int cursorY, int lineHeight, bool hig
|
|||||||
cursorY += lineHeight;
|
cursorY += lineHeight;
|
||||||
tft.setCursor(0, cursorY);
|
tft.setCursor(0, cursorY);
|
||||||
}
|
}
|
||||||
if (c == ' ') {
|
if (c == ' ') { // Handle spaces separately to ensure background color is applied (do we need this anyhmore since .trim() was removed?)
|
||||||
// Draw background for spaces
|
|
||||||
int spaceWidth = tft.textWidth(" ");
|
int spaceWidth = tft.textWidth(" ");
|
||||||
tft.fillRect(tft.getCursorX(), tft.getCursorY(), spaceWidth, lineHeight, bgColor);
|
tft.fillRect(tft.getCursorX(), tft.getCursorY(), spaceWidth, lineHeight, bgColor);
|
||||||
tft.setCursor(tft.getCursorX() + spaceWidth, tft.getCursorY());
|
tft.setCursor(tft.getCursorX() + spaceWidth, tft.getCursorY());
|
||||||
} else {
|
} else {
|
||||||
// Ensure that background color is applied to characters
|
|
||||||
tft.fillRect(tft.getCursorX(), tft.getCursorY(), tft.textWidth(String(c)), lineHeight, bgColor);
|
tft.fillRect(tft.getCursorX(), tft.getCursorY(), tft.textWidth(String(c)), lineHeight, bgColor);
|
||||||
tft.setTextColor(fgColor, bgColor);
|
tft.setTextColor(fgColor, bgColor);
|
||||||
tft.print(c);
|
tft.print(c);
|
||||||
@ -755,7 +753,7 @@ int renderFormattedMessage(String message, int cursorY, int lineHeight, bool hig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure trailing spaces are displayed with background color
|
// Ensure trailing spaces are displayed with background color (do we need this anymore since .trim() was removed?)
|
||||||
if (message.endsWith(" ")) {
|
if (message.endsWith(" ")) {
|
||||||
int trailingSpaces = 0;
|
int trailingSpaces = 0;
|
||||||
for (int i = message.length() - 1; i >= 0 && message[i] == ' '; i--) {
|
for (int i = message.length() - 1; i >= 0 && message[i] == ' '; i--) {
|
||||||
@ -913,7 +911,7 @@ void addLine(String senderNick, String message, String type, uint16_t errorColor
|
|||||||
formattedMessage = "* " + senderNick + " " + message;
|
formattedMessage = "* " + senderNick + " " + message;
|
||||||
} else if (type == "error") {
|
} else if (type == "error") {
|
||||||
formattedMessage = "ERROR " + message;
|
formattedMessage = "ERROR " + message;
|
||||||
senderNick = "ERROR"; // Use ERROR as senderNick to highlight it in red
|
senderNick = "ERROR"; // Probably a better way to handle this than emulating a NICK
|
||||||
} else {
|
} else {
|
||||||
formattedMessage = senderNick + ": " + message;
|
formattedMessage = senderNick + ": " + message;
|
||||||
}
|
}
|
||||||
@ -1054,10 +1052,10 @@ void displayInputLine() {
|
|||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
|
|
||||||
int inputWidth = SCREEN_WIDTH - tft.textWidth("> ");
|
|
||||||
String displayInput = inputBuffer;
|
String displayInput = inputBuffer;
|
||||||
int displayWidth = tft.textWidth(displayInput);
|
int displayWidth = tft.textWidth(displayInput);
|
||||||
|
int inputWidth = SCREEN_WIDTH - tft.textWidth("> ");
|
||||||
|
|
||||||
// Allow the input to scroll if it exceeds the screen width
|
// Allow the input to scroll if it exceeds the screen width
|
||||||
while (displayWidth > inputWidth) {
|
while (displayWidth > inputWidth) {
|
||||||
displayInput = displayInput.substring(1);
|
displayInput = displayInput.substring(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user