MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / GetText

Method GetText

plugins/Cardinal/src/DearImGuiColorTextEditor/TextEditor.cpp:77–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77std::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
114TextEditor::Coordinates TextEditor::GetActualCursorCoordinates() const
115{

Callers 1

getTextMethod · 0.80

Calls 3

CoordinatesClass · 0.85
sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected