| 108 | } |
| 109 | |
| 110 | void ScrollableTextArea::fromString(const String &text) { |
| 111 | clear(); |
| 112 | int startIdx = 0; |
| 113 | int endIdx = 0; |
| 114 | |
| 115 | while (endIdx < text.length()) { |
| 116 | if (text[endIdx] == '\n') { |
| 117 | addLine(text.substring(startIdx, endIdx)); |
| 118 | startIdx = endIdx + 1; |
| 119 | } |
| 120 | |
| 121 | endIdx++; |
| 122 | } |
| 123 | |
| 124 | // Add the last line if there’s remaining text (text does not ends with \n) |
| 125 | if (startIdx < text.length()) { addLine(text.substring(startIdx, endIdx)); } |
| 126 | } |
| 127 | |
| 128 | // for devices it will act as a scrollable text area |
| 129 | void ScrollableTextArea::addLine(const String &text) { |
no test coverage detected