Skip to content

Commit 69ba98f

Browse files
authored
Merge pull request #13 from meshtastic/newline
Always break on newline character
2 parents 1800ad5 + b6ca371 commit 69ba98f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/OLEDDisplay.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,18 @@ uint16_t OLEDDisplay::drawStringMaxWidth(int16_t xMove, int16_t yMove, uint16_t
683683
continue;
684684
strWidth += pgm_read_byte(fontData + JUMPTABLE_START + (c - firstChar) * JUMPTABLE_BYTES + JUMPTABLE_WIDTH);
685685

686+
// Always break on newline
687+
if (text[i] == '\n') {
688+
drawStringResult = drawStringInternal(xMove, yMove + (lineNumber++) * lineHeight , &text[lastDrawnPos], i - lastDrawnPos, strWidth, true);
689+
if (firstLineChars == 0)
690+
firstLineChars = i;
691+
692+
lastDrawnPos = i + 1;
693+
strWidth = 0;
694+
if (drawStringResult == 0) // we are past the display already?
695+
break;
696+
}
697+
686698
// Always try to break on a space, dash or slash
687699
if (text[i] == ' ' || text[i]== '-' || text[i] == '/') {
688700
preferredBreakpoint = i + 1;

0 commit comments

Comments
 (0)