Skip to content

Commit

Permalink
Merge pull request #13 from meshtastic/newline
Browse files Browse the repository at this point in the history
Always break on newline character
  • Loading branch information
thebentern authored Jun 13, 2024
2 parents 1800ad5 + b6ca371 commit 69ba98f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/OLEDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,18 @@ uint16_t OLEDDisplay::drawStringMaxWidth(int16_t xMove, int16_t yMove, uint16_t
continue;
strWidth += pgm_read_byte(fontData + JUMPTABLE_START + (c - firstChar) * JUMPTABLE_BYTES + JUMPTABLE_WIDTH);

// Always break on newline
if (text[i] == '\n') {
drawStringResult = drawStringInternal(xMove, yMove + (lineNumber++) * lineHeight , &text[lastDrawnPos], i - lastDrawnPos, strWidth, true);
if (firstLineChars == 0)
firstLineChars = i;

lastDrawnPos = i + 1;
strWidth = 0;
if (drawStringResult == 0) // we are past the display already?
break;
}

// Always try to break on a space, dash or slash
if (text[i] == ' ' || text[i]== '-' || text[i] == '/') {
preferredBreakpoint = i + 1;
Expand Down

0 comments on commit 69ba98f

Please sign in to comment.