Skip to content

Commit

Permalink
Github Issue #175: Added pre/post steps to process pressing of arrow …
Browse files Browse the repository at this point in the history
…keys
  • Loading branch information
AngryFender committed Jun 16, 2024
1 parent 99bc859 commit 879f788
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mkedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,31 @@ void MkEdit::setSelectionUsingArrowKeys(bool isShiftPressed)
}
}

void MkEdit::setPreArrowKeys(bool isShiftPressed)
{

}

void MkEdit::setPostArrowKeys(bool isShiftPressed)
{
disconnectSignals();
QTextCursor cursor = this->textCursor();
if(!isShiftPressed){
selectRange.selectionFirstStartBlock = selectRange.selectionEndBlock = cursor.blockNumber();
selectRange.selectionFirstStartPosInBlock = selectRange.selectionEndPosInBlock = cursor.positionInBlock();
selectRange.hasSelection = false;
emit cursorPosChanged( selectRange.hasSelection, cursor.blockNumber(), getVisibleRect(), &selectRange);
connectSignals();
return;
}

if(!cursor.hasSelection()){
selectRange.selectionFirstStartBlock = cursor.blockNumber();
selectRange.selectionFirstStartPosInBlock = cursor.positionInBlock();
}
connectSignals();
}

void MkEdit::restoreTextCursor(int blockNo, int posInBlock, bool hasSelection)
{
QTextCursor cursor = this->textCursor();
Expand Down
2 changes: 2 additions & 0 deletions mkedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class MkEdit : public QTextEdit
void showSelectionAfterUndo();
void showSelectionAfterRedo();
void setSelectionUsingArrowKeys(bool isShiftPressed);
void setPreArrowKeys(bool isShiftPressed);
void setPostArrowKeys(bool isShiftPressed);

void restoreTextCursor(int blockNo, int posInBlock, bool hasSelection);

Expand Down

0 comments on commit 879f788

Please sign in to comment.