Compare commits

...

5 Commits

Author SHA1 Message Date
Dionysus
5312071d1c
Merge pull request #7 from imnotacoder-eeeee/main
Fixed multi-line with my beta fix, and normalized colors to match master
2024-05-29 23:15:03 -04:00
imnotacoder-eeeee
432ccdca90 MULTILINE FIX BETA, SET COLORS TO MASTER BRANCHES 2024-05-29 21:35:51 -04:00
imnotacoder-eeeee
252e97f139 multi-line doesnt seem bugged and joins still work, will work on the small gap in buffer at the bottom 2024-05-29 21:34:07 -04:00
imnotacoder-eeeee
711e8dee5b multi-line doesnt seem bugged and joins still work, will work on the small gap in buffer at the bottom 2024-05-29 21:31:51 -04:00
e
8ff6e5811e
Update README.md
Changed /debug to /info.
2024-05-29 21:18:10 -04:00
2 changed files with 41 additions and 9 deletions

View File

@ -34,7 +34,7 @@ The device will scan for WiFi networks on boot. Once the list is displayed, you
###### IRC commands
| Command | Description |
| --------------- | --------------------------- |
| `/debug` | Show hardware information |
| `/info` | Show hardware information |
| `/me <message>` | Send an ACTION message |
| `/nick <new>` | Change your NICK on IRC |
| `/raw <data>` | Send RAW data to the server |
@ -98,4 +98,4 @@ The device will scan for WiFi networks on boot. Once the list is displayed, you
___
###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/acid-drop) • [SuperNETs](https://git.supernets.org/acidvegas/acid-drop) • [GitHub](https://github.com/acidvegas/acid-drop) • [GitLab](https://gitlab.com/acidvegas/acid-drop) • [Codeberg](https://codeberg.org/acidvegas/acid-drop)
###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/acid-drop) • [SuperNETs](https://git.supernets.org/acidvegas/acid-drop) • [GitHub](https://github.com/acidvegas/acid-drop) • [GitLab](https://gitlab.com/acidvegas/acid-drop) • [Codeberg](https://codeberg.org/acidvegas/acid-drop)

View File

@ -555,18 +555,31 @@ int calculateLinesRequired(String message) {
int linesRequired = 1;
int lineWidth = 0;
for (char c : message) {
lineWidth += tft.textWidth(String(c));
if (lineWidth > SCREEN_WIDTH) {
linesRequired++;
lineWidth = tft.textWidth(String(c));
for (unsigned int i = 0; i < message.length(); i++) {
char c = message[i];
if (c == '\x03') {
// Skip color code sequences from calculate instead of render to solve nick overlay issue
while (i < message.length() && (isdigit(message[i + 1]) || message[i + 1] == ',')) {
i++;
if (isdigit(message[i + 1])) {
i++;
}
if (message[i] == ',' && isdigit(message[i + 1])) {
i++;
}
}
} else if (c != '\x02' && c != '\x0F' && c != '\x1F') { // Ignore other formatting codes as they are not as prevalent
lineWidth += tft.textWidth(String(c));
if (lineWidth > SCREEN_WIDTH) {
linesRequired++;
lineWidth = tft.textWidth(String(c));
}
}
}
return linesRequired;
}
void displayCenteredText(String text) {
tft.fillScreen(TFT_BLACK);
tft.setTextDatum(MC_DATUM);
@ -872,10 +885,29 @@ void displayLines() {
tft.fillRect(0, STATUS_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - STATUS_BAR_HEIGHT - INPUT_LINE_HEIGHT, TFT_BLACK);
int cursorY = STATUS_BAR_HEIGHT;
int totalLinesHeight = 0;
std::vector<int> lineHeights;
// Calculate total height needed for all lines
for (const String& line : lines) {
int lineHeight = calculateLinesRequired(line) * CHAR_HEIGHT;
lineHeights.push_back(lineHeight);
totalLinesHeight += lineHeight;
}
// Remove lines from the top if they exceed the screen height
while (totalLinesHeight > SCREEN_HEIGHT - STATUS_BAR_HEIGHT - INPUT_LINE_HEIGHT) {
totalLinesHeight -= lineHeights.front();
lines.erase(lines.begin());
mentions.erase(mentions.begin());
lineHeights.erase(lineHeights.begin());
}
// Render each line
for (size_t i = 0; i < lines.size(); ++i) {
const String& line = lines[i];
bool mention = mentions[i];
tft.setCursor(0, cursorY);
if (line.startsWith("JOIN ")) {