work save

This commit is contained in:
Roy Qu 2022-07-02 10:39:31 +08:00
parent cd135b19a2
commit 3f814901d5
5 changed files with 547 additions and 659 deletions

File diff suppressed because it is too large Load Diff

View File

@ -186,8 +186,8 @@ public:
//normalized buffer coord operations
ContentsCoord fromBufferCoord(const BufferCoord& p) const;
ContentsCoord createNormalizedBufferCoord(int aChar,int aLine) const;
QStringList getContents(const ContentsCoord& pStart,const ContentsCoord& pEnd);
QString getJoinedContents(const ContentsCoord& pStart,const ContentsCoord& pEnd, const QString& joinStr);
// QStringList getContents(const ContentsCoord& pStart,const ContentsCoord& pEnd);
// QString getJoinedContents(const ContentsCoord& pStart,const ContentsCoord& pEnd, const QString& joinStr);
int leftSpaces(const QString& line) const;
QString GetLeftSpacing(int charCount,bool wantTabs) const;
@ -271,7 +271,7 @@ public:
void addCaretToUndo();
void addLeftTopToUndo();
void replaceAll(const QString& text) {
mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,"", activeSelectionMode());
mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
selectAll();
setSelText(text);
}
@ -368,6 +368,8 @@ public:
QString selText();
QStringList getContent(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode) const;
QString lineBreak();
SynEditorOptions getOptions() const;
@ -491,7 +493,7 @@ private:
QRect clientRect();
void synFontChanged();
void doOnPaintTransient(SynTransientType TransientType);
void doSetSelText(const QString& Value);
void doSetSelText(const QString& value);
void updateLastCaretX();
void ensureCursorPosVisible();
@ -503,8 +505,7 @@ private:
void internalSetCaretY(int Value);
void setStatusChanged(SynStatusChanges changes);
void doOnStatusChange(SynStatusChanges changes);
void insertBlock(const BufferCoord& BB, const BufferCoord& BE, const QString& ChangeStr,
bool AddToUndoList);
void insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText);
void updateScrollbars();
void updateCaret();
void recalcCharExtent();
@ -549,17 +550,22 @@ private:
void moveCaretToLineStart(bool isSelection);
void moveCaretToLineEnd(bool isSelection);
void setSelectedTextEmpty();
void setSelTextPrimitive(const QString& aValue);
void setSelTextPrimitive(const QStringList& text);
void setSelTextPrimitiveEx(SynSelectionMode PasteMode,
const QString& Value, bool AddToUndoList);
const QStringList& text);
void doLinesDeleted(int FirstLine, int Count);
void doLinesInserted(int FirstLine, int Count);
void properSetLine(int ALine, const QString& ALineText, bool notify = true);
void deleteSelection(const BufferCoord& BB, const BufferCoord& BE);
void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
int insertTextByNormalMode(const QString& Value);
int insertTextByColumnMode(const QString& Value,bool AddToUndoList);
int insertTextByLineMode(const QString& Value);
//primitive edit operations
void doDeleteText(const BufferCoord& startPos, const BufferCoord& endPos, SynSelectionMode mode);
void doInsertText(const BufferCoord& pos, const QStringList& text, SynSelectionMode mode);
int doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos);
void deleteFromTo(const BufferCoord& start, const BufferCoord& end);
void setSelWord();
void setWordBlock(BufferCoord Value);
@ -590,8 +596,8 @@ private:
void doDeleteLine();
void doSelecteLine();
void doDuplicateLine();
void doMoveSelUp(bool addUndo=true);
void doMoveSelDown(bool addUndo=true);
void doMoveSelUp();
void doMoveSelDown();
void clearAll();
void insertLine(bool moveCaret);
void doTabKey();

View File

@ -881,7 +881,7 @@ SynEditUndoList::SynEditUndoList():QObject()
}
void SynEditUndoList::AddChange(SynChangeReason AReason, const BufferCoord &AStart,
const BufferCoord &AEnd, const QString &ChangeText,
const BufferCoord &AEnd, const QStringList& ChangeText,
SynSelectionMode SelMode)
{
if (mLockCount != 0)
@ -908,8 +908,8 @@ void SynEditUndoList::AddGroupBreak()
{
//Add the GroupBreak even if ItemCount = 0. Since items are stored in
//reverse order in TCustomSynEdit.fRedoList, a GroupBreak could be lost.
if (LastChangeReason() != SynChangeReason::crGroupBreak) {
AddChange(SynChangeReason::crGroupBreak, {0,0}, {0,0}, "", SynSelectionMode::smNormal);
if (LastChangeReason() != SynChangeReason::crNothing) {
AddChange(SynChangeReason::crNothing, {0,0}, {0,0}, QStringList(), SynSelectionMode::smNormal);
}
}
@ -992,7 +992,7 @@ void SynEditUndoList::PushItem(PSynEditUndoItem Item)
return;
mItems.append(Item);
ensureMaxEntries();
if (Item->changeReason()!= SynChangeReason::crGroupBreak)
if (Item->changeReason()!= SynChangeReason::crNothing)
emit addedUndo();
}
@ -1124,9 +1124,9 @@ BufferCoord SynEditUndoItem::changeEndPos() const
return mChangeEndPos;
}
QString SynEditUndoItem::changeStr() const
QStringList SynEditUndoItem::changeText() const
{
return mChangeStr;
return mChangeText;
}
int SynEditUndoItem::changeNumber() const
@ -1136,13 +1136,13 @@ int SynEditUndoItem::changeNumber() const
SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SynSelectionMode selMode,
BufferCoord startPos, BufferCoord endPos,
const QString &str, int number)
const QStringList& text, int number)
{
mChangeReason = reason;
mChangeSelMode = selMode;
mChangeStartPos = startPos;
mChangeEndPos = endPos;
mChangeStr = str;
mChangeText = text;
mChangeNumber = number;
}

View File

@ -166,7 +166,7 @@ enum class SynChangeReason {
crDelete,
crCaret, //just restore the Caret, allowing better Undo behavior
crSelection, //restore Selection
crGroupBreak,
crNothing,
crLeftTop,
crLineBreak,
crMoveSelectionUp,
@ -191,21 +191,21 @@ private:
SynSelectionMode mChangeSelMode;
BufferCoord mChangeStartPos;
BufferCoord mChangeEndPos;
QString mChangeStr;
QStringList mChangeText;
int mChangeNumber;
public:
SynEditUndoItem(SynChangeReason reason,
SynSelectionMode selMode,
BufferCoord startPos,
BufferCoord endPos,
const QString& str,
const QStringList& text,
int number);
SynChangeReason changeReason() const;
SynSelectionMode changeSelMode() const;
BufferCoord changeStartPos() const;
BufferCoord changeEndPos() const;
QString changeStr() const;
QStringList changeText() const;
int changeNumber() const;
};
using PSynEditUndoItem = std::shared_ptr<SynEditUndoItem>;
@ -216,7 +216,7 @@ public:
explicit SynEditUndoList();
void AddChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd,
const QString& ChangeText, SynSelectionMode SelMode);
const QStringList& ChangeText, SynSelectionMode SelMode);
void AddGroupBreak();
void BeginBlock();

View File

@ -0,0 +1,30 @@
1. 使用基本操作
doDeleteText 删除内容
doInsertText 插入内容
3. 返回内容时使用QStringList代替QString
涉及:
注释/取消注释
缩进/取消缩进
移动当前选择上一行
删除当前单词
删除当前行
复制当前行
DELETE/BACKSPACE
回车
输入 空格 字符
复制
粘贴
鼠标拖拽
列模式