Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Context not available. | |||||
59 | #include <KMessageWidget> | 59 | #include <KMessageWidget> | ||
---|---|---|---|---|---|
60 | #include <KIO/StatJob> | 60 | #include <KIO/StatJob> | ||
61 | 61 | | |||
62 | #include <memory> | ||||
63 | | ||||
62 | // Konsole | 64 | // Konsole | ||
63 | #include "Filter.h" | 65 | #include "Filter.h" | ||
64 | #include "konsoledebug.h" | 66 | #include "konsoledebug.h" | ||
Context not available. | |||||
425 | , _usesMouseTracking(false) | 427 | , _usesMouseTracking(false) | ||
426 | , _alternateScrolling(true) | 428 | , _alternateScrolling(true) | ||
427 | , _bracketedPasteMode(false) | 429 | , _bracketedPasteMode(false) | ||
428 | , _iPntSel(QPoint()) | 430 | , _initialSelectionPoint(QPoint()) | ||
429 | , _pntSel(QPoint()) | 431 | , _currentSelectionPoint(QPoint()) | ||
430 | , _tripleSelBegin(QPoint()) | 432 | , _tripleSelBegin(QPoint()) | ||
431 | , _actSel(0) | 433 | , _actSel(0) | ||
432 | , _wordSelectionMode(false) | 434 | , _wordSelectionMode(false) | ||
Context not available. | |||||
2136 | _screenWindow->clearSelection(); | 2138 | _screenWindow->clearSelection(); | ||
2137 | 2139 | | |||
2138 | pos.ry() += _scrollBar->value(); | 2140 | pos.ry() += _scrollBar->value(); | ||
2139 | _iPntSel = _pntSel = pos; | 2141 | _initialSelectionPoint = _currentSelectionPoint = pos; | ||
2140 | _actSel = 1; // left mouse button pressed but nothing selected yet. | 2142 | _actSel = 1; // left mouse button pressed but nothing selected yet. | ||
2141 | } else if (_usesMouseTracking && !_readOnly) { | 2143 | } else if (_usesMouseTracking && !_readOnly) { | ||
2142 | emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0); | 2144 | emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0); | ||
Context not available. | |||||
2315 | 2317 | | |||
2316 | int linesBeyondWidget = 0; | 2318 | int linesBeyondWidget = 0; | ||
2317 | 2319 | | |||
2318 | QRect textBounds(tLx + _contentRect.left(), | 2320 | const QRect textBounds(tLx + _contentRect.left(), | ||
2319 | tLy + _contentRect.top(), | 2321 | tLy + _contentRect.top(), | ||
2320 | _usedColumns * _fontWidth - 1, | 2322 | _usedColumns * _fontWidth - 1, | ||
2321 | _usedLines * _fontHeight - 1); | 2323 | _usedLines * _fontHeight - 1); | ||
2322 | 2324 | | |||
2325 | const QRect characterBounds(0, 0, _columns, _lines); | ||||
2326 | | ||||
2323 | QPoint pos = position; | 2327 | QPoint pos = position; | ||
2324 | 2328 | | |||
2325 | // Adjust position within text area bounds. | 2329 | // Adjust position within text area bounds. | ||
Context not available. | |||||
2339 | 2343 | | |||
2340 | int charColumn = 0; | 2344 | int charColumn = 0; | ||
2341 | int charLine = 0; | 2345 | int charLine = 0; | ||
2342 | getCharacterPosition(pos, charLine, charColumn, true); | 2346 | getCharacterPosition(pos, charLine, charColumn, !_wordSelectionMode && !_lineSelectionMode); | ||
2343 | 2347 | | |||
2344 | QPoint here = QPoint(charColumn, charLine); | 2348 | const QPoint cursorPosition(charColumn, charLine); | ||
2345 | QPoint ohere; | 2349 | QPoint selectionEnd = QPoint(charColumn, charLine); | ||
2346 | QPoint _iPntSelCorr = _iPntSel; | 2350 | QPoint selectionStart; | ||
2347 | _iPntSelCorr.ry() -= _scrollBar->value(); | 2351 | QPoint initialSelectionBegin = _initialSelectionPoint; | ||
2348 | QPoint _pntSelCorr = _pntSel; | 2352 | initialSelectionBegin.ry() -= _scrollBar->value(); | ||
2349 | _pntSelCorr.ry() -= _scrollBar->value(); | 2353 | QPoint initialSelectionEnd = _initialSelectionEnd; | ||
2354 | initialSelectionEnd.ry() -= _scrollBar->value(); | ||||
2355 | QPoint previousSelectionPoint = _currentSelectionPoint; | ||||
2356 | previousSelectionPoint.ry() -= _scrollBar->value(); | ||||
2350 | bool swapping = false; | 2357 | bool swapping = false; | ||
2351 | 2358 | | |||
2359 | int offset = 0; | ||||
2360 | | ||||
2352 | if (_wordSelectionMode) { | 2361 | if (_wordSelectionMode) { | ||
2353 | // Extend to word boundaries | 2362 | // Extend to word boundaries | ||
2354 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | 2363 | const bool extendingLeft = (selectionEnd.y() < initialSelectionBegin.y() || | ||
2355 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | 2364 | (selectionEnd.y() == initialSelectionBegin.y() && selectionEnd.x() < initialSelectionBegin.x())); | ||
2356 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | 2365 | const bool wasExtendingLeft = (previousSelectionPoint.y() < initialSelectionBegin.y() || | ||
2357 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | 2366 | (previousSelectionPoint.y() == initialSelectionBegin.y() && previousSelectionPoint.x() < initialSelectionBegin.x())); | ||
2358 | swapping = left_not_right != old_left_not_right; | 2367 | swapping = extendingLeft != wasExtendingLeft; | ||
2359 | 2368 | | |||
2360 | // Find left (left_not_right ? from here : from start of word) | 2369 | if (extendingLeft) { | ||
2361 | QPoint left = left_not_right ? here : _iPntSelCorr; | 2370 | selectionEnd = findWordStart(cursorPosition); | ||
2362 | // Find left (left_not_right ? from end of word : from here) | 2371 | selectionStart = initialSelectionEnd; | ||
2363 | QPoint right = left_not_right ? _iPntSelCorr : here; | | |||
2364 | | ||||
2365 | if (left.y() < 0 || left.y() >= _lines || left.x() < 0 || left.x() >= _columns) { | | |||
2366 | left = _pntSelCorr; | | |||
2367 | } else { | 2372 | } else { | ||
2368 | left = findWordStart(left); | 2373 | selectionEnd = findWordEnd(cursorPosition); | ||
2369 | } | 2374 | selectionStart = initialSelectionBegin; | ||
2370 | if (right.y() < 0 || right.y() >= _lines || right.x() < 0 || right.x() >= _columns) { | | |||
2371 | right = _pntSelCorr; | | |||
2372 | } else { | | |||
2373 | right = findWordEnd(right); | | |||
2374 | } | 2375 | } | ||
2375 | 2376 | | |||
2376 | // Pick which is start (ohere) and which is extension (here) | 2377 | selectionStart.rx()++; | ||
2377 | if (left_not_right) { | | |||
2378 | here = left; | | |||
2379 | ohere = right; | | |||
2380 | } else { | | |||
2381 | here = right; | | |||
2382 | ohere = left; | | |||
2383 | } | | |||
2384 | ohere.rx()++; | | |||
2385 | } | 2378 | } | ||
2386 | 2379 | | |||
2387 | if (_lineSelectionMode) { | 2380 | if (_lineSelectionMode) { | ||
2388 | // Extend to complete line | 2381 | // Extend to complete line | ||
2389 | const bool above_not_below = (here.y() < _iPntSelCorr.y()); | 2382 | const bool extendingUpwards = (selectionEnd.y() < initialSelectionBegin.y()); | ||
2390 | if (above_not_below) { | 2383 | const bool wasExtendingUpwards = (previousSelectionPoint.y() < initialSelectionBegin.y()); | ||
2391 | ohere = findLineEnd(_iPntSelCorr); | 2384 | swapping = extendingUpwards != wasExtendingUpwards; | ||
2392 | here = findLineStart(here); | 2385 | if (extendingUpwards) { | ||
2386 | selectionEnd = findLineStart(selectionEnd); | ||||
2387 | selectionStart = initialSelectionEnd; | ||||
2393 | } else { | 2388 | } else { | ||
2394 | ohere = findLineStart(_iPntSelCorr); | 2389 | selectionStart = initialSelectionBegin; | ||
2395 | here = findLineEnd(here); | 2390 | selectionEnd = findLineEnd(selectionEnd); | ||
2396 | } | 2391 | } | ||
2397 | 2392 | | |||
2398 | swapping = !(_tripleSelBegin == ohere); | 2393 | _tripleSelBegin = selectionStart; | ||
2399 | _tripleSelBegin = ohere; | | |||
2400 | 2394 | | |||
2401 | ohere.rx()++; | 2395 | selectionStart.rx()++; | ||
2402 | } | 2396 | } | ||
2403 | 2397 | | |||
2404 | int offset = 0; | | |||
2405 | if (!_wordSelectionMode && !_lineSelectionMode) { | 2398 | if (!_wordSelectionMode && !_lineSelectionMode) { | ||
2406 | QChar selClass; | 2399 | QChar selClass; | ||
2407 | 2400 | | |||
2408 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | 2401 | const bool extendingLeft = (selectionEnd.y() < initialSelectionBegin.y() || | ||
2409 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | 2402 | (selectionEnd.y() == initialSelectionBegin.y() && selectionEnd.x() < initialSelectionBegin.x())); | ||
2410 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | 2403 | const bool wasExtendingLeft = (previousSelectionPoint.y() < initialSelectionBegin.y() || | ||
2411 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | 2404 | (previousSelectionPoint.y() == initialSelectionBegin.y() && previousSelectionPoint.x() < initialSelectionBegin.x())); | ||
2412 | swapping = left_not_right != old_left_not_right; | 2405 | swapping = extendingLeft != wasExtendingLeft; | ||
2413 | 2406 | | |||
2414 | // Find left (left_not_right ? from here : from start) | 2407 | // Find left (left_not_right ? from here : from start) | ||
2415 | const QPoint left = left_not_right ? here : _iPntSelCorr; | 2408 | const QPoint left = extendingLeft ? selectionEnd : initialSelectionBegin; | ||
2416 | 2409 | | |||
2417 | // Find left (left_not_right ? from start : from here) | 2410 | // Find left (left_not_right ? from start : from here) | ||
2418 | QPoint right = left_not_right ? _iPntSelCorr : here; | 2411 | QPoint right = extendingLeft ? initialSelectionBegin : selectionEnd; | ||
2419 | if (right.x() > 0 && !_columnSelectionMode) { | 2412 | if (right.x() > 0 && !_columnSelectionMode) { | ||
2420 | if (right.x() - 1 < _columns && right.y() < _lines) { | 2413 | if (right.x() - 1 < _columns && right.y() < _lines) { | ||
2421 | selClass = charClass(_image[loc(right.x() - 1, right.y())]); | 2414 | selClass = charClass(_image[loc(right.x() - 1, right.y())]); | ||
Context not available. | |||||
2423 | } | 2416 | } | ||
2424 | 2417 | | |||
2425 | // Pick which is start (ohere) and which is extension (here) | 2418 | // Pick which is start (ohere) and which is extension (here) | ||
2426 | if (left_not_right) { | 2419 | if (extendingLeft) { | ||
2427 | here = left; | 2420 | selectionEnd = left; | ||
2428 | ohere = right; | 2421 | selectionStart = right; | ||
2429 | offset = 0; | 2422 | offset = 0; | ||
2430 | } else { | 2423 | } else { | ||
2431 | here = right; | 2424 | selectionEnd = right; | ||
2432 | ohere = left; | 2425 | selectionStart = left; | ||
2433 | offset = -1; | 2426 | offset = -1; | ||
2434 | } | 2427 | } | ||
2435 | } | 2428 | } | ||
2436 | 2429 | | |||
2437 | if ((here == _pntSelCorr) && (scroll == _scrollBar->value())) { | 2430 | if ((selectionEnd == previousSelectionPoint) && (scroll == _scrollBar->value())) { | ||
2438 | return; // not moved | 2431 | return; // not moved | ||
2439 | } | 2432 | } | ||
2440 | 2433 | | |||
2441 | if (here == ohere) { | 2434 | if (selectionEnd == selectionStart) { | ||
2442 | return; // It's not left, it's not right. | 2435 | return; // It's not left, it's not right. | ||
2443 | } | 2436 | } | ||
2444 | 2437 | | |||
2445 | if (_actSel < 2 || swapping) { | 2438 | if (_actSel < 2 || swapping) { | ||
2446 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | 2439 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | ||
2447 | _screenWindow->setSelectionStart(ohere.x() , ohere.y() , true); | 2440 | _screenWindow->setSelectionStart(selectionStart.x() , selectionStart.y() , true); | ||
2448 | } else { | 2441 | } else { | ||
2449 | _screenWindow->setSelectionStart(ohere.x() - 1 - offset , ohere.y() , false); | 2442 | _screenWindow->setSelectionStart(selectionStart.x() - 1 - offset , selectionStart.y() , false); | ||
2450 | } | 2443 | } | ||
2451 | } | 2444 | } | ||
2452 | 2445 | | |||
2453 | _actSel = 2; // within selection | 2446 | _actSel = 2; // within selection | ||
2454 | _pntSel = here; | 2447 | _currentSelectionPoint = selectionEnd; | ||
2455 | _pntSel.ry() += _scrollBar->value(); | 2448 | _currentSelectionPoint.ry() += _scrollBar->value(); | ||
2456 | 2449 | | |||
2457 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | 2450 | if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { | ||
2458 | _screenWindow->setSelectionEnd(here.x() , here.y()); | 2451 | _screenWindow->setSelectionEnd(selectionEnd.x() , selectionEnd.y()); | ||
2459 | } else { | 2452 | } else { | ||
2460 | _screenWindow->setSelectionEnd(here.x() + offset , here.y()); | 2453 | _screenWindow->setSelectionEnd(selectionEnd.x() + offset , selectionEnd.y()); | ||
2461 | } | 2454 | } | ||
2462 | } | 2455 | } | ||
2463 | 2456 | | |||
Context not available. | |||||
2585 | } | 2578 | } | ||
2586 | 2579 | | |||
2587 | _screenWindow->clearSelection(); | 2580 | _screenWindow->clearSelection(); | ||
2588 | _iPntSel = pos; | 2581 | _currentSelectionPoint = pos; | ||
2589 | _iPntSel.ry() += _scrollBar->value(); | 2582 | _currentSelectionPoint.ry() += _scrollBar->value(); | ||
2590 | 2583 | | |||
2591 | _wordSelectionMode = true; | 2584 | _wordSelectionMode = true; | ||
2592 | _actSel = 2; // within selection | 2585 | _actSel = 2; // within selection | ||
Context not available. | |||||
2602 | _screenWindow->setSelectionStart(bgnSel.x() , bgnSel.y() , false); | 2595 | _screenWindow->setSelectionStart(bgnSel.x() , bgnSel.y() , false); | ||
2603 | _screenWindow->setSelectionEnd(endSel.x() , endSel.y()); | 2596 | _screenWindow->setSelectionEnd(endSel.x() , endSel.y()); | ||
2604 | 2597 | | |||
2598 | _initialSelectionPoint = bgnSel; | ||||
2599 | _initialSelectionPoint.ry() += _scrollBar->value(); | ||||
2600 | | ||||
2601 | _initialSelectionEnd = endSel; | ||||
2602 | _initialSelectionEnd.ry() += _scrollBar->value(); | ||||
2603 | | ||||
2605 | copyToX11Selection(); | 2604 | copyToX11Selection(); | ||
2606 | } | 2605 | } | ||
2607 | 2606 | | |||
Context not available. | |||||
2764 | 2763 | | |||
2765 | Screen *screen = _screenWindow->screen(); | 2764 | Screen *screen = _screenWindow->screen(); | ||
2766 | Character *image = _image; | 2765 | Character *image = _image; | ||
2767 | Character *tmp_image = nullptr; | 2766 | std::unique_ptr<Character[]> tempImage; | ||
2768 | 2767 | | |||
2769 | int imgLine = pnt.y(); | 2768 | int imgLine = pnt.y(); | ||
2769 | | ||||
2770 | if (imgLine < 0 || imgLine >= _lines) { | ||||
2771 | return pnt; | ||||
2772 | } | ||||
2773 | | ||||
2770 | int x = pnt.x(); | 2774 | int x = pnt.x(); | ||
2771 | int y = imgLine + firstVisibleLine; | 2775 | int y = imgLine + firstVisibleLine; | ||
2772 | int imgLoc = loc(x, imgLine); | 2776 | int imgLoc = loc(x, imgLine); | ||
Context not available. | |||||
2774 | const QChar selClass = charClass(image[imgLoc]); | 2778 | const QChar selClass = charClass(image[imgLoc]); | ||
2775 | const int imageSize = regSize * _columns; | 2779 | const int imageSize = regSize * _columns; | ||
2776 | 2780 | | |||
2777 | while (true) { | 2781 | while (imgLoc >= 0) { | ||
2778 | for (;;imgLoc--, x--) { | 2782 | for (; imgLoc > 0 && imgLine >= 0; imgLoc--, x--) { | ||
2779 | if (imgLoc < 1) { | 2783 | const QChar &curClass = charClass(image[imgLoc - 1]); | ||
2780 | // no more chars in this region | 2784 | if (curClass != selClass) { | ||
2781 | break; | 2785 | return {x, y - firstVisibleLine}; | ||
2782 | } | 2786 | } | ||
2787 | | ||||
2788 | // has previous char on this line | ||||
2783 | if (x > 0) { | 2789 | if (x > 0) { | ||
2784 | // has previous char on this line | 2790 | continue; | ||
2785 | if (charClass(image[imgLoc - 1]) == selClass) { | | |||
2786 | continue; | | |||
2787 | } | | |||
2788 | goto out; | | |||
2789 | } else if (imgLine > 0) { | | |||
2790 | // not the first line in the session | | |||
2791 | if ((lineProperties[imgLine - 1] & LINE_WRAPPED) != 0) { | | |||
2792 | // have continuation on prev line | | |||
2793 | if (charClass(image[imgLoc - 1]) == selClass) { | | |||
2794 | x = _columns; | | |||
2795 | imgLine--; | | |||
2796 | y--; | | |||
2797 | continue; | | |||
2798 | } | | |||
2799 | } | | |||
2800 | goto out; | | |||
2801 | } else if (y > 0) { | | |||
2802 | // want more data, but need to fetch new region | | |||
2803 | break; | | |||
2804 | } else { | | |||
2805 | goto out; | | |||
2806 | } | 2791 | } | ||
2792 | | ||||
2793 | // not the first line in the session | ||||
2794 | if ((lineProperties[imgLine - 1] & LINE_WRAPPED) == 0) { | ||||
2795 | return {x, y - firstVisibleLine}; | ||||
2796 | } | ||||
2797 | | ||||
2798 | // have continuation on prev line | ||||
2799 | x = _columns; | ||||
2800 | imgLine--; | ||||
2801 | y--; | ||||
2807 | } | 2802 | } | ||
2803 | | ||||
2808 | if (y <= 0) { | 2804 | if (y <= 0) { | ||
2809 | // No more data | 2805 | return {x, y - firstVisibleLine}; | ||
2810 | goto out; | | |||
2811 | } | 2806 | } | ||
2812 | int newRegStart = qMax(0, y - regSize + 1); | 2807 | | ||
2808 | // Fetch new region | ||||
2809 | const int newRegStart = qMax(y - regSize + 1, 0); | ||||
2813 | lineProperties = screen->getLineProperties(newRegStart, y - 1); | 2810 | lineProperties = screen->getLineProperties(newRegStart, y - 1); | ||
2814 | imgLine = y - newRegStart; | 2811 | imgLine = y - newRegStart; | ||
2815 | 2812 | | |||
2816 | delete[] tmp_image; | 2813 | if (!tempImage) { | ||
2817 | tmp_image = new Character[imageSize]; | 2814 | tempImage.reset(new Character[imageSize]); | ||
2818 | image = tmp_image; | 2815 | image = tempImage.get(); | ||
2819 | | ||||
2820 | screen->getImage(tmp_image, imageSize, newRegStart, y - 1); | | |||
2821 | imgLoc = loc(x, imgLine); | | |||
2822 | if (imgLoc < 1) { | | |||
2823 | // Reached the start of the session | | |||
2824 | break; | | |||
2825 | } | 2816 | } | ||
2817 | | ||||
2818 | screen->getImage(image, imageSize, newRegStart, y - 1); | ||||
2819 | imgLoc = loc(x, imgLine); | ||||
2826 | } | 2820 | } | ||
2827 | out: | 2821 | | ||
2828 | delete[] tmp_image; | | |||
2829 | return {x, y - firstVisibleLine}; | 2822 | return {x, y - firstVisibleLine}; | ||
2830 | } | 2823 | } | ||
2831 | 2824 | | |||
Context not available. | |||||
2833 | { | 2826 | { | ||
2834 | const int regSize = qMax(_screenWindow->windowLines(), 10); | 2827 | const int regSize = qMax(_screenWindow->windowLines(), 10); | ||
2835 | const int curLine = _screenWindow->currentLine(); | 2828 | const int curLine = _screenWindow->currentLine(); | ||
2836 | int i = pnt.y(); | 2829 | int line = pnt.y(); | ||
2830 | | ||||
2831 | // The selection is already scrolled out of view, so assume it is already at a boundary | ||||
2832 | if (line < 0 || line >= _lines) { | ||||
2833 | return pnt; | ||||
2834 | } | ||||
2835 | | ||||
2837 | int x = pnt.x(); | 2836 | int x = pnt.x(); | ||
2838 | int y = i + curLine; | 2837 | int y = line + curLine; | ||
2839 | int j = loc(x, i); | | |||
2840 | QVector<LineProperty> lineProperties = _lineProperties; | 2838 | QVector<LineProperty> lineProperties = _lineProperties; | ||
2841 | Screen *screen = _screenWindow->screen(); | 2839 | Screen *screen = _screenWindow->screen(); | ||
2842 | Character *image = _image; | 2840 | Character *image = _image; | ||
2843 | Character *tmp_image = nullptr; | 2841 | std::unique_ptr<Character[]> tempImage; | ||
2844 | const QChar selClass = charClass(image[j]); | 2842 | | ||
2843 | int imgPos = loc(x, line); | ||||
2844 | const QChar selClass = charClass(image[imgPos]); | ||||
2845 | QChar curClass; | ||||
2846 | QChar nextClass; | ||||
2847 | | ||||
2845 | const int imageSize = regSize * _columns; | 2848 | const int imageSize = regSize * _columns; | ||
2846 | const int maxY = _screenWindow->lineCount() - 1; | 2849 | const int maxY = _screenWindow->lineCount(); | ||
2847 | const int maxX = _columns - 1; | 2850 | const int maxX = _columns - 1; | ||
2848 | 2851 | | |||
2849 | while (true) { | 2852 | while (x >= 0 && line >= 0) { | ||
2850 | const int lineCount = lineProperties.count(); | 2853 | imgPos = loc(x, line); | ||
2851 | for (;;j++, x++) { | 2854 | | ||
2852 | if (x < maxX) { | 2855 | const int visibleLinesCount = lineProperties.count(); | ||
2853 | if (charClass(image[j + 1]) == selClass && | 2856 | bool changedClass = false; | ||
2854 | // A colon right before whitespace is never part of a word | 2857 | | ||
2855 | ! (image[j + 1].character == ':' && charClass(image[j + 2]) == QLatin1Char(' '))) { | 2858 | for (;y < maxY && line < visibleLinesCount; imgPos++, x++) { | ||
2856 | continue; | 2859 | curClass = charClass(image[imgPos + 1]); | ||
2857 | } | 2860 | nextClass = charClass(image[imgPos + 2]); | ||
2858 | goto out; | 2861 | | ||
2859 | } else if (i < lineCount - 1) { | 2862 | changedClass = curClass != selClass && | ||
2860 | if (((lineProperties[i] & LINE_WRAPPED) != 0) && | 2863 | // A colon right before whitespace is never part of a word | ||
2861 | charClass(image[j + 1]) == selClass && | 2864 | !(image[imgPos + 1].character == ':' && nextClass == QLatin1Char(' ')); | ||
2862 | // A colon right before whitespace is never part of a word | 2865 | | ||
2863 | ! (image[j + 1].character == ':' && charClass(image[j + 2]) == QLatin1Char(' '))) { | 2866 | if (changedClass) { | ||
2864 | x = -1; | | |||
2865 | i++; | | |||
2866 | y++; | | |||
2867 | continue; | | |||
2868 | } | | |||
2869 | goto out; | | |||
2870 | } else if (y < maxY) { | | |||
2871 | if (i < lineCount && ((lineProperties[i] & LINE_WRAPPED) == 0)) { | | |||
2872 | goto out; | | |||
2873 | } | | |||
2874 | break; | 2867 | break; | ||
2875 | } else { | 2868 | } | ||
2876 | goto out; | 2869 | | ||
2870 | if (x >= maxX) { | ||||
2871 | if ((lineProperties[line] & LINE_WRAPPED) == 0) { | ||||
2872 | break; | ||||
2873 | } | ||||
2874 | | ||||
2875 | line++; | ||||
2876 | y++; | ||||
2877 | x = -1; | ||||
2877 | } | 2878 | } | ||
2878 | } | 2879 | } | ||
2879 | int newRegEnd = qMin(y + regSize - 1, maxY); | 2880 | | ||
2880 | lineProperties = screen->getLineProperties(y, newRegEnd); | 2881 | if (changedClass) { | ||
2881 | i = 0; | 2882 | break; | ||
2882 | if (tmp_image == nullptr) { | | |||
2883 | tmp_image = new Character[imageSize]; | | |||
2884 | image = tmp_image; | | |||
2885 | } | 2883 | } | ||
2886 | screen->getImage(tmp_image, imageSize, y, newRegEnd); | 2884 | | ||
2887 | x--; | 2885 | if (line < visibleLinesCount && ((lineProperties[line] & LINE_WRAPPED) == 0)) { | ||
2888 | j = loc(x, i); | 2886 | break; | ||
2887 | } | ||||
2888 | | ||||
2889 | const int newRegEnd = qMin(y + regSize - 1, maxY - 1); | ||||
2890 | lineProperties = screen->getLineProperties(y, newRegEnd); | ||||
2891 | if (!tempImage) { | ||||
2892 | tempImage.reset(new Character[imageSize]); | ||||
2893 | image = tempImage.get(); | ||||
2894 | } | ||||
2895 | screen->getImage(tempImage.get(), imageSize, y, newRegEnd); | ||||
2896 | | ||||
2897 | line = 0; | ||||
2889 | } | 2898 | } | ||
2890 | out: | 2899 | | ||
2891 | y -= curLine; | 2900 | y -= curLine; | ||
2892 | // In word selection mode don't select @ (64) if at end of word. | 2901 | // In word selection mode don't select @ (64) if at end of word. | ||
2893 | if (((image[j].rendition & RE_EXTENDED_CHAR) == 0) && | 2902 | if (((image[imgPos].rendition & RE_EXTENDED_CHAR) == 0) && | ||
2894 | (QChar(image[j].character) == QLatin1Char('@')) && | 2903 | (QChar(image[imgPos].character) == QLatin1Char('@')) && | ||
2895 | (y > pnt.y() || x > pnt.x())) { | 2904 | (y > pnt.y() || x > pnt.x())) { | ||
2896 | if (x > 0) { | 2905 | if (x > 0) { | ||
2897 | x--; | 2906 | x--; | ||
Context not available. | |||||
2899 | y--; | 2908 | y--; | ||
2900 | } | 2909 | } | ||
2901 | } | 2910 | } | ||
2902 | delete[] tmp_image; | | |||
2903 | 2911 | | |||
2904 | return {x, y}; | 2912 | return {x, y}; | ||
2905 | } | 2913 | } | ||
Context not available. | |||||
2935 | 2943 | | |||
2936 | void TerminalDisplay::selectLine(QPoint pos, bool entireLine) | 2944 | void TerminalDisplay::selectLine(QPoint pos, bool entireLine) | ||
2937 | { | 2945 | { | ||
2938 | _iPntSel = pos; | 2946 | _initialSelectionPoint = pos; | ||
2939 | 2947 | | |||
2940 | _screenWindow->clearSelection(); | 2948 | _screenWindow->clearSelection(); | ||
2941 | 2949 | | |||
Context not available. | |||||
2945 | _actSel = 2; // within selection | 2953 | _actSel = 2; // within selection | ||
2946 | 2954 | | |||
2947 | if (!entireLine) { // Select from cursor to end of line | 2955 | if (!entireLine) { // Select from cursor to end of line | ||
2948 | _tripleSelBegin = findWordStart(_iPntSel); | 2956 | _tripleSelBegin = findWordStart(pos); | ||
2949 | _screenWindow->setSelectionStart(_tripleSelBegin.x(), | 2957 | _screenWindow->setSelectionStart(_tripleSelBegin.x(), | ||
2950 | _tripleSelBegin.y() , false); | 2958 | _tripleSelBegin.y() , false); | ||
2951 | } else { | 2959 | } else { | ||
2952 | _tripleSelBegin = findLineStart(_iPntSel); | 2960 | _tripleSelBegin = findLineStart(pos); | ||
2953 | _screenWindow->setSelectionStart(0 , _tripleSelBegin.y() , false); | 2961 | _screenWindow->setSelectionStart(0 , _tripleSelBegin.y() , false); | ||
2954 | } | 2962 | } | ||
2955 | 2963 | | |||
2956 | _iPntSel = findLineEnd(_iPntSel); | 2964 | _initialSelectionPoint = findLineStart(_initialSelectionPoint); | ||
2957 | _screenWindow->setSelectionEnd(_iPntSel.x() , _iPntSel.y()); | 2965 | _initialSelectionEnd = findLineEnd(pos); | ||
2966 | | ||||
2967 | _screenWindow->setSelectionEnd(_initialSelectionEnd.x() , _initialSelectionEnd.y()); | ||||
2958 | 2968 | | |||
2959 | copyToX11Selection(); | 2969 | copyToX11Selection(); | ||
2960 | 2970 | | |||
2961 | _iPntSel.ry() += _scrollBar->value(); | 2971 | _initialSelectionPoint.ry() += _scrollBar->value(); | ||
2972 | _initialSelectionEnd.ry() += _scrollBar->value(); | ||||
2962 | } | 2973 | } | ||
2963 | 2974 | | |||
2964 | void TerminalDisplay::selectCurrentLine() | 2975 | void TerminalDisplay::selectCurrentLine() | ||
Context not available. |