From 076a92fb776fc3b13be91219c0334d9b5f829d59 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 16 Apr 2022 20:14:47 +0800 Subject: [PATCH] - fix: tab/shift+tab not correctly handled in options dialog's code template page --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 8 ++++++++ RedPandaIDE/mainwindow.ui | 4 ++-- RedPandaIDE/qsynedit/KeyStrokes.cpp | 19 ++++++++++++++++++- RedPandaIDE/qsynedit/KeyStrokes.h | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 6 +++++- RedPandaIDE/qsynedit/SynEdit.h | 1 + 7 files changed, 36 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7d39c54a..71966c61 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ Red Panda C++ Version 1.0.4 - fix: files will be saved to default encoding inspite of its original encoding - fix: parenthesis skip doesn't work when editing non-c/c++ files - enhancement: prefer local headers over system headers when complete #include header path + - fix: tab/shift+tab not correctly handled in options dialog's code template page Red Panda C++ Version 1.0.3 - fix: when oj problem grabbed by competitive companion received, diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8a0776ce..5c6e2150 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -176,6 +176,9 @@ Editor::Editor(QWidget *parent, const QString& filename, mParentPageControl->addTab(this,""); updateCaption(); } + if (mParentPageControl==nullptr) { + setExtraKeystrokes(); + } connect(&mFunctionTipTimer, &QTimer::timeout, this, &Editor::onFunctionTipsTimer); @@ -668,8 +671,13 @@ void Editor::keyPressEvent(QKeyEvent *event) pMainWindow->functionTip()->hide(); return; case Qt::Key_Tab: + handled = true; tab(); return; + case Qt::Key_Backtab: + handled = true; + shifttab(); + return; case Qt::Key_Up: if (pMainWindow->functionTip()->isVisible()) { handled = true; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 987c956b..3f86a77c 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -2843,7 +2843,7 @@ Delete Line - Ctrl+D + Ctrl+E @@ -2851,7 +2851,7 @@ Duplicate Line - Ctrl+E + Ctrl+D diff --git a/RedPandaIDE/qsynedit/KeyStrokes.cpp b/RedPandaIDE/qsynedit/KeyStrokes.cpp index c346b4a1..01a079f7 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.cpp +++ b/RedPandaIDE/qsynedit/KeyStrokes.cpp @@ -274,5 +274,22 @@ void SynEditKeyStrokes::resetDefaults() // add(SynEditorCommand::ecNormalSelect, Qt::Key_N, Qt::ControlModifier | Qt::ShiftModifier); // add(SynEditorCommand::ecColumnSelect, Qt::Key_C, Qt::ControlModifier | Qt::ShiftModifier); // add(SynEditorCommand::ecLineSelect, Qt::Key_L, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier); + // add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier); +} + +void SynEditKeyStrokes::setExtraKeyStrokes() +{ + add(SynEditorCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); + add(SynEditorCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); + + add(SynEditorCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier); + add(SynEditorCommand::ecDeleteLine, Qt::Key_E, Qt::ControlModifier); + + add(SynEditorCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier); + add(SynEditorCommand::ecCopy, Qt::Key_C, Qt::ControlModifier); + add(SynEditorCommand::ecPaste, Qt::Key_V, Qt::ControlModifier); + add(SynEditorCommand::ecCut, Qt::Key_X, Qt::ControlModifier); + + add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); + add(SynEditorCommand::ecRedo, Qt::Key_Y, Qt::ControlModifier); } diff --git a/RedPandaIDE/qsynedit/KeyStrokes.h b/RedPandaIDE/qsynedit/KeyStrokes.h index fd4138db..362d106d 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.h +++ b/RedPandaIDE/qsynedit/KeyStrokes.h @@ -244,6 +244,7 @@ public: PSynEditKeyStroke findKeySequence(const QKeySequence& keySeq); void clear(); void resetDefaults(); + void setExtraKeyStrokes(); private: SynEditKeyStrokeList mList; }; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index dca25886..ed9c42e2 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -933,6 +933,11 @@ void SynEdit::setDefaultKeystrokes() mKeyStrokes.resetDefaults(); } +void SynEdit::setExtraKeystrokes() +{ + mKeyStrokes.setExtraKeyStrokes(); +} + void SynEdit::invalidateLine(int Line) { QRect rcInval; @@ -2425,7 +2430,6 @@ void SynEdit::doTabKey() Spaces = '\t'; NewCaretX = mCaretX + 1; } - setSelTextPrimitive(Spaces); // Undo is already handled in SetSelText when SelectionMode is Column if (mActiveSelectionMode != SynSelectionMode::smColumn) { diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index f56f6d32..3bd36fe9 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -201,6 +201,7 @@ public: int foldRowToLine(int Row) const; int foldLineToRow(int Line) const; void setDefaultKeystrokes(); + void setExtraKeystrokes(); void invalidateLine(int Line); void invalidateLines(int FirstLine, int LastLine); void invalidateSelection();