| 1158 | } |
| 1159 | |
| 1160 | void TextEditor::SetText(const std::string & aText) |
| 1161 | { |
| 1162 | mLines.clear(); |
| 1163 | mLines.emplace_back(Line()); |
| 1164 | for (auto chr : aText) |
| 1165 | { |
| 1166 | if (chr == '\r') |
| 1167 | { |
| 1168 | // ignore the carriage return character |
| 1169 | } |
| 1170 | else if (chr == '\n') |
| 1171 | mLines.emplace_back(Line()); |
| 1172 | else |
| 1173 | { |
| 1174 | mLines.back().emplace_back(Glyph(chr, PaletteIndex::Default)); |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | mTextChanged = true; |
| 1179 | mScrollToTop = true; |
| 1180 | |
| 1181 | mUndoBuffer.clear(); |
| 1182 | mUndoIndex = 0; |
| 1183 | |
| 1184 | Colorize(); |
| 1185 | } |
| 1186 | |
| 1187 | void TextEditor::SetTextLines(const std::vector<std::string> & aLines) |
| 1188 | { |
no test coverage detected