- enhancement: prevent group undo when caret position changed
- fix: undo link break may lose leading spaces refactor undo
This commit is contained in:
parent
a86544d6ae
commit
2d7c2145e3
2
NEWS.md
2
NEWS.md
|
@ -9,6 +9,8 @@ Red Panda C++ Version 1.1.4
|
||||||
- refactor of undo system
|
- refactor of undo system
|
||||||
- fix: calculation of the code block ranges when inserting/deleting
|
- fix: calculation of the code block ranges when inserting/deleting
|
||||||
- fix: undo chains
|
- fix: undo chains
|
||||||
|
- enhancement: prevent group undo when caret position changed
|
||||||
|
- fix: undo link break may lose leading spaces
|
||||||
|
|
||||||
Red Panda C++ Version 1.1.3
|
Red Panda C++ Version 1.1.3
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool CppRefacter::findOccurence(Editor *editor, const BufferCoord &pos)
|
||||||
PStatement statement = editor->parser()->findStatementOf(
|
PStatement statement = editor->parser()->findStatementOf(
|
||||||
editor->filename(),
|
editor->filename(),
|
||||||
expression,
|
expression,
|
||||||
pos.Line);
|
pos.line);
|
||||||
// definition of the symbol not found
|
// definition of the symbol not found
|
||||||
if (!statement)
|
if (!statement)
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,7 +117,7 @@ void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QSt
|
||||||
QStringList expression;
|
QStringList expression;
|
||||||
QChar s=editor->charAt(pos);
|
QChar s=editor->charAt(pos);
|
||||||
if (!editor->isIdentChar(s)) {
|
if (!editor->isIdentChar(s)) {
|
||||||
expression = editor->getExpressionAtPosition(BufferCoord{pos.Char-1,pos.Line});
|
expression = editor->getExpressionAtPosition(BufferCoord{pos.ch-1,pos.line});
|
||||||
} else {
|
} else {
|
||||||
expression = editor->getExpressionAtPosition(pos);
|
expression = editor->getExpressionAtPosition(pos);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QSt
|
||||||
PStatement oldStatement = editor->parser()->findStatementOf(
|
PStatement oldStatement = editor->parser()->findStatementOf(
|
||||||
editor->filename(),
|
editor->filename(),
|
||||||
expression,
|
expression,
|
||||||
pos.Line);
|
pos.line);
|
||||||
// definition of the symbol not found
|
// definition of the symbol not found
|
||||||
if (!oldStatement)
|
if (!oldStatement)
|
||||||
return;
|
return;
|
||||||
|
@ -144,7 +144,7 @@ void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QSt
|
||||||
PStatement newStatement = editor->parser()->findStatementOf(
|
PStatement newStatement = editor->parser()->findStatementOf(
|
||||||
editor->filename(),
|
editor->filename(),
|
||||||
newExpression,
|
newExpression,
|
||||||
pos.Line);
|
pos.line);
|
||||||
if (newStatement && fullParentName(newStatement) == oldScope) {
|
if (newStatement && fullParentName(newStatement) == oldScope) {
|
||||||
QMessageBox::critical(editor,
|
QMessageBox::critical(editor,
|
||||||
tr("Rename Symbol Error"),
|
tr("Rename Symbol Error"),
|
||||||
|
@ -231,19 +231,19 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
||||||
if (token == statement->command) {
|
if (token == statement->command) {
|
||||||
//same name symbol , test if the same statement;
|
//same name symbol , test if the same statement;
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.Line = posY+1;
|
p.line = posY+1;
|
||||||
p.Char = start+1;
|
p.ch = start+1;
|
||||||
|
|
||||||
QStringList expression = editor.getExpressionAtPosition(p);
|
QStringList expression = editor.getExpressionAtPosition(p);
|
||||||
PStatement tokenStatement = parser->findStatementOf(
|
PStatement tokenStatement = parser->findStatementOf(
|
||||||
filename,
|
filename,
|
||||||
expression, p.Line);
|
expression, p.line);
|
||||||
if (tokenStatement
|
if (tokenStatement
|
||||||
&& (tokenStatement->line == statement->line)
|
&& (tokenStatement->line == statement->line)
|
||||||
&& (tokenStatement->fileName == statement->fileName)) {
|
&& (tokenStatement->fileName == statement->fileName)) {
|
||||||
PSearchResultTreeItem item = std::make_shared<SearchResultTreeItem>();
|
PSearchResultTreeItem item = std::make_shared<SearchResultTreeItem>();
|
||||||
item->filename = filename;
|
item->filename = filename;
|
||||||
item->line = p.Line;
|
item->line = p.line;
|
||||||
item->start = start;
|
item->start = start;
|
||||||
item->len = token.length();
|
item->len = token.length();
|
||||||
item->parent = parentItem.get();
|
item->parent = parentItem.get();
|
||||||
|
@ -291,13 +291,13 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
||||||
if (token == statement->command) {
|
if (token == statement->command) {
|
||||||
//same name symbol , test if the same statement;
|
//same name symbol , test if the same statement;
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.Line = posY+1;
|
p.line = posY+1;
|
||||||
p.Char = start;
|
p.ch = start;
|
||||||
|
|
||||||
QStringList expression = editor.getExpressionAtPosition(p);
|
QStringList expression = editor.getExpressionAtPosition(p);
|
||||||
PStatement tokenStatement = parser->findStatementOf(
|
PStatement tokenStatement = parser->findStatementOf(
|
||||||
filename,
|
filename,
|
||||||
expression, p.Line);
|
expression, p.line);
|
||||||
if (tokenStatement
|
if (tokenStatement
|
||||||
&& (tokenStatement->line == statement->line)
|
&& (tokenStatement->line == statement->line)
|
||||||
&& (tokenStatement->fileName == statement->fileName)) {
|
&& (tokenStatement->fileName == statement->fileName)) {
|
||||||
|
|
|
@ -595,7 +595,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
if (s=="*/") {
|
if (s=="*/") {
|
||||||
BufferCoord p = caretXY();
|
BufferCoord p = caretXY();
|
||||||
setBlockBegin(p);
|
setBlockBegin(p);
|
||||||
p.Char = lineText().length()+1;
|
p.ch = lineText().length()+1;
|
||||||
setBlockEnd(p);
|
setBlockEnd(p);
|
||||||
setSelText("");
|
setSelText("");
|
||||||
}
|
}
|
||||||
|
@ -652,10 +652,10 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
s=lineBreak()+"* ";
|
s=lineBreak()+"* ";
|
||||||
insertString(s,false);
|
insertString(s,false);
|
||||||
BufferCoord p = caretXY();
|
BufferCoord p = caretXY();
|
||||||
p.Line++;
|
p.line++;
|
||||||
p.Char = document()->getString(p.Line-1).length()+1;
|
p.ch = document()->getString(p.line-1).length()+1;
|
||||||
if (right>0) {
|
if (right>0) {
|
||||||
p.Char -=right+1;
|
p.ch -=right+1;
|
||||||
}
|
}
|
||||||
setCaretXY(p);
|
setCaretXY(p);
|
||||||
}
|
}
|
||||||
|
@ -718,7 +718,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
if (t.isEmpty())
|
if (t.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (activeSelectionMode()==SynSelectionMode::smColumn)
|
if (activeSelectionMode()==SynSelectionMode::Column)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QChar ch = t[0];
|
QChar ch = t[0];
|
||||||
|
@ -932,7 +932,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
if (cursor() == Qt::PointingHandCursor) {
|
if (cursor() == Qt::PointingHandCursor) {
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
if (pointToCharLine(mapFromGlobal(QCursor::pos()),p)) {
|
if (pointToCharLine(mapFromGlobal(QCursor::pos()),p)) {
|
||||||
if (line==p.Line){
|
if (line==p.line){
|
||||||
int pos1=std::max(lineText.indexOf("<"),lineText.indexOf("\""));
|
int pos1=std::max(lineText.indexOf("<"),lineText.indexOf("\""));
|
||||||
int pos2=std::max(lineText.lastIndexOf(">"),lineText.lastIndexOf("\""));
|
int pos2=std::max(lineText.lastIndexOf(">"),lineText.lastIndexOf("\""));
|
||||||
pos1++;
|
pos1++;
|
||||||
|
@ -954,15 +954,15 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
PStatement statement = parser()->findStatementOf(
|
PStatement statement = parser()->findStatementOf(
|
||||||
filename(),
|
filename(),
|
||||||
expression,
|
expression,
|
||||||
p.Line);
|
p.line);
|
||||||
StatementKind kind = getKindOfStatement(statement);
|
StatementKind kind = getKindOfStatement(statement);
|
||||||
if (kind == StatementKind::skUnknown) {
|
if (kind == StatementKind::skUnknown) {
|
||||||
BufferCoord pBeginPos,pEndPos;
|
BufferCoord pBeginPos,pEndPos;
|
||||||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||||
if ((pEndPos.Line>=1)
|
if ((pEndPos.line>=1)
|
||||||
&& (pEndPos.Char>=0)
|
&& (pEndPos.ch>=0)
|
||||||
&& (pEndPos.Char+1 < document()->getString(pEndPos.Line-1).length())
|
&& (pEndPos.ch+1 < document()->getString(pEndPos.line-1).length())
|
||||||
&& (document()->getString(pEndPos.Line-1)[pEndPos.Char+1] == '(')) {
|
&& (document()->getString(pEndPos.line-1)[pEndPos.ch+1] == '(')) {
|
||||||
kind = StatementKind::skFunction;
|
kind = StatementKind::skFunction;
|
||||||
} else {
|
} else {
|
||||||
kind = StatementKind::skVariable;
|
kind = StatementKind::skVariable;
|
||||||
|
@ -983,7 +983,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
if (cursor() == Qt::PointingHandCursor) {
|
if (cursor() == Qt::PointingHandCursor) {
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
if (pointToCharLine(mapFromGlobal(QCursor::pos()),p)) {
|
if (pointToCharLine(mapFromGlobal(QCursor::pos()),p)) {
|
||||||
if (line==p.Line && (aChar<=p.Char && p.Char<aChar+token.length())) {
|
if (line==p.line && (aChar<=p.ch && p.ch<aChar+token.length())) {
|
||||||
style.setFlag(SynFontStyle::fsUnderline);
|
style.setFlag(SynFontStyle::fsUnderline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1005,15 +1005,15 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
} else if (!selAvail() && attr->name() == SYNS_AttrSymbol
|
} else if (!selAvail() && attr->name() == SYNS_AttrSymbol
|
||||||
&& pSettings->editor().highlightMathingBraces()) {
|
&& pSettings->editor().highlightMathingBraces()) {
|
||||||
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
|
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
|
||||||
if ( (line == mHighlightCharPos1.Line)
|
if ( (line == mHighlightCharPos1.line)
|
||||||
&& (aChar == mHighlightCharPos1.Char)) {
|
&& (aChar == mHighlightCharPos1.ch)) {
|
||||||
if (mCurrentHighlighWordForeground.isValid())
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
foreground = mCurrentHighlighWordForeground;
|
foreground = mCurrentHighlighWordForeground;
|
||||||
if (mCurrentHighlighWordBackground.isValid())
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
background = mCurrentHighlighWordBackground;
|
background = mCurrentHighlighWordBackground;
|
||||||
}
|
}
|
||||||
if ((line == mHighlightCharPos2.Line)
|
if ((line == mHighlightCharPos2.line)
|
||||||
&& (aChar == mHighlightCharPos2.Char)) {
|
&& (aChar == mHighlightCharPos2.ch)) {
|
||||||
if (mCurrentHighlighWordForeground.isValid())
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
foreground = mCurrentHighlighWordForeground;
|
foreground = mCurrentHighlighWordForeground;
|
||||||
if (mCurrentHighlighWordBackground.isValid())
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
|
@ -1067,7 +1067,7 @@ bool Editor::event(QEvent *event)
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case TipType::Preprocessor:
|
case TipType::Preprocessor:
|
||||||
// When hovering above a preprocessor line, determine if we want to show an include or a identifier hint
|
// When hovering above a preprocessor line, determine if we want to show an include or a identifier hint
|
||||||
s = document()->getString(p.Line - 1);
|
s = document()->getString(p.line - 1);
|
||||||
isIncludeLine = mParser->isIncludeLine(s);
|
isIncludeLine = mParser->isIncludeLine(s);
|
||||||
if (!isIncludeLine)
|
if (!isIncludeLine)
|
||||||
s = wordAtRowCol(p);
|
s = wordAtRowCol(p);
|
||||||
|
@ -1130,7 +1130,7 @@ bool Editor::event(QEvent *event)
|
||||||
!mCompletionPopup->isVisible()
|
!mCompletionPopup->isVisible()
|
||||||
&& !mHeaderCompletionPopup->isVisible()) {
|
&& !mHeaderCompletionPopup->isVisible()) {
|
||||||
if (pSettings->editor().enableIdentifierToolTips())
|
if (pSettings->editor().enableIdentifierToolTips())
|
||||||
hint = getParserHint(QStringList(),s,p.Line);
|
hint = getParserHint(QStringList(),s,p.line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TipType::Identifier:
|
case TipType::Identifier:
|
||||||
|
@ -1139,9 +1139,9 @@ bool Editor::event(QEvent *event)
|
||||||
&& !mHeaderCompletionPopup->isVisible()) {
|
&& !mHeaderCompletionPopup->isVisible()) {
|
||||||
if (pMainWindow->debugger()->executing()
|
if (pMainWindow->debugger()->executing()
|
||||||
&& (pSettings->editor().enableDebugTooltips())) {
|
&& (pSettings->editor().enableDebugTooltips())) {
|
||||||
showDebugHint(s,p.Line);
|
showDebugHint(s,p.line);
|
||||||
} else if (pSettings->editor().enableIdentifierToolTips()) { //if devEditor.ParserHints {
|
} else if (pSettings->editor().enableIdentifierToolTips()) { //if devEditor.ParserHints {
|
||||||
hint = getParserHint(expression, s, p.Line);
|
hint = getParserHint(expression, s, p.line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1209,7 +1209,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
if (pointToCharLine(event->pos(),p)) {
|
if (pointToCharLine(event->pos(),p)) {
|
||||||
QString s = document()->getString(p.Line - 1);
|
QString s = document()->getString(p.line - 1);
|
||||||
if (mParser->isIncludeLine(s)) {
|
if (mParser->isIncludeLine(s)) {
|
||||||
QString filename = mParser->getHeaderFileName(mFilename,s);
|
QString filename = mParser->getHeaderFileName(mFilename,s);
|
||||||
Editor * e = pMainWindow->editorList()->getEditorByFilename(filename);
|
Editor * e = pMainWindow->editorList()->getEditorByFilename(filename);
|
||||||
|
@ -1323,8 +1323,8 @@ void Editor::resizeEvent(QResizeEvent *event)
|
||||||
void Editor::copyToClipboard()
|
void Editor::copyToClipboard()
|
||||||
{
|
{
|
||||||
if (pSettings->editor().copySizeLimit()) {
|
if (pSettings->editor().copySizeLimit()) {
|
||||||
int startLine = blockBegin().Line;
|
int startLine = blockBegin().line;
|
||||||
int endLine = blockEnd().Line;
|
int endLine = blockEnd().line;
|
||||||
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
|
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
|
||||||
QMessageBox::critical(pMainWindow,tr("Error"),
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
||||||
tr("The text to be copied exceeds count limit!"));
|
tr("The text to be copied exceeds count limit!"));
|
||||||
|
@ -1348,8 +1348,8 @@ void Editor::copyToClipboard()
|
||||||
void Editor::cutToClipboard()
|
void Editor::cutToClipboard()
|
||||||
{
|
{
|
||||||
if (pSettings->editor().copySizeLimit()) {
|
if (pSettings->editor().copySizeLimit()) {
|
||||||
int startLine = blockBegin().Line;
|
int startLine = blockBegin().line;
|
||||||
int endLine = blockEnd().Line;
|
int endLine = blockEnd().line;
|
||||||
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
|
if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) {
|
||||||
QMessageBox::critical(pMainWindow,tr("Error"),
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
||||||
tr("The text to be cut exceeds count limit!"));
|
tr("The text to be cut exceeds count limit!"));
|
||||||
|
@ -1428,8 +1428,8 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT
|
||||||
if ((line<1) || (line>document()->count()))
|
if ((line<1) || (line>document()->count()))
|
||||||
return;
|
return;
|
||||||
pError = std::make_shared<SyntaxIssue>();
|
pError = std::make_shared<SyntaxIssue>();
|
||||||
p.Char = startChar;
|
p.ch = startChar;
|
||||||
p.Line = line;
|
p.line = line;
|
||||||
if (startChar >= document()->getString(line-1).length()) {
|
if (startChar >= document()->getString(line-1).length()) {
|
||||||
start = 1;
|
start = 1;
|
||||||
token = document()->getString(line-1);
|
token = document()->getString(line-1);
|
||||||
|
@ -1472,8 +1472,8 @@ void Editor::gotoNextSyntaxIssue()
|
||||||
if (iter==mSyntaxIssues.end())
|
if (iter==mSyntaxIssues.end())
|
||||||
return;
|
return;
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.Char = (*iter)->at(0)->startChar;
|
p.ch = (*iter)->at(0)->startChar;
|
||||||
p.Line = iter.key();
|
p.line = iter.key();
|
||||||
setCaretXY(p);
|
setCaretXY(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1486,8 +1486,8 @@ void Editor::gotoPrevSyntaxIssue()
|
||||||
return;
|
return;
|
||||||
iter--;
|
iter--;
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.Char = (*iter)->at(0)->startChar;
|
p.ch = (*iter)->at(0)->startChar;
|
||||||
p.Line = iter.key();
|
p.line = iter.key();
|
||||||
setCaretXY(p);
|
setCaretXY(p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1522,11 +1522,11 @@ Editor::PSyntaxIssueList Editor::getSyntaxIssuesAtLine(int line)
|
||||||
|
|
||||||
Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const BufferCoord &pos)
|
Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const BufferCoord &pos)
|
||||||
{
|
{
|
||||||
PSyntaxIssueList lst = getSyntaxIssuesAtLine(pos.Line);
|
PSyntaxIssueList lst = getSyntaxIssuesAtLine(pos.line);
|
||||||
if (!lst)
|
if (!lst)
|
||||||
return PSyntaxIssue();
|
return PSyntaxIssue();
|
||||||
foreach (const PSyntaxIssue& issue, *lst) {
|
foreach (const PSyntaxIssue& issue, *lst) {
|
||||||
if (issue->startChar<=pos.Char && pos.Char<=issue->endChar)
|
if (issue->startChar<=pos.ch && pos.ch<=issue->endChar)
|
||||||
return issue;
|
return issue;
|
||||||
}
|
}
|
||||||
return PSyntaxIssue();
|
return PSyntaxIssue();
|
||||||
|
@ -1590,8 +1590,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!selAvail() && highlighter() && pSettings->editor().highlightMathingBraces()){
|
} else if (!selAvail() && highlighter() && pSettings->editor().highlightMathingBraces()){
|
||||||
invalidateLine(mHighlightCharPos1.Line);
|
invalidateLine(mHighlightCharPos1.line);
|
||||||
invalidateLine(mHighlightCharPos2.Line);
|
invalidateLine(mHighlightCharPos2.line);
|
||||||
mHighlightCharPos1 = BufferCoord{0,0};
|
mHighlightCharPos1 = BufferCoord{0,0};
|
||||||
mHighlightCharPos2 = BufferCoord{0,0};
|
mHighlightCharPos2 = BufferCoord{0,0};
|
||||||
// Is there a bracket char before us?
|
// Is there a bracket char before us?
|
||||||
|
@ -1599,26 +1599,26 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
||||||
int ch = caretX() - 2;
|
int ch = caretX() - 2;
|
||||||
BufferCoord coord;
|
BufferCoord coord;
|
||||||
if (ch>=0 && ch<lineLength && isBraceChar(lineText()[ch]) ) {
|
if (ch>=0 && ch<lineLength && isBraceChar(lineText()[ch]) ) {
|
||||||
coord.Char = ch+1;
|
coord.ch = ch+1;
|
||||||
coord.Line = caretY();
|
coord.line = caretY();
|
||||||
}
|
}
|
||||||
//or after us?
|
//or after us?
|
||||||
ch = caretX()-1;
|
ch = caretX()-1;
|
||||||
if (ch>=0 && ch<lineLength && isBraceChar(lineText()[ch]) ) {
|
if (ch>=0 && ch<lineLength && isBraceChar(lineText()[ch]) ) {
|
||||||
coord.Char = ch+1;
|
coord.ch = ch+1;
|
||||||
coord.Line = caretY();
|
coord.line = caretY();
|
||||||
}
|
}
|
||||||
PSynHighlighterAttribute attr;
|
PSynHighlighterAttribute attr;
|
||||||
QString token;
|
QString token;
|
||||||
if (getHighlighterAttriAtRowCol(coord,token,attr)
|
if (getHighlighterAttriAtRowCol(coord,token,attr)
|
||||||
&& attr == highlighter()->symbolAttribute()) {
|
&& attr == highlighter()->symbolAttribute()) {
|
||||||
BufferCoord complementCharPos = getMatchingBracketEx(coord);
|
BufferCoord complementCharPos = getMatchingBracketEx(coord);
|
||||||
if (!foldHidesLine(coord.Line)
|
if (!foldHidesLine(coord.line)
|
||||||
&& !foldHidesLine(complementCharPos.Line)) {
|
&& !foldHidesLine(complementCharPos.line)) {
|
||||||
mHighlightCharPos1 = coord;
|
mHighlightCharPos1 = coord;
|
||||||
mHighlightCharPos2 = complementCharPos;
|
mHighlightCharPos2 = complementCharPos;
|
||||||
invalidateLine(mHighlightCharPos1.Line);
|
invalidateLine(mHighlightCharPos1.line);
|
||||||
invalidateLine(mHighlightCharPos2.Line);
|
invalidateLine(mHighlightCharPos2.line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1812,8 +1812,8 @@ QStringList Editor::getExpressionAtPosition(
|
||||||
QStringList result;
|
QStringList result;
|
||||||
if (!highlighter())
|
if (!highlighter())
|
||||||
return result;
|
return result;
|
||||||
int line = pos.Line-1;
|
int line = pos.line-1;
|
||||||
int ch = pos.Char-1;
|
int ch = pos.ch-1;
|
||||||
int symbolMatchingLevel = 0;
|
int symbolMatchingLevel = 0;
|
||||||
LastSymbolType lastSymbolType=LastSymbolType::None;
|
LastSymbolType lastSymbolType=LastSymbolType::None;
|
||||||
PSynHighlighter highlighter;
|
PSynHighlighter highlighter;
|
||||||
|
@ -1842,7 +1842,7 @@ QStringList Editor::getExpressionAtPosition(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PSynHighlighterAttribute attr = highlighter->getTokenAttribute();
|
PSynHighlighterAttribute attr = highlighter->getTokenAttribute();
|
||||||
if ( (line == pos.Line-1)
|
if ( (line == pos.line-1)
|
||||||
&& (start<=ch) && (ch<=endPos)) {
|
&& (start<=ch) && (ch<=endPos)) {
|
||||||
if (attr==highlighter->commentAttribute() || attr == highlighter->stringAttribute()) {
|
if (attr==highlighter->commentAttribute() || attr == highlighter->stringAttribute()) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -2035,11 +2035,11 @@ QString Editor::getWordForCompletionSearch(const BufferCoord &pos,bool permitTil
|
||||||
QString result = "";
|
QString result = "";
|
||||||
QString s;
|
QString s;
|
||||||
|
|
||||||
s = document()->getString(pos.Line - 1);
|
s = document()->getString(pos.line - 1);
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
|
||||||
int wordBegin = pos.Char - 1 - 1; //BufferCoord::Char starts with 1
|
int wordBegin = pos.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||||
int wordEnd = pos.Char - 1 - 1;
|
int wordEnd = pos.ch - 1 - 1;
|
||||||
|
|
||||||
while ((wordBegin >= 0) && (wordBegin<len)) {
|
while ((wordBegin >= 0) && (wordBegin<len)) {
|
||||||
if (isIdentChar(s[wordBegin])) {
|
if (isIdentChar(s[wordBegin])) {
|
||||||
|
@ -2228,7 +2228,7 @@ bool Editor::handleParentheseSkip()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BufferCoord pos = getMatchingBracket();
|
BufferCoord pos = getMatchingBracket();
|
||||||
if (pos.Line != 0) {
|
if (pos.line != 0) {
|
||||||
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2279,7 +2279,7 @@ bool Editor::handleBracketSkip()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BufferCoord pos = getMatchingBracket();
|
BufferCoord pos = getMatchingBracket();
|
||||||
if (pos.Line != 0) {
|
if (pos.line != 0) {
|
||||||
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2368,7 +2368,7 @@ bool Editor::handleBraceSkip()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BufferCoord pos = getMatchingBracket();
|
BufferCoord pos = getMatchingBracket();
|
||||||
if (pos.Line != 0) {
|
if (pos.line != 0) {
|
||||||
bool oldInsertMode = insertMode();
|
bool oldInsertMode = insertMode();
|
||||||
setInsertMode(false); //set mode to overwrite
|
setInsertMode(false); //set mode to overwrite
|
||||||
commandProcessor(SynEditorCommand::ecChar,'}');
|
commandProcessor(SynEditorCommand::ecChar,'}');
|
||||||
|
@ -2484,7 +2484,7 @@ bool Editor::handleGlobalIncludeSkip()
|
||||||
if (!s.startsWith("include")) //it's not #include
|
if (!s.startsWith("include")) //it's not #include
|
||||||
return false;
|
return false;
|
||||||
BufferCoord pos = getMatchingBracket();
|
BufferCoord pos = getMatchingBracket();
|
||||||
if (pos.Line != 0) {
|
if (pos.line != 0) {
|
||||||
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2970,7 +2970,7 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete)
|
||||||
QString memberOperator;
|
QString memberOperator;
|
||||||
QStringList memberExpression;
|
QStringList memberExpression;
|
||||||
BufferCoord pos = caretXY();
|
BufferCoord pos = caretXY();
|
||||||
pos.Char--;
|
pos.ch--;
|
||||||
QStringList ownerExpression = getOwnerExpressionAndMemberAtPositionForCompletion(
|
QStringList ownerExpression = getOwnerExpressionAndMemberAtPositionForCompletion(
|
||||||
pos,
|
pos,
|
||||||
memberOperator,
|
memberOperator,
|
||||||
|
@ -3128,7 +3128,7 @@ void Editor::completionInsert(bool appendFunc)
|
||||||
||
|
||
|
||||||
(statement->kind == StatementKind::skPreprocessor
|
(statement->kind == StatementKind::skPreprocessor
|
||||||
&& !statement->args.isEmpty())) {
|
&& !statement->args.isEmpty())) {
|
||||||
QChar nextCh = nextNonSpaceChar(caretY()-1,p.Char-1);
|
QChar nextCh = nextNonSpaceChar(caretY()-1,p.ch-1);
|
||||||
if (nextCh=='(') {
|
if (nextCh=='(') {
|
||||||
funcAddOn = "";
|
funcAddOn = "";
|
||||||
} else if (isIdentChar(nextCh) || nextCh == '"'
|
} else if (isIdentChar(nextCh) || nextCh == '"'
|
||||||
|
@ -3188,8 +3188,8 @@ void Editor::headerCompletionInsert()
|
||||||
|
|
||||||
// delete the part of the word that's already been typed ...
|
// delete the part of the word that's already been typed ...
|
||||||
BufferCoord p = caretXY();
|
BufferCoord p = caretXY();
|
||||||
int posBegin = p.Char-1;
|
int posBegin = p.ch-1;
|
||||||
int posEnd = p.Char-1;
|
int posEnd = p.ch-1;
|
||||||
QString sLine = lineText();
|
QString sLine = lineText();
|
||||||
while ((posBegin>0) &&
|
while ((posBegin>0) &&
|
||||||
(isIdentChar(sLine[posBegin-1]) || (sLine[posBegin-1]=='.') || (sLine[posBegin-1]=='+')))
|
(isIdentChar(sLine[posBegin-1]) || (sLine[posBegin-1]=='.') || (sLine[posBegin-1]=='+')))
|
||||||
|
@ -3198,9 +3198,9 @@ void Editor::headerCompletionInsert()
|
||||||
while ((posEnd < sLine.length())
|
while ((posEnd < sLine.length())
|
||||||
&& (isIdentChar(sLine[posEnd]) || (sLine[posEnd]=='.') || (sLine[posBegin-1]=='+')))
|
&& (isIdentChar(sLine[posEnd]) || (sLine[posEnd]=='.') || (sLine[posBegin-1]=='+')))
|
||||||
posEnd++;
|
posEnd++;
|
||||||
p.Char = posBegin+1;
|
p.ch = posBegin+1;
|
||||||
setBlockBegin(p);
|
setBlockBegin(p);
|
||||||
p.Char = posEnd+1;
|
p.ch = posEnd+1;
|
||||||
setBlockEnd(p);
|
setBlockEnd(p);
|
||||||
|
|
||||||
setSelText(headerName);
|
setSelText(headerName);
|
||||||
|
@ -3379,7 +3379,7 @@ Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
||||||
// do not allow when dragging selection
|
// do not allow when dragging selection
|
||||||
if (isPointInSelection(pos))
|
if (isPointInSelection(pos))
|
||||||
return TipType::Selection;
|
return TipType::Selection;
|
||||||
} else if (mParser && mParser->isIncludeLine(document()->getString(pos.Line-1))) {
|
} else if (mParser && mParser->isIncludeLine(document()->getString(pos.line-1))) {
|
||||||
return TipType::Preprocessor;
|
return TipType::Preprocessor;
|
||||||
}else if (attr == highlighter()->identifierAttribute())
|
}else if (attr == highlighter()->identifierAttribute())
|
||||||
return TipType::Identifier;
|
return TipType::Identifier;
|
||||||
|
@ -3539,8 +3539,8 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
});
|
});
|
||||||
const int maxLines=10;
|
const int maxLines=10;
|
||||||
BufferCoord caretPos = caretXY();
|
BufferCoord caretPos = caretXY();
|
||||||
int currentLine = caretPos.Line-1;
|
int currentLine = caretPos.line-1;
|
||||||
int currentChar = caretPos.Char-1;
|
int currentChar = caretPos.ch-1;
|
||||||
BufferCoord functionNamePos{-1,-1};
|
BufferCoord functionNamePos{-1,-1};
|
||||||
bool foundFunctionStart = false;
|
bool foundFunctionStart = false;
|
||||||
int parenthesisLevel = 0;
|
int parenthesisLevel = 0;
|
||||||
|
@ -3556,7 +3556,7 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
|
|
||||||
while (currentLine>=0) {
|
while (currentLine>=0) {
|
||||||
QString line = document()->getString(currentLine);
|
QString line = document()->getString(currentLine);
|
||||||
if (currentLine!=caretPos.Line-1)
|
if (currentLine!=caretPos.line-1)
|
||||||
currentChar = line.length();
|
currentChar = line.length();
|
||||||
QStringList tokens;
|
QStringList tokens;
|
||||||
QList<int> positions;
|
QList<int> positions;
|
||||||
|
@ -3578,15 +3578,15 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
if (foundFunctionStart) {
|
if (foundFunctionStart) {
|
||||||
if (attr!=highlighter()->identifierAttribute())
|
if (attr!=highlighter()->identifierAttribute())
|
||||||
return; // not a function
|
return; // not a function
|
||||||
functionNamePos.Line = currentLine+1;
|
functionNamePos.line = currentLine+1;
|
||||||
functionNamePos.Char = start+1;
|
functionNamePos.ch = start+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tokens.append(token);
|
tokens.append(token);
|
||||||
positions.append(start);
|
positions.append(start);
|
||||||
} else if (attr == highlighter()->commentAttribute()
|
} else if (attr == highlighter()->commentAttribute()
|
||||||
&& currentLine == caretPos.Line-1 && start<caretPos.Char
|
&& currentLine == caretPos.line-1 && start<caretPos.ch
|
||||||
&& start+token.length()>=caretPos.Char) {
|
&& start+token.length()>=caretPos.ch) {
|
||||||
return; // in comment, do nothing
|
return; // in comment, do nothing
|
||||||
}
|
}
|
||||||
highlighter()->next();
|
highlighter()->next();
|
||||||
|
@ -3616,8 +3616,8 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
// found start of function
|
// found start of function
|
||||||
foundFunctionStart = true;
|
foundFunctionStart = true;
|
||||||
if (i>0) {
|
if (i>0) {
|
||||||
functionNamePos.Line = currentLine+1;
|
functionNamePos.line = currentLine+1;
|
||||||
functionNamePos.Char = positions[i-1]+1;
|
functionNamePos.ch = positions[i-1]+1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (tokens[i]=="[") {
|
} else if (tokens[i]=="[") {
|
||||||
|
@ -3641,13 +3641,13 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (functionNamePos.Char>=0)
|
if (functionNamePos.ch>=0)
|
||||||
break;
|
break;
|
||||||
currentLine--;
|
currentLine--;
|
||||||
if (caretPos.Line-currentLine>maxLines)
|
if (caretPos.line-currentLine>maxLines)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
isFunction = functionNamePos.Char>=0;
|
isFunction = functionNamePos.ch>=0;
|
||||||
currentParamPos = paramsCount-1;
|
currentParamPos = paramsCount-1;
|
||||||
if (!isFunction)
|
if (!isFunction)
|
||||||
return;
|
return;
|
||||||
|
@ -3655,8 +3655,8 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
|
|
||||||
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
||||||
|
|
||||||
int x = pWordBegin.Char-1-1;
|
int x = pWordBegin.ch-1-1;
|
||||||
QString line = document()->getString(pWordBegin.Line-1);
|
QString line = document()->getString(pWordBegin.line-1);
|
||||||
bool hasPreviousWord=false;
|
bool hasPreviousWord=false;
|
||||||
while (x>=0) {
|
while (x>=0) {
|
||||||
QChar ch=line[x];
|
QChar ch=line[x];
|
||||||
|
@ -3674,13 +3674,13 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
|
|
||||||
if (x >= 0 && hasPreviousWord) {
|
if (x >= 0 && hasPreviousWord) {
|
||||||
BufferCoord pos = pWordBegin;
|
BufferCoord pos = pWordBegin;
|
||||||
pos.Char = x+1;
|
pos.ch = x+1;
|
||||||
QString previousWord = getPreviousWordAtPositionForSuggestion(pos);
|
QString previousWord = getPreviousWordAtPositionForSuggestion(pos);
|
||||||
|
|
||||||
PStatement statement = mParser->findStatementOf(
|
PStatement statement = mParser->findStatementOf(
|
||||||
mFilename,
|
mFilename,
|
||||||
previousWord,
|
previousWord,
|
||||||
pos.Line);
|
pos.line);
|
||||||
if (statement) {
|
if (statement) {
|
||||||
PStatement typeStatement = mParser->findTypeDef(statement,mFilename);
|
PStatement typeStatement = mParser->findTypeDef(statement,mFilename);
|
||||||
if (typeStatement && typeStatement->kind == StatementKind::skClass) {
|
if (typeStatement && typeStatement->kind == StatementKind::skClass) {
|
||||||
|
@ -3703,7 +3703,7 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
pMainWindow->functionTip()->clearTips();
|
pMainWindow->functionTip()->clearTips();
|
||||||
QList<PStatement> statements=mParser->getListOfFunctions(mFilename,
|
QList<PStatement> statements=mParser->getListOfFunctions(mFilename,
|
||||||
s,
|
s,
|
||||||
functionNamePos.Line);
|
functionNamePos.line);
|
||||||
|
|
||||||
foreach (const PStatement statement, statements) {
|
foreach (const PStatement statement, statements) {
|
||||||
pMainWindow->functionTip()->addTip(
|
pMainWindow->functionTip()->addTip(
|
||||||
|
@ -3762,11 +3762,11 @@ void Editor::popUserCodeInTabStops()
|
||||||
tabStopEnd = n+p->endX+1;
|
tabStopEnd = n+p->endX+1;
|
||||||
}
|
}
|
||||||
mTabStopY = caretY() + p->y;
|
mTabStopY = caretY() + p->y;
|
||||||
newCursorPos.Line = mTabStopY;
|
newCursorPos.line = mTabStopY;
|
||||||
newCursorPos.Char = tabStopBegin;
|
newCursorPos.ch = tabStopBegin;
|
||||||
setCaretXY(newCursorPos);
|
setCaretXY(newCursorPos);
|
||||||
setBlockBegin(newCursorPos);
|
setBlockBegin(newCursorPos);
|
||||||
newCursorPos.Char = tabStopEnd;
|
newCursorPos.ch = tabStopEnd;
|
||||||
setBlockEnd(newCursorPos);
|
setBlockEnd(newCursorPos);
|
||||||
|
|
||||||
mTabStopBegin = tabStopBegin;
|
mTabStopBegin = tabStopBegin;
|
||||||
|
@ -3794,13 +3794,13 @@ void Editor::onExportedFormatToken(PSynHighlighter syntaxHighlighter, int Line,
|
||||||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||||
// qDebug()<<s;
|
// qDebug()<<s;
|
||||||
PStatement statement = mParser->findStatementOf(mFilename,
|
PStatement statement = mParser->findStatementOf(mFilename,
|
||||||
s , p.Line);
|
s , p.line);
|
||||||
StatementKind kind = getKindOfStatement(statement);
|
StatementKind kind = getKindOfStatement(statement);
|
||||||
if (kind == StatementKind::skUnknown) {
|
if (kind == StatementKind::skUnknown) {
|
||||||
if ((pEndPos.Line>=1)
|
if ((pEndPos.line>=1)
|
||||||
&& (pEndPos.Char>=0)
|
&& (pEndPos.ch>=0)
|
||||||
&& (pEndPos.Char < document()->getString(pEndPos.Line-1).length())
|
&& (pEndPos.ch < document()->getString(pEndPos.line-1).length())
|
||||||
&& (document()->getString(pEndPos.Line-1)[pEndPos.Char] == '(')) {
|
&& (document()->getString(pEndPos.line-1)[pEndPos.ch] == '(')) {
|
||||||
kind = StatementKind::skFunction;
|
kind = StatementKind::skFunction;
|
||||||
} else {
|
} else {
|
||||||
kind = StatementKind::skVariable;
|
kind = StatementKind::skVariable;
|
||||||
|
@ -3926,7 +3926,7 @@ void Editor::gotoDeclaration(const BufferCoord &pos)
|
||||||
PStatement statement = parser()->findStatementOf(
|
PStatement statement = parser()->findStatementOf(
|
||||||
filename(),
|
filename(),
|
||||||
expression,
|
expression,
|
||||||
pos.Line);
|
pos.line);
|
||||||
// QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
|
// QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||||
// if (phrase.isEmpty())
|
// if (phrase.isEmpty())
|
||||||
// return;
|
// return;
|
||||||
|
@ -3940,7 +3940,7 @@ void Editor::gotoDeclaration(const BufferCoord &pos)
|
||||||
}
|
}
|
||||||
QString filename;
|
QString filename;
|
||||||
int line;
|
int line;
|
||||||
if (statement->fileName == mFilename && statement->line == pos.Line) {
|
if (statement->fileName == mFilename && statement->line == pos.line) {
|
||||||
filename = statement->definitionFileName;
|
filename = statement->definitionFileName;
|
||||||
line = statement->definitionLine;
|
line = statement->definitionLine;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3961,7 +3961,7 @@ void Editor::gotoDefinition(const BufferCoord &pos)
|
||||||
PStatement statement = parser()->findStatementOf(
|
PStatement statement = parser()->findStatementOf(
|
||||||
filename(),
|
filename(),
|
||||||
expression,
|
expression,
|
||||||
pos.Line);
|
pos.line);
|
||||||
|
|
||||||
if (!statement) {
|
if (!statement) {
|
||||||
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
|
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
|
||||||
|
@ -3969,7 +3969,7 @@ void Editor::gotoDefinition(const BufferCoord &pos)
|
||||||
}
|
}
|
||||||
QString filename;
|
QString filename;
|
||||||
int line;
|
int line;
|
||||||
if (statement->definitionFileName == mFilename && statement->definitionLine == pos.Line) {
|
if (statement->definitionFileName == mFilename && statement->definitionLine == pos.line) {
|
||||||
filename = statement->fileName;
|
filename = statement->fileName;
|
||||||
line = statement->line;
|
line = statement->line;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3986,17 +3986,17 @@ QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pW
|
||||||
{
|
{
|
||||||
QString result = "";
|
QString result = "";
|
||||||
QString s;
|
QString s;
|
||||||
if ((p.Line<1) || (p.Line>editor->document()->count())) {
|
if ((p.line<1) || (p.line>editor->document()->count())) {
|
||||||
pWordBegin = p;
|
pWordBegin = p;
|
||||||
pWordEnd = p;
|
pWordEnd = p;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
s = editor->document()->getString(p.Line - 1);
|
s = editor->document()->getString(p.line - 1);
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
|
||||||
int wordBegin = p.Char - 1 - 1; //BufferCoord::Char starts with 1
|
int wordBegin = p.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||||
int wordEnd = p.Char - 1 - 1;
|
int wordEnd = p.ch - 1 - 1;
|
||||||
|
|
||||||
// Copy forward until end of word
|
// Copy forward until end of word
|
||||||
if (purpose == Editor::WordPurpose::wpEvaluation
|
if (purpose == Editor::WordPurpose::wpEvaluation
|
||||||
|
@ -4121,10 +4121,10 @@ QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pW
|
||||||
|
|
||||||
// Get end result
|
// Get end result
|
||||||
result = s.mid(wordBegin+1, wordEnd - wordBegin);
|
result = s.mid(wordBegin+1, wordEnd - wordBegin);
|
||||||
pWordBegin.Line = p.Line;
|
pWordBegin.line = p.line;
|
||||||
pWordBegin.Char = wordBegin+1;
|
pWordBegin.ch = wordBegin+1;
|
||||||
pWordEnd.Line = p.Line;
|
pWordEnd.line = p.line;
|
||||||
pWordEnd.Char = wordEnd;
|
pWordEnd.ch = wordEnd;
|
||||||
|
|
||||||
// last line still have part of word
|
// last line still have part of word
|
||||||
if (!result.isEmpty()
|
if (!result.isEmpty()
|
||||||
|
@ -4135,7 +4135,7 @@ QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pW
|
||||||
|| purpose == Editor::WordPurpose::wpEvaluation
|
|| purpose == Editor::WordPurpose::wpEvaluation
|
||||||
|| purpose == Editor::WordPurpose::wpInformation)) {
|
|| purpose == Editor::WordPurpose::wpInformation)) {
|
||||||
int i = wordBegin;
|
int i = wordBegin;
|
||||||
int line=p.Line;
|
int line=p.line;
|
||||||
while (line>=1) {
|
while (line>=1) {
|
||||||
while (i>=0) {
|
while (i>=0) {
|
||||||
if (s[i] == ' '
|
if (s[i] == ' '
|
||||||
|
@ -4155,8 +4155,8 @@ QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pW
|
||||||
} else {
|
} else {
|
||||||
BufferCoord highlightPos;
|
BufferCoord highlightPos;
|
||||||
BufferCoord pDummy;
|
BufferCoord pDummy;
|
||||||
highlightPos.Line = line;
|
highlightPos.line = line;
|
||||||
highlightPos.Char = i+1;
|
highlightPos.ch = i+1;
|
||||||
result = getWordAtPosition(editor, highlightPos,pWordBegin,pDummy,purpose)+result;
|
result = getWordAtPosition(editor, highlightPos,pWordBegin,pDummy,purpose)+result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4197,14 +4197,14 @@ QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pW
|
||||||
QString Editor::getPreviousWordAtPositionForSuggestion(const BufferCoord &p)
|
QString Editor::getPreviousWordAtPositionForSuggestion(const BufferCoord &p)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
if ((p.Line<1) || (p.Line>document()->count())) {
|
if ((p.line<1) || (p.line>document()->count())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
bool inFunc = testInFunc(p.Char-1,p.Line-1);
|
bool inFunc = testInFunc(p.ch-1,p.line-1);
|
||||||
|
|
||||||
QString s = document()->getString(p.Line - 1);
|
QString s = document()->getString(p.line - 1);
|
||||||
int wordBegin;
|
int wordBegin;
|
||||||
int wordEnd = p.Char-1;
|
int wordEnd = p.ch-1;
|
||||||
if (wordEnd >= s.length())
|
if (wordEnd >= s.length())
|
||||||
wordEnd = s.length()-1;
|
wordEnd = s.length()-1;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -2203,8 +2203,8 @@ void MainWindow::loadLastOpens()
|
||||||
if (!editor)
|
if (!editor)
|
||||||
continue;
|
continue;
|
||||||
BufferCoord pos;
|
BufferCoord pos;
|
||||||
pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1);
|
pos.ch = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1);
|
||||||
pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1);
|
pos.line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1);
|
||||||
editor->setCaretXY(pos);
|
editor->setCaretXY(pos);
|
||||||
editor->setTopLine(
|
editor->setTopLine(
|
||||||
lastOpenIni.GetLongValue(sectionName,"TopLine", 1)
|
lastOpenIni.GetLongValue(sectionName,"TopLine", 1)
|
||||||
|
@ -4002,7 +4002,7 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
|
||||||
mEditorContextMenuPos = pos;
|
mEditorContextMenuPos = pos;
|
||||||
int line;
|
int line;
|
||||||
if (editor->getPositionOfMouse(p)) {
|
if (editor->getPositionOfMouse(p)) {
|
||||||
line=p.Line;
|
line=p.line;
|
||||||
//mouse on editing area
|
//mouse on editing area
|
||||||
menu.addAction(ui->actionCompile_Run);
|
menu.addAction(ui->actionCompile_Run);
|
||||||
menu.addAction(ui->actionDebug);
|
menu.addAction(ui->actionDebug);
|
||||||
|
@ -6466,16 +6466,16 @@ void MainWindow::on_actionRename_Symbol_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
|
QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
|
||||||
if (expression.isEmpty() && oldCaretXY.Char>1) {
|
if (expression.isEmpty() && oldCaretXY.ch>1) {
|
||||||
BufferCoord coord=oldCaretXY;
|
BufferCoord coord=oldCaretXY;
|
||||||
coord.Char--;
|
coord.ch--;
|
||||||
expression = editor->getExpressionAtPosition(coord);
|
expression = editor->getExpressionAtPosition(coord);
|
||||||
}
|
}
|
||||||
// Find it's definition
|
// Find it's definition
|
||||||
PStatement oldStatement = editor->parser()->findStatementOf(
|
PStatement oldStatement = editor->parser()->findStatementOf(
|
||||||
editor->filename(),
|
editor->filename(),
|
||||||
expression,
|
expression,
|
||||||
oldCaretXY.Line);
|
oldCaretXY.line);
|
||||||
// definition of the symbol not found
|
// definition of the symbol not found
|
||||||
if (!oldStatement)
|
if (!oldStatement)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -621,16 +621,16 @@ int CountLines(const QString &Line, int start)
|
||||||
|
|
||||||
void ensureNotAfter(BufferCoord &cord1, BufferCoord &cord2)
|
void ensureNotAfter(BufferCoord &cord1, BufferCoord &cord2)
|
||||||
{
|
{
|
||||||
if((cord1.Line > cord2.Line) || (
|
if((cord1.line > cord2.line) || (
|
||||||
cord1.Line == cord2.Line &&
|
cord1.line == cord2.line &&
|
||||||
cord1.Char > cord2.Char)) {
|
cord1.ch > cord2.ch)) {
|
||||||
std::swap(cord1,cord2);
|
std::swap(cord1,cord2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord minBufferCoord(const BufferCoord &P1, const BufferCoord &P2)
|
BufferCoord minBufferCoord(const BufferCoord &P1, const BufferCoord &P2)
|
||||||
{
|
{
|
||||||
if ( (P2.Line < P1.Line) || ( (P2.Line == P1.Line) && (P2.Char < P1.Char)) ) {
|
if ( (P2.line < P1.line) || ( (P2.line == P1.line) && (P2.ch < P1.ch)) ) {
|
||||||
return P2;
|
return P2;
|
||||||
} else {
|
} else {
|
||||||
return P1;
|
return P1;
|
||||||
|
@ -639,7 +639,7 @@ BufferCoord minBufferCoord(const BufferCoord &P1, const BufferCoord &P2)
|
||||||
|
|
||||||
BufferCoord maxBufferCoord(const BufferCoord &P1, const BufferCoord &P2)
|
BufferCoord maxBufferCoord(const BufferCoord &P1, const BufferCoord &P2)
|
||||||
{
|
{
|
||||||
if ( (P2.Line > P1.Line) || ( (P2.Line == P1.Line) && (P2.Char > P1.Char)) ) {
|
if ( (P2.line > P1.line) || ( (P2.line == P1.line) && (P2.ch > P1.ch)) ) {
|
||||||
return P2;
|
return P2;
|
||||||
} else {
|
} else {
|
||||||
return P1;
|
return P1;
|
||||||
|
@ -672,5 +672,5 @@ QStringList splitStrings(const QString &text)
|
||||||
|
|
||||||
int calSpanLines(const BufferCoord &startPos, const BufferCoord &endPos)
|
int calSpanLines(const BufferCoord &startPos, const BufferCoord &endPos)
|
||||||
{
|
{
|
||||||
return std::abs(endPos.Line - startPos.Line+1);
|
return std::abs(endPos.line - startPos.line+1);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -184,8 +184,8 @@ public:
|
||||||
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ public:
|
||||||
void addLeftTopToUndo();
|
void addLeftTopToUndo();
|
||||||
void addSelectionToUndo();
|
void addSelectionToUndo();
|
||||||
void replaceAll(const QString& text) {
|
void replaceAll(const QString& text) {
|
||||||
mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
|
mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
|
||||||
selectAll();
|
selectAll();
|
||||||
setSelText(text);
|
setSelText(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -846,7 +846,7 @@ SynEditUndoList::SynEditUndoList():QObject()
|
||||||
mInitialChangeNumber = 0;
|
mInitialChangeNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::AddChange(SynChangeReason AReason, const BufferCoord &AStart,
|
void SynEditUndoList::addChange(SynChangeReason AReason, const BufferCoord &AStart,
|
||||||
const BufferCoord &AEnd, const QStringList& ChangeText,
|
const BufferCoord &AEnd, const QStringList& ChangeText,
|
||||||
SynSelectionMode SelMode)
|
SynSelectionMode SelMode)
|
||||||
{
|
{
|
||||||
|
@ -867,31 +867,32 @@ void SynEditUndoList::AddChange(SynChangeReason AReason, const BufferCoord &ASta
|
||||||
PSynEditUndoItem NewItem = std::make_shared<SynEditUndoItem>(AReason,
|
PSynEditUndoItem NewItem = std::make_shared<SynEditUndoItem>(AReason,
|
||||||
SelMode,AStart,AEnd,ChangeText,
|
SelMode,AStart,AEnd,ChangeText,
|
||||||
changeNumber);
|
changeNumber);
|
||||||
PushItem(NewItem);
|
pushItem(NewItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::AddGroupBreak()
|
void SynEditUndoList::addGroupBreak()
|
||||||
{
|
{
|
||||||
//Add the GroupBreak even if ItemCount = 0. Since items are stored in
|
if (!canUndo())
|
||||||
//reverse order in TCustomSynEdit.fRedoList, a GroupBreak could be lost.
|
return;
|
||||||
if (LastChangeReason() != SynChangeReason::crGroupBreak) {
|
|
||||||
AddChange(SynChangeReason::crGroupBreak, {0,0}, {0,0}, QStringList(), SynSelectionMode::smNormal);
|
if (lastChangeReason() != SynChangeReason::GroupBreak) {
|
||||||
|
addChange(SynChangeReason::GroupBreak, {0,0}, {0,0}, QStringList(), SynSelectionMode::Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::BeginBlock()
|
void SynEditUndoList::beginBlock()
|
||||||
{
|
{
|
||||||
mBlockCount++;
|
mBlockCount++;
|
||||||
mBlockChangeNumber = mNextChangeNumber;
|
mBlockChangeNumber = mNextChangeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::Clear()
|
void SynEditUndoList::clear()
|
||||||
{
|
{
|
||||||
mItems.clear();
|
mItems.clear();
|
||||||
mFullUndoImposible = false;
|
mFullUndoImposible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::DeleteItem(int index)
|
void SynEditUndoList::deleteItem(int index)
|
||||||
{
|
{
|
||||||
if (index <0 || index>=mItems.count()) {
|
if (index <0 || index>=mItems.count()) {
|
||||||
ListIndexOutOfBounds(index);
|
ListIndexOutOfBounds(index);
|
||||||
|
@ -899,7 +900,7 @@ void SynEditUndoList::DeleteItem(int index)
|
||||||
mItems.removeAt(index);
|
mItems.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::EndBlock()
|
void SynEditUndoList::endBlock()
|
||||||
{
|
{
|
||||||
if (mBlockCount > 0) {
|
if (mBlockCount > 0) {
|
||||||
mBlockCount--;
|
mBlockCount--;
|
||||||
|
@ -909,16 +910,16 @@ void SynEditUndoList::EndBlock()
|
||||||
mNextChangeNumber++;
|
mNextChangeNumber++;
|
||||||
if (mNextChangeNumber == 0)
|
if (mNextChangeNumber == 0)
|
||||||
mNextChangeNumber++;
|
mNextChangeNumber++;
|
||||||
if (mItems.count() > 0 && PeekItem()->changeNumber() == iBlockID)
|
if (mItems.count() > 0 && peekItem()->changeNumber() == iBlockID)
|
||||||
emit addedUndo();
|
emit addedUndo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SynChangeReason SynEditUndoList::LastChangeReason()
|
SynChangeReason SynEditUndoList::lastChangeReason()
|
||||||
{
|
{
|
||||||
if (mItems.count() == 0)
|
if (mItems.count() == 0)
|
||||||
return SynChangeReason::crNothing;
|
return SynChangeReason::Nothing;
|
||||||
else
|
else
|
||||||
return mItems.last()->changeReason();
|
return mItems.last()->changeReason();
|
||||||
}
|
}
|
||||||
|
@ -928,12 +929,12 @@ bool SynEditUndoList::isEmpty()
|
||||||
return mItems.count()==0;
|
return mItems.count()==0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::Lock()
|
void SynEditUndoList::lock()
|
||||||
{
|
{
|
||||||
mLockCount++;
|
mLockCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSynEditUndoItem SynEditUndoList::PeekItem()
|
PSynEditUndoItem SynEditUndoList::peekItem()
|
||||||
{
|
{
|
||||||
if (mItems.count() == 0)
|
if (mItems.count() == 0)
|
||||||
return PSynEditUndoItem();
|
return PSynEditUndoItem();
|
||||||
|
@ -941,7 +942,7 @@ PSynEditUndoItem SynEditUndoList::PeekItem()
|
||||||
return mItems.last();
|
return mItems.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
PSynEditUndoItem SynEditUndoList::PopItem()
|
PSynEditUndoItem SynEditUndoList::popItem()
|
||||||
{
|
{
|
||||||
if (mItems.count() == 0)
|
if (mItems.count() == 0)
|
||||||
return PSynEditUndoItem();
|
return PSynEditUndoItem();
|
||||||
|
@ -952,28 +953,28 @@ PSynEditUndoItem SynEditUndoList::PopItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::PushItem(PSynEditUndoItem Item)
|
void SynEditUndoList::pushItem(PSynEditUndoItem Item)
|
||||||
{
|
{
|
||||||
if (!Item)
|
if (!Item)
|
||||||
return;
|
return;
|
||||||
mItems.append(Item);
|
mItems.append(Item);
|
||||||
ensureMaxEntries();
|
ensureMaxEntries();
|
||||||
if (Item->changeReason()!= SynChangeReason::crGroupBreak)
|
if (Item->changeReason()!= SynChangeReason::GroupBreak)
|
||||||
emit addedUndo();
|
emit addedUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::Unlock()
|
void SynEditUndoList::unlock()
|
||||||
{
|
{
|
||||||
if (mLockCount > 0)
|
if (mLockCount > 0)
|
||||||
mLockCount--;
|
mLockCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEditUndoList::CanUndo()
|
bool SynEditUndoList::canUndo()
|
||||||
{
|
{
|
||||||
return mItems.count()>0;
|
return mItems.count()>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEditUndoList::ItemCount()
|
int SynEditUndoList::itemCount()
|
||||||
{
|
{
|
||||||
return mItems.count();
|
return mItems.count();
|
||||||
}
|
}
|
||||||
|
@ -993,10 +994,10 @@ void SynEditUndoList::setMaxUndoActions(int maxUndoActions)
|
||||||
|
|
||||||
bool SynEditUndoList::initialState()
|
bool SynEditUndoList::initialState()
|
||||||
{
|
{
|
||||||
if (ItemCount() == 0) {
|
if (itemCount() == 0) {
|
||||||
return mInitialChangeNumber == 0;
|
return mInitialChangeNumber == 0;
|
||||||
} else {
|
} else {
|
||||||
return PeekItem()->changeNumber() == mInitialChangeNumber;
|
return peekItem()->changeNumber() == mInitialChangeNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,15 +1012,15 @@ PSynEditUndoItem SynEditUndoList::item(int index)
|
||||||
void SynEditUndoList::setInitialState(const bool Value)
|
void SynEditUndoList::setInitialState(const bool Value)
|
||||||
{
|
{
|
||||||
if (Value) {
|
if (Value) {
|
||||||
if (ItemCount() == 0)
|
if (itemCount() == 0)
|
||||||
mInitialChangeNumber = 0;
|
mInitialChangeNumber = 0;
|
||||||
else
|
else
|
||||||
mInitialChangeNumber = PeekItem()->changeNumber();
|
mInitialChangeNumber = peekItem()->changeNumber();
|
||||||
} else if (ItemCount() == 0) {
|
} else if (itemCount() == 0) {
|
||||||
if (mInitialChangeNumber == 0) {
|
if (mInitialChangeNumber == 0) {
|
||||||
mInitialChangeNumber = -1;
|
mInitialChangeNumber = -1;
|
||||||
}
|
}
|
||||||
} else if (PeekItem()->changeNumber() == mInitialChangeNumber) {
|
} else if (peekItem()->changeNumber() == mInitialChangeNumber) {
|
||||||
mInitialChangeNumber = -1;
|
mInitialChangeNumber = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,16 +161,16 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SynChangeReason {
|
enum class SynChangeReason {
|
||||||
crInsert,
|
Insert,
|
||||||
crDelete,
|
Delete,
|
||||||
crCaret, //just restore the Caret, allowing better Undo behavior
|
Caret, //just restore the Caret, allowing better Undo behavior
|
||||||
crSelection, //restore Selection
|
Selection, //restore Selection
|
||||||
crGroupBreak,
|
GroupBreak,
|
||||||
crLeftTop,
|
LeftTop,
|
||||||
crLineBreak,
|
LineBreak,
|
||||||
crMoveSelectionUp,
|
MoveSelectionUp,
|
||||||
crMoveSelectionDown,
|
MoveSelectionDown,
|
||||||
crNothing
|
Nothing // undo list empty
|
||||||
};
|
};
|
||||||
class SynEditUndoItem {
|
class SynEditUndoItem {
|
||||||
private:
|
private:
|
||||||
|
@ -202,24 +202,24 @@ class SynEditUndoList : public QObject {
|
||||||
public:
|
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 QStringList& ChangeText, SynSelectionMode SelMode);
|
const QStringList& ChangeText, SynSelectionMode SelMode);
|
||||||
|
|
||||||
void AddGroupBreak();
|
void addGroupBreak();
|
||||||
void BeginBlock();
|
void beginBlock();
|
||||||
void Clear();
|
void clear();
|
||||||
void DeleteItem(int index);
|
void deleteItem(int index);
|
||||||
void EndBlock();
|
void endBlock();
|
||||||
SynChangeReason LastChangeReason();
|
SynChangeReason lastChangeReason();
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
void Lock();
|
void lock();
|
||||||
PSynEditUndoItem PeekItem();
|
PSynEditUndoItem peekItem();
|
||||||
PSynEditUndoItem PopItem();
|
PSynEditUndoItem popItem();
|
||||||
void PushItem(PSynEditUndoItem Item);
|
void pushItem(PSynEditUndoItem Item);
|
||||||
void Unlock();
|
void unlock();
|
||||||
|
|
||||||
bool CanUndo();
|
bool canUndo();
|
||||||
int ItemCount();
|
int itemCount();
|
||||||
|
|
||||||
int maxUndoActions() const;
|
int maxUndoActions() const;
|
||||||
void setMaxUndoActions(int maxUndoActions);
|
void setMaxUndoActions(int maxUndoActions);
|
||||||
|
|
|
@ -133,7 +133,7 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
|
||||||
if (edit->mGutter.activeLineTextColor().isValid()) {
|
if (edit->mGutter.activeLineTextColor().isValid()) {
|
||||||
if (
|
if (
|
||||||
(edit->mCaretY==vLine) ||
|
(edit->mCaretY==vLine) ||
|
||||||
(edit->mActiveSelectionMode == SynSelectionMode::smColumn && vLine >= selectionStart.Line && vLine <= selectionEnd.Line)
|
(edit->mActiveSelectionMode == SynSelectionMode::Column && vLine >= selectionStart.line && vLine <= selectionEnd.line)
|
||||||
)
|
)
|
||||||
painter->setPen(edit->mGutter.activeLineTextColor());
|
painter->setPen(edit->mGutter.activeLineTextColor());
|
||||||
else
|
else
|
||||||
|
@ -253,59 +253,59 @@ void SynEditTextPainter::ComputeSelectionInfo()
|
||||||
if (!edit->mHideSelection || edit->hasFocus()) {
|
if (!edit->mHideSelection || edit->hasFocus()) {
|
||||||
bAnySelection = true;
|
bAnySelection = true;
|
||||||
// Get the *real* start of the selected area.
|
// Get the *real* start of the selected area.
|
||||||
if (edit->mBlockBegin.Line < edit->mBlockEnd.Line) {
|
if (edit->mBlockBegin.line < edit->mBlockEnd.line) {
|
||||||
vStart = edit->mBlockBegin;
|
vStart = edit->mBlockBegin;
|
||||||
vEnd = edit->mBlockEnd;
|
vEnd = edit->mBlockEnd;
|
||||||
} else if (edit->mBlockBegin.Line > edit->mBlockEnd.Line) {
|
} else if (edit->mBlockBegin.line > edit->mBlockEnd.line) {
|
||||||
vEnd = edit->mBlockBegin;
|
vEnd = edit->mBlockBegin;
|
||||||
vStart = edit->mBlockEnd;
|
vStart = edit->mBlockEnd;
|
||||||
} else if (edit->mBlockBegin.Char != edit->mBlockEnd.Char) {
|
} else if (edit->mBlockBegin.ch != edit->mBlockEnd.ch) {
|
||||||
// it is only on this line.
|
// it is only on this line.
|
||||||
vStart.Line = edit->mBlockBegin.Line;
|
vStart.line = edit->mBlockBegin.line;
|
||||||
vEnd.Line = vStart.Line;
|
vEnd.line = vStart.line;
|
||||||
if (edit->mBlockBegin.Char < edit->mBlockEnd.Char) {
|
if (edit->mBlockBegin.ch < edit->mBlockEnd.ch) {
|
||||||
vStart.Char = edit->mBlockBegin.Char;
|
vStart.ch = edit->mBlockBegin.ch;
|
||||||
vEnd.Char = edit->mBlockEnd.Char;
|
vEnd.ch = edit->mBlockEnd.ch;
|
||||||
} else {
|
} else {
|
||||||
vStart.Char = edit->mBlockEnd.Char;
|
vStart.ch = edit->mBlockEnd.ch;
|
||||||
vEnd.Char = edit->mBlockBegin.Char;
|
vEnd.ch = edit->mBlockBegin.ch;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
bAnySelection = false;
|
bAnySelection = false;
|
||||||
if (edit->mInputPreeditString.length()>0) {
|
if (edit->mInputPreeditString.length()>0) {
|
||||||
if (vStart.Line == edit->mCaretY && vStart.Char >=edit->mCaretX) {
|
if (vStart.line == edit->mCaretY && vStart.ch >=edit->mCaretX) {
|
||||||
vStart.Char+=edit->mInputPreeditString.length();
|
vStart.ch+=edit->mInputPreeditString.length();
|
||||||
}
|
}
|
||||||
if (vEnd.Line == edit->mCaretY && vEnd.Char >edit->mCaretX) {
|
if (vEnd.line == edit->mCaretY && vEnd.ch >edit->mCaretX) {
|
||||||
vEnd.Char+=edit->mInputPreeditString.length();
|
vEnd.ch+=edit->mInputPreeditString.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there is any visible selection so far, then test if there is an
|
// If there is any visible selection so far, then test if there is an
|
||||||
// intersection with the area to be painted.
|
// intersection with the area to be painted.
|
||||||
if (bAnySelection) {
|
if (bAnySelection) {
|
||||||
// Don't care if the selection is not visible.
|
// Don't care if the selection is not visible.
|
||||||
bAnySelection = (vEnd.Line >= vFirstLine) && (vStart.Line <= vLastLine);
|
bAnySelection = (vEnd.line >= vFirstLine) && (vStart.line <= vLastLine);
|
||||||
if (bAnySelection) {
|
if (bAnySelection) {
|
||||||
// Transform the selection from text space into screen space
|
// Transform the selection from text space into screen space
|
||||||
vSelStart = edit->bufferToDisplayPos(vStart);
|
vSelStart = edit->bufferToDisplayPos(vStart);
|
||||||
vSelEnd = edit->bufferToDisplayPos(vEnd);
|
vSelEnd = edit->bufferToDisplayPos(vEnd);
|
||||||
if (edit->mInputPreeditString.length()
|
if (edit->mInputPreeditString.length()
|
||||||
&& vStart.Line == edit->mCaretY) {
|
&& vStart.line == edit->mCaretY) {
|
||||||
QString sLine = edit->lineText().left(edit->mCaretX-1)
|
QString sLine = edit->lineText().left(edit->mCaretX-1)
|
||||||
+ edit->mInputPreeditString
|
+ edit->mInputPreeditString
|
||||||
+ edit->lineText().mid(edit->mCaretX-1);
|
+ edit->lineText().mid(edit->mCaretX-1);
|
||||||
vSelStart.Column = edit->charToColumn(sLine,vStart.Char);
|
vSelStart.Column = edit->charToColumn(sLine,vStart.ch);
|
||||||
}
|
}
|
||||||
if (edit->mInputPreeditString.length()
|
if (edit->mInputPreeditString.length()
|
||||||
&& vEnd.Line == edit->mCaretY) {
|
&& vEnd.line == edit->mCaretY) {
|
||||||
QString sLine = edit->lineText().left(edit->mCaretX-1)
|
QString sLine = edit->lineText().left(edit->mCaretX-1)
|
||||||
+ edit->mInputPreeditString
|
+ edit->mInputPreeditString
|
||||||
+ edit->lineText().mid(edit->mCaretX-1);
|
+ edit->lineText().mid(edit->mCaretX-1);
|
||||||
vSelEnd.Column = edit->charToColumn(sLine,vEnd.Char);
|
vSelEnd.Column = edit->charToColumn(sLine,vEnd.ch);
|
||||||
}
|
}
|
||||||
// In the column selection mode sort the begin and end of the selection,
|
// In the column selection mode sort the begin and end of the selection,
|
||||||
// this makes the painting code simpler.
|
// this makes the painting code simpler.
|
||||||
if (edit->mActiveSelectionMode == SynSelectionMode::smColumn && vSelStart.Column > vSelEnd.Column)
|
if (edit->mActiveSelectionMode == SynSelectionMode::Column && vSelStart.Column > vSelEnd.Column)
|
||||||
std::swap(vSelStart.Column, vSelEnd.Column);
|
std::swap(vSelStart.Column, vSelEnd.Column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -821,8 +821,8 @@ void SynEditTextPainter::PaintLines()
|
||||||
// Get the line.
|
// Get the line.
|
||||||
sLine = edit->mDocument->getString(vLine - 1);
|
sLine = edit->mDocument->getString(vLine - 1);
|
||||||
// determine whether will be painted with ActiveLineColor
|
// determine whether will be painted with ActiveLineColor
|
||||||
if (edit->mActiveSelectionMode == SynSelectionMode::smColumn) {
|
if (edit->mActiveSelectionMode == SynSelectionMode::Column) {
|
||||||
bCurrentLine = (vLine >= selectionBegin.Line && vLine <= selectionEnd.Line);
|
bCurrentLine = (vLine >= selectionBegin.line && vLine <= selectionEnd.line);
|
||||||
} else {
|
} else {
|
||||||
bCurrentLine = (edit->mCaretY == vLine);
|
bCurrentLine = (edit->mCaretY == vLine);
|
||||||
}
|
}
|
||||||
|
@ -859,8 +859,8 @@ void SynEditTextPainter::PaintLines()
|
||||||
// selection mode and a good start for the smNormal mode.
|
// selection mode and a good start for the smNormal mode.
|
||||||
nLineSelStart = FirstCol;
|
nLineSelStart = FirstCol;
|
||||||
nLineSelEnd = LastCol + 1;
|
nLineSelEnd = LastCol + 1;
|
||||||
if ((edit->mActiveSelectionMode == SynSelectionMode::smColumn) ||
|
if ((edit->mActiveSelectionMode == SynSelectionMode::Column) ||
|
||||||
((edit->mActiveSelectionMode == SynSelectionMode::smNormal) && (cRow == vSelStart.Row)) ) {
|
((edit->mActiveSelectionMode == SynSelectionMode::Normal) && (cRow == vSelStart.Row)) ) {
|
||||||
int ch = edit->columnToChar(vLine,vSelStart.Column);
|
int ch = edit->columnToChar(vLine,vSelStart.Column);
|
||||||
ch = edit->charToColumn(vLine,ch);
|
ch = edit->charToColumn(vLine,ch);
|
||||||
if (ch > LastCol) {
|
if (ch > LastCol) {
|
||||||
|
@ -871,8 +871,8 @@ void SynEditTextPainter::PaintLines()
|
||||||
bComplexLine = true;
|
bComplexLine = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( (edit->mActiveSelectionMode == SynSelectionMode::smColumn) ||
|
if ( (edit->mActiveSelectionMode == SynSelectionMode::Column) ||
|
||||||
((edit->mActiveSelectionMode == SynSelectionMode::smNormal) && (cRow == vSelEnd.Row)) ) {
|
((edit->mActiveSelectionMode == SynSelectionMode::Normal) && (cRow == vSelEnd.Row)) ) {
|
||||||
int ch = edit->columnToChar(vLine,vSelEnd.Column);
|
int ch = edit->columnToChar(vLine,vSelEnd.Column);
|
||||||
int col = edit->charToColumn(vLine,ch);
|
int col = edit->charToColumn(vLine,ch);
|
||||||
if (col<vSelEnd.Column)
|
if (col<vSelEnd.Column)
|
||||||
|
|
|
@ -17,270 +17,37 @@
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
#include "SynEdit.h"
|
#include "SynEdit.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
ContentsCoord::ContentsCoord(const SynEdit *edit, int ch, int line)
|
|
||||||
{
|
|
||||||
Q_ASSERT(edit!=nullptr);
|
|
||||||
mEdit = edit;
|
|
||||||
mChar = ch;
|
|
||||||
mLine = line;
|
|
||||||
normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentsCoord::normalize()
|
|
||||||
{
|
|
||||||
if (mEdit->document()->count()==0) {
|
|
||||||
mChar = 0;
|
|
||||||
mLine = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int aLine = mLine;
|
|
||||||
int aChar = mChar;
|
|
||||||
int line = aLine-1;
|
|
||||||
int lineCount = mEdit->document()->count();
|
|
||||||
if (line>=lineCount) {
|
|
||||||
mChar = mEdit->document()->getString(lineCount-1).length()+1;
|
|
||||||
mLine = lineCount;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (line<0) {
|
|
||||||
mChar = 0;
|
|
||||||
mLine = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (aChar<1) {
|
|
||||||
while (true) {
|
|
||||||
line--;
|
|
||||||
if (line < 0) {
|
|
||||||
mChar = 0;
|
|
||||||
mLine = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString s = mEdit->document()->getString(line);
|
|
||||||
int len = s.length();
|
|
||||||
aChar+=len+1;
|
|
||||||
if (aChar>=1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (true) {
|
|
||||||
QString s =mEdit->document()->getString(line);
|
|
||||||
int len = s.length();
|
|
||||||
if (aChar<=len+1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (line == lineCount-1) {
|
|
||||||
mChar = 1;
|
|
||||||
mLine = lineCount+1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
aChar -= len+1;
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mChar = aChar;
|
|
||||||
mLine = line+1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ContentsCoord::line() const
|
|
||||||
{
|
|
||||||
return mLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentsCoord::setLine(int newLine)
|
|
||||||
{
|
|
||||||
mLine = newLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::atStart()
|
|
||||||
{
|
|
||||||
return mLine<1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::atEnd()
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit!=nullptr);
|
|
||||||
return mLine>mEdit->document()->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
const SynEdit *ContentsCoord::edit() const
|
|
||||||
{
|
|
||||||
return mEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ContentsCoord &ContentsCoord::operator=(const ContentsCoord &coord)
|
|
||||||
{
|
|
||||||
mEdit = coord.mEdit;
|
|
||||||
mChar = coord.mChar;
|
|
||||||
mLine = coord.mLine;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ContentsCoord &ContentsCoord::operator=(const ContentsCoord &&coord)
|
|
||||||
{
|
|
||||||
if (this!=&coord) {
|
|
||||||
mEdit = coord.mEdit;
|
|
||||||
mChar = coord.mChar;
|
|
||||||
mLine = coord.mLine;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::operator==(const ContentsCoord &coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
return (mLine == coord.mLine)
|
|
||||||
&& (mChar == coord.mChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::operator<(const ContentsCoord &coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
return (mLine < coord.mLine) || (mLine == coord.mLine && mChar < coord.mChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::operator<=(const ContentsCoord &coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
return (mLine < coord.mLine) || (mLine == coord.mLine && mChar <= coord.mChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::operator>(const ContentsCoord &coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
return (mLine > coord.mLine) || (mLine == coord.mLine && mChar > coord.mChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentsCoord::operator>=(const ContentsCoord &coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
return (mLine > coord.mLine) || (mLine == coord.mLine && mChar >= coord.mChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ContentsCoord::operator-(const ContentsCoord& coord) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit == coord.mEdit);
|
|
||||||
if (mLine == coord.mLine) {
|
|
||||||
return mChar - coord.mChar;
|
|
||||||
} else if (mLine > coord.mLine) {
|
|
||||||
size_t result = mEdit->document()->getString(coord.mLine-1).length()+1-coord.mChar;
|
|
||||||
int line = coord.mLine+1;
|
|
||||||
while (line<=mLine-1) {
|
|
||||||
result += mEdit->document()->getString(line-1).length()+1;
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
if (mLine<=mEdit->document()->count()) {
|
|
||||||
result += mChar;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
return coord - (*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ContentsCoord &ContentsCoord::operator+=(int delta)
|
|
||||||
{
|
|
||||||
mChar+=delta;
|
|
||||||
normalize();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ContentsCoord &ContentsCoord::operator-=(int delta)
|
|
||||||
{
|
|
||||||
mChar-=delta;
|
|
||||||
normalize();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferCoord ContentsCoord::toBufferCoord() const
|
|
||||||
{
|
|
||||||
return BufferCoord{mChar,mLine};
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentsCoord ContentsCoord::operator-(int delta) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit != nullptr);
|
|
||||||
return ContentsCoord(mEdit,mChar-delta,mLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentsCoord ContentsCoord::operator+(int delta) const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit != nullptr);
|
|
||||||
return ContentsCoord(mEdit,mChar+delta,mLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
QChar ContentsCoord::operator*() const
|
|
||||||
{
|
|
||||||
Q_ASSERT(mEdit != nullptr);
|
|
||||||
if (mLine < 1) {
|
|
||||||
return QChar('\0');
|
|
||||||
}
|
|
||||||
if (mLine > mEdit->document()->count()) {
|
|
||||||
return QChar('\0');
|
|
||||||
}
|
|
||||||
QString s = mEdit->document()->getString(mLine-1);
|
|
||||||
if (mChar >= s.length()+1 ) {
|
|
||||||
return QChar('\n');
|
|
||||||
}
|
|
||||||
//qDebug()<<mLine<<":"<<mChar<<" '"<<s<<"'";
|
|
||||||
return s[mChar-1];
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentsCoord::ContentsCoord()
|
|
||||||
{
|
|
||||||
mEdit = nullptr;
|
|
||||||
mLine = 0;
|
|
||||||
mEdit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentsCoord::ContentsCoord(const ContentsCoord &coord):
|
|
||||||
ContentsCoord(coord.mEdit,
|
|
||||||
coord.mChar,
|
|
||||||
coord.mLine)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int ContentsCoord::ch() const
|
|
||||||
{
|
|
||||||
return mChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentsCoord::setCh(int newChar)
|
|
||||||
{
|
|
||||||
mChar = newChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BufferCoord::operator==(const BufferCoord &coord)
|
bool BufferCoord::operator==(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return coord.Char == Char && coord.Line == Line;
|
return coord.ch == ch && coord.line == line;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCoord::operator>=(const BufferCoord &coord)
|
bool BufferCoord::operator>=(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return (Line > coord.Line)
|
return (line > coord.line)
|
||||||
|| (Line == coord.Line && Char >= coord.Char);
|
|| (line == coord.line && ch >= coord.ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCoord::operator>(const BufferCoord &coord)
|
bool BufferCoord::operator>(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return (Line > coord.Line)
|
return (line > coord.line)
|
||||||
|| (Line == coord.Line && Char > coord.Char);
|
|| (line == coord.line && ch > coord.ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCoord::operator<(const BufferCoord &coord)
|
bool BufferCoord::operator<(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return (Line < coord.Line)
|
return (line < coord.line)
|
||||||
|| (Line == coord.Line && Char < coord.Char);
|
|| (line == coord.line && ch < coord.ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCoord::operator<=(const BufferCoord &coord)
|
bool BufferCoord::operator<=(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return (Line < coord.Line)
|
return (line < coord.line)
|
||||||
|| (Line == coord.Line && Char <= coord.Char);
|
|| (line == coord.line && ch <= coord.ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferCoord::operator!=(const BufferCoord &coord)
|
bool BufferCoord::operator!=(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return coord.Char != Char || coord.Line != Line;
|
return coord.ch != ch || coord.line != line;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
enum class SynSelectionMode {smNormal, smLine, smColumn};
|
enum class SynSelectionMode {Normal, Line, Column};
|
||||||
|
|
||||||
struct BufferCoord {
|
struct BufferCoord {
|
||||||
int Char;
|
int ch;
|
||||||
int Line;
|
int line;
|
||||||
bool operator==(const BufferCoord& coord);
|
bool operator==(const BufferCoord& coord);
|
||||||
bool operator>=(const BufferCoord& coord);
|
bool operator>=(const BufferCoord& coord);
|
||||||
bool operator>(const BufferCoord& coord);
|
bool operator>(const BufferCoord& coord);
|
||||||
|
@ -35,50 +35,6 @@ struct BufferCoord {
|
||||||
bool operator!=(const BufferCoord& coord);
|
bool operator!=(const BufferCoord& coord);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SynEdit;
|
|
||||||
/**
|
|
||||||
* Nomalized buffer posistion:
|
|
||||||
* (0,0) means at the start of the file ('\0')
|
|
||||||
* (1,count of lines+1) means at the end of the file ('\0')
|
|
||||||
* (length of the line+1, line) means at the line break of the line ('\n')
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ContentsCoord {
|
|
||||||
public:
|
|
||||||
ContentsCoord();
|
|
||||||
ContentsCoord(const ContentsCoord& coord);
|
|
||||||
int ch() const;
|
|
||||||
void setCh(int newChar);
|
|
||||||
|
|
||||||
int line() const;
|
|
||||||
void setLine(int newLine);
|
|
||||||
bool atStart();
|
|
||||||
bool atEnd();
|
|
||||||
const SynEdit *edit() const;
|
|
||||||
const ContentsCoord& operator=(const ContentsCoord& coord);
|
|
||||||
const ContentsCoord& operator=(const ContentsCoord&& coord);
|
|
||||||
bool operator==(const ContentsCoord& coord) const;
|
|
||||||
bool operator<(const ContentsCoord& coord) const;
|
|
||||||
bool operator<=(const ContentsCoord& coord) const;
|
|
||||||
bool operator>(const ContentsCoord& coord) const;
|
|
||||||
bool operator>=(const ContentsCoord& coord) const;
|
|
||||||
size_t operator-(const ContentsCoord& coord) const;
|
|
||||||
const ContentsCoord& operator+=(int delta);
|
|
||||||
const ContentsCoord& operator-=(int delta);
|
|
||||||
ContentsCoord operator+(int delta) const;
|
|
||||||
ContentsCoord operator-(int delta) const;
|
|
||||||
BufferCoord toBufferCoord() const;
|
|
||||||
QChar operator*() const;
|
|
||||||
private:
|
|
||||||
ContentsCoord(const SynEdit* edit, int ch, int line);
|
|
||||||
void normalize();
|
|
||||||
private:
|
|
||||||
int mChar;
|
|
||||||
int mLine;
|
|
||||||
const SynEdit* mEdit;
|
|
||||||
friend class SynEdit;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DisplayCoord {
|
struct DisplayCoord {
|
||||||
int Column;
|
int Column;
|
||||||
int Row;
|
int Row;
|
||||||
|
|
|
@ -63,24 +63,24 @@ void SynExporter::ExportRange(PSynDocument ALines, BufferCoord Start, BufferCoor
|
||||||
// abort if not all necessary conditions are met
|
// abort if not all necessary conditions are met
|
||||||
if (!ALines || !mHighlighter || (ALines->count() == 0))
|
if (!ALines || !mHighlighter || (ALines->count() == 0))
|
||||||
return;
|
return;
|
||||||
Stop.Line = std::max(1, std::min(Stop.Line, ALines->count()));
|
Stop.line = std::max(1, std::min(Stop.line, ALines->count()));
|
||||||
Stop.Char = std::max(1, std::min(Stop.Char, ALines->getString(Stop.Line - 1).length() + 1));
|
Stop.ch = std::max(1, std::min(Stop.ch, ALines->getString(Stop.line - 1).length() + 1));
|
||||||
Start.Line = std::max(1, std::min(Start.Line, ALines->count()));
|
Start.line = std::max(1, std::min(Start.line, ALines->count()));
|
||||||
Start.Char = std::max(1, std::min(Start.Char, ALines->getString(Start.Line - 1).length() + 1));
|
Start.ch = std::max(1, std::min(Start.ch, ALines->getString(Start.line - 1).length() + 1));
|
||||||
if ( (Start.Line > ALines->count()) || (Start.Line > Stop.Line) )
|
if ( (Start.line > ALines->count()) || (Start.line > Stop.line) )
|
||||||
return;
|
return;
|
||||||
if ((Start.Line == Stop.Line) && (Start.Char >= Stop.Char))
|
if ((Start.line == Stop.line) && (Start.ch >= Stop.ch))
|
||||||
return;
|
return;
|
||||||
// initialization
|
// initialization
|
||||||
mBuffer.clear();
|
mBuffer.clear();
|
||||||
// export all the lines into fBuffer
|
// export all the lines into fBuffer
|
||||||
mFirstAttribute = true;
|
mFirstAttribute = true;
|
||||||
|
|
||||||
if (Start.Line == 1)
|
if (Start.line == 1)
|
||||||
mHighlighter->resetState();
|
mHighlighter->resetState();
|
||||||
else
|
else
|
||||||
mHighlighter->setState(ALines->ranges(Start.Line-2));
|
mHighlighter->setState(ALines->ranges(Start.line-2));
|
||||||
for (int i = Start.Line; i<=Stop.Line; i++) {
|
for (int i = Start.line; i<=Stop.line; i++) {
|
||||||
QString Line = ALines->getString(i-1);
|
QString Line = ALines->getString(i-1);
|
||||||
// order is important, since Start.Y might be equal to Stop.Y
|
// order is important, since Start.Y might be equal to Stop.Y
|
||||||
// if (i == Stop.Line)
|
// if (i == Stop.Line)
|
||||||
|
@ -93,19 +93,19 @@ void SynExporter::ExportRange(PSynDocument ALines, BufferCoord Start, BufferCoor
|
||||||
PSynHighlighterAttribute attri = mHighlighter->getTokenAttribute();
|
PSynHighlighterAttribute attri = mHighlighter->getTokenAttribute();
|
||||||
int startPos = mHighlighter->getTokenPos();
|
int startPos = mHighlighter->getTokenPos();
|
||||||
QString token = mHighlighter->getToken();
|
QString token = mHighlighter->getToken();
|
||||||
if (i==Start.Line && (startPos+token.length() < Start.Char)) {
|
if (i==Start.line && (startPos+token.length() < Start.ch)) {
|
||||||
mHighlighter->next();
|
mHighlighter->next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i==Stop.Line && (startPos >= Stop.Char-1)) {
|
if (i==Stop.line && (startPos >= Stop.ch-1)) {
|
||||||
mHighlighter->next();
|
mHighlighter->next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i==Stop.Line && (startPos+token.length() > Stop.Char)) {
|
if (i==Stop.line && (startPos+token.length() > Stop.ch)) {
|
||||||
token = token.remove(Stop.Char - startPos - 1);
|
token = token.remove(Stop.ch - startPos - 1);
|
||||||
}
|
}
|
||||||
if (i==Start.Line && startPos < Start.Char-1) {
|
if (i==Start.line && startPos < Start.ch-1) {
|
||||||
token = token.mid(Start.Char-1-startPos);
|
token = token.mid(Start.ch-1-startPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Token = ReplaceReservedChars(token);
|
QString Token = ReplaceReservedChars(token);
|
||||||
|
@ -115,7 +115,7 @@ void SynExporter::ExportRange(PSynDocument ALines, BufferCoord Start, BufferCoor
|
||||||
FormatToken(Token);
|
FormatToken(Token);
|
||||||
mHighlighter->next();
|
mHighlighter->next();
|
||||||
}
|
}
|
||||||
if (i!=Stop.Line)
|
if (i!=Stop.line)
|
||||||
FormatNewLine();
|
FormatNewLine();
|
||||||
}
|
}
|
||||||
if (!mFirstAttribute)
|
if (!mFirstAttribute)
|
||||||
|
|
|
@ -1374,7 +1374,6 @@ void Settings::Editor::doLoad()
|
||||||
mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true);
|
mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true);
|
||||||
mUndoLimit = intValue("undo_limit",0);
|
mUndoLimit = intValue("undo_limit",0);
|
||||||
|
|
||||||
|
|
||||||
//tooltips
|
//tooltips
|
||||||
mEnableTooltips = boolValue("enable_tooltips",true);
|
mEnableTooltips = boolValue("enable_tooltips",true);
|
||||||
mEnableDebugTooltips = boolValue("enable_debug_tooltips",true);
|
mEnableDebugTooltips = boolValue("enable_debug_tooltips",true);
|
||||||
|
|
Loading…
Reference in New Issue