Lines Matching defs:pos
88 const std::vector<SkRect>& pos = line.fCursorPos;
89 for (size_t i = 0; i < pos.size(); ++i) {
90 if (pos[i] != kUnsetRect && pos[i].contains(pt.x(), pt.y())) {
129 SkRect pos = {0, 0, 0, 0};
131 pos = cLine.fCursorPos[cursor.fTextByteIndex];
133 pos.fRight = pos.fLeft + 1;
134 pos.fLeft -= 1;
135 return offset(pos, cLine.fOrigin);
146 Editor::TextPosition Editor::insert(TextPosition pos, const char* utf8Text, size_t byteLen) {
148 return pos;
150 pos = this->move(Editor::Movement::kNowhere, pos);
152 if (pos.fParagraphIndex < fLines.size()) {
153 fLines[pos.fParagraphIndex].fText.insert(pos.fTextByteIndex, utf8Text, byteLen);
154 this->markDirty(&fLines[pos.fParagraphIndex]);
156 SkASSERT(pos.fParagraphIndex == fLines.size());
157 SkASSERT(pos.fTextByteIndex == 0);
160 pos = Editor::TextPosition{pos.fTextByteIndex + byteLen, pos.fParagraphIndex};
161 size_t newlinecount = count_char(fLines[pos.fParagraphIndex].fText, '\n');
163 StringSlice src = std::move(fLines[pos.fParagraphIndex].fText);
164 std::vector<TextLine>::const_iterator next = fLines.begin() + pos.fParagraphIndex + 1;
166 TextLine* line = &fLines[pos.fParagraphIndex];
171 return pos;
280 Editor::TextPosition Editor::move(Editor::Movement move, Editor::TextPosition pos) const {
285 if (pos.fParagraphIndex >= fLines.size()) {
286 pos.fParagraphIndex = fLines.size() - 1;
287 pos.fTextByteIndex = fLines[pos.fParagraphIndex].fText.size();
289 pos.fTextByteIndex = align_column(fLines[pos.fParagraphIndex].fText, pos.fTextByteIndex);
292 SkASSERT(pos.fParagraphIndex < fLines.size());
293 SkASSERT(pos.fTextByteIndex <= fLines[pos.fParagraphIndex].fText.size());
295 SkASSERT(pos.fTextByteIndex == fLines[pos.fParagraphIndex].fText.size() ||
296 !is_utf8_continuation(fLines[pos.fParagraphIndex].fText.begin()[pos.fTextByteIndex]));
302 if (0 == pos.fTextByteIndex) {
303 if (pos.fParagraphIndex > 0) {
304 --pos.fParagraphIndex;
305 pos.fTextByteIndex = fLines[pos.fParagraphIndex].fText.size();
308 const auto& str = fLines[pos.fParagraphIndex].fText;
309 pos.fTextByteIndex =
310 prev_utf8(begin(str) + pos.fTextByteIndex, begin(str)) - begin(str);
314 if (fLines[pos.fParagraphIndex].fText.size() == pos.fTextByteIndex) {
315 if (pos.fParagraphIndex + 1 < fLines.size()) {
316 ++pos.fParagraphIndex;
317 pos.fTextByteIndex = 0;
320 const auto& str = fLines[pos.fParagraphIndex].fText;
321 pos.fTextByteIndex =
322 next_utf8(begin(str) + pos.fTextByteIndex, end(str)) - begin(str);
327 const std::vector<size_t>& list = fLines[pos.fParagraphIndex].fLineEndOffsets;
328 size_t f = find_first_larger(list, pos.fTextByteIndex);
329 pos.fTextByteIndex = f > 0 ? list[f - 1] : 0;
334 const std::vector<size_t>& list = fLines[pos.fParagraphIndex].fLineEndOffsets;
335 size_t f = find_first_larger(list, pos.fTextByteIndex);
337 pos.fTextByteIndex = list[f] > 0 ? list[f] - 1 : 0;
339 pos.fTextByteIndex = fLines[pos.fParagraphIndex].fText.size();
345 SkASSERT(pos.fTextByteIndex < fLines[pos.fParagraphIndex].fCursorPos.size());
346 float x = fLines[pos.fParagraphIndex].fCursorPos[pos.fTextByteIndex].left();
347 const std::vector<size_t>& list = fLines[pos.fParagraphIndex].fLineEndOffsets;
348 size_t f = find_first_larger(list, pos.fTextByteIndex);
352 pos.fTextByteIndex = find_closest_x(fLines[pos.fParagraphIndex].fCursorPos, x,
355 } else if (pos.fParagraphIndex > 0) {
356 --pos.fParagraphIndex;
357 const auto& newLine = fLines[pos.fParagraphIndex];
360 pos.fTextByteIndex = find_closest_x(newLine.fCursorPos, x,
364 pos.fTextByteIndex = find_closest_x(newLine.fCursorPos, x, 0,
368 pos.fTextByteIndex =
369 align_column(fLines[pos.fParagraphIndex].fText, pos.fTextByteIndex);
374 const std::vector<size_t>& list = fLines[pos.fParagraphIndex].fLineEndOffsets;
375 float x = fLines[pos.fParagraphIndex].fCursorPos[pos.fTextByteIndex].left();
377 size_t f = find_first_larger(list, pos.fTextByteIndex);
379 const auto& bounds = fLines[pos.fParagraphIndex].fCursorPos;
380 pos.fTextByteIndex = find_closest_x(bounds, x, list[f],
383 } else if (pos.fParagraphIndex + 1 < fLines.size()) {
384 ++pos.fParagraphIndex;
385 const auto& bounds = fLines[pos.fParagraphIndex].fCursorPos;
386 const std::vector<size_t>& l2 = fLines[pos.fParagraphIndex].fLineEndOffsets;
387 pos.fTextByteIndex = find_closest_x(bounds, x, 0,
390 pos.fTextByteIndex = fLines[pos.fParagraphIndex].fText.size();
392 pos.fTextByteIndex =
393 align_column(fLines[pos.fParagraphIndex].fText, pos.fTextByteIndex);
398 if (pos.fTextByteIndex == 0) {
399 pos = this->move(Editor::Movement::kLeft, pos);
402 const std::vector<bool>& words = fLines[pos.fParagraphIndex].fWordBoundaries;
403 SkASSERT(words.size() == fLines[pos.fParagraphIndex].fText.size());
405 --pos.fTextByteIndex;
406 } while (pos.fTextByteIndex > 0 && !words[pos.fTextByteIndex]);
411 const StringSlice& text = fLines[pos.fParagraphIndex].fText;
412 if (pos.fTextByteIndex == text.size()) {
413 pos = this->move(Editor::Movement::kRight, pos);
416 const std::vector<bool>& words = fLines[pos.fParagraphIndex].fWordBoundaries;
419 ++pos.fTextByteIndex;
420 } while (pos.fTextByteIndex < text.size() && !words[pos.fTextByteIndex]);
425 return pos;
438 for (TextPosition pos = std::min(options.fSelectionBegin, options.fSelectionEnd, cmp),
440 pos < end;
441 pos = this->move(Editor::Movement::kRight, pos))
443 SkASSERT(pos.fParagraphIndex < fLines.size());
444 const TextLine& l = fLines[pos.fParagraphIndex];
445 c->drawRect(offset(l.fCursorPos[pos.fTextByteIndex], l.fOrigin), selection);