From 2ff9dee9c00e5e75cbde2c367b33688510a94782 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 5 Jul 2022 22:05:12 +0800 Subject: [PATCH] clean up qsynedit --- RedPandaIDE/qsynedit/KeyStrokes.cpp | 20 --- RedPandaIDE/qsynedit/KeyStrokes.h | 48 ++------ RedPandaIDE/qsynedit/MiscClasses.cpp | 174 --------------------------- RedPandaIDE/qsynedit/MiscClasses.h | 76 ------------ RedPandaIDE/qsynedit/SynEdit.cpp | 2 - RedPandaIDE/qsynedit/SynEdit.h | 6 - RedPandaIDE/qsynedit/TextPainter.cpp | 5 - RedPandaIDE/qsynedit/TextPainter.h | 1 - RedPandaIDE/qsynedit/Types.h | 4 - 9 files changed, 11 insertions(+), 325 deletions(-) diff --git a/RedPandaIDE/qsynedit/KeyStrokes.cpp b/RedPandaIDE/qsynedit/KeyStrokes.cpp index 61255c2a..ea99faa2 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.cpp +++ b/RedPandaIDE/qsynedit/KeyStrokes.cpp @@ -251,26 +251,6 @@ void SynEditKeyStrokes::resetDefaults() // add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); // add(SynEditorCommand::ecRedo, Qt::Key_Z, Qt::ControlModifier|Qt::ShiftModifier); -// add(SynEditorCommand::ecGotoMarker0, Qt::Key_0, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker1, Qt::Key_1, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker2, Qt::Key_2, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker3, Qt::Key_3, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker4, Qt::Key_4, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker5, Qt::Key_5, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker6, Qt::Key_6, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker7, Qt::Key_7, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker8, Qt::Key_8, Qt::ControlModifier); -// add(SynEditorCommand::ecGotoMarker9, Qt::Key_9, Qt::ControlModifier); -// add(SynEditorCommand::ecSetMarker0, Qt::Key_0, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker1, Qt::Key_1, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker2, Qt::Key_2, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker3, Qt::Key_3, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker4, Qt::Key_4, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker5, Qt::Key_5, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker6, Qt::Key_6, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker7, Qt::Key_7, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker8, Qt::Key_8, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecSetMarker9, Qt::Key_9, Qt::ControlModifier | Qt::ShiftModifier); // 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); diff --git a/RedPandaIDE/qsynedit/KeyStrokes.h b/RedPandaIDE/qsynedit/KeyStrokes.h index 362d106d..e7808444 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.h +++ b/RedPandaIDE/qsynedit/KeyStrokes.h @@ -107,30 +107,6 @@ enum class SynEditorCommand { ecMatchBracket = 250, // Go to matching bracket - ecGotoMarker0 = 301, // Goto marker - ecGotoMarker1 = 302, // Goto marker - ecGotoMarker2 = 303, // Goto marker - ecGotoMarker3 = 304, // Goto marker - ecGotoMarker4 = 305, // Goto marker - ecGotoMarker5 = 306, // Goto marker - ecGotoMarker6 = 307, // Goto marker - ecGotoMarker7 = 308, // Goto marker - ecGotoMarker8 = 309, // Goto marker - ecGotoMarker9 = 310, // Goto marker - ecSetMarker0 = 351, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker1 = 352, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker2 = 353, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker3 = 354, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker4 = 355, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker5 = 356, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker6 = 357, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker7 = 358, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker8 = 359, // Set marker, Data = PPoint - X, Y Pos - ecSetMarker9 = 360, // Set marker, Data = PPoint - X, Y Pos - - ecGotFocus = 480, - ecLostFocus = 481, - ecContextHelp = 490, // Help on Word, Data = Word ecDeleteLastChar = 501, // Delete last char (i.e. backspace key) @@ -176,24 +152,22 @@ enum class SynEditorCommand { ecZoomOut = 631, //Increase Font Size ecZoomIn = 632, //Decrease Font Size - ecAutoCompletion = 650, ecLineBreakAtBegin = 651, //add a line break at the begin of the line ecLineBreakAtEnd = 652, - ecInsertLineAtBegin = 653, - ecInsertLineAtEnd = 654, - - ecUserFirst = 1001, // Start of user-defined commands - - //### Code Folding ### - ecCollapse = ecUserFirst + 100, - ecUncollapse = ecUserFirst + 101, - ecCollapseLevel = ecUserFirst + 102, - ecUncollapseLevel = ecUserFirst + 103, - ecCollapseAll = ecUserFirst + 104, - ecUncollapseAll = ecUserFirst + 105, + ecCollapse = 700, + ecUncollapse = 701, + ecCollapseLevel = 702, + ecUncollapseLevel = 703, + ecCollapseAll = 704, + ecUncollapseAll = 705, //### End Code Folding ### + + ecUserFirst = 1001, // Start of user-defined commands + + + }; class SynKeyError: public BaseError { diff --git a/RedPandaIDE/qsynedit/MiscClasses.cpp b/RedPandaIDE/qsynedit/MiscClasses.cpp index fad76cda..87b89512 100644 --- a/RedPandaIDE/qsynedit/MiscClasses.cpp +++ b/RedPandaIDE/qsynedit/MiscClasses.cpp @@ -333,177 +333,3 @@ void SynGutter::setBorderColor(const QColor &value) setChanged(); } } - - -SynEditMark::SynEditMark(QObject * /*parent*/) -{ - mBookmarkNum = -1; -} - -int SynEditMark::Char() const -{ - return mChar; -} - -void SynEditMark::setChar(int value) -{ - if (value != mChar) { - mChar = value; - } -} - -int SynEditMark::image() const -{ - return mImage; -} - -void SynEditMark::setImage(int image) -{ - if (mImage != image) { - mImage = image; - if (mVisible) - emit changed(); - } -} - -bool SynEditMark::visible() const -{ - return mVisible; -} - -void SynEditMark::setVisible(bool visible) -{ - if (mVisible!=visible) { - mVisible = visible; - emit changed(); - } -} - -int SynEditMark::bookmarkNum() const -{ - return mBookmarkNum; -} - -void SynEditMark::setBookmarkNum(int bookmarkNum) -{ - mBookmarkNum = bookmarkNum; -} - -bool SynEditMark::internalImage() const -{ - return mInternalImage; -} - -void SynEditMark::setInternalImage(bool internalImage) -{ - if (mInternalImage!=internalImage) { - mInternalImage = internalImage; - if (mVisible) - emit changed(); - } -} - -bool SynEditMark::isBookmark() const -{ - return (mBookmarkNum>=0); -} - -int SynEditMark::line() const -{ - return mLine; -} - -void SynEditMark::setLine(int line) -{ - if (mLine!=line) { - if (mVisible && mLine>0) - emit changed(); - mLine = line; - if (mVisible && mLine>0) - emit changed(); - } -} - -SynBookMarkOpt::SynBookMarkOpt(QObject */*parent*/) -{ - mDrawBookmarksFirst = true; - mEnableKeys = true; - mGlyphsVisible = true; - mLeftMargin = 2; - mXOffset = 12; -} - -PSynIconList SynBookMarkOpt::bookmarkImages() const -{ - return mBookmarkImages; -} - -void SynBookMarkOpt::setBookmarkImages(const PSynIconList &images) -{ - if (mBookmarkImages != images) { - mBookmarkImages = images; - emit changed(); - } -} - -bool SynBookMarkOpt::drawBookmarksFirst() const -{ - return mDrawBookmarksFirst; -} - -void SynBookMarkOpt::setDrawBookmarksFirst(bool drawBookmarksFirst) -{ - if (mDrawBookmarksFirst != drawBookmarksFirst) { - mDrawBookmarksFirst = drawBookmarksFirst; - emit changed(); - } -} - -bool SynBookMarkOpt::enableKeys() const -{ - return mEnableKeys; -} - -void SynBookMarkOpt::setEnableKeys(bool enableKeys) -{ - mEnableKeys = enableKeys; -} - -bool SynBookMarkOpt::glyphsVisible() const -{ - return mGlyphsVisible; -} - -void SynBookMarkOpt::setGlyphsVisible(bool glyphsVisible) -{ - if (mGlyphsVisible!=glyphsVisible) { - mGlyphsVisible = glyphsVisible; - emit changed(); - } -} - -int SynBookMarkOpt::leftMargin() const -{ - return mLeftMargin; -} - -void SynBookMarkOpt::setLeftMargin(int leftMargin) -{ - if (leftMargin!=mLeftMargin) { - mLeftMargin = leftMargin; - emit changed(); - } -} - -int SynBookMarkOpt::xOffset() const -{ - return mXOffset; -} - -void SynBookMarkOpt::setXOffset(int xOffset) -{ - if (mXOffset!=xOffset) { - mXOffset = xOffset; - emit changed(); - } -} diff --git a/RedPandaIDE/qsynedit/MiscClasses.h b/RedPandaIDE/qsynedit/MiscClasses.h index 7d38e5df..c2341de9 100644 --- a/RedPandaIDE/qsynedit/MiscClasses.h +++ b/RedPandaIDE/qsynedit/MiscClasses.h @@ -124,80 +124,4 @@ private: using PSynGutter = std::shared_ptr; -class SynEditMark : public QObject { - Q_OBJECT -public: - explicit SynEditMark(QObject* parent = nullptr); - int Char() const; - void setChar(int value); - - int image() const; - void setImage(int image); - - bool visible() const; - void setVisible(bool visible); - - int bookmarkNum() const; - void setBookmarkNum(int bookmarkNum); - - bool internalImage() const; - void setInternalImage(bool internalImage); - - bool isBookmark() const ; - - int line() const; - void setLine(int line); - -signals: - void changed(); -protected: - int mLine; - int mChar; - int mImage; - bool mVisible; - bool mInternalImage; - int mBookmarkNum; - -}; - -using PSynEditMark = std::shared_ptr; - -using SynEditMarkList = QList; - -using PSynEditMarkList = std::shared_ptr; - -class SynBookMarkOpt: public QObject { - Q_OBJECT -public: - explicit SynBookMarkOpt(QObject* parent=nullptr); - PSynIconList bookmarkImages() const; - void setBookmarkImages(const PSynIconList &images); - - bool drawBookmarksFirst() const; - void setDrawBookmarksFirst(bool drawBookmarksFirst); - - bool enableKeys() const; - void setEnableKeys(bool enableKeys); - - bool glyphsVisible() const; - void setGlyphsVisible(bool glyphsVisible); - - int leftMargin() const; - void setLeftMargin(int leftMargin); - - int xOffset() const; - void setXOffset(int xOffset); - -signals: - void changed(); -private: - PSynIconList mBookmarkImages; - bool mDrawBookmarksFirst; - bool mEnableKeys; - bool mGlyphsVisible; - int mLeftMargin; - int mXOffset; -}; - -using PSynBookMarkOpt = std::shared_ptr; #endif // MISCCLASSES_H diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 4354ad2e..50c9cb08 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -91,7 +91,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), mSelectedBackground = palette().color(QPalette::Highlight); mSelectedForeground = palette().color(QPalette::HighlightedText); - mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::onBookMarkOptionsChanged); // fRightEdge has to be set before FontChanged is called for the first time mRightEdge = 80; @@ -2399,7 +2398,6 @@ void SynEdit::doMoveSelDown() void SynEdit::clearAll() { mDocument->clear(); - mMarkList.clear(); mUndoList->clear(); mRedoList->clear(); setModified(false); diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index b707ad53..5cc23748 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -138,7 +138,6 @@ enum class SynScrollBarKind { using SynPaintTransientProc = std::function; */ -using SynPlaceMarkProc = std::function; using SynProcessCommandProc = std::function; using SynMouseCursorProc = std::function; using SynPaintProc = std::function; @@ -689,9 +688,7 @@ private: QColor mActiveLineColor; PSynEditUndoList mUndoList; PSynEditUndoList mRedoList; - SynEditMarkList mBookMarks; QPoint mMouseDownPos; - SynBookMarkOpt mBookMarkOpt; bool mHideSelection; int mMouseWheelAccumulator; SynEditCaretType mOverwriteCaret; @@ -700,7 +697,6 @@ private: SynEditKeyStrokes mKeyStrokes; bool mModified; QDateTime mLastModifyTime; - SynEditMarkList mMarkList; int mExtraLineSpacing; SynSelectionMode mSelectionMode; SynSelectionMode mActiveSelectionMode; //mode of the active selection @@ -729,12 +725,10 @@ private: int mPainterLock; // lock counter to prevent repaint while painting bool mUndoing; // event handlers - SynPlaceMarkProc mOnClearMark; SynProcessCommandProc mOnCommandProcessed; SynMouseCursorProc mOnMouseCursor; SynPaintProc mOnPaint; // SynPreparePaintHighlightTokenProc mOnPaintHighlightToken; - SynPlaceMarkProc mOnPlaceMark; SynProcessCommandProc mOnProcessingCommand; SynProcessCommandProc mOnProcessingUserCommand; diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp index 0ec61a16..9a9dcea0 100644 --- a/RedPandaIDE/qsynedit/TextPainter.cpp +++ b/RedPandaIDE/qsynedit/TextPainter.cpp @@ -1093,8 +1093,3 @@ void SynEditTextPainter::PaintLines() bCurrentLine = false; } } - -void SynEditTextPainter::drawMark(PSynEditMark , int &, int ) -{ - //todo -} diff --git a/RedPandaIDE/qsynedit/TextPainter.h b/RedPandaIDE/qsynedit/TextPainter.h index c9200a4f..f9de7ef7 100644 --- a/RedPandaIDE/qsynedit/TextPainter.h +++ b/RedPandaIDE/qsynedit/TextPainter.h @@ -60,7 +60,6 @@ private: void PaintFoldAttributes(); void GetBraceColorAttr(int level, PSynHighlighterAttribute &attr); void PaintLines(); - void drawMark(PSynEditMark aMark,int& aGutterOff, int aMarkRow); private: SynEdit* edit; diff --git a/RedPandaIDE/qsynedit/Types.h b/RedPandaIDE/qsynedit/Types.h index d8f11174..424707d0 100644 --- a/RedPandaIDE/qsynedit/Types.h +++ b/RedPandaIDE/qsynedit/Types.h @@ -52,10 +52,6 @@ Q_DECLARE_FLAGS(SynFontStyles,SynFontStyle) Q_DECLARE_OPERATORS_FOR_FLAGS(SynFontStyles) -using PSynIcon = std::shared_ptr; -using SynIconList = QList; -using PSynIconList = std::shared_ptr; - enum class SynEditingAreaType { eatRectangleBorder, eatWaveUnderLine,