MCPcopy Create free account
hub / github.com/KDE/kdevelop / textWord

Method textWord

kdevplatform/shell/textdocument.cpp:524–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524QString TextDocument::textWord() const
525{
526 VERIFY_FOREGROUND_LOCKED
527 Q_D(const TextDocument);
528
529 if (!d->document) {
530 return QString();
531 }
532
533 KTextEditor::View *view = activeTextView();
534
535 if (view) {
536 KTextEditor::Cursor start = view->cursorPosition();
537 qCDebug(SHELL) << "got start position from view:" << start.line() << start.column();
538 QString linestr = textLine();
539 int startPos = qMax( qMin( start.column(), linestr.length() - 1 ), 0 );
540 int endPos = startPos;
541 startPos --;
542 while (startPos >= 0 &&
543 (linestr[startPos].isLetterOrNumber() || linestr[startPos] == QLatin1Char('_') || linestr[startPos] == QLatin1Char('~'))) {
544 --startPos;
545 }
546
547 while (endPos < linestr.length() &&
548 (linestr[endPos].isLetterOrNumber() || linestr[endPos] == QLatin1Char('_') || linestr[endPos] == QLatin1Char('~'))) {
549 ++endPos;
550 }
551 if( startPos != endPos )
552 {
553 qCDebug(SHELL) << "found word" << startPos << endPos << linestr.mid( startPos+1, endPos - startPos - 1 );
554 return linestr.mid( startPos + 1, endPos - startPos - 1 );
555 }
556 }
557
558 return PartDocument::textWord();
559}
560
561void TextDocument::setTextSelection(const KTextEditor::Range &range)
562{

Callers 2

showQuickOpenWidgetMethod · 0.45
patternFromSelectionFunction · 0.45

Calls 6

midMethod · 0.80
QStringClass · 0.70
cursorPositionMethod · 0.45
lineMethod · 0.45
columnMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected