MCPcopy Create free account
hub / github.com/KDE/kdiff3 / calcTokenPos

Method calcTokenPos

src/Utils.cpp:134–156  ·  view source on GitHub ↗

TODO: Needed? Only user of isCTokenChar. Calculate where a token starts and ends, given the x-position on screen.

Source from the content-addressed store, hash-verified

132//TODO: Needed? Only user of isCTokenChar.
133/// Calculate where a token starts and ends, given the x-position on screen.
134void Utils::calcTokenPos(const QString& s, qint32 posOnScreen, qsizetype& pos1, qsizetype& pos2)
135{
136 qsizetype pos = std::max(0, posOnScreen);
137 if(pos >= s.length())
138 {
139 pos1 = s.length();
140 pos2 = s.length();
141 return;
142 }
143
144 pos1 = pos;
145 pos2 = pos + 1;
146
147 if(isCTokenChar(s[pos1]))
148 {
149 while(pos1 >= 0 && isCTokenChar(s[pos1]))
150 --pos1;
151 ++pos1;
152
153 while(pos2 < s.length() && isCTokenChar(s[pos2]))
154 ++pos2;
155 }
156}
157
158QString Utils::calcHistoryLead(const QString& s)
159{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected