Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Context not available. | |||||
58 | #include <KMessageWidget> | 58 | #include <KMessageWidget> | ||
---|---|---|---|---|---|
59 | #include <KIO/StatJob> | 59 | #include <KIO/StatJob> | ||
60 | 60 | | |||
61 | #include <memory> | ||||
62 | | ||||
61 | // Konsole | 63 | // Konsole | ||
62 | #include "Filter.h" | 64 | #include "Filter.h" | ||
63 | #include "konsoledebug.h" | 65 | #include "konsoledebug.h" | ||
Context not available. | |||||
417 | , _usesMouseTracking(false) | 419 | , _usesMouseTracking(false) | ||
418 | , _alternateScrolling(true) | 420 | , _alternateScrolling(true) | ||
419 | , _bracketedPasteMode(false) | 421 | , _bracketedPasteMode(false) | ||
420 | , _iPntSel(QPoint()) | 422 | , _initialSelectionPoint(QPoint()) | ||
421 | , _pntSel(QPoint()) | 423 | , _currentSelectionPoint(QPoint()) | ||
422 | , _tripleSelBegin(QPoint()) | 424 | , _tripleSelBegin(QPoint()) | ||
423 | , _actSel(0) | 425 | , _actSel(0) | ||
424 | , _wordSelectionMode(false) | 426 | , _wordSelectionMode(false) | ||
Context not available. | |||||
2476 | _screenWindow->clearSelection(); | 2478 | _screenWindow->clearSelection(); | ||
2477 | 2479 | | |||
2478 | pos.ry() += _scrollBar->value(); | 2480 | pos.ry() += _scrollBar->value(); | ||
2479 | _iPntSel = _pntSel = pos; | 2481 | _initialSelectionPoint = _currentSelectionPoint = pos; | ||
2480 | _actSel = 1; // left mouse button pressed but nothing selected yet. | 2482 | _actSel = 1; // left mouse button pressed but nothing selected yet. | ||
2481 | } else if (_usesMouseTracking && !_readOnly) { | 2483 | } else if (_usesMouseTracking && !_readOnly) { | ||
2482 | emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0); | 2484 | emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0); | ||
Context not available. | |||||
2655 | 2657 | | |||
2656 | int linesBeyondWidget = 0; | 2658 | int linesBeyondWidget = 0; | ||
2657 | 2659 | | |||
2658 | QRect textBounds(tLx + _contentRect.left(), | 2660 | const QRect textBounds(tLx + _contentRect.left(), | ||
2659 | tLy + _contentRect.top(), | 2661 | tLy + _contentRect.top(), | ||
2660 | _usedColumns * _fontWidth - 1, | 2662 | _usedColumns * _fontWidth - 1, | ||
2661 | _usedLines * _fontHeight - 1); | 2663 | _usedLines * _fontHeight - 1); | ||
2662 | 2664 | | |||
2665 | const QRect characterBounds(0, 0, _columns, _lines); | ||||
2666 | | ||||
2663 | QPoint pos = position; | 2667 | QPoint pos = position; | ||
2664 | 2668 | | |||
2665 | // Adjust position within text area bounds. | 2669 | // Adjust position within text area bounds. | ||
Context not available. | |||||
2679 | 2683 | | |||
2680 | int charColumn = 0; | 2684 | int charColumn = 0; | ||
2681 | int charLine = 0; | 2685 | int charLine = 0; | ||
2682 | getCharacterPosition(pos, charLine, charColumn, true); | 2686 | getCharacterPosition(pos, charLine, charColumn, !_wordSelectionMode && !_lineSelectionMode); | ||
2683 | 2687 | | |||
2684 | QPoint here = QPoint(charColumn, charLine); | 2688 | const QPoint cursorPosition(charColumn, charLine); | ||
2685 | QPoint ohere; | 2689 | QPoint selectionEnd = QPoint(charColumn, charLine); | ||
2686 | QPoint _iPntSelCorr = _iPntSel; | 2690 | QPoint selectionStart; | ||
2687 | _iPntSelCorr.ry() -= _scrollBar->value(); | 2691 | QPoint initialSelectionBegin = _initialSelectionPoint; | ||
2688 | QPoint _pntSelCorr = _pntSel; | 2692 | initialSelectionBegin.ry() -= _scrollBar->value(); | ||
2689 | _pntSelCorr.ry() -= _scrollBar->value(); | 2693 | QPoint initialSelectionEnd = _initialSelectionEnd; | ||
2694 | initialSelectionEnd.ry() -= _scrollBar->value(); | ||||
2695 | QPoint previousSelectionPoint = _currentSelectionPoint; | ||||
2696 | previousSelectionPoint.ry() -= _scrollBar->value(); | ||||
2690 | bool swapping = false; | 2697 | bool swapping = false; | ||
2691 | 2698 | | |||
2699 | int offset = 0; | ||||
2700 | | ||||
2692 | if (_wordSelectionMode) { | 2701 | if (_wordSelectionMode) { | ||
2693 | // Extend to word boundaries | 2702 | // Extend to word boundaries | ||
2694 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | 2703 | const bool extendingLeft = (selectionEnd.y() < initialSelectionBegin.y() || | ||
2695 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | 2704 | (selectionEnd.y() == initialSelectionBegin.y() && selectionEnd.x() < initialSelectionBegin.x())); | ||
2696 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | 2705 | const bool wasExtendingLeft = (previousSelectionPoint.y() < initialSelectionBegin.y() || | ||
2697 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | 2706 | (previousSelectionPoint.y() == initialSelectionBegin.y() && previousSelectionPoint.x() < initialSelectionBegin.x())); | ||
2698 | swapping = left_not_right != old_left_not_right; | 2707 | swapping = extendingLeft != wasExtendingLeft; | ||
2699 | 2708 | | |||
2700 | // Find left (left_not_right ? from here : from start of word) | 2709 | if (extendingLeft) { | ||
2701 | QPoint left = left_not_right ? here : _iPntSelCorr; | 2710 | selectionEnd = findWordStart(cursorPosition); | ||
2702 | // Find left (left_not_right ? from end of word : from here) | 2711 | selectionStart = initialSelectionEnd; | ||
2703 | QPoint right = left_not_right ? _iPntSelCorr : here; | | |||
2704 | | ||||
2705 | left = findWordStart(left); | | |||
2706 | right = findWordEnd(right); | | |||
2707 | | ||||
2708 | // Pick which is start (ohere) and which is extension (here) | | |||
2709 | if (left_not_right) { | | |||
2710 | here = left; | | |||
2711 | ohere = right; | | |||
2712 | } else { | 2712 | } else { | ||
2713 | here = right; | 2713 | selectionEnd = findWordEnd(cursorPosition); | ||
2714 | ohere = left; | 2714 | selectionStart = initialSelectionBegin; | ||
2715 | } | 2715 | } | ||
2716 | ohere.rx()++; | 2716 | | ||
2717 | selectionStart.rx()++; | ||||
2717 | } | 2718 | } | ||
2718 | 2719 | | |||
2719 | if (_lineSelectionMode) { | 2720 | if (_lineSelectionMode) { | ||
2720 | // Extend to complete line | 2721 | // Extend to complete line | ||
2721 | const bool above_not_below = (here.y() < _iPntSelCorr.y()); | 2722 | const bool extendingUpwards = (selectionEnd.y() < initialSelectionBegin.y()); | ||
2722 | if (above_not_below) { | 2723 | const bool wasExtendingUpwards = (previousSelectionPoint.y() < initialSelectionBegin.y()); | ||
2723 | ohere = findLineEnd(_iPntSelCorr); | 2724 | swapping = extendingUpwards != wasExtendingUpwards; | ||
2724 | here = findLineStart(here); | 2725 | if (extendingUpwards) { | ||
2726 | selectionEnd = findLineStart(selectionEnd); | ||||
2727 | selectionStart = initialSelectionEnd; | ||||
2725 | } else { | 2728 | } else { | ||
2726 | ohere = findLineStart(_iPntSelCorr); | 2729 | selectionStart = initialSelectionBegin; | ||
2727 | here = findLineEnd(here); | 2730 | selectionEnd = findLineEnd(selectionEnd); | ||
2728 | } | 2731 | } | ||
2729 | 2732 | | |||
2730 | swapping = !(_tripleSelBegin == ohere); | 2733 | _tripleSelBegin = selectionStart; | ||
2731 | _tripleSelBegin = ohere; | | |||
2732 | 2734 | | |||
2733 | ohere.rx()++; | 2735 | selectionStart.rx()++; | ||
2734 | } | 2736 | } | ||
2735 | 2737 | | |||
2736 | int offset = 0; | | |||
2737 | if (!_wordSelectionMode && !_lineSelectionMode) { | 2738 | if (!_wordSelectionMode && !_lineSelectionMode) { | ||
2738 | QChar selClass; | 2739 | QChar selClass; | ||
2739 | 2740 | | |||
2740 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | 2741 | const bool extendingLeft = (selectionEnd.y() < initialSelectionBegin.y() || | ||
2741 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | 2742 | (selectionEnd.y() == initialSelectionBegin.y() && selectionEnd.x() < initialSelectionBegin.x())); | ||
2742 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | 2743 | const bool wasExtendingLeft = (previousSelectionPoint.y() < initialSelectionBegin.y() || | ||
2743 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | 2744 | (previousSelectionPoint.y() == initialSelectionBegin.y() && previousSelectionPoint.x() < initialSelectionBegin.x())); | ||
2744 | swapping = left_not_right != old_left_not_right; | 2745 | swapping = extendingLeft != wasExtendingLeft; | ||
2745 | 2746 | | |||
2746 | // Find left (left_not_right ? from here : from start) | 2747 | // Find left (left_not_right ? from here : from start) | ||
2747 | const QPoint left = left_not_right ? here : _iPntSelCorr; | 2748 | const QPoint left = extendingLeft ? selectionEnd : initialSelectionBegin; | ||
2748 | 2749 | | |||
2749 | // Find left (left_not_right ? from start : from here) | 2750 | // Find left (left_not_right ? from start : from here) | ||
2750 | QPoint right = left_not_right ? _iPntSelCorr : here; | 2751 | QPoint right = extendingLeft ? initialSelectionBegin : selectionEnd; | ||
2751 | if (right.x() > 0 && !_columnSelectionMode) { | 2752 | if (right.x() > 0 && !_columnSelectionMode) { | ||
2752 | if (right.x() - 1 < _columns && right.y() < _lines) { | 2753 | if (right.x() - 1 < _columns && right.y() < _lines) { | ||
2753 | selClass = charClass(_image[loc(right.x() - 1, right.y())]); | 2754 | selClass = charClass(_image[loc(right.x() - 1, right.y())]); | ||
Context not available. | |||||
2755 | } | 2756 | } | ||
2756 | 2757 | | |||
2757 | // Pick which is start (ohere) and which is extension (here) | 2758 | // Pick which is start (ohere) and which is extension (here) | ||
2758 | if (left_not_right) { | 2759 | if (extendingLeft) { | ||
2759 | here = left; | 2760 | selectionEnd = left; | ||
2760 | ohere = right; | 2761 | selectionStart = right; | ||
2761 | offset = 0; | 2762 | offset = 0; | ||
2762 | } else { | 2763 | } else { | ||
2763 | here = right; | 2764 | selectionEnd = right; | ||
2764 | ohere = left; | 2765 | selectionStart = left; | ||
2765 | offset = -1; | 2766 | offset = -1; | ||
2766 | } | 2767 | } | ||
2767 | } | 2768 | } | ||
2768 | 2769 | | |||
2769 | if ((here == _pntSelCorr) && (scroll == _scrollBar->value())) { | 2770 | if ((selectionEnd == previousSelectionPoint) && (scroll == _scrollBar->value())) { | ||
2770 | return; // not moved | 2771 | return; // not moved | ||
2771 | } | 2772 | } | ||
2772 | 2773 | | |||
2773 | if (here == ohere) { | 2774 | if (selectionEnd == selectionStart) { | ||
2774 | return; // It's not left, it's not right. | 2775 | return; // It's not left, it's not right. | ||
2775 | } | 2776 | } | ||
2776 | 2777 | | |||
2777 | if (_actSel < 2 || swapping) { | 2778 | if (_actSel < 2 || swapping) { | ||
2778 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | 2779 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | ||
2779 | _screenWindow->setSelectionStart(ohere.x() , ohere.y() , true); | 2780 | _screenWindow->setSelectionStart(selectionStart.x() , selectionStart.y() , true); | ||
2780 | } else { | 2781 | } else { | ||
2781 | _screenWindow->setSelectionStart(ohere.x() - 1 - offset , ohere.y() , false); | 2782 | _screenWindow->setSelectionStart(selectionStart.x() - 1 - offset , selectionStart.y() , false); | ||
2782 | } | 2783 | } | ||
2783 | } | 2784 | } | ||
2784 | 2785 | | |||
2785 | _actSel = 2; // within selection | 2786 | _actSel = 2; // within selection | ||
2786 | _pntSel = here; | 2787 | _currentSelectionPoint = selectionEnd; | ||
2787 | _pntSel.ry() += _scrollBar->value(); | 2788 | _currentSelectionPoint.ry() += _scrollBar->value(); | ||
2788 | 2789 | | |||
2789 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | 2790 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | ||
2790 | _screenWindow->setSelectionEnd(here.x() , here.y()); | 2791 | _screenWindow->setSelectionEnd(selectionEnd.x() , selectionEnd.y()); | ||
2791 | } else { | 2792 | } else { | ||
2792 | _screenWindow->setSelectionEnd(here.x() + offset , here.y()); | 2793 | _screenWindow->setSelectionEnd(selectionEnd.x() + offset , selectionEnd.y()); | ||
2793 | } | 2794 | } | ||
2794 | } | 2795 | } | ||
2795 | 2796 | | |||
Context not available. | |||||
2917 | } | 2918 | } | ||
2918 | 2919 | | |||
2919 | _screenWindow->clearSelection(); | 2920 | _screenWindow->clearSelection(); | ||
2920 | _iPntSel = pos; | 2921 | _currentSelectionPoint = pos; | ||
2921 | _iPntSel.ry() += _scrollBar->value(); | 2922 | _currentSelectionPoint.ry() += _scrollBar->value(); | ||
2922 | 2923 | | |||
2923 | _wordSelectionMode = true; | 2924 | _wordSelectionMode = true; | ||
2924 | _actSel = 2; // within selection | 2925 | _actSel = 2; // within selection | ||
Context not available. | |||||
2934 | _screenWindow->setSelectionStart(bgnSel.x() , bgnSel.y() , false); | 2935 | _screenWindow->setSelectionStart(bgnSel.x() , bgnSel.y() , false); | ||
2935 | _screenWindow->setSelectionEnd(endSel.x() , endSel.y()); | 2936 | _screenWindow->setSelectionEnd(endSel.x() , endSel.y()); | ||
2936 | 2937 | | |||
2938 | _initialSelectionPoint = bgnSel; | ||||
2939 | _initialSelectionPoint.ry() += _scrollBar->value(); | ||||
2940 | | ||||
2941 | _initialSelectionEnd = endSel; | ||||
2942 | _initialSelectionEnd.ry() += _scrollBar->value(); | ||||
2943 | | ||||
2937 | copyToX11Selection(); | 2944 | copyToX11Selection(); | ||
2938 | } | 2945 | } | ||
2939 | 2946 | | |||
Context not available. | |||||
3096 | 3103 | | |||
3097 | Screen *screen = _screenWindow->screen(); | 3104 | Screen *screen = _screenWindow->screen(); | ||
3098 | Character *image = _image; | 3105 | Character *image = _image; | ||
3099 | Character *tmp_image = nullptr; | 3106 | std::unique_ptr<Character[]> tempImage; | ||
3100 | 3107 | | |||
3101 | int imgLine = pnt.y(); | 3108 | int imgLine = pnt.y(); | ||
3109 | | ||||
3110 | if (imgLine < 0 || imgLine >= _lines) { | ||||
3111 | return pnt; | ||||
3112 | } | ||||
3113 | | ||||
3102 | int x = pnt.x(); | 3114 | int x = pnt.x(); | ||
3103 | int y = imgLine + firstVisibleLine; | 3115 | int y = imgLine + firstVisibleLine; | ||
3104 | int imgLoc = loc(x, imgLine); | 3116 | int imgLoc = loc(x, imgLine); | ||
Context not available. | |||||
3106 | const QChar selClass = charClass(image[imgLoc]); | 3118 | const QChar selClass = charClass(image[imgLoc]); | ||
3107 | const int imageSize = regSize * _columns; | 3119 | const int imageSize = regSize * _columns; | ||
3108 | 3120 | | |||
3109 | while (true) { | 3121 | while (imgLoc >= 0) { | ||
3110 | for (;;imgLoc--, x--) { | 3122 | for (; imgLoc > 0 && imgLine >= 0; imgLoc--, x--) { | ||
3111 | if (imgLoc < 1) { | 3123 | const QChar &curClass = charClass(image[imgLoc - 1]); | ||
3112 | // no more chars in this region | 3124 | if (curClass != selClass) { | ||
3113 | break; | 3125 | return {x, y - firstVisibleLine}; | ||
3114 | } | 3126 | } | ||
3127 | | ||||
3128 | // has previous char on this line | ||||
3115 | if (x > 0) { | 3129 | if (x > 0) { | ||
3116 | // has previous char on this line | 3130 | continue; | ||
3117 | if (charClass(image[imgLoc - 1]) == selClass) { | | |||
3118 | continue; | | |||
3119 | } | | |||
3120 | goto out; | | |||
3121 | } else if (imgLine > 0) { | | |||
3122 | // not the first line in the session | | |||
3123 | if ((lineProperties[imgLine - 1] & LINE_WRAPPED) != 0) { | | |||
3124 | // have continuation on prev line | | |||
3125 | if (charClass(image[imgLoc - 1]) == selClass) { | | |||
3126 | x = _columns; | | |||
3127 | imgLine--; | | |||
3128 | y--; | | |||
3129 | continue; | | |||
3130 | } | | |||
3131 | } | | |||
3132 | goto out; | | |||
3133 | } else if (y > 0) { | | |||
3134 | // want more data, but need to fetch new region | | |||
3135 | break; | | |||
3136 | } else { | | |||
3137 | goto out; | | |||
3138 | } | 3131 | } | ||
3132 | | ||||
3133 | // not the first line in the session | ||||
3134 | if ((lineProperties[imgLine - 1] & LINE_WRAPPED) == 0) { | ||||
3135 | return {x, y - firstVisibleLine}; | ||||
3136 | } | ||||
3137 | | ||||
3138 | // have continuation on prev line | ||||
3139 | x = _columns; | ||||
3140 | imgLine--; | ||||
3141 | y--; | ||||
3139 | } | 3142 | } | ||
3143 | | ||||
3140 | if (y <= 0) { | 3144 | if (y <= 0) { | ||
3141 | // No more data | 3145 | return {x, y - firstVisibleLine}; | ||
3142 | goto out; | | |||
3143 | } | 3146 | } | ||
3144 | int newRegStart = qMax(0, y - regSize + 1); | 3147 | | ||
3148 | // Fetch new region | ||||
3149 | const int newRegStart = qMax(y - regSize + 1, 0); | ||||
3145 | lineProperties = screen->getLineProperties(newRegStart, y - 1); | 3150 | lineProperties = screen->getLineProperties(newRegStart, y - 1); | ||
3146 | imgLine = y - newRegStart; | 3151 | imgLine = y - newRegStart; | ||
3147 | 3152 | | |||
3148 | delete[] tmp_image; | 3153 | if (!tempImage) { | ||
3149 | tmp_image = new Character[imageSize]; | 3154 | tempImage.reset(new Character[imageSize]); | ||
3150 | image = tmp_image; | 3155 | image = tempImage.get(); | ||
3151 | | ||||
3152 | screen->getImage(tmp_image, imageSize, newRegStart, y - 1); | | |||
3153 | imgLoc = loc(x, imgLine); | | |||
3154 | if (imgLoc < 1) { | | |||
3155 | // Reached the start of the session | | |||
3156 | break; | | |||
3157 | } | 3156 | } | ||
3157 | | ||||
3158 | screen->getImage(image, imageSize, newRegStart, y - 1); | ||||
3159 | imgLoc = loc(x, imgLine); | ||||
3158 | } | 3160 | } | ||
3159 | out: | 3161 | | ||
3160 | delete[] tmp_image; | | |||
3161 | return {x, y - firstVisibleLine}; | 3162 | return {x, y - firstVisibleLine}; | ||
3162 | } | 3163 | } | ||
3163 | 3164 | | |||
Context not available. | |||||
3165 | { | 3166 | { | ||
3166 | const int regSize = qMax(_screenWindow->windowLines(), 10); | 3167 | const int regSize = qMax(_screenWindow->windowLines(), 10); | ||
3167 | const int curLine = _screenWindow->currentLine(); | 3168 | const int curLine = _screenWindow->currentLine(); | ||
3168 | int i = pnt.y(); | 3169 | int line = pnt.y(); | ||
3170 | | ||||
3171 | // The selection is already scrolled out of view, so assume it is already at a boundary | ||||
3172 | if (line < 0 || line >= _lines) { | ||||
3173 | return pnt; | ||||
3174 | } | ||||
3175 | | ||||
3169 | int x = pnt.x(); | 3176 | int x = pnt.x(); | ||
3170 | int y = i + curLine; | 3177 | int y = line + curLine; | ||
3171 | int j = loc(x, i); | | |||
3172 | QVector<LineProperty> lineProperties = _lineProperties; | 3178 | QVector<LineProperty> lineProperties = _lineProperties; | ||
3173 | Screen *screen = _screenWindow->screen(); | 3179 | Screen *screen = _screenWindow->screen(); | ||
3174 | Character *image = _image; | 3180 | Character *image = _image; | ||
3175 | Character *tmp_image = nullptr; | 3181 | std::unique_ptr<Character[]> tempImage; | ||
3176 | const QChar selClass = charClass(image[j]); | 3182 | | ||
3183 | int imgPos = loc(x, line); | ||||
3184 | const QChar selClass = charClass(image[imgPos]); | ||||
3185 | QChar curClass; | ||||
3186 | QChar nextClass; | ||||
3187 | | ||||
3177 | const int imageSize = regSize * _columns; | 3188 | const int imageSize = regSize * _columns; | ||
3178 | const int maxY = _screenWindow->lineCount() - 1; | 3189 | const int maxY = _screenWindow->lineCount(); | ||
3179 | const int maxX = _columns - 1; | 3190 | const int maxX = _columns - 1; | ||
3180 | 3191 | | |||
3181 | while (true) { | 3192 | while (x >= 0 && line >= 0) { | ||
3182 | const int lineCount = lineProperties.count(); | 3193 | imgPos = loc(x, line); | ||
3183 | for (;;j++, x++) { | 3194 | | ||
3184 | if (x < maxX) { | 3195 | const int visibleLinesCount = lineProperties.count(); | ||
3185 | if (charClass(image[j + 1]) == selClass && | 3196 | bool changedClass = false; | ||
3186 | // A colon right before whitespace is never part of a word | 3197 | | ||
3187 | ! (image[j + 1].character == ':' && charClass(image[j + 2]) == QLatin1Char(' '))) { | 3198 | for (;y < maxY && line < visibleLinesCount; imgPos++, x++) { | ||
3188 | continue; | 3199 | curClass = charClass(image[imgPos + 1]); | ||
3189 | } | 3200 | nextClass = charClass(image[imgPos + 2]); | ||
3190 | goto out; | 3201 | | ||
3191 | } else if (i < lineCount - 1) { | 3202 | changedClass = curClass != selClass && | ||
3192 | if (((lineProperties[i] & LINE_WRAPPED) != 0) && | 3203 | // A colon right before whitespace is never part of a word | ||
3193 | charClass(image[j + 1]) == selClass && | 3204 | !(image[imgPos + 1].character == ':' && nextClass == QLatin1Char(' ')); | ||
3194 | // A colon right before whitespace is never part of a word | 3205 | | ||
3195 | ! (image[j + 1].character == ':' && charClass(image[j + 2]) == QLatin1Char(' '))) { | 3206 | if (changedClass) { | ||
3196 | x = -1; | | |||
3197 | i++; | | |||
3198 | y++; | | |||
3199 | continue; | | |||
3200 | } | | |||
3201 | goto out; | | |||
3202 | } else if (y < maxY) { | | |||
3203 | if (i < lineCount && ((lineProperties[i] & LINE_WRAPPED) == 0)) { | | |||
3204 | goto out; | | |||
3205 | } | | |||
3206 | break; | 3207 | break; | ||
3207 | } else { | 3208 | } | ||
3208 | goto out; | 3209 | | ||
3210 | if (x >= maxX) { | ||||
3211 | if ((lineProperties[line] & LINE_WRAPPED) == 0) { | ||||
3212 | break; | ||||
3213 | } | ||||
3214 | | ||||
3215 | line++; | ||||
3216 | y++; | ||||
3217 | x = -1; | ||||
3209 | } | 3218 | } | ||
3210 | } | 3219 | } | ||
3211 | int newRegEnd = qMin(y + regSize - 1, maxY); | 3220 | | ||
3212 | lineProperties = screen->getLineProperties(y, newRegEnd); | 3221 | if (changedClass) { | ||
3213 | i = 0; | 3222 | break; | ||
3214 | if (tmp_image == nullptr) { | | |||
3215 | tmp_image = new Character[imageSize]; | | |||
3216 | image = tmp_image; | | |||
3217 | } | 3223 | } | ||
3218 | screen->getImage(tmp_image, imageSize, y, newRegEnd); | 3224 | | ||
3219 | x--; | 3225 | if (line < visibleLinesCount && ((lineProperties[line] & LINE_WRAPPED) == 0)) { | ||
3220 | j = loc(x, i); | 3226 | break; | ||
3227 | } | ||||
3228 | | ||||
3229 | const int newRegEnd = qMin(y + regSize - 1, maxY - 1); | ||||
3230 | lineProperties = screen->getLineProperties(y, newRegEnd); | ||||
3231 | if (!tempImage) { | ||||
3232 | tempImage.reset(new Character[imageSize]); | ||||
3233 | image = tempImage.get(); | ||||
3234 | } | ||||
3235 | screen->getImage(tempImage.get(), imageSize, y, newRegEnd); | ||||
3236 | | ||||
3237 | line = 0; | ||||
3221 | } | 3238 | } | ||
3222 | out: | 3239 | | ||
3223 | y -= curLine; | 3240 | y -= curLine; | ||
3224 | // In word selection mode don't select @ (64) if at end of word. | 3241 | // In word selection mode don't select @ (64) if at end of word. | ||
3225 | if (((image[j].rendition & RE_EXTENDED_CHAR) == 0) && | 3242 | if (((image[imgPos].rendition & RE_EXTENDED_CHAR) == 0) && | ||
3226 | (QChar(image[j].character) == QLatin1Char('@')) && | 3243 | (QChar(image[imgPos].character) == QLatin1Char('@')) && | ||
3227 | (y > pnt.y() || x > pnt.x())) { | 3244 | (y > pnt.y() || x > pnt.x())) { | ||
3228 | if (x > 0) { | 3245 | if (x > 0) { | ||
3229 | x--; | 3246 | x--; | ||
Context not available. | |||||
3231 | y--; | 3248 | y--; | ||
3232 | } | 3249 | } | ||
3233 | } | 3250 | } | ||
3234 | delete[] tmp_image; | | |||
3235 | 3251 | | |||
3236 | return {x, y}; | 3252 | return {x, y}; | ||
3237 | } | 3253 | } | ||
Context not available. | |||||
3267 | 3283 | | |||
3268 | void TerminalDisplay::selectLine(QPoint pos, bool entireLine) | 3284 | void TerminalDisplay::selectLine(QPoint pos, bool entireLine) | ||
3269 | { | 3285 | { | ||
3270 | _iPntSel = pos; | 3286 | _initialSelectionPoint = pos; | ||
3271 | 3287 | | |||
3272 | _screenWindow->clearSelection(); | 3288 | _screenWindow->clearSelection(); | ||
3273 | 3289 | | |||
Context not available. | |||||
3277 | _actSel = 2; // within selection | 3293 | _actSel = 2; // within selection | ||
3278 | 3294 | | |||
3279 | if (!entireLine) { // Select from cursor to end of line | 3295 | if (!entireLine) { // Select from cursor to end of line | ||
3280 | _tripleSelBegin = findWordStart(_iPntSel); | 3296 | _tripleSelBegin = findWordStart(pos); | ||
3281 | _screenWindow->setSelectionStart(_tripleSelBegin.x(), | 3297 | _screenWindow->setSelectionStart(_tripleSelBegin.x(), | ||
3282 | _tripleSelBegin.y() , false); | 3298 | _tripleSelBegin.y() , false); | ||
3283 | } else { | 3299 | } else { | ||
3284 | _tripleSelBegin = findLineStart(_iPntSel); | 3300 | _tripleSelBegin = findLineStart(pos); | ||
3285 | _screenWindow->setSelectionStart(0 , _tripleSelBegin.y() , false); | 3301 | _screenWindow->setSelectionStart(0 , _tripleSelBegin.y() , false); | ||
3286 | } | 3302 | } | ||
3287 | 3303 | | |||
3288 | _iPntSel = findLineEnd(_iPntSel); | 3304 | _initialSelectionPoint = findLineStart(_initialSelectionPoint); | ||
3289 | _screenWindow->setSelectionEnd(_iPntSel.x() , _iPntSel.y()); | 3305 | _initialSelectionEnd = findLineEnd(pos); | ||
3306 | | ||||
3307 | _screenWindow->setSelectionEnd(_initialSelectionEnd.x() , _initialSelectionEnd.y()); | ||||
3290 | 3308 | | |||
3291 | copyToX11Selection(); | 3309 | copyToX11Selection(); | ||
3292 | 3310 | | |||
3293 | _iPntSel.ry() += _scrollBar->value(); | 3311 | _initialSelectionPoint.ry() += _scrollBar->value(); | ||
3312 | _initialSelectionEnd.ry() += _scrollBar->value(); | ||||
3294 | } | 3313 | } | ||
3295 | 3314 | | |||
3296 | void TerminalDisplay::selectCurrentLine() | 3315 | void TerminalDisplay::selectCurrentLine() | ||
Context not available. |