Skip to content

Commit

Permalink
make cursor next/prev block available for shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Jun 8, 2024
1 parent 9b6bb45 commit 5698236
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/qcodeedit/lib/qeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4678,6 +4678,11 @@ QHash<QString, int> QEditor::getEditOperations(bool excludeDefault){
addEditOperation(CursorPageDown, Qt::NoModifier, Qt::Key_PageDown);
addEditOperation(SelectPageDown, Qt::ShiftModifier, Qt::Key_PageDown);

registerEditOperation(CursorNextBlock);
registerEditOperation(SelectCursorNextBlock);
registerEditOperation(CursorPrevBlock);
registerEditOperation(SelectCursorPrevBlock);

addEditOperation(DeleteLeft, Qt::NoModifier, Qt::Key_Backspace);
addEditOperation(DeleteRight, QKeySequence::Delete);
#ifdef Q_OS_MAC
Expand Down Expand Up @@ -4771,6 +4776,9 @@ QString QEditor::translateEditOperation(const EditOperation& op){
case CursorPageUp: return tr("Move cursor one page up");
case CursorPageDown: return tr("Move cursor one page down");

case CursorNextBlock: return tr("Move cursor to next block");
case CursorPrevBlock: return tr("Move cursor to previous block");

case EnumForSelectionStart: return tr("Internal");

case SelectCursorUp: return tr("Select up");
Expand All @@ -4788,6 +4796,9 @@ QString QEditor::translateEditOperation(const EditOperation& op){
case SelectPageUp: return tr("Select page up");
case SelectPageDown: return tr("Select page down");

case SelectCursorNextBlock: return tr("Select to next block");
case SelectCursorPrevBlock: return tr("Select to previous block");

case EnumForCursorEnd: return tr("Internal");

case DeleteLeft: return tr("Delete left character");
Expand Down Expand Up @@ -4909,6 +4920,15 @@ void QEditor::cursorMoveOperation(QDocumentCursor &cursor, EditOperation eop){
cutBuffer.clear();
pageDown(mode);
return;

case CursorNextBlock: case SelectCursorNextBlock:
op = QDocumentCursor::NextBlock;
cutBuffer.clear();
break;
case CursorPrevBlock: case SelectCursorPrevBlock:
op = QDocumentCursor::PreviousBlock;
cutBuffer.clear();
break;
default:
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/qcodeedit/lib/qeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class QCE_EXPORT QEditor : public QAbstractScrollArea
CursorPageUp,
CursorPageDown,

CursorNextBlock,
CursorPrevBlock,

EnumForSelectionStart = 0x2000,

SelectCursorUp,
Expand All @@ -155,6 +158,9 @@ class QCE_EXPORT QEditor : public QAbstractScrollArea
SelectPageUp,
SelectPageDown,

SelectCursorNextBlock,
SelectCursorPrevBlock,

EnumForCursorEnd = 0x3000,

DeleteLeft,
Expand Down

0 comments on commit 5698236

Please sign in to comment.