| 522 | } |
| 523 | |
| 524 | QString 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 | |
| 561 | void TextDocument::setTextSelection(const KTextEditor::Range &range) |
| 562 | { |