Work save:
This commit is contained in:
parent
322c4bba4f
commit
3b28894d51
|
@ -1016,16 +1016,18 @@ int Document::xposToGlyphStartChar(int line, int xpos)
|
|||
int Document::charToGlyphStartPosition(int line, const QString newStr, int charPos)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
QList<int> glyphStartCharList;
|
||||
if (mLines[line]->lineText() == newStr)
|
||||
glyphStartCharList = mLines[line]->glyphStartCharList();
|
||||
else
|
||||
glyphStartCharList = calcGlyphStartCharList(newStr);
|
||||
int glyphIdx = charToGlyphIndex(mLines[line]->lineText(), glyphStartCharList, charPos);
|
||||
if (mLines[line]->lineText() == newStr) {
|
||||
return charToGlyphStartPosition(line,charPos);
|
||||
} else {
|
||||
QList<int> glyphStartCharList = calcGlyphStartCharList(newStr);
|
||||
int glyphIdx = charToGlyphIndex(newStr, glyphStartCharList, charPos);
|
||||
int width;
|
||||
QList<int> glyphStartPositionList = calcGlyphPositionList(newStr, width);
|
||||
if (glyphIdx<glyphStartCharList.length())
|
||||
return glyphStartCharList[glyphIdx];
|
||||
return glyphStartPositionList[glyphIdx];
|
||||
else
|
||||
return newStr.length();
|
||||
return width;
|
||||
}
|
||||
}
|
||||
|
||||
int Document::xposToGlyphStartChar(int line, const QString newStr, int xpos)
|
||||
|
@ -1217,7 +1219,7 @@ int DocumentLine::glyphWidth(int i)
|
|||
{
|
||||
if (i<0 || i>=mGlyphPositionList.length())
|
||||
return 0;
|
||||
if(mWidth<0)
|
||||
if( mWidth <0)
|
||||
updateWidth();
|
||||
int start = glyphStartPosition(i);
|
||||
int end;
|
||||
|
|
|
@ -1885,7 +1885,7 @@ void QSynEdit::doDeleteLastChar()
|
|||
bool shouldAddGroupBreak=false;
|
||||
QString tempStr = lineText();
|
||||
int tempStrLen = tempStr.length();
|
||||
BufferCoord Caret = caretXY();
|
||||
BufferCoord caretBackup = caretXY();
|
||||
QStringList helper;
|
||||
if (mCaretX > tempStrLen + 1) {
|
||||
// only move caret one column
|
||||
|
@ -1902,31 +1902,13 @@ void QSynEdit::doDeleteLastChar()
|
|||
helper.append("");
|
||||
shouldAddGroupBreak=true;
|
||||
}
|
||||
} else {
|
||||
// delete text before the caret
|
||||
// int startChar = charTo
|
||||
// int caretXPos = charToGlyph(mCaretY,mCaretX);
|
||||
int SpaceCount1 = leftSpaces(tempStr);
|
||||
int SpaceCount2 = 0;
|
||||
int newCaretX;
|
||||
|
||||
if (SpaceCount1 == mCaretX - 1) {
|
||||
//how much till the next tab column
|
||||
int BackCounter = (mCaretX - 1) % tabSize();
|
||||
if (BackCounter == 0)
|
||||
BackCounter = tabSize();
|
||||
SpaceCount2 = std::max(0,SpaceCount1 - tabSize());
|
||||
newCaretX = xposToGlyphStartChar(mCaretY,SpaceCount2+1);
|
||||
helper.append(tempStr.mid(newCaretX - 1, mCaretX - newCaretX));
|
||||
tempStr.remove(newCaretX-1,mCaretX - newCaretX);
|
||||
properSetLine(mCaretY - 1, tempStr);
|
||||
internalSetCaretX(newCaretX);
|
||||
} else {
|
||||
// delete char
|
||||
int glyphIndex = mDocument->charToGlyphIndex(mCaretY-1,mCaretX-1);
|
||||
Q_ASSERT(glyphIndex>0);
|
||||
int oldCaretX = mCaretX;
|
||||
int newCaretX = mDocument->glyphStartChar(mCaretY-1, glyphIndex-1)+1;
|
||||
qDebug()<<"delete last char:"<<oldCaretX<<newCaretX<<glyphIndex<<mCaretY;
|
||||
QString s = tempStr.mid(newCaretX-1, oldCaretX-newCaretX);
|
||||
internalSetCaretX(newCaretX);
|
||||
if (s==' ' || s=='\t')
|
||||
|
@ -1935,9 +1917,8 @@ void QSynEdit::doDeleteLastChar()
|
|||
tempStr.remove(newCaretX-1, oldCaretX-newCaretX);
|
||||
properSetLine(mCaretY - 1, tempStr);
|
||||
}
|
||||
}
|
||||
if ((Caret.ch != mCaretX) || (Caret.line != mCaretY)) {
|
||||
mUndoList->addChange(ChangeReason::Delete, caretXY(), Caret, helper,
|
||||
if ((caretBackup.ch != mCaretX) || (caretBackup.line != mCaretY)) {
|
||||
mUndoList->addChange(ChangeReason::Delete, caretXY(), caretBackup, helper,
|
||||
mActiveSelectionMode);
|
||||
if (shouldAddGroupBreak)
|
||||
mUndoList->addGroupBreak();
|
||||
|
|
|
@ -95,11 +95,12 @@ enum EditorOption {
|
|||
eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
||||
eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters
|
||||
eoShowRainbowColor = 0x00080000,
|
||||
eoSelectWordByDblClick= 0x00100000,
|
||||
eoSelectWordByDblClick = 0x00100000,
|
||||
eoShowLeadingSpaces = 0x00200000,
|
||||
eoShowTrailingSpaces = 0x00400000,
|
||||
eoShowInnerSpaces= 0x00800000,
|
||||
eoShowInnerSpaces = 0x00800000,
|
||||
eoShowLineBreaks = 0x01000000,
|
||||
eoForceMonospace = 0x02000000,
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(EditorOptions, EditorOption)
|
||||
|
|
Loading…
Reference in New Issue