| 1526 | // ── Edit mode key handling ── |
| 1527 | |
| 1528 | bool RcxEditor::handleEditKey(QKeyEvent* ke) { |
| 1529 | // User list is handled via userListActivated signal, not here |
| 1530 | // SCI_AUTOCACTIVE is for autocomplete, not user lists |
| 1531 | |
| 1532 | switch (ke->key()) { |
| 1533 | case Qt::Key_Return: |
| 1534 | case Qt::Key_Enter: |
| 1535 | commitInlineEdit(); |
| 1536 | return true; |
| 1537 | case Qt::Key_Tab: |
| 1538 | m_lastTabTarget = m_editState.target; |
| 1539 | commitInlineEdit(); |
| 1540 | return true; |
| 1541 | case Qt::Key_Escape: |
| 1542 | cancelInlineEdit(); |
| 1543 | return true; |
| 1544 | case Qt::Key_Up: |
| 1545 | case Qt::Key_Down: |
| 1546 | case Qt::Key_PageUp: |
| 1547 | case Qt::Key_PageDown: |
| 1548 | return true; // block line navigation |
| 1549 | case Qt::Key_Delete: { |
| 1550 | int line, col; |
| 1551 | m_sci->getCursorPosition(&line, &col); |
| 1552 | if (col >= editEndCol()) return true; // block at end |
| 1553 | return false; // allow delete within span |
| 1554 | } |
| 1555 | case Qt::Key_Left: |
| 1556 | case Qt::Key_Backspace: { |
| 1557 | int line, col; |
| 1558 | m_sci->getCursorPosition(&line, &col); |
| 1559 | int minCol = m_editState.spanStart; |
| 1560 | // Don't allow backing into "0x" prefix |
| 1561 | if (m_editState.target == EditTarget::Value || m_editState.target == EditTarget::BaseAddress) { |
| 1562 | QString lineText = getLineText(m_sci, m_editState.line); |
| 1563 | if (lineText.mid(m_editState.spanStart, 2).startsWith(QStringLiteral("0x"), Qt::CaseInsensitive)) |
| 1564 | minCol = m_editState.spanStart + 2; |
| 1565 | } |
| 1566 | // If there's an active selection, collapse it to the left end (Left only, not Backspace) |
| 1567 | if (ke->key() == Qt::Key_Left) { |
| 1568 | int sL, sC, eL, eC; |
| 1569 | m_sci->getSelection(&sL, &sC, &eL, &eC); |
| 1570 | if (sL >= 0 && (sL != eL || sC != eC)) { |
| 1571 | int leftEnd = qMax(qMin(sC, eC), minCol); |
| 1572 | m_sci->setCursorPosition(m_editState.line, leftEnd); |
| 1573 | return true; |
| 1574 | } |
| 1575 | } |
| 1576 | if (col <= minCol) return true; |
| 1577 | return false; |
| 1578 | } |
| 1579 | case Qt::Key_Right: { |
| 1580 | int line, col; |
| 1581 | m_sci->getCursorPosition(&line, &col); |
| 1582 | // If there's an active selection, collapse it to the right end first |
| 1583 | int sL, sC, eL, eC; |
| 1584 | m_sci->getSelection(&sL, &sC, &eL, &eC); |
| 1585 | if (sL >= 0 && (sL != eL || sC != eC)) { |
nothing calls this directly
no test coverage detected