- enhancement: Internal optimization for open/edit files.
This commit is contained in:
parent
bbe79297ef
commit
e0438b1bf9
1
NEWS.md
1
NEWS.md
|
@ -31,6 +31,7 @@ Red Panda C++ Version 2.27
|
|||
- fix: "float" in #include "float.h" is wrong syntax colored.
|
||||
- enhancement: Unify syntax color for #include header name
|
||||
- enhancement: Issue #229 Press Enter/Return in the tree view in files panel will open the file.
|
||||
- enhancement: Internal optimization for open/edit files.
|
||||
|
||||
Red Panda C++ Version 2.26
|
||||
- enhancement: Code suggestion for embedded std::vectors.
|
||||
|
|
|
@ -5298,6 +5298,7 @@ void Editor::setActiveBreakpointFocus(int Line, bool setFocus)
|
|||
|
||||
void Editor::applySettings()
|
||||
{
|
||||
incPaintLock();
|
||||
QSynedit::EditorOptions options = QSynedit::eoAltSetsColumnMode |
|
||||
QSynedit::eoDragDropEditing | QSynedit::eoDropFiles | QSynedit::eoKeepCaretX | QSynedit::eoTabsToSpaces |
|
||||
QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo
|
||||
|
@ -5414,6 +5415,7 @@ void Editor::applySettings()
|
|||
setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed());
|
||||
setMouseSelectionScrollSpeed(pSettings->editor().mouseSelectionScrollSpeed());
|
||||
invalidate();
|
||||
decPaintLock();
|
||||
}
|
||||
|
||||
static QSynedit::PTokenAttribute createRainbowAttribute(const QString& attrName, const QString& schemeName, const QString& schemeItemName) {
|
||||
|
|
|
@ -146,7 +146,10 @@ int Document::longestLineWidth() {
|
|||
mIndexOfLongestLine = -1;
|
||||
if (mLines.count() > 0 ) {
|
||||
for (int i=0;i<mLines.size();i++) {
|
||||
int len = lineWidth(i);
|
||||
int len = mLines[i]->width();
|
||||
//Just estimate it.
|
||||
if (len<0)
|
||||
len = mCharWidth * mLines[i]->lineText().length();
|
||||
if (len > MaxLen) {
|
||||
MaxLen = len;
|
||||
mIndexOfLongestLine = i;
|
||||
|
|
|
@ -634,7 +634,12 @@ bool QSynEdit::pointToLine(const QPoint &point, int &line)
|
|||
|
||||
void QSynEdit::invalidateGutter()
|
||||
{
|
||||
invalidateGutterLines(-1, -1);
|
||||
if (mPaintLock>0) {
|
||||
mStateFlags.setFlag(StateFlag::sfGutterRedrawNeeded);
|
||||
} else {
|
||||
mStateFlags.setFlag(StateFlag::sfGutterRedrawNeeded, false);
|
||||
invalidateGutterLines(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void QSynEdit::invalidateGutterLine(int aLine)
|
||||
|
@ -1050,10 +1055,12 @@ void QSynEdit::invalidateRect(const QRect &rect)
|
|||
|
||||
void QSynEdit::invalidate()
|
||||
{
|
||||
if (mPainterLock>0)
|
||||
return;
|
||||
// qDebug()<<"invalidate";
|
||||
viewport()->update();
|
||||
if (mPainterLock>0) {
|
||||
mStateFlags.setFlag(StateFlag::sfRedrawNeeded);
|
||||
} else {
|
||||
mStateFlags.setFlag(StateFlag::sfRedrawNeeded, false);
|
||||
viewport()->update();
|
||||
}
|
||||
}
|
||||
|
||||
void QSynEdit::lockPainter()
|
||||
|
@ -2968,6 +2975,10 @@ void QSynEdit::decPaintLock()
|
|||
}
|
||||
if (mStateFlags.testFlag(StateFlag::sfCaretChanged))
|
||||
updateCaret();
|
||||
if (mStateFlags.testFlag(StateFlag::sfGutterRedrawNeeded))
|
||||
invalidateGutter();
|
||||
if (mStateFlags.testFlag(StateFlag::sfRedrawNeeded))
|
||||
invalidate();
|
||||
if (mStatusChanges!=0)
|
||||
doOnStatusChange(mStatusChanges);
|
||||
onEndFirstPaintLock();
|
||||
|
@ -3001,8 +3012,10 @@ QRect QSynEdit::clientRect() const
|
|||
|
||||
void QSynEdit::synFontChanged()
|
||||
{
|
||||
incPaintLock();
|
||||
recalcCharExtent();
|
||||
onSizeOrFontChanged(true);
|
||||
decPaintLock();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3799,8 +3812,12 @@ void QSynEdit::setLineSpacingFactor(double newLineSpacingFactor)
|
|||
{
|
||||
if (newLineSpacingFactor<1.0)
|
||||
newLineSpacingFactor = 1.0;
|
||||
mLineSpacingFactor = newLineSpacingFactor;
|
||||
recalcCharExtent();
|
||||
if (mLineSpacingFactor != newLineSpacingFactor) {
|
||||
incPaintLock();
|
||||
mLineSpacingFactor = newLineSpacingFactor;
|
||||
recalcCharExtent();
|
||||
decPaintLock();
|
||||
}
|
||||
}
|
||||
|
||||
ScrollStyle QSynEdit::scrollBars() const
|
||||
|
@ -3912,8 +3929,10 @@ int QSynEdit::rightEdge() const
|
|||
void QSynEdit::setRightEdge(int newRightEdge)
|
||||
{
|
||||
if (mRightEdge != newRightEdge) {
|
||||
incPaintLock();
|
||||
mRightEdge = newRightEdge;
|
||||
invalidate();
|
||||
decPaintLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4006,8 +4025,10 @@ void QSynEdit::setCaretColor(const QColor &caretColor)
|
|||
void QSynEdit::setTabSize(int newTabSize)
|
||||
{
|
||||
if (newTabSize!=tabSize()) {
|
||||
incPaintLock();
|
||||
mDocument->setTabSize(newTabSize);
|
||||
invalidate();
|
||||
decPaintLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4023,6 +4044,7 @@ static bool sameEditorOption(const EditorOptions& value1, const EditorOptions& v
|
|||
void QSynEdit::setOptions(const EditorOptions &Value)
|
||||
{
|
||||
if (Value != mOptions) {
|
||||
incPaintLock();
|
||||
//bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles);
|
||||
//if (!mOptions.testFlag(eoScrollPastEol))
|
||||
setLeftPos(mLeftPos);
|
||||
|
@ -4037,8 +4059,6 @@ void QSynEdit::setOptions(const EditorOptions &Value)
|
|||
|| !sameEditorOption(Value,mOptions, eoShowTrailingSpaces)
|
||||
|| !sameEditorOption(Value,mOptions, eoShowLineBreaks)
|
||||
|| !sameEditorOption(Value,mOptions, eoShowRainbowColor);
|
||||
//bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions);
|
||||
bool bUpdateScroll = true;
|
||||
mOptions = Value;
|
||||
|
||||
mDocument->setForceMonospace(mOptions.testFlag(eoForceMonospace) );
|
||||
|
@ -4052,13 +4072,9 @@ void QSynEdit::setOptions(const EditorOptions &Value)
|
|||
setBlockEnd(vTempBlockEnd);
|
||||
}
|
||||
updateScrollbars();
|
||||
// (un)register HWND as drop target
|
||||
// if bSetDrag and not (csDesigning in ComponentState) and HandleAllocated then
|
||||
// DragAcceptFiles(Handle, (eoDropFiles in fOptions));
|
||||
if (bUpdateAll)
|
||||
invalidate();
|
||||
if (bUpdateScroll)
|
||||
updateScrollbars();
|
||||
decPaintLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6889,6 +6905,7 @@ void QSynEdit::setTopLine(int Value)
|
|||
|
||||
void QSynEdit::onGutterChanged()
|
||||
{
|
||||
incPaintLock();
|
||||
if (mGutter.showLineNumbers() && mGutter.autoSize())
|
||||
mGutter.autoSizeDigitCount(mDocument->count());
|
||||
int nW;
|
||||
|
@ -6902,6 +6919,7 @@ void QSynEdit::onGutterChanged()
|
|||
invalidateGutter();
|
||||
else
|
||||
setGutterWidth(nW);
|
||||
decPaintLock();
|
||||
}
|
||||
|
||||
void QSynEdit::onScrollTimeout()
|
||||
|
|
|
@ -61,13 +61,15 @@ Q_DECLARE_FLAGS(StatusChanges, StatusChange)
|
|||
Q_DECLARE_OPERATORS_FOR_FLAGS(StatusChanges)
|
||||
|
||||
enum class StateFlag {
|
||||
sfCaretChanged = 0x0001,
|
||||
sfScrollbarChanged = 0x0002,
|
||||
sfLinesChanging = 0x0004,
|
||||
sfIgnoreNextChar = 0x0008,
|
||||
sfCaretVisible = 0x0010,
|
||||
sfDblClicked = 0x0020,
|
||||
sfWaitForDragging = 0x0040
|
||||
sfCaretChanged = 0x0001,
|
||||
sfScrollbarChanged = 0x0002,
|
||||
sfLinesChanging = 0x0004,
|
||||
sfIgnoreNextChar = 0x0008,
|
||||
sfCaretVisible = 0x0010,
|
||||
sfDblClicked = 0x0020,
|
||||
sfWaitForDragging = 0x0040,
|
||||
sfRedrawNeeded = 0x0080,
|
||||
sfGutterRedrawNeeded = 0x0100,
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(StateFlags,StateFlag)
|
||||
|
@ -271,6 +273,8 @@ public:
|
|||
void addGroupBreak();
|
||||
void beginEditing();
|
||||
void endEditing();
|
||||
void beginSetting();
|
||||
void endSetting();
|
||||
void addCaretToUndo();
|
||||
void addLeftTopToUndo();
|
||||
void addSelectionToUndo();
|
||||
|
@ -498,6 +502,8 @@ protected:
|
|||
|
||||
protected:
|
||||
void doSelectLine();
|
||||
void incPaintLock();
|
||||
void decPaintLock();
|
||||
private:
|
||||
BufferCoord ensureBufferCoordValid(const BufferCoord& coord);
|
||||
void beginEditingWithoutUndo();
|
||||
|
@ -506,8 +512,7 @@ private:
|
|||
void computeCaret();
|
||||
void computeScroll(bool isDragging);
|
||||
|
||||
void incPaintLock();
|
||||
void decPaintLock();
|
||||
|
||||
int clientWidth() const;
|
||||
int clientHeight() const;
|
||||
int clientTop() const;
|
||||
|
@ -743,6 +748,7 @@ private:
|
|||
int mPaintTransientLock;
|
||||
bool mIsScrolling;
|
||||
int mPainterLock; // lock counter to prevent repaint while painting
|
||||
int mOptionLock; // lock counter to prevent recalculate glyph widths while change settings;
|
||||
bool mUndoing;
|
||||
// event handlers
|
||||
// ProcessCommandProc mOnCommandProcessed;
|
||||
|
|
Loading…
Reference in New Issue