diff --git a/NEWS.md b/NEWS.md index b159c019..716f04a0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -32,6 +32,7 @@ Red Panda C++ Version 1.0.0 - fix: parse error in avxintrin.h - fix: switch disassembly mode doesn't update contents - fix: if there is a Red Panda C++ process running program, other Red Panda C++ processes can't run program correctly. + - enhancement: ctrl+enter insert a new line at the end of current line Red Panda C++ Version 0.14.5 - fix: the "gnu c++ 20" option in compiler set options is wrong diff --git a/RedPandaIDE/qsynedit/KeyStrokes.cpp b/RedPandaIDE/qsynedit/KeyStrokes.cpp index accdba91..43ba1003 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.cpp +++ b/RedPandaIDE/qsynedit/KeyStrokes.cpp @@ -223,8 +223,10 @@ void SynEditKeyStrokes::resetDefaults() add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier); + add(SynEditorCommand::ecLineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier); + add(SynEditorCommand::ecLineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier); add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier); diff --git a/RedPandaIDE/qsynedit/KeyStrokes.h b/RedPandaIDE/qsynedit/KeyStrokes.h index ad19bc14..ff82b227 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.h +++ b/RedPandaIDE/qsynedit/KeyStrokes.h @@ -178,8 +178,11 @@ enum class SynEditorCommand { ecUserFirst = 1001, // Start of user-defined commands - ecAutoCompletion = 650, - + ecAutoCompletion = 650, + ecLineBreakAtBegin = 651, //add a line break at the begin of the line + ecLineBreakAtEnd = 652, + ecInsertLineAtBegin = 653, + ecInsertLineAtEnd = 654, //### Code Folding ### ecCollapse = ecUserFirst + 100, diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 05ff4cf2..105a7d2f 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -5628,10 +5628,22 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) clearAll(); break; case SynEditorCommand::ecInsertLine: - insertLine(Command == SynEditorCommand::ecInsertLine); + insertLine(false); break; case SynEditorCommand::ecLineBreak: - insertLine(Command == SynEditorCommand::ecLineBreak); + insertLine(true); + break; + case SynEditorCommand::ecLineBreakAtEnd: + mUndoList->BeginBlock(); + mUndoList->AddChange( + SynChangeReason::crCaret, + caretXY(), + caretXY(), + "", + activeSelectionMode()); + moveCaretToLineEnd(false); + insertLine(true); + mUndoList->EndBlock(); break; case SynEditorCommand::ecTab: doTabKey();