Added input buffer protection so we do not exceed the 512 limit IRC servers have

This commit is contained in:
Dionysus 2024-05-28 19:45:12 -04:00
parent 0d59ab3b7e
commit eec732eb29
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
1 changed files with 8 additions and 95 deletions

View File

@ -531,100 +531,7 @@ uint16_t getColorFromCode(int colorCode) {
case 2: return tft.color565(0, 0, 128); // Dark Blue (Navy)
case 3: return TFT_GREEN;
case 4: return TFT_RED;
case 5: return tft.color565(128, 0, 0); // Brown (Maroon)
case 6: return tft.color565(128, 0, 128); // Purple
case 7: return tft.color565(255, 165, 0); // Orange
case 8: return TFT_YELLOW;
case 9: return tft.color565(144, 238, 144); // Light Green
case 10: return tft.color565(0, 255, 255); // Cyan (Light Blue)
case 11: return tft.color565(224, 255, 255); // Light Cyan (Aqua)
case 12: return TFT_BLUE;
case 13: return tft.color565(255, 192, 203); // Pink (Light Purple)
case 14: return tft.color565(128, 128, 128); // Grey
case 15: return tft.color565(211, 211, 211); // Light Grey
case 16: return 0x4000;
case 17: return 0x4100;
case 18: return 0x4220;
case 19: return 0x3220;
case 20: return 0x0220;
case 21: return 0x0225;
case 22: return 0x0228;
case 23: return 0x0128;
case 24: return 0x0008;
case 25: return 0x2808;
case 26: return 0x4008;
case 27: return 0x4005;
case 28: return 0x7000;
case 29: return 0x71C0;
case 30: return 0x73A0;
case 31: return 0x53A0;
case 32: return 0x03A0;
case 33: return 0x03A9;
case 34: return 0x03AE;
case 35: return 0x020E;
case 36: return 0x000E;
case 37: return 0x480E;
case 38: return 0x700E;
case 39: return 0x7008;
case 40: return 0xB000;
case 41: return 0xB300;
case 42: return 0xB5A0;
case 43: return 0x7DA0;
case 44: return 0x05A0;
case 45: return 0x05AE;
case 46: return 0x05B6;
case 47: return 0x0316;
case 48: return 0x0016;
case 49: return 0x7016;
case 50: return 0xB016;
case 51: return 0xB00D;
case 52: return 0xF800;
case 53: return 0xFC60;
case 54: return 0xFFE0;
case 55: return 0xB7E0;
case 56: return 0x07E0;
case 57: return 0x07F4;
case 58: return 0x07FF;
case 59: return 0x047F;
case 60: return 0x001F;
case 61: return 0xA01F;
case 62: return 0xF81F;
case 63: return 0xF813;
case 64: return 0xFACB;
case 65: return 0xFDAB;
case 66: return 0xFFEE;
case 67: return 0xCFEC;
case 68: return 0x6FED;
case 69: return 0x67F9;
case 70: return 0x6FFF;
case 71: return 0x5DBF;
case 72: return 0x5ADF;
case 73: return 0xC2DF;
case 74: return 0xFB3F;
case 75: return 0xFAD7;
case 76: return 0xFCF3;
case 77: return 0xFE93;
case 78: return 0xFFF3;
case 79: return 0xE7F3;
case 80: return 0x9FF3;
case 81: return 0x9FFB;
case 82: return 0x9FFF;
case 83: return 0x9E9F;
case 84: return 0x9CFF;
case 85: return 0xDCFF;
case 86: return 0xFCFF;
case 87: return 0xFCBA;
case 88: return 0x0000;
case 89: return 0x1082;
case 90: return 0x2945;
case 91: return 0x31A6;
case 92: return 0x4A69;
case 93: return 0x632C;
case 94: return 0x8410;
case 95: return 0x9CF3;
case 96: return 0xBDF7;
case 97: return 0xE71C;
case 98: return 0xFFFF;
default: return TFT_WHITE;
}
}
@ -1036,7 +943,7 @@ void handleKeyboardInput(char key) {
if (!screenOn)
turnOnScreen();
}
} else {
} else if (inputBuffer.length() <= 510) { // Ensure we do not exceed 512 characters (IRC limit)
inputBuffer += key;
displayInputLine();
lastActivityTime = millis();
@ -1063,7 +970,13 @@ void displayInputLine() {
displayWidth = tft.textWidth(displayInput);
}
// Add a visual indicator if the max input length is reached
if (inputBuffer.length() >= 510) {
tft.setTextColor(TFT_RED);
}
tft.print("> " + displayInput);
tft.setTextColor(TFT_WHITE); // Reset text color
}