- fix: indent can't be correctly undo

- change: press tab when there are selections will do indent
This commit is contained in:
Roy Qu 2021-11-30 20:43:58 +08:00
parent 4a89e97844
commit b4e70c4879
3 changed files with 27 additions and 19 deletions

View File

@ -1,5 +1,10 @@
Version 0.10.4 For Dev-C++ 7 Beta
- fix: indent can't be correctly undo
- change: press tab when there are selections will do indent
Version 0.10.3 For Dev-C++ 7 Beta Version 0.10.3 For Dev-C++ 7 Beta
- enhancement: treat files ended with ".C" or ".CPP" as C++ files - enhancement: treat files ended with ".C" or ".CPP" as C++ files
- enhancement: add option "ignore spaces when validating problem cases" to the "Executor"/"Problem Set" option tab.
Version 0.10.2 For Dev-C++ 7 Beta Version 0.10.2 For Dev-C++ 7 Beta
- fix: select by mouse can't correctly set mouse's column position - fix: select by mouse can't correctly set mouse's column position

View File

@ -2442,8 +2442,9 @@ bool SynEdit::canDoBlockIndent()
BufferCoord BE; BufferCoord BE;
if (selAvail()) { if (selAvail()) {
BB = blockBegin(); // BB = blockBegin();
BE = blockEnd(); // BE = blockEnd();
return true;
} else { } else {
BB = caretXY(); BB = caretXY();
BE = caretXY(); BE = caretXY();
@ -2579,16 +2580,16 @@ void SynEdit::computeScroll(int X, int Y, bool isDragging)
void SynEdit::doBlockIndent() void SynEdit::doBlockIndent()
{ {
BufferCoord OrgCaretPos; BufferCoord oldCaretPos;
BufferCoord BB, BE; BufferCoord BB, BE;
QString StrToInsert; QString StrToInsert;
int e,x,i; int e,x,i;
QString Spaces; QString Spaces;
SynSelectionMode OrgSelectionMode; SynSelectionMode oldSelectionMode;
BufferCoord InsertionPos; BufferCoord InsertionPos;
OrgSelectionMode = mActiveSelectionMode; oldSelectionMode = mActiveSelectionMode;
OrgCaretPos = caretXY(); oldCaretPos = caretXY();
StrToInsert = nullptr; StrToInsert = nullptr;
auto action = finally([&,this]{ auto action = finally([&,this]{
@ -2596,9 +2597,9 @@ void SynEdit::doBlockIndent()
BB.Char += Spaces.length(); BB.Char += Spaces.length();
if (BE.Char > 1) if (BE.Char > 1)
BE.Char+=Spaces.length(); BE.Char+=Spaces.length();
setCaretAndSelection(OrgCaretPos, setCaretAndSelection(oldCaretPos,
BB, BE); BB, BE);
setActiveSelectionMode(OrgSelectionMode); setActiveSelectionMode(oldSelectionMode);
}); });
// keep current selection detail // keep current selection detail
if (selAvail()) { if (selAvail()) {
@ -2647,7 +2648,7 @@ void SynEdit::doBlockIndent()
{BE.Char + Spaces.length(), BE.Line}, {BE.Char + Spaces.length(), BE.Line},
"", SynSelectionMode::smColumn); "", SynSelectionMode::smColumn);
//adjust the x position of orgcaretpos appropriately //adjust the x position of orgcaretpos appropriately
OrgCaretPos.Char = x; oldCaretPos.Char = x;
} }
} }
@ -2665,7 +2666,7 @@ void SynEdit::doBlockUnindent()
BB = caretXY(); BB = caretXY();
BE = caretXY(); BE = caretXY();
} }
BufferCoord OrgCaretPos = caretXY(); BufferCoord oldCaretPos = caretXY();
int x = 0; int x = 0;
int e = BE.Line; int e = BE.Line;
@ -2694,7 +2695,7 @@ void SynEdit::doBlockUnindent()
FirstIndent = charsToDelete; FirstIndent = charsToDelete;
if (i==e) if (i==e)
LastIndent = charsToDelete; LastIndent = charsToDelete;
if (i==OrgCaretPos.Line) if (i==oldCaretPos.Line)
x = charsToDelete; x = charsToDelete;
QString TempString = Line.mid(charsToDelete); QString TempString = Line.mid(charsToDelete);
mLines->putString(i-1,TempString); mLines->putString(i-1,TempString);
@ -2704,10 +2705,10 @@ void SynEdit::doBlockUnindent()
// restore selection // restore selection
//adjust the x position of orgcaretpos appropriately //adjust the x position of orgcaretpos appropriately
OrgCaretPos.Char -= x; oldCaretPos.Char -= x;
BB.Char -= FirstIndent; BB.Char -= FirstIndent;
BE.Char -= LastIndent; BE.Char -= LastIndent;
setCaretAndSelection(OrgCaretPos, BB, BE); setCaretAndSelection(oldCaretPos, BB, BE);
} }
void SynEdit::doAddChar(QChar AChar) void SynEdit::doAddChar(QChar AChar)
@ -4117,6 +4118,7 @@ void SynEdit::doUndoItem()
Item->changeStartPos(), Item->changeStartPos(),
Item->changeEndPos()); Item->changeEndPos());
QString TmpStr = selText(); QString TmpStr = selText();
qDebug()<<TmpStr;
setSelTextPrimitiveEx( setSelTextPrimitiveEx(
Item->changeSelMode(), Item->changeSelMode(),
Item->changeStr(), Item->changeStr(),
@ -4532,11 +4534,12 @@ QString SynEdit::selText()
std::swap(ColFrom, ColTo); std::swap(ColFrom, ColTo);
QString result; QString result;
for (int i = First; i <= Last; i++) { for (int i = First; i <= Last; i++) {
int l = columnToChar(i,ColFrom); int l = columnToChar(i+1,ColFrom);
int r = columnToChar(i,ColTo-1); int r = columnToChar(i+1,ColTo-1)+1;
QString s = mLines->getString(i); QString s = mLines->getString(i);
result += s.mid(l-1,r-l); result += s.mid(l-1,r-l);
result+=lineBreak(); if (i<Last)
result+=lineBreak();
} }
return result; return result;
} }
@ -5062,8 +5065,8 @@ void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE)
std::swap(ColFrom, ColTo); std::swap(ColFrom, ColTo);
QString result; QString result;
for (int i = First; i <= Last; i++) { for (int i = First; i <= Last; i++) {
int l = columnToChar(i,ColFrom); int l = columnToChar(i+1,ColFrom);
int r = columnToChar(i,ColTo-1); int r = columnToChar(i+1,ColTo-1)+1;
QString s = mLines->getString(i); QString s = mLines->getString(i);
s.remove(l-1,r-l); s.remove(l-1,r-l);
properSetLine(i,s); properSetLine(i,s);

View File

@ -2,6 +2,6 @@
#define VERSION_H #define VERSION_H
#include <QObject> #include <QObject>
#define DEVCPP_VERSION "beta.0.10.3" #define DEVCPP_VERSION "beta.0.10.4"
#endif // VERSION_H #endif // VERSION_H