* work save
This commit is contained in:
parent
8256928f53
commit
89af3d6b4f
|
@ -234,7 +234,7 @@ void MainWindow::on_actionSelectAll_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
if (editor != NULL ) {
|
if (editor != NULL ) {
|
||||||
editor->CommandProcessor()
|
editor->CommandProcessor(SynEditorCommand::ecSelectAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ void SynEditKeyStrokes::resetDefaults()
|
||||||
add(SynEditorCommand::ecSelLineEnd, Qt::Key_End, Qt::ShiftModifier);
|
add(SynEditorCommand::ecSelLineEnd, Qt::Key_End, Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecEditorBottom, Qt::Key_End, Qt::ControlModifier);
|
add(SynEditorCommand::ecEditorBottom, Qt::Key_End, Qt::ControlModifier);
|
||||||
add(SynEditorCommand::ecSelEditorBottom, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier);
|
add(SynEditorCommand::ecSelEditorBottom, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier);
|
||||||
add(SynEditorCommand::ecToggleMode, Qt::Key_Insert, Qt::ShiftModifier);
|
add(SynEditorCommand::ecToggleMode, Qt::Key_Insert, Qt::NoModifier);
|
||||||
add(SynEditorCommand::ecCopy, Qt::Key_Insert, Qt::ControlModifier);
|
add(SynEditorCommand::ecCopy, Qt::Key_Insert, Qt::ControlModifier);
|
||||||
add(SynEditorCommand::ecCut, Qt::Key_Delete, Qt::ShiftModifier);
|
add(SynEditorCommand::ecCut, Qt::Key_Delete, Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecPaste, Qt::Key_Insert, Qt::ShiftModifier);
|
add(SynEditorCommand::ecPaste, Qt::Key_Insert, Qt::ShiftModifier);
|
||||||
|
|
|
@ -85,6 +85,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mOverwriteCaret = SynEditCaretType::ctBlock;
|
mOverwriteCaret = SynEditCaretType::ctBlock;
|
||||||
mSelectionMode = SynSelectionMode::smNormal;
|
mSelectionMode = SynSelectionMode::smNormal;
|
||||||
mActiveSelectionMode = SynSelectionMode::smNormal;
|
mActiveSelectionMode = SynSelectionMode::smNormal;
|
||||||
|
mReadOnly = false;
|
||||||
qDebug()<<"init SynEdit: 7";
|
qDebug()<<"init SynEdit: 7";
|
||||||
|
|
||||||
//stop qt to auto fill background
|
//stop qt to auto fill background
|
||||||
|
@ -108,7 +109,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mLeftChar = 1;
|
mLeftChar = 1;
|
||||||
mTopLine = 1;
|
mTopLine = 1;
|
||||||
mCaretX = 1;
|
mCaretX = 1;
|
||||||
mLastCaretX = 1;
|
mLastCaretColumn = 1;
|
||||||
mCaretY = 1;
|
mCaretY = 1;
|
||||||
mBlockBegin.Char = 1;
|
mBlockBegin.Char = 1;
|
||||||
mBlockBegin.Line = 1;
|
mBlockBegin.Line = 1;
|
||||||
|
@ -486,7 +487,7 @@ BufferCoord SynEdit::displayToBufferPos(const DisplayCoord &p)
|
||||||
BufferCoord Result{p.Column,p.Row};
|
BufferCoord Result{p.Column,p.Row};
|
||||||
// Account for code folding
|
// Account for code folding
|
||||||
if (mUseCodeFolding)
|
if (mUseCodeFolding)
|
||||||
Result.Line = foldRowToLine(p.Column);
|
Result.Line = foldRowToLine(p.Row);
|
||||||
// Account for tabs
|
// Account for tabs
|
||||||
if (Result.Line <= mLines->count() ) {
|
if (Result.Line <= mLines->count() ) {
|
||||||
Result.Char = columnToChar(Result.Line,p.Column);
|
Result.Char = columnToChar(Result.Line,p.Column);
|
||||||
|
@ -782,7 +783,6 @@ void SynEdit::clearUndo()
|
||||||
BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y)
|
BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y)
|
||||||
{
|
{
|
||||||
QChar Test;
|
QChar Test;
|
||||||
int NumBrackets;
|
|
||||||
QString vDummy;
|
QString vDummy;
|
||||||
PSynHighlighterAttribute attr;
|
PSynHighlighterAttribute attr;
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
|
@ -796,48 +796,46 @@ BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y)
|
||||||
if (PosY<1 )
|
if (PosY<1 )
|
||||||
return Result;
|
return Result;
|
||||||
QString Line = mLines->getString(PosY - 1);
|
QString Line = mLines->getString(PosY - 1);
|
||||||
if (PosX > Length(Line)) or (PosX<1) then
|
if ((PosX > Line.length()) || (PosX<1))
|
||||||
PosX := Length(Line);
|
PosX = Line.length();
|
||||||
numBrackets := 1;
|
int numBrackets = 1;
|
||||||
while True do begin
|
while (true) {
|
||||||
if Length(Line)=0 then begin;
|
if (Line.isEmpty()){
|
||||||
dec(PosY);
|
PosY--;
|
||||||
if PosY<1 then
|
if (PosY<1)
|
||||||
Exit;
|
return Result;
|
||||||
Line := Lines[PosY - 1];
|
Line = mLines->getString(PosY - 1);
|
||||||
PosX := Length(Line);
|
PosX = Line.length();
|
||||||
continue;
|
continue;
|
||||||
end;
|
}
|
||||||
Test := Line[PosX];
|
Test = Line[PosX-1];
|
||||||
p.Char := PosX;
|
p.Char = PosX;
|
||||||
p.Line := PosY;
|
p.Line = PosY;
|
||||||
if Test in ['{','}'] then begin
|
if (Test=='{' || Test == '}') {
|
||||||
if GetHighlighterAttriAtRowCol(p, vDummy, attr) then
|
if (GetHighlighterAttriAtRowCol(p, vDummy, attr)) {
|
||||||
isCommentOrStringOrChar :=
|
isCommentOrStringOrChar =
|
||||||
(attr = Highlighter.StringAttribute) or (attr = Highlighter.CommentAttribute) or (attr.Name
|
(attr == mHighlighter->stringAttribute()) ||
|
||||||
=
|
(attr == mHighlighter->commentAttribute()) ||
|
||||||
'Character')
|
(attr->name() == SYNS_AttrCharacter);
|
||||||
else
|
} else
|
||||||
isCommentOrStringOrChar := false;
|
isCommentOrStringOrChar = false;
|
||||||
if (Test = '{') and (not isCommentOrStringOrChar) then
|
if ((Test == '{') && (! isCommentOrStringOrChar))
|
||||||
dec(NumBrackets)
|
numBrackets--;
|
||||||
else if (Test = '}') and (not isCommentOrStringOrChar) then
|
else if ((Test == '}') && (!isCommentOrStringOrChar))
|
||||||
inc(NumBrackets);
|
numBrackets++;
|
||||||
if NumBrackets = 0 then begin
|
if (numBrackets == 0) {
|
||||||
// matching bracket found, set caret and bail out
|
return p;
|
||||||
Result := p;
|
}
|
||||||
exit;
|
}
|
||||||
end;
|
PosX--;
|
||||||
end;
|
if (PosX<1) {
|
||||||
dec(PosX);
|
PosY--;
|
||||||
if PosX<1 then begin
|
if (PosY<1)
|
||||||
dec(PosY);
|
return Result;
|
||||||
if PosY<1 then
|
Line = mLines->getString(PosY - 1);
|
||||||
Exit;
|
PosX = Line.length();
|
||||||
Line := Lines[PosY - 1];
|
}
|
||||||
PosX := Length(Line);
|
}
|
||||||
end;
|
|
||||||
end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::charColumns(QChar ch)
|
int SynEdit::charColumns(QChar ch)
|
||||||
|
@ -1081,7 +1079,7 @@ void SynEdit::DeleteLastChar()
|
||||||
//TabBuffer := Lines.ExpandedStrings[CaretY - 1];
|
//TabBuffer := Lines.ExpandedStrings[CaretY - 1];
|
||||||
int Len = Temp.length();
|
int Len = Temp.length();
|
||||||
BufferCoord Caret = caretXY();
|
BufferCoord Caret = caretXY();
|
||||||
int vTabTrim = 0;
|
// int vTabTrim = 0;
|
||||||
QString helper = "";
|
QString helper = "";
|
||||||
if (mCaretX > Len + 1) {
|
if (mCaretX > Len + 1) {
|
||||||
// if (mOptions.setFlag(eoSmartTabDelete)) {
|
// if (mOptions.setFlag(eoSmartTabDelete)) {
|
||||||
|
@ -1443,8 +1441,9 @@ void SynEdit::InsertLine(bool moveCaret)
|
||||||
Temp2.remove(0, mCaretX - 1);
|
Temp2.remove(0, mCaretX - 1);
|
||||||
ProperSetLine(mCaretY-1,Temp);
|
ProperSetLine(mCaretY-1,Temp);
|
||||||
QString Temp4=GetLeftSpacing(SpaceCount1, true);
|
QString Temp4=GetLeftSpacing(SpaceCount1, true);
|
||||||
if (mOptions.testFlag(eoAddIndent) && GetHighlighterAttriAtRowCol(BufferCoord{Temp3.length(), mCaretY},
|
if (mOptions.testFlag(eoAddIndent) &&
|
||||||
Temp3, &Attr)) { // only add indent to source files
|
GetHighlighterAttriAtRowCol(BufferCoord{Temp3.length(), mCaretY},
|
||||||
|
Temp3, Attr)) { // only add indent to source files
|
||||||
if (Attr != mHighlighter->commentAttribute()) { // and outside of comments
|
if (Attr != mHighlighter->commentAttribute()) { // and outside of comments
|
||||||
if ((!Temp.isEmpty() && Temp[Temp.length()-1] ==':')
|
if ((!Temp.isEmpty() && Temp[Temp.length()-1] ==':')
|
||||||
|| (
|
|| (
|
||||||
|
@ -1555,8 +1554,6 @@ void SynEdit::DoTabKey()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int iLine = 0;
|
|
||||||
int MinLen = 0;
|
|
||||||
{
|
{
|
||||||
mUndoList->BeginBlock();
|
mUndoList->BeginBlock();
|
||||||
auto action = finally([this]{
|
auto action = finally([this]{
|
||||||
|
@ -1600,8 +1597,8 @@ void SynEdit::DoTabKey()
|
||||||
void SynEdit::DoShiftTabKey()
|
void SynEdit::DoShiftTabKey()
|
||||||
{
|
{
|
||||||
// Provide Visual Studio like block indenting
|
// Provide Visual Studio like block indenting
|
||||||
if (mOptions.testFlag(eoTabIndent) && CanBlockUnindent()) {
|
if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) {
|
||||||
doBlockUnIndent();
|
doBlockUnindent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,8 +1742,7 @@ void SynEdit::doBlockIndent()
|
||||||
BufferCoord OrgCaretPos;
|
BufferCoord OrgCaretPos;
|
||||||
BufferCoord BB, BE;
|
BufferCoord BB, BE;
|
||||||
QString StrToInsert;
|
QString StrToInsert;
|
||||||
int Run;
|
int e,x,i;
|
||||||
int e,x,i,InsertStrLen;
|
|
||||||
QString Spaces;
|
QString Spaces;
|
||||||
SynSelectionMode OrgSelectionMode;
|
SynSelectionMode OrgSelectionMode;
|
||||||
BufferCoord InsertionPos;
|
BufferCoord InsertionPos;
|
||||||
|
@ -1990,7 +1986,7 @@ void SynEdit::doOnPaintTransient(SynTransientType TransientType)
|
||||||
void SynEdit::updateLastCaretX()
|
void SynEdit::updateLastCaretX()
|
||||||
{
|
{
|
||||||
mMBCSStepAside = false;
|
mMBCSStepAside = false;
|
||||||
mLastCaretX = displayX();
|
mLastCaretColumn = displayX();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::ensureCursorPosVisible()
|
void SynEdit::ensureCursorPosVisible()
|
||||||
|
@ -2921,10 +2917,10 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection)
|
||||||
|
|
||||||
if (ptO.Row != ptDst.Row) {
|
if (ptO.Row != ptDst.Row) {
|
||||||
if (mOptions.testFlag(eoKeepCaretX))
|
if (mOptions.testFlag(eoKeepCaretX))
|
||||||
ptDst.Column = mLastCaretX;
|
ptDst.Column = mLastCaretColumn;
|
||||||
}
|
}
|
||||||
BufferCoord vDstLineChar = displayToBufferPos(ptDst);
|
BufferCoord vDstLineChar = displayToBufferPos(ptDst);
|
||||||
int SaveLastCaretX = mLastCaretX;
|
int SaveLastCaretX = mLastCaretColumn;
|
||||||
bool NewStepAside = mMBCSStepAside;
|
bool NewStepAside = mMBCSStepAside;
|
||||||
|
|
||||||
// set caret and block begin / end
|
// set caret and block begin / end
|
||||||
|
@ -2936,7 +2932,7 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection)
|
||||||
// UpdateLastCaretX, called by SetCaretXYEx, changes them. This is the one
|
// UpdateLastCaretX, called by SetCaretXYEx, changes them. This is the one
|
||||||
// case where we don't want that.
|
// case where we don't want that.
|
||||||
mMBCSStepAside = NewStepAside;
|
mMBCSStepAside = NewStepAside;
|
||||||
mLastCaretX = SaveLastCaretX;
|
mLastCaretColumn = SaveLastCaretX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::MoveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection)
|
void SynEdit::MoveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection)
|
||||||
|
@ -3558,6 +3554,28 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
||||||
case SynEditorCommand::ecChar:
|
case SynEditorCommand::ecChar:
|
||||||
DoAddChar(AChar);
|
DoAddChar(AChar);
|
||||||
break;
|
break;
|
||||||
|
case SynEditorCommand::ecInsertMode:
|
||||||
|
if (!mReadOnly)
|
||||||
|
mInserting = true;
|
||||||
|
break;
|
||||||
|
case SynEditorCommand::ecOverwriteMode:
|
||||||
|
if (!mReadOnly)
|
||||||
|
mInserting = false;
|
||||||
|
break;
|
||||||
|
case SynEditorCommand::ecToggleMode:
|
||||||
|
if (!mReadOnly) {
|
||||||
|
mInserting = !mInserting;
|
||||||
|
updateCaret();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// InsertMode := TRUE;
|
||||||
|
// end;
|
||||||
|
// ecOverwriteMode: begin
|
||||||
|
// InsertMode := FALSE;
|
||||||
|
// end;
|
||||||
|
// ecToggleMode: begin
|
||||||
|
// InsertMode := not InsertMode;
|
||||||
|
// end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// procedure ForceCaretX(aCaretX: integer);
|
// procedure ForceCaretX(aCaretX: integer);
|
||||||
|
|
|
@ -448,7 +448,7 @@ private:
|
||||||
BufferCoord mBlockBegin;
|
BufferCoord mBlockBegin;
|
||||||
BufferCoord mBlockEnd;
|
BufferCoord mBlockEnd;
|
||||||
int mCaretX;
|
int mCaretX;
|
||||||
int mLastCaretX;
|
int mLastCaretColumn;
|
||||||
int mCaretY;
|
int mCaretY;
|
||||||
int mCharsInWindow;
|
int mCharsInWindow;
|
||||||
int mCharWidth;
|
int mCharWidth;
|
||||||
|
|
Loading…
Reference in New Issue