work save
This commit is contained in:
parent
cd135b19a2
commit
3f814901d5
File diff suppressed because it is too large
Load Diff
|
@ -186,8 +186,8 @@ public:
|
||||||
//normalized buffer coord operations
|
//normalized buffer coord operations
|
||||||
ContentsCoord fromBufferCoord(const BufferCoord& p) const;
|
ContentsCoord fromBufferCoord(const BufferCoord& p) const;
|
||||||
ContentsCoord createNormalizedBufferCoord(int aChar,int aLine) const;
|
ContentsCoord createNormalizedBufferCoord(int aChar,int aLine) const;
|
||||||
QStringList getContents(const ContentsCoord& pStart,const ContentsCoord& pEnd);
|
// QStringList getContents(const ContentsCoord& pStart,const ContentsCoord& pEnd);
|
||||||
QString getJoinedContents(const ContentsCoord& pStart,const ContentsCoord& pEnd, const QString& joinStr);
|
// QString getJoinedContents(const ContentsCoord& pStart,const ContentsCoord& pEnd, const QString& joinStr);
|
||||||
|
|
||||||
int leftSpaces(const QString& line) const;
|
int leftSpaces(const QString& line) const;
|
||||||
QString GetLeftSpacing(int charCount,bool wantTabs) const;
|
QString GetLeftSpacing(int charCount,bool wantTabs) const;
|
||||||
|
@ -271,7 +271,7 @@ public:
|
||||||
void addCaretToUndo();
|
void addCaretToUndo();
|
||||||
void addLeftTopToUndo();
|
void addLeftTopToUndo();
|
||||||
void replaceAll(const QString& text) {
|
void replaceAll(const QString& text) {
|
||||||
mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,"", activeSelectionMode());
|
mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
|
||||||
selectAll();
|
selectAll();
|
||||||
setSelText(text);
|
setSelText(text);
|
||||||
}
|
}
|
||||||
|
@ -368,6 +368,8 @@ public:
|
||||||
|
|
||||||
QString selText();
|
QString selText();
|
||||||
|
|
||||||
|
QStringList getContent(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode) const;
|
||||||
|
|
||||||
QString lineBreak();
|
QString lineBreak();
|
||||||
|
|
||||||
SynEditorOptions getOptions() const;
|
SynEditorOptions getOptions() const;
|
||||||
|
@ -491,7 +493,7 @@ private:
|
||||||
QRect clientRect();
|
QRect clientRect();
|
||||||
void synFontChanged();
|
void synFontChanged();
|
||||||
void doOnPaintTransient(SynTransientType TransientType);
|
void doOnPaintTransient(SynTransientType TransientType);
|
||||||
void doSetSelText(const QString& Value);
|
void doSetSelText(const QString& value);
|
||||||
|
|
||||||
void updateLastCaretX();
|
void updateLastCaretX();
|
||||||
void ensureCursorPosVisible();
|
void ensureCursorPosVisible();
|
||||||
|
@ -503,8 +505,7 @@ 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& BB, const BufferCoord& BE, const QString& ChangeStr,
|
void insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText);
|
||||||
bool AddToUndoList);
|
|
||||||
void updateScrollbars();
|
void updateScrollbars();
|
||||||
void updateCaret();
|
void updateCaret();
|
||||||
void recalcCharExtent();
|
void recalcCharExtent();
|
||||||
|
@ -549,17 +550,22 @@ private:
|
||||||
void moveCaretToLineStart(bool isSelection);
|
void moveCaretToLineStart(bool isSelection);
|
||||||
void moveCaretToLineEnd(bool isSelection);
|
void moveCaretToLineEnd(bool isSelection);
|
||||||
void setSelectedTextEmpty();
|
void setSelectedTextEmpty();
|
||||||
void setSelTextPrimitive(const QString& aValue);
|
void setSelTextPrimitive(const QStringList& text);
|
||||||
void setSelTextPrimitiveEx(SynSelectionMode PasteMode,
|
void setSelTextPrimitiveEx(SynSelectionMode PasteMode,
|
||||||
const QString& Value, bool AddToUndoList);
|
const QStringList& text);
|
||||||
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, bool notify = true);
|
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);
|
//primitive edit operations
|
||||||
int insertTextByNormalMode(const QString& Value);
|
void doDeleteText(const BufferCoord& startPos, const BufferCoord& endPos, SynSelectionMode mode);
|
||||||
int insertTextByColumnMode(const QString& Value,bool AddToUndoList);
|
void doInsertText(const BufferCoord& pos, const QStringList& text, SynSelectionMode mode);
|
||||||
int insertTextByLineMode(const QString& Value);
|
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 deleteFromTo(const BufferCoord& start, const BufferCoord& end);
|
||||||
void setSelWord();
|
void setSelWord();
|
||||||
void setWordBlock(BufferCoord Value);
|
void setWordBlock(BufferCoord Value);
|
||||||
|
@ -590,8 +596,8 @@ private:
|
||||||
void doDeleteLine();
|
void doDeleteLine();
|
||||||
void doSelecteLine();
|
void doSelecteLine();
|
||||||
void doDuplicateLine();
|
void doDuplicateLine();
|
||||||
void doMoveSelUp(bool addUndo=true);
|
void doMoveSelUp();
|
||||||
void doMoveSelDown(bool addUndo=true);
|
void doMoveSelDown();
|
||||||
void clearAll();
|
void clearAll();
|
||||||
void insertLine(bool moveCaret);
|
void insertLine(bool moveCaret);
|
||||||
void doTabKey();
|
void doTabKey();
|
||||||
|
|
|
@ -881,7 +881,7 @@ SynEditUndoList::SynEditUndoList():QObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::AddChange(SynChangeReason AReason, const BufferCoord &AStart,
|
void SynEditUndoList::AddChange(SynChangeReason AReason, const BufferCoord &AStart,
|
||||||
const BufferCoord &AEnd, const QString &ChangeText,
|
const BufferCoord &AEnd, const QStringList& ChangeText,
|
||||||
SynSelectionMode SelMode)
|
SynSelectionMode SelMode)
|
||||||
{
|
{
|
||||||
if (mLockCount != 0)
|
if (mLockCount != 0)
|
||||||
|
@ -908,8 +908,8 @@ void SynEditUndoList::AddGroupBreak()
|
||||||
{
|
{
|
||||||
//Add the GroupBreak even if ItemCount = 0. Since items are stored in
|
//Add the GroupBreak even if ItemCount = 0. Since items are stored in
|
||||||
//reverse order in TCustomSynEdit.fRedoList, a GroupBreak could be lost.
|
//reverse order in TCustomSynEdit.fRedoList, a GroupBreak could be lost.
|
||||||
if (LastChangeReason() != SynChangeReason::crGroupBreak) {
|
if (LastChangeReason() != SynChangeReason::crNothing) {
|
||||||
AddChange(SynChangeReason::crGroupBreak, {0,0}, {0,0}, "", SynSelectionMode::smNormal);
|
AddChange(SynChangeReason::crNothing, {0,0}, {0,0}, QStringList(), SynSelectionMode::smNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -992,7 +992,7 @@ void SynEditUndoList::PushItem(PSynEditUndoItem Item)
|
||||||
return;
|
return;
|
||||||
mItems.append(Item);
|
mItems.append(Item);
|
||||||
ensureMaxEntries();
|
ensureMaxEntries();
|
||||||
if (Item->changeReason()!= SynChangeReason::crGroupBreak)
|
if (Item->changeReason()!= SynChangeReason::crNothing)
|
||||||
emit addedUndo();
|
emit addedUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,9 +1124,9 @@ BufferCoord SynEditUndoItem::changeEndPos() const
|
||||||
return mChangeEndPos;
|
return mChangeEndPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SynEditUndoItem::changeStr() const
|
QStringList SynEditUndoItem::changeText() const
|
||||||
{
|
{
|
||||||
return mChangeStr;
|
return mChangeText;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEditUndoItem::changeNumber() const
|
int SynEditUndoItem::changeNumber() const
|
||||||
|
@ -1136,13 +1136,13 @@ int SynEditUndoItem::changeNumber() const
|
||||||
|
|
||||||
SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SynSelectionMode selMode,
|
SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SynSelectionMode selMode,
|
||||||
BufferCoord startPos, BufferCoord endPos,
|
BufferCoord startPos, BufferCoord endPos,
|
||||||
const QString &str, int number)
|
const QStringList& text, int number)
|
||||||
{
|
{
|
||||||
mChangeReason = reason;
|
mChangeReason = reason;
|
||||||
mChangeSelMode = selMode;
|
mChangeSelMode = selMode;
|
||||||
mChangeStartPos = startPos;
|
mChangeStartPos = startPos;
|
||||||
mChangeEndPos = endPos;
|
mChangeEndPos = endPos;
|
||||||
mChangeStr = str;
|
mChangeText = text;
|
||||||
mChangeNumber = number;
|
mChangeNumber = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ enum class SynChangeReason {
|
||||||
crDelete,
|
crDelete,
|
||||||
crCaret, //just restore the Caret, allowing better Undo behavior
|
crCaret, //just restore the Caret, allowing better Undo behavior
|
||||||
crSelection, //restore Selection
|
crSelection, //restore Selection
|
||||||
crGroupBreak,
|
crNothing,
|
||||||
crLeftTop,
|
crLeftTop,
|
||||||
crLineBreak,
|
crLineBreak,
|
||||||
crMoveSelectionUp,
|
crMoveSelectionUp,
|
||||||
|
@ -191,21 +191,21 @@ private:
|
||||||
SynSelectionMode mChangeSelMode;
|
SynSelectionMode mChangeSelMode;
|
||||||
BufferCoord mChangeStartPos;
|
BufferCoord mChangeStartPos;
|
||||||
BufferCoord mChangeEndPos;
|
BufferCoord mChangeEndPos;
|
||||||
QString mChangeStr;
|
QStringList mChangeText;
|
||||||
int mChangeNumber;
|
int mChangeNumber;
|
||||||
public:
|
public:
|
||||||
SynEditUndoItem(SynChangeReason reason,
|
SynEditUndoItem(SynChangeReason reason,
|
||||||
SynSelectionMode selMode,
|
SynSelectionMode selMode,
|
||||||
BufferCoord startPos,
|
BufferCoord startPos,
|
||||||
BufferCoord endPos,
|
BufferCoord endPos,
|
||||||
const QString& str,
|
const QStringList& text,
|
||||||
int number);
|
int number);
|
||||||
|
|
||||||
SynChangeReason changeReason() const;
|
SynChangeReason changeReason() const;
|
||||||
SynSelectionMode changeSelMode() const;
|
SynSelectionMode changeSelMode() const;
|
||||||
BufferCoord changeStartPos() const;
|
BufferCoord changeStartPos() const;
|
||||||
BufferCoord changeEndPos() const;
|
BufferCoord changeEndPos() const;
|
||||||
QString changeStr() const;
|
QStringList changeText() const;
|
||||||
int changeNumber() const;
|
int changeNumber() const;
|
||||||
};
|
};
|
||||||
using PSynEditUndoItem = std::shared_ptr<SynEditUndoItem>;
|
using PSynEditUndoItem = std::shared_ptr<SynEditUndoItem>;
|
||||||
|
@ -216,7 +216,7 @@ public:
|
||||||
explicit SynEditUndoList();
|
explicit SynEditUndoList();
|
||||||
|
|
||||||
void AddChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd,
|
void AddChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd,
|
||||||
const QString& ChangeText, SynSelectionMode SelMode);
|
const QStringList& ChangeText, SynSelectionMode SelMode);
|
||||||
|
|
||||||
void AddGroupBreak();
|
void AddGroupBreak();
|
||||||
void BeginBlock();
|
void BeginBlock();
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
1. 使用基本操作
|
||||||
|
doDeleteText 删除内容
|
||||||
|
doInsertText 插入内容
|
||||||
|
|
||||||
|
3. 返回内容时,使用QStringList代替QString
|
||||||
|
|
||||||
|
涉及:
|
||||||
|
|
||||||
|
注释/取消注释
|
||||||
|
缩进/取消缩进
|
||||||
|
|
||||||
|
移动当前选择上一行
|
||||||
|
|
||||||
|
删除当前单词
|
||||||
|
删除当前行
|
||||||
|
复制当前行
|
||||||
|
|
||||||
|
DELETE/BACKSPACE
|
||||||
|
|
||||||
|
回车
|
||||||
|
|
||||||
|
输入 空格 字符
|
||||||
|
|
||||||
|
复制
|
||||||
|
|
||||||
|
粘贴
|
||||||
|
|
||||||
|
鼠标拖拽
|
||||||
|
|
||||||
|
列模式
|
Loading…
Reference in New Issue