| 75 | } |
| 76 | |
| 77 | std::string TextEditor::GetText(const Coordinates & aStart, const Coordinates & aEnd) const |
| 78 | { |
| 79 | std::string result; |
| 80 | |
| 81 | auto lstart = aStart.mLine; |
| 82 | auto lend = aEnd.mLine; |
| 83 | auto istart = GetCharacterIndex(aStart); |
| 84 | auto iend = GetCharacterIndex(aEnd); |
| 85 | size_t s = 0; |
| 86 | |
| 87 | for (size_t i = lstart; i < lend; i++) |
| 88 | s += mLines[i].size(); |
| 89 | |
| 90 | result.reserve(s + s / 8); |
| 91 | |
| 92 | while (istart < iend || lstart < lend) |
| 93 | { |
| 94 | if (lstart >= (int)mLines.size()) |
| 95 | break; |
| 96 | |
| 97 | auto& line = mLines[lstart]; |
| 98 | if (istart < (int)line.size()) |
| 99 | { |
| 100 | result += line[istart].mChar; |
| 101 | istart++; |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | istart = 0; |
| 106 | ++lstart; |
| 107 | result += '\n'; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return result; |
| 112 | } |
| 113 | |
| 114 | TextEditor::Coordinates TextEditor::GetActualCursorCoordinates() const |
| 115 | { |
no test coverage detected