- fix: greatly reduces paste time

This commit is contained in:
royqh1979@gmail.com 2021-11-13 13:03:42 +08:00
parent a6e8846282
commit be2c1ec77f
6 changed files with 21 additions and 14 deletions

View File

@ -6,6 +6,7 @@ Version 0.8.7 For Dev-C++ 7 Beta
- enhancement: drag & drop text in the editor - enhancement: drag & drop text in the editor
- enhancement: auto calcuate caret line size basing on font size - enhancement: auto calcuate caret line size basing on font size
- enhancement: shift+mouse wheel to scroll horizontally - enhancement: shift+mouse wheel to scroll horizontally
- fix: greatly reduces paste time
Version 0.8.6 For Dev-C++ 7 Beta Version 0.8.6 For Dev-C++ 7 Beta
- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+) - enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+)

View File

@ -4942,12 +4942,13 @@ void SynEdit::doLinesInserted(int firstLine, int count)
// end; // end;
} }
void SynEdit::properSetLine(int ALine, const QString &ALineText) void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify)
{ {
if (mOptions.testFlag(eoTrimTrailingSpaces)) if (mOptions.testFlag(eoTrimTrailingSpaces)) {
mLines->putString(ALine,TrimRight(ALineText)); mLines->putString(ALine,TrimRight(ALineText),notify);
else } else {
mLines->putString(ALine,ALineText); mLines->putString(ALine,ALineText,notify);
}
} }
void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE) void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE)
@ -5041,6 +5042,10 @@ void SynEdit::insertText(const QString &Value, SynSelectionMode PasteMode,bool A
int SynEdit::insertTextByNormalMode(const QString &Value) int SynEdit::insertTextByNormalMode(const QString &Value)
{ {
mLines->beginUpdate();
auto actionLines = finally([this] {
mLines->endUpdate();
});
QString sLeftSide; QString sLeftSide;
QString sRightSide; QString sRightSide;
QString Str; QString Str;
@ -5090,9 +5095,9 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = P; Start = P;
P = GetEOL(Value,Start); P = GetEOL(Value,Start);
if (P == Start) { if (P == Start) {
if (P<Value.length()) if (P<Value.length())
Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true); Str = GetLeftSpacing(calcIndentSpaces(caretY,"",true),true);
else else
Str = sRightSide; Str = sRightSide;
} else { } else {
Str = Value.mid(Start, P-Start); Str = Value.mid(Start, P-Start);
@ -5103,7 +5108,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str); Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str);
} }
} }
properSetLine(caretY - 1, Str); properSetLine(caretY - 1, Str,false);
rescanRange(caretY); rescanRange(caretY);
Result++; Result++;
} }

View File

@ -504,7 +504,7 @@ private:
const QString& Value, bool AddToUndoList); const QString& Value, bool AddToUndoList);
void doLinesDeleted(int FirstLine, int Count); void doLinesDeleted(int FirstLine, int Count);
void doLinesInserted(int FirstLine, int Count); void doLinesInserted(int FirstLine, int Count);
void properSetLine(int ALine, const QString& ALineText); void properSetLine(int ALine, const QString& ALineText, bool notify = true);
void deleteSelection(const BufferCoord& BB, const BufferCoord& BE); void deleteSelection(const BufferCoord& BB, const BufferCoord& BE);
void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList); void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
int insertTextByNormalMode(const QString& Value); int insertTextByNormalMode(const QString& Value);

View File

@ -397,7 +397,7 @@ QString SynEditStringList::getTextStr() const
return result; return result;
} }
void SynEditStringList::putString(int Index, const QString &s) { void SynEditStringList::putString(int Index, const QString &s, bool notify) {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
if (Index == mList.count()) { if (Index == mList.count()) {
add(s); add(s);
@ -409,7 +409,8 @@ void SynEditStringList::putString(int Index, const QString &s) {
mIndexOfLongestLine = -1; mIndexOfLongestLine = -1;
mList[Index]->fString = s; mList[Index]->fString = s;
mList[Index]->fColumns = -1; mList[Index]->fColumns = -1;
emit putted(Index,1); if (notify)
emit putted(Index,1);
endUpdate(); endUpdate();
} }
} }

View File

@ -67,7 +67,7 @@ public:
void setContents(const QStringList& text); void setContents(const QStringList& text);
QStringList contents(); QStringList contents();
void putString(int Index, const QString& s); void putString(int Index, const QString& s, bool notify=true);
void putObject(int Index, void * AObject); void putObject(int Index, void * AObject);
void beginUpdate(); void beginUpdate();

View File

@ -3,7 +3,7 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "beta.0.8.6" #define DEVCPP_VERSION "beta.0.8.8"
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN