- fix: alt+shift+left/right can't select

- fix: Input any content will exit column mode.
This commit is contained in:
Roy Qu 2023-01-10 16:52:39 +08:00
parent d75ffef9bb
commit 7324475277
5 changed files with 43 additions and 24 deletions

View File

@ -20,6 +20,8 @@ Red Panda C++ Version 2.8
- change: Disable undo limit by default.
- fix: "Goto declaration" / "Goto definition" / "Find occurences" not correctly disabled for non-c/c++ files.
- fix: Can't save new file using filename with custom suffix.
- fix: alt+shift+left/right can't select
- fix: Input any content will exit column mode.
Red Panda C++ Version 2.7

View File

@ -57,13 +57,16 @@ SaveException::SaveException(const QString& reason) {
mReason = reason;
mReasonBuffer = mReason.toLocal8Bit();
}
SaveException::SaveException(const QString&& reason) {
mReason = reason;
mReasonBuffer = mReason.toLocal8Bit();
}
const QString& SaveException::reason() const noexcept{
return mReason;
}
const char* SaveException::what() const noexcept {
return mReasonBuffer;
}

View File

@ -191,10 +191,12 @@ void EditKeyStrokes::resetDefaults()
add(EditCommand::ScrollDown, Qt::Key_Down, Qt::ControlModifier);
add(EditCommand::Left, Qt::Key_Left, Qt::NoModifier);
add(EditCommand::SelLeft, Qt::Key_Left, Qt::ShiftModifier);
add(EditCommand::SelLeft, Qt::Key_Left, Qt::KeyboardModifiers(Qt::ShiftModifier | Qt::AltModifier));
add(EditCommand::WordLeft, Qt::Key_Left, Qt::ControlModifier);
add(EditCommand::SelWordLeft, Qt::Key_Left, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));
add(EditCommand::Right, Qt::Key_Right, Qt::NoModifier);
add(EditCommand::SelRight, Qt::Key_Right, Qt::ShiftModifier);
add(EditCommand::SelRight, Qt::Key_Right, Qt::KeyboardModifiers(Qt::ShiftModifier | Qt::AltModifier));
add(EditCommand::WordRight, Qt::Key_Right, Qt::ControlModifier);
add(EditCommand::SelWordRight, Qt::Key_Right, Qt::KeyboardModifiers(Qt::ShiftModifier|Qt::ControlModifier));

View File

@ -4364,6 +4364,8 @@ void SynEdit::doUndoItem()
item->changeSelMode(),
item->changeNumber());
internalSetCaretXY(item->changeStartPos());
setBlockBegin(caretXY());
ensureCursorPosVisible();
break;
}
case ChangeReason::MoveSelectionUp:
@ -4407,6 +4409,7 @@ void SynEdit::doUndoItem()
item->changeText(),
item->changeSelMode(),
item->changeNumber());
setBlockBegin(caretXY());
ensureCursorPosVisible();
break;
}
@ -5487,19 +5490,34 @@ void SynEdit::doInsertText(const BufferCoord& pos,
case SelectionMode::Normal:
insertedLines = doInsertTextByNormalMode(pos,text, newPos);
doLinesInserted(pos.line+1, insertedLines);
internalSetCaretXY(newPos);
setBlockBegin(newPos);
ensureCursorPosVisible();
break;
case SelectionMode::Column:
insertedLines = doInsertTextByColumnMode(pos,text, newPos, startLine,endLine);
insertedLines = doInsertTextByColumnMode(pos,text, startLine,endLine);
doLinesInserted(endLine-insertedLines+1,insertedLines);
if (!text.isEmpty()) {
int textLen = text.back().length();
BufferCoord bb=blockBegin();
BufferCoord be=blockEnd();
bb.ch+=textLen;
be.ch+=textLen;
internalSetCaretXY(bb);
setBlockBegin(bb);
setBlockEnd(be);
ensureCursorPosVisible();
}
break;
case SelectionMode::Line:
insertedLines = doInsertTextByLineMode(pos,text, newPos);
doLinesInserted(pos.line, insertedLines);
break;
}
internalSetCaretXY(newPos);
setBlockBegin(newPos);
ensureCursorPosVisible();
break;
}
}
int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos)
@ -5594,7 +5612,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList&
return result;
}
int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos, int startLine, int endLine)
int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, int startLine, int endLine)
{
QString str;
QString tempString;
@ -5651,12 +5669,6 @@ int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList&
}
line++;
}
newPos=pos;
if (!text[0].isEmpty()) {
newPos.ch+=text[0].length();
// mCaretX+=firstLineLen;
// mStatusChanges.setFlag(SynStatusChange::scCaretX);
}
if (!mUndoing) {
mUndoList->endBlock();
}
@ -6761,30 +6773,30 @@ BufferCoord SynEdit::blockEnd() const
return mBlockEnd;
}
void SynEdit::setBlockEnd(BufferCoord Value)
void SynEdit::setBlockEnd(BufferCoord value)
{
//setActiveSelectionMode(mSelectionMode);
Value.line = minMax(Value.line, 1, mDocument->count());
value.line = minMax(value.line, 1, mDocument->count());
if (mActiveSelectionMode == SelectionMode::Normal) {
if (Value.line >= 1 && Value.line <= mDocument->count())
Value.ch = std::min(Value.ch, getDisplayStringAtLine(Value.line).length() + 1);
if (value.line >= 1 && value.line <= mDocument->count())
value.ch = std::min(value.ch, getDisplayStringAtLine(value.line).length() + 1);
else
Value.ch = 1;
value.ch = 1;
} else {
int maxLen = mDocument->lengthOfLongestLine();
if (syntaxer())
maxLen = maxLen+stringColumns(syntaxer()->foldString(),maxLen);
Value.ch = minMax(Value.ch, 1, maxLen+1);
value.ch = minMax(value.ch, 1, maxLen+1);
}
if (Value.ch != mBlockEnd.ch || Value.line != mBlockEnd.line) {
if (mActiveSelectionMode == SelectionMode::Column && Value.ch != mBlockEnd.ch) {
if (value.ch != mBlockEnd.ch || value.line != mBlockEnd.line) {
if (mActiveSelectionMode == SelectionMode::Column && value.ch != mBlockEnd.ch) {
invalidateLines(
std::min(mBlockBegin.line, std::min(mBlockEnd.line, Value.line)),
std::max(mBlockBegin.line, std::max(mBlockEnd.line, Value.line)));
mBlockEnd = Value;
std::min(mBlockBegin.line, std::min(mBlockEnd.line, value.line)),
std::max(mBlockBegin.line, std::max(mBlockEnd.line, value.line)));
mBlockEnd = value;
} else {
int nLine = mBlockEnd.line;
mBlockEnd = Value;
mBlockEnd = value;
if (mActiveSelectionMode != SelectionMode::Column || mBlockBegin.ch != mBlockEnd.ch)
invalidateLines(nLine, mBlockEnd.line);
}

View File

@ -550,7 +550,7 @@ private:
void doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode);
void doInsertText(const BufferCoord& pos, const QStringList& text, SelectionMode mode, int startLine, int endLine);
int doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos, int startLine, int endLine);
int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, int startLine, int endLine);
int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
void doTrimTrailingSpaces();