Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 1467 Lines • ▼ Show 20 Line(s) | |||||
1468 | { | 1468 | { | ||
1469 | if (!_screenWindow.isNull()) { | 1469 | if (!_screenWindow.isNull()) { | ||
1470 | return _screenWindow->cursorPosition(); | 1470 | return _screenWindow->cursorPosition(); | ||
1471 | } else { | 1471 | } else { | ||
1472 | return QPoint(0, 0); | 1472 | return QPoint(0, 0); | ||
1473 | } | 1473 | } | ||
1474 | } | 1474 | } | ||
1475 | 1475 | | |||
1476 | inline bool TerminalDisplay::isCursorOnDisplay() const | ||||
1477 | { | ||||
1478 | return cursorPosition().x() < _columns && | ||||
1479 | cursorPosition().y() < _lines; | ||||
1480 | } | ||||
1481 | | ||||
1476 | FilterChain* TerminalDisplay::filterChain() const | 1482 | FilterChain* TerminalDisplay::filterChain() const | ||
1477 | { | 1483 | { | ||
1478 | return _filterChain; | 1484 | return _filterChain; | ||
1479 | } | 1485 | } | ||
1480 | 1486 | | |||
1481 | void TerminalDisplay::paintFilters(QPainter& painter) | 1487 | void TerminalDisplay::paintFilters(QPainter& painter) | ||
1482 | { | 1488 | { | ||
1483 | if (_filterUpdateRequired) { | 1489 | if (_filterUpdateRequired) { | ||
1484 | return; | 1490 | return; | ||
1485 | } | 1491 | } | ||
1486 | 1492 | | |||
1487 | // get color of character under mouse and use it to draw | 1493 | // get color of character under mouse and use it to draw | ||
1488 | // lines for filters | 1494 | // lines for filters | ||
1489 | QPoint cursorPos = mapFromGlobal(QCursor::pos()); | 1495 | QPoint cursorPos = mapFromGlobal(QCursor::pos()); | ||
1490 | int cursorLine; | 1496 | int cursorLine; | ||
1491 | int cursorColumn; | 1497 | int cursorColumn; | ||
1492 | 1498 | | |||
1493 | getCharacterPosition(cursorPos, cursorLine, cursorColumn, false); | 1499 | getCharacterPosition(cursorPos, cursorLine, cursorColumn, false); | ||
1494 | Character cursorCharacter = _image[loc(cursorColumn, cursorLine)]; | 1500 | Character cursorCharacter = _image[loc(qMin(cursorColumn, _columns - 1), cursorLine)]; | ||
1495 | 1501 | | |||
1496 | painter.setPen(QPen(cursorCharacter.foregroundColor.color(colorTable()))); | 1502 | painter.setPen(QPen(cursorCharacter.foregroundColor.color(colorTable()))); | ||
1497 | 1503 | | |||
1498 | // iterate over hotspots identified by the display's currently active filters | 1504 | // iterate over hotspots identified by the display's currently active filters | ||
1499 | // and draw appropriate visuals to indicate the presence of the hotspot | 1505 | // and draw appropriate visuals to indicate the presence of the hotspot | ||
1500 | 1506 | | |||
1501 | int urlNumber = 0; | 1507 | int urlNumber = 0; | ||
1502 | QList<Filter::HotSpot*> spots = _filterChain->hotSpots(); | 1508 | QList<Filter::HotSpot*> spots = _filterChain->hotSpots(); | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 1509 | foreach(Filter::HotSpot* spot, spots) { | |||
1546 | 1552 | | |||
1547 | for (int line = spot->startLine() ; line <= spot->endLine() ; line++) { | 1553 | for (int line = spot->startLine() ; line <= spot->endLine() ; line++) { | ||
1548 | int startColumn = 0; | 1554 | int startColumn = 0; | ||
1549 | int endColumn = _columns - 1; // TODO use number of _columns which are actually | 1555 | int endColumn = _columns - 1; // TODO use number of _columns which are actually | ||
1550 | // occupied on this line rather than the width of the | 1556 | // occupied on this line rather than the width of the | ||
1551 | // display in _columns | 1557 | // display in _columns | ||
1552 | 1558 | | |||
1553 | // Check image size so _image[] is valid (see makeImage) | 1559 | // Check image size so _image[] is valid (see makeImage) | ||
1554 | if (loc(endColumn, line) > _imageSize) { | 1560 | if (endColumn >= _columns || line >= _lines) { | ||
1555 | break; | 1561 | break; | ||
1556 | } | 1562 | } | ||
1557 | 1563 | | |||
1558 | // ignore whitespace at the end of the lines | 1564 | // ignore whitespace at the end of the lines | ||
1559 | while (_image[loc(endColumn, line)].isSpace() && endColumn > 0) { | 1565 | while (_image[loc(endColumn, line)].isSpace() && endColumn > 0) { | ||
1560 | endColumn--; | 1566 | endColumn--; | ||
1561 | } | 1567 | } | ||
1562 | 1568 | | |||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 1688 | } else { | |||
1684 | const quint16 c = _image[loc(x, y)].character; | 1690 | const quint16 c = _image[loc(x, y)].character; | ||
1685 | if (c != 0u) { | 1691 | if (c != 0u) { | ||
1686 | Q_ASSERT(p < bufferSize); | 1692 | Q_ASSERT(p < bufferSize); | ||
1687 | disstrU[p++] = c; //fontMap(c); | 1693 | disstrU[p++] = c; //fontMap(c); | ||
1688 | } | 1694 | } | ||
1689 | } | 1695 | } | ||
1690 | 1696 | | |||
1691 | const bool lineDraw = _image[loc(x, y)].isLineChar(); | 1697 | const bool lineDraw = _image[loc(x, y)].isLineChar(); | ||
1692 | const bool doubleWidth = (_image[ qMin(loc(x, y) + 1, _imageSize) ].character == 0); | 1698 | const bool doubleWidth = (_image[qMin(loc(x, y) + 1, _imageSize - 1)].character == 0); | ||
1693 | const CharacterColor currentForeground = _image[loc(x, y)].foregroundColor; | 1699 | const CharacterColor currentForeground = _image[loc(x, y)].foregroundColor; | ||
1694 | const CharacterColor currentBackground = _image[loc(x, y)].backgroundColor; | 1700 | const CharacterColor currentBackground = _image[loc(x, y)].backgroundColor; | ||
1695 | const RenditionFlags currentRendition = _image[loc(x, y)].rendition; | 1701 | const RenditionFlags currentRendition = _image[loc(x, y)].rendition; | ||
1696 | const bool rtl = isRtl(_image[loc(x, y)]); | 1702 | const bool rtl = isRtl(_image[loc(x, y)]); | ||
1697 | 1703 | | |||
1698 | if(_image[loc(x, y)].character <= 0x7e || rtl) { | 1704 | if(_image[loc(x, y)].character <= 0x7e || rtl) { | ||
1699 | while (x + len <= rlx && | 1705 | while (x + len <= rlx && | ||
1700 | _image[loc(x + len, y)].foregroundColor == currentForeground && | 1706 | _image[loc(x + len, y)].foregroundColor == currentForeground && | ||
1701 | _image[loc(x + len, y)].backgroundColor == currentBackground && | 1707 | _image[loc(x + len, y)].backgroundColor == currentBackground && | ||
1702 | (_image[loc(x + len, y)].rendition & ~RE_EXTENDED_CHAR) == (currentRendition & ~RE_EXTENDED_CHAR) && | 1708 | (_image[loc(x + len, y)].rendition & ~RE_EXTENDED_CHAR) == (currentRendition & ~RE_EXTENDED_CHAR) && | ||
1703 | (_image[ qMin(loc(x + len, y) + 1, _imageSize) ].character == 0) == doubleWidth && | 1709 | (_image[qMin(loc(x + len, y) + 1, _imageSize - 1)].character == 0) == doubleWidth && | ||
1704 | _image[loc(x + len, y)].isLineChar() == lineDraw && | 1710 | _image[loc(x + len, y)].isLineChar() == lineDraw && | ||
1705 | (_image[loc(x + len, y)].character <= 0x7e || rtl)) { | 1711 | (_image[loc(x + len, y)].character <= 0x7e || rtl)) { | ||
1706 | const quint16 c = _image[loc(x + len, y)].character; | 1712 | const quint16 c = _image[loc(x + len, y)].character; | ||
1707 | if ((_image[loc(x + len, y)].rendition & RE_EXTENDED_CHAR) != 0) { | 1713 | if ((_image[loc(x + len, y)].rendition & RE_EXTENDED_CHAR) != 0) { | ||
1708 | // sequence of characters | 1714 | // sequence of characters | ||
1709 | ushort extendedCharLength = 0; | 1715 | ushort extendedCharLength = 0; | ||
1710 | const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(c, extendedCharLength); | 1716 | const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(c, extendedCharLength); | ||
1711 | if (chars != nullptr) { | 1717 | if (chars != nullptr) { | ||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 1929 | { | |||
1924 | Q_ASSERT(_allowBlinkingCursor); | 1930 | Q_ASSERT(_allowBlinkingCursor); | ||
1925 | 1931 | | |||
1926 | _cursorBlinking = !_cursorBlinking; | 1932 | _cursorBlinking = !_cursorBlinking; | ||
1927 | updateCursor(); | 1933 | updateCursor(); | ||
1928 | } | 1934 | } | ||
1929 | 1935 | | |||
1930 | void TerminalDisplay::updateCursor() | 1936 | void TerminalDisplay::updateCursor() | ||
1931 | { | 1937 | { | ||
1932 | int cursorLocation = loc(cursorPosition().x(), cursorPosition().y()); | 1938 | if (!isCursorOnDisplay()){ | ||
1939 | return; | ||||
1940 | } | ||||
1941 | | ||||
1942 | const int cursorLocation = loc(cursorPosition().x(), cursorPosition().y()); | ||||
1943 | Q_ASSERT(cursorLocation < _imageSize); | ||||
1944 | | ||||
1933 | int charWidth = konsole_wcwidth(_image[cursorLocation].character); | 1945 | int charWidth = konsole_wcwidth(_image[cursorLocation].character); | ||
1934 | QRect cursorRect = imageToWidget(QRect(cursorPosition(), QSize(charWidth, 1))); | 1946 | QRect cursorRect = imageToWidget(QRect(cursorPosition(), QSize(charWidth, 1))); | ||
1935 | update(cursorRect); | 1947 | update(cursorRect); | ||
1936 | } | 1948 | } | ||
1937 | 1949 | | |||
1938 | /* ------------------------------------------------------------------------- */ | 1950 | /* ------------------------------------------------------------------------- */ | ||
1939 | /* */ | 1951 | /* */ | ||
1940 | /* Geometry & Resizing */ | 1952 | /* Geometry & Resizing */ | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 2005 | { | |||
1997 | 2009 | | |||
1998 | // confirm that array will be of non-zero size, since the painting code | 2010 | // confirm that array will be of non-zero size, since the painting code | ||
1999 | // assumes a non-zero array length | 2011 | // assumes a non-zero array length | ||
2000 | Q_ASSERT(_lines > 0 && _columns > 0); | 2012 | Q_ASSERT(_lines > 0 && _columns > 0); | ||
2001 | Q_ASSERT(_usedLines <= _lines && _usedColumns <= _columns); | 2013 | Q_ASSERT(_usedLines <= _lines && _usedColumns <= _columns); | ||
2002 | 2014 | | |||
2003 | _imageSize = _lines * _columns; | 2015 | _imageSize = _lines * _columns; | ||
2004 | 2016 | | |||
2005 | // We over-commit one character so that we can be more relaxed in dealing with | 2017 | _image = new Character[_imageSize]; | ||
2006 | // certain boundary conditions: _image[_imageSize] is a valid but unused position | | |||
2007 | _image = new Character[_imageSize + 1]; | | |||
2008 | 2018 | | |||
2009 | clearImage(); | 2019 | clearImage(); | ||
2010 | } | 2020 | } | ||
2011 | 2021 | | |||
2012 | void TerminalDisplay::clearImage() | 2022 | void TerminalDisplay::clearImage() | ||
2013 | { | 2023 | { | ||
2014 | for (int i = 0; i <= _imageSize; ++i) { | 2024 | for (int i = 0; i < _imageSize; ++i) { | ||
2015 | _image[i] = Screen::DefaultChar; | 2025 | _image[i] = Screen::DefaultChar; | ||
2016 | } | 2026 | } | ||
2017 | } | 2027 | } | ||
2018 | 2028 | | |||
2019 | void TerminalDisplay::calcGeometry() | 2029 | void TerminalDisplay::calcGeometry() | ||
2020 | { | 2030 | { | ||
2021 | _scrollBar->resize(_scrollBar->sizeHint().width(), contentsRect().height()); | 2031 | _scrollBar->resize(_scrollBar->sizeHint().width(), contentsRect().height()); | ||
2022 | _contentRect = contentsRect().adjusted(_margin, _margin, -_margin, -_margin); | 2032 | _contentRect = contentsRect().adjusted(_margin, _margin, -_margin, -_margin); | ||
▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Line(s) | 2475 | if (_wordSelectionMode) { | |||
2470 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | 2480 | const bool left_not_right = (here.y() < _iPntSelCorr.y() || | ||
2471 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | 2481 | (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); | ||
2472 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | 2482 | const bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || | ||
2473 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | 2483 | (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); | ||
2474 | swapping = left_not_right != old_left_not_right; | 2484 | swapping = left_not_right != old_left_not_right; | ||
2475 | 2485 | | |||
2476 | // Find left (left_not_right ? from here : from start) | 2486 | // Find left (left_not_right ? from here : from start) | ||
2477 | QPoint left = left_not_right ? here : _iPntSelCorr; | 2487 | QPoint left = left_not_right ? here : _iPntSelCorr; | ||
2478 | i = loc(left.x(), left.y()); | 2488 | i = loc(qBound(0, left.x(), _columns - 1), qBound(0, left.y(), _lines - 1)); | ||
2479 | if (i >= 0 && i <= _imageSize) { | 2489 | if (i >= 0 && i < _imageSize) { | ||
2480 | selClass = charClass(_image[i]); | 2490 | selClass = charClass(_image[qMin(i, _imageSize - 1)]); | ||
2481 | while (((left.x() > 0) || (left.y() > 0 && ((_lineProperties[left.y() - 1] & LINE_WRAPPED) != 0))) | 2491 | while (((left.x() > 0) || (left.y() > 0 && ((_lineProperties[left.y() - 1] & LINE_WRAPPED) != 0))) | ||
2482 | && charClass(_image[i - 1]) == selClass) { | 2492 | && charClass(_image[i - 1]) == selClass) { | ||
2483 | i--; | 2493 | i--; | ||
2484 | if (left.x() > 0) { | 2494 | if (left.x() > 0) { | ||
2485 | left.rx()--; | 2495 | left.rx()--; | ||
2486 | } else { | 2496 | } else { | ||
2487 | left.rx() = _usedColumns - 1; | 2497 | left.rx() = _usedColumns - 1; | ||
2488 | left.ry()--; | 2498 | left.ry()--; | ||
2489 | } | 2499 | } | ||
2490 | } | 2500 | } | ||
2491 | } | 2501 | } | ||
2492 | 2502 | | |||
2493 | // Find left (left_not_right ? from start : from here) | 2503 | // Find left (left_not_right ? from start : from here) | ||
2494 | QPoint right = left_not_right ? _iPntSelCorr : here; | 2504 | QPoint right = left_not_right ? _iPntSelCorr : here; | ||
2495 | i = loc(right.x(), right.y()); | 2505 | i = loc(qBound(0, left.x(), _columns - 1), qBound(0, left.y(), _lines - 1)); | ||
2496 | if (i >= 0 && i <= _imageSize) { | 2506 | if (i >= 0 && i < _imageSize) { | ||
2497 | selClass = charClass(_image[i]); | 2507 | selClass = charClass(_image[qMin(i, _imageSize - 1)]); | ||
2498 | while (((right.x() < _usedColumns - 1) || (right.y() < _usedLines - 1 && ((_lineProperties[right.y()] & LINE_WRAPPED) != 0))) | 2508 | while (((right.x() < _usedColumns - 1) || (right.y() < _usedLines - 1 && ((_lineProperties[right.y()] & LINE_WRAPPED) != 0))) | ||
2499 | && charClass(_image[i + 1]) == selClass) { | 2509 | && charClass(_image[i + 1]) == selClass) { | ||
2500 | i++; | 2510 | i++; | ||
2501 | if (right.x() < _usedColumns - 1) { | 2511 | if (right.x() < _usedColumns - 1) { | ||
2502 | right.rx()++; | 2512 | right.rx()++; | ||
2503 | } else { | 2513 | } else { | ||
2504 | right.rx() = 0; | 2514 | right.rx() = 0; | ||
2505 | right.ry()++; | 2515 | right.ry()++; | ||
Show All 40 Lines | 2549 | if (!_wordSelectionMode && !_lineSelectionMode) { | |||
2546 | swapping = left_not_right != old_left_not_right; | 2556 | swapping = left_not_right != old_left_not_right; | ||
2547 | 2557 | | |||
2548 | // Find left (left_not_right ? from here : from start) | 2558 | // Find left (left_not_right ? from here : from start) | ||
2549 | const QPoint left = left_not_right ? here : _iPntSelCorr; | 2559 | const QPoint left = left_not_right ? here : _iPntSelCorr; | ||
2550 | 2560 | | |||
2551 | // Find left (left_not_right ? from start : from here) | 2561 | // Find left (left_not_right ? from start : from here) | ||
2552 | QPoint right = left_not_right ? _iPntSelCorr : here; | 2562 | QPoint right = left_not_right ? _iPntSelCorr : here; | ||
2553 | if (right.x() > 0 && !_columnSelectionMode) { | 2563 | if (right.x() > 0 && !_columnSelectionMode) { | ||
2554 | int i = loc(right.x(), right.y()); | 2564 | if (right.x() - 1 < _columns && right.y() < _lines) { | ||
2555 | if (i >= 0 && i <= _imageSize) { | 2565 | selClass = charClass(_image[loc(right.x() - 1, right.y())]); | ||
2556 | selClass = charClass(_image[i - 1]); | | |||
2557 | /* if (selClass == ' ') | | |||
2558 | { | | |||
2559 | while ( right.x() < _usedColumns-1 && charClass(_image[i+1].character) == selClass && (right.y()<_usedLines-1) && | | |||
2560 | !(_lineProperties[right.y()] & LINE_WRAPPED)) | | |||
2561 | { i++; right.rx()++; } | | |||
2562 | if (right.x() < _usedColumns-1) | | |||
2563 | right = left_not_right ? _iPntSelCorr : here; | | |||
2564 | else | | |||
2565 | right.rx()++; // will be balanced later because of offset=-1; | | |||
2566 | }*/ | | |||
2567 | } | 2566 | } | ||
2568 | } | 2567 | } | ||
2569 | 2568 | | |||
2570 | // Pick which is start (ohere) and which is extension (here) | 2569 | // Pick which is start (ohere) and which is extension (here) | ||
2571 | if (left_not_right) { | 2570 | if (left_not_right) { | ||
2572 | here = left; | 2571 | here = left; | ||
2573 | ohere = right; | 2572 | ohere = right; | ||
2574 | offset = 0; | 2573 | offset = 0; | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 2708 | if (_screenWindow.isNull()) { | |||
2710 | return; | 2709 | return; | ||
2711 | } | 2710 | } | ||
2712 | 2711 | | |||
2713 | int charLine = 0; | 2712 | int charLine = 0; | ||
2714 | int charColumn = 0; | 2713 | int charColumn = 0; | ||
2715 | 2714 | | |||
2716 | getCharacterPosition(ev->pos(), charLine, charColumn); | 2715 | getCharacterPosition(ev->pos(), charLine, charColumn); | ||
2717 | 2716 | | |||
2718 | QPoint pos(charColumn, charLine); | 2717 | QPoint pos(qMin(charColumn, _columns - 1), qMin(charLine, _lines - 1)); | ||
2719 | 2718 | | |||
2720 | // pass on double click as two clicks. | 2719 | // pass on double click as two clicks. | ||
2721 | if (!_mouseMarks && !(ev->modifiers() & Qt::ShiftModifier)) { | 2720 | if (!_mouseMarks && !(ev->modifiers() & Qt::ShiftModifier)) { | ||
2722 | if(!_readOnly) { | 2721 | if(!_readOnly) { | ||
2723 | // Send just _ONE_ click event, since the first click of the double click | 2722 | // Send just _ONE_ click event, since the first click of the double click | ||
2724 | // was already sent by the click handler | 2723 | // was already sent by the click handler | ||
2725 | emit mouseSignal(0, charColumn + 1, | 2724 | emit mouseSignal(0, charColumn + 1, | ||
2726 | charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), | 2725 | charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), | ||
▲ Show 20 Lines • Show All 624 Lines • ▼ Show 20 Line(s) | |||||
3351 | 3350 | | |||
3352 | void TerminalDisplay::inputMethodEvent(QInputMethodEvent* event) | 3351 | void TerminalDisplay::inputMethodEvent(QInputMethodEvent* event) | ||
3353 | { | 3352 | { | ||
3354 | if (!event->commitString().isEmpty()) { | 3353 | if (!event->commitString().isEmpty()) { | ||
3355 | QKeyEvent keyEvent(QEvent::KeyPress, 0, Qt::NoModifier, event->commitString()); | 3354 | QKeyEvent keyEvent(QEvent::KeyPress, 0, Qt::NoModifier, event->commitString()); | ||
3356 | emit keyPressedSignal(&keyEvent); | 3355 | emit keyPressedSignal(&keyEvent); | ||
3357 | } | 3356 | } | ||
3358 | 3357 | | |||
3359 | if (!_readOnly) { | 3358 | if (!_readOnly && isCursorOnDisplay()) { | ||
3360 | _inputMethodData.preeditString = event->preeditString(); | 3359 | _inputMethodData.preeditString = event->preeditString(); | ||
3361 | update(preeditRect() | _inputMethodData.previousPreeditRect); | 3360 | update(preeditRect() | _inputMethodData.previousPreeditRect); | ||
3362 | } | 3361 | } | ||
3363 | event->accept(); | 3362 | event->accept(); | ||
3364 | } | 3363 | } | ||
3365 | 3364 | | |||
3366 | QVariant TerminalDisplay::inputMethodQuery(Qt::InputMethodQuery query) const | 3365 | QVariant TerminalDisplay::inputMethodQuery(Qt::InputMethodQuery query) const | ||
3367 | { | 3366 | { | ||
3368 | const QPoint cursorPos = cursorPosition(); | 3367 | const QPoint cursorPos = cursorPosition(); | ||
3369 | switch (query) { | 3368 | switch (query) { | ||
3370 | case Qt::ImMicroFocus: | 3369 | case Qt::ImMicroFocus: | ||
3371 | return imageToWidget(QRect(cursorPos.x(), cursorPos.y(), 1, 1)); | 3370 | return imageToWidget(QRect(cursorPos.x(), cursorPos.y(), 1, 1)); | ||
3372 | case Qt::ImFont: | 3371 | case Qt::ImFont: | ||
3373 | return font(); | 3372 | return font(); | ||
3374 | case Qt::ImCursorPosition: | 3373 | case Qt::ImCursorPosition: | ||
3375 | // return the cursor position within the current line | 3374 | // return the cursor position within the current line | ||
3376 | return cursorPos.x(); | 3375 | return cursorPos.x(); | ||
3377 | case Qt::ImSurroundingText: { | 3376 | case Qt::ImSurroundingText: { | ||
3378 | // return the text from the current line | 3377 | // return the text from the current line | ||
3379 | QString lineText; | 3378 | QString lineText; | ||
3380 | QTextStream stream(&lineText); | 3379 | QTextStream stream(&lineText); | ||
3381 | PlainTextDecoder decoder; | 3380 | PlainTextDecoder decoder; | ||
3382 | decoder.begin(&stream); | 3381 | decoder.begin(&stream); | ||
3382 | if (isCursorOnDisplay()) { | ||||
3383 | decoder.decodeLine(&_image[loc(0, cursorPos.y())], _usedColumns, LINE_DEFAULT); | 3383 | decoder.decodeLine(&_image[loc(0, cursorPos.y())], _usedColumns, LINE_DEFAULT); | ||
3384 | } | ||||
3384 | decoder.end(); | 3385 | decoder.end(); | ||
3385 | return lineText; | 3386 | return lineText; | ||
3386 | } | 3387 | } | ||
3387 | case Qt::ImCurrentSelection: | 3388 | case Qt::ImCurrentSelection: | ||
3388 | return QString(); | 3389 | return QString(); | ||
3389 | default: | 3390 | default: | ||
3390 | break; | 3391 | break; | ||
3391 | } | 3392 | } | ||
Show All 13 Lines | 3404 | const QRect stringRect(_contentRect.left() + _fontWidth * cursorPosition().x(), | |||
3405 | _fontWidth * preeditLength, | 3406 | _fontWidth * preeditLength, | ||
3406 | _fontHeight); | 3407 | _fontHeight); | ||
3407 | 3408 | | |||
3408 | return stringRect.intersected(_contentRect); | 3409 | return stringRect.intersected(_contentRect); | ||
3409 | } | 3410 | } | ||
3410 | 3411 | | |||
3411 | void TerminalDisplay::drawInputMethodPreeditString(QPainter& painter , const QRect& rect) | 3412 | void TerminalDisplay::drawInputMethodPreeditString(QPainter& painter , const QRect& rect) | ||
3412 | { | 3413 | { | ||
3413 | if (_inputMethodData.preeditString.isEmpty()) { | 3414 | if (_inputMethodData.preeditString.isEmpty() || !isCursorOnDisplay()) { | ||
3414 | return; | 3415 | return; | ||
3415 | } | 3416 | } | ||
3416 | 3417 | | |||
3417 | const QPoint cursorPos = cursorPosition(); | 3418 | const QPoint cursorPos = cursorPosition(); | ||
3418 | 3419 | | |||
3419 | bool invertColors = false; | 3420 | bool invertColors = false; | ||
3420 | const QColor background = _colorTable[DEFAULT_BACK_COLOR]; | 3421 | const QColor background = _colorTable[DEFAULT_BACK_COLOR]; | ||
3421 | const QColor foreground = _colorTable[DEFAULT_FORE_COLOR]; | 3422 | const QColor foreground = _colorTable[DEFAULT_FORE_COLOR]; | ||
▲ Show 20 Lines • Show All 505 Lines • Show Last 20 Lines |