- fix: block indent doesn't work

This commit is contained in:
Roy Qu 2022-07-25 09:45:06 +08:00
parent 1b56f1b615
commit 7db3a7ebc1
6 changed files with 37 additions and 19 deletions

View File

@ -1,3 +1,7 @@
Red Panda C++ Version 1.1.6
- fix: block indent doesn't work
Red Panda C++ Version 1.1.5 Red Panda C++ Version 1.1.5
- change: uncheck "hide unsupported files" in files view shouldn't gray out non-c files - change: uncheck "hide unsupported files" in files view shouldn't gray out non-c files

View File

@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
} }
isEmpty(APP_VERSION) { isEmpty(APP_VERSION) {
APP_VERSION=1.1.5 APP_VERSION=1.1.6
} }
macos: { macos: {

View File

@ -871,7 +871,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View File

@ -2774,7 +2774,6 @@ void SynEdit::doBlockIndent()
QStringList strToInsert; QStringList strToInsert;
int e,x,i; int e,x,i;
QString spaces; QString spaces;
BufferCoord insertionPos;
oldCaretPos = caretXY(); oldCaretPos = caretXY();
@ -2802,19 +2801,41 @@ void SynEdit::doBlockIndent()
} else { } else {
spaces = "\t"; spaces = "\t";
} }
for (i = BB.line; i<e;i++) { // for (i = BB.line; i<e;i++) {
strToInsert.append(spaces); // strToInsert.append(spaces);
} // }
strToInsert.append(spaces); // strToInsert.append(spaces);
mUndoList->beginBlock(); mUndoList->beginBlock();
mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode());
mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
insertionPos.line = BB.line; int ch;
if (mActiveSelectionMode == SynSelectionMode::Column) if (mActiveSelectionMode == SynSelectionMode::Column)
insertionPos.ch = std::min(BB.ch, BE.ch); ch = std::min(BB.ch, BE.ch);
else else
insertionPos.ch = 1; ch = 1;
insertBlock(insertionPos, strToInsert); for (i = BB.line; i<=e;i++) {
if (i>mDocument->count())
break;
QString line=mDocument->getString(i-1);
if (ch>line.length()) {
mUndoList->addChange(
SynChangeReason::Insert,
BufferCoord{line.length(), i},
BufferCoord{line.length()+spaces.length(), i},
QStringList(),
SynSelectionMode::Normal);
line+=spaces;
} else {
mUndoList->addChange(
SynChangeReason::Insert,
BufferCoord{ch, i},
BufferCoord{ch+spaces.length(), i},
QStringList(),
SynSelectionMode::Normal);
line = line.left(ch-1)+spaces+line.mid(ch-1);
}
properSetLine(i-1,line);
}
//adjust caret and selection //adjust caret and selection
oldCaretPos.ch = x; oldCaretPos.ch = x;
if (BB.ch > 1) if (BB.ch > 1)
@ -3255,12 +3276,6 @@ void SynEdit::doOnStatusChange(SynStatusChanges)
mStatusChanges = SynStatusChange::scNone; mStatusChanges = SynStatusChange::scNone;
} }
void SynEdit::insertBlock(const BufferCoord& startPos, const QStringList& blockText)
{
setCaretAndSelection(startPos, startPos, startPos);
setSelTextPrimitiveEx(SynSelectionMode::Column, blockText);
}
void SynEdit::updateScrollbars() void SynEdit::updateScrollbars()
{ {
int nMaxScroll; int nMaxScroll;

View File

@ -509,7 +509,6 @@ private:
void internalSetCaretY(int Value); void internalSetCaretY(int Value);
void setStatusChanged(SynStatusChanges changes); void setStatusChanged(SynStatusChanges changes);
void doOnStatusChange(SynStatusChanges changes); void doOnStatusChange(SynStatusChanges changes);
void insertBlock(const BufferCoord& startPos, const QStringList& blockText);
void updateScrollbars(); void updateScrollbars();
void updateCaret(); void updateCaret();
void recalcCharExtent(); void recalcCharExtent();

View File

@ -23,7 +23,7 @@ SUBDIRS += \
APP_NAME = RedPandaCPP APP_NAME = RedPandaCPP
APP_VERSION = 1.1.5 APP_VERSION = 1.1.6
linux: { linux: {
isEmpty(PREFIX) { isEmpty(PREFIX) {