for devices it will act as a scrollable text area
| 127 | |
| 128 | // for devices it will act as a scrollable text area |
| 129 | void ScrollableTextArea::addLine(const String &text) { |
| 130 | if (text.isEmpty()) { |
| 131 | linesBuffer.emplace_back(""); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | String buff; |
| 136 | size_t start = 0; |
| 137 | bool firstLine = true; |
| 138 | |
| 139 | // Automatically split into multiple lines |
| 140 | while (start < text.length()) { |
| 141 | size_t len = _maxCharactersPerLine; |
| 142 | |
| 143 | if (!firstLine && _indentWrappedLines) { |
| 144 | buff = " " + text.substring(start, start + len - 1); // Reduce length for space |
| 145 | start += len - 1; |
| 146 | } else { |
| 147 | buff = text.substring(start, start + len); |
| 148 | start += len; |
| 149 | } |
| 150 | if (buff.endsWith("\r")) buff.remove(buff.length() - 1); |
| 151 | |
| 152 | linesBuffer.emplace_back(buff); |
| 153 | firstLine = false; |
| 154 | } |
| 155 | |
| 156 | _redraw = true; |
| 157 | } |
| 158 | |
| 159 | void ScrollableTextArea::draw(bool force) { |
| 160 | if (!_redraw && !force) return; |
no outgoing calls
no test coverage detected