diff --git a/NEWS.md b/NEWS.md index ee80ac75..ff9fb9f9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,7 @@ Red Panda C++ Version 2.8 - fix: Input any content will exit column mode. - fix: Result of scope calculation not right if a for statement immediately follows another for statement. - fix: Function parameters that is pointer,reference or array can't be correctly parsed. + - fix: In column mode, selection that contain lines with different length will cause error. Red Panda C++ Version 2.7 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index ed2cfdb5..f7672ff3 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3819,7 +3819,7 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG - stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); +// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif @@ -3833,7 +3833,7 @@ void CppParser::internalParse(const QString &fileName) if (mTokenizer.tokenCount() == 0) return; #ifdef QT_DEBUG - mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); +// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); #endif #ifdef QT_DEBUG lastIndex = -1; @@ -3844,12 +3844,11 @@ void CppParser::internalParse(const QString &fileName) break; } #ifdef QT_DEBUG - mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); - mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); +// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); +// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); #endif //reduce memory usage internalClear(); - } } diff --git a/libs/qsynedit/qsynedit/KeyStrokes.h b/libs/qsynedit/qsynedit/KeyStrokes.h index dcc51fa7..38e2d6fc 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.h +++ b/libs/qsynedit/qsynedit/KeyStrokes.h @@ -106,10 +106,6 @@ enum class EditCommand { OverwriteMode = 222, // Set overwrite mode ToggleMode = 223, // Toggle ins/ovr mode - NormalSelect = 231, // Normal selection mode - ColumnSelect = 232, // Column selection mode - LineSelect = 233, // Line selection mode - MatchBracket = 250, // Go to matching bracket ContextHelp = 490, // Help on Word, Data = Word diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 180b0134..f180cd63 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -112,7 +112,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), this->setLineWidth(1); mInsertCaret = EditCaretType::ctVerticalLine; mOverwriteCaret = EditCaretType::ctBlock; - mSelectionMode = SelectionMode::Normal; mActiveSelectionMode = SelectionMode::Normal; mReadOnly = false; @@ -4624,19 +4623,6 @@ void SynEdit::doZoomOut() setFont(newFont); } -SelectionMode SynEdit::selectionMode() const -{ - return mSelectionMode; -} - -void SynEdit::setSelectionMode(SelectionMode value) -{ - if (mSelectionMode!=value) { - mSelectionMode = value; - setActiveSelectionMode(value); - } -} - QString SynEdit::selText() const { if (!selAvail()) { @@ -4876,6 +4862,15 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) BufferCoord ptDst = ptO; QString s = displayLineText(); int nLineLen = s.length(); + + if (mOptions.testFlag(eoAltSetsColumnMode) && + (mActiveSelectionMode != SelectionMode::Line)) { + if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) { + setActiveSelectionMode(SelectionMode::Column); + } else + setActiveSelectionMode(SelectionMode::Normal); + } + // only moving or selecting one char can change the line //bool bChangeY = !mOptions.testFlag(SynEditorOption::eoScrollPastEol); bool bChangeY=true; @@ -4912,13 +4907,7 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) } // set caret and block begin / end incPaintLock(); - if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SelectionMode::Line)) { - if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) { - setActiveSelectionMode(SelectionMode::Column); - } else - setActiveSelectionMode(selectionMode()); - } + moveCaretAndSelection(mBlockBegin, ptDst, isSelection); decPaintLock(); } @@ -4942,6 +4931,14 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) if (mOptions.testFlag(eoKeepCaretX)) ptDst.Column = mLastCaretColumn; } + if (mOptions.testFlag(eoAltSetsColumnMode) && + (mActiveSelectionMode != SelectionMode::Line)) { + if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) + setActiveSelectionMode(SelectionMode::Column); + else + setActiveSelectionMode(SelectionMode::Normal); + } + BufferCoord vDstLineChar = displayToBufferPos(ptDst); if (mActiveSelectionMode==SelectionMode::Column) { @@ -4955,13 +4952,6 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) // set caret and block begin / end incPaintLock(); - if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SelectionMode::Line)) { - if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) - setActiveSelectionMode(SelectionMode::Column); - else - setActiveSelectionMode(selectionMode()); - } moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); decPaintLock(); @@ -5119,10 +5109,18 @@ void SynEdit::setSelTextPrimitiveEx(SelectionMode mode, const QStringList &text) if (mode == SelectionMode::Column) { int colBegin = charToColumn(startPos.line,startPos.ch); int colEnd = charToColumn(endPos.line,endPos.ch); - if (colBegingetString(be.line-1).length(); insertedLines = doInsertTextByColumnMode(text, startLine,endLine); doLinesInserted(endLine-insertedLines+1,insertedLines); if (!text.isEmpty()) { - int textLen = text.back().length(); - BufferCoord bb=blockBegin(); - BufferCoord be=blockEnd(); + int textLen = mDocument->getString(be.line-1).length()-lenBefore; bb.ch+=textLen; be.ch+=textLen; internalSetCaretXY(bb); @@ -5508,6 +5507,7 @@ void SynEdit::doInsertText(const BufferCoord& pos, setBlockEnd(be); ensureCursorPosVisible(); } + } break; case SelectionMode::Line: insertedLines = doInsertTextByLineMode(pos,text, newPos); @@ -5994,15 +5994,6 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData) case EditCommand::ToggleBlockComment: doToggleBlockComment(); break; - case EditCommand::NormalSelect: - setSelectionMode(SelectionMode::Normal); - break; - case EditCommand::LineSelect: - setSelectionMode(SelectionMode::Line); - break; - case EditCommand::ColumnSelect: - setSelectionMode(SelectionMode::Column); - break; case EditCommand::ScrollLeft: horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); break; @@ -6238,8 +6229,8 @@ void SynEdit::focusOutEvent(QFocusEvent *) void SynEdit::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Escape && mActiveSelectionMode != mSelectionMode) { - setActiveSelectionMode(selectionMode()); + if (event->key() == Qt::Key_Escape && mActiveSelectionMode != SelectionMode::Normal) { + setActiveSelectionMode(SelectionMode::Normal); setBlockBegin(caretXY()); setBlockEnd(caretXY()); event->accept(); @@ -6293,7 +6284,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) computeCaret(); mStateFlags.setFlag(StateFlag::sfWaitForDragging,false); if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2) - && (mSelectionMode == SelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { + && (mActiveSelectionMode == SelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { bStartDrag = true; } if (bStartDrag && !mReadOnly) { @@ -6308,7 +6299,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) if (event->modifiers() == Qt::AltModifier && !mReadOnly) setActiveSelectionMode(SelectionMode::Column); else - setActiveSelectionMode(selectionMode()); + setActiveSelectionMode(SelectionMode::Normal); //Selection mode must be set before calling SetBlockBegin setBlockBegin(caretXY()); } @@ -6370,7 +6361,7 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) if (event->modifiers() == Qt::AltModifier && !mReadOnly) setActiveSelectionMode(SelectionMode::Column); else - setActiveSelectionMode(selectionMode()); + setActiveSelectionMode(SelectionMode::Normal); } } else if (buttons == Qt::NoButton) { updateMouseCursor(); diff --git a/libs/qsynedit/qsynedit/SynEdit.h b/libs/qsynedit/qsynedit/SynEdit.h index 826372b1..49874576 100644 --- a/libs/qsynedit/qsynedit/SynEdit.h +++ b/libs/qsynedit/qsynedit/SynEdit.h @@ -351,9 +351,6 @@ public: const PDocument& document() const; bool empty(); - SelectionMode selectionMode() const; - void setSelectionMode(SelectionMode value); - QString selText() const; QStringList getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const; @@ -687,7 +684,6 @@ private: bool mModified; QDateTime mLastModifyTime; double mLineSpacingFactor; - SelectionMode mSelectionMode; SelectionMode mActiveSelectionMode; //mode of the active selection bool mWantReturns; bool mWantTabs;