Merge branch 'master' of github.com:royqh1979/RedPanda-CPP
This commit is contained in:
commit
3e4f6b6548
1
NEWS.md
1
NEWS.md
|
@ -3,3 +3,4 @@ Version 0.2
|
||||||
- fix: add watch not work when there's no editor openned;
|
- fix: add watch not work when there's no editor openned;
|
||||||
- enhancement: rainbow parenthesis
|
- enhancement: rainbow parenthesis
|
||||||
- enhancement: run executable with parameters
|
- enhancement: run executable with parameters
|
||||||
|
- add: widget for function tips
|
|
@ -99,6 +99,7 @@ SOURCES += \
|
||||||
widgets/consolewidget.cpp \
|
widgets/consolewidget.cpp \
|
||||||
widgets/custommakefileinfodialog.cpp \
|
widgets/custommakefileinfodialog.cpp \
|
||||||
widgets/filepropertiesdialog.cpp \
|
widgets/filepropertiesdialog.cpp \
|
||||||
|
widgets/functiontipwidget.cpp \
|
||||||
widgets/headercompletionpopup.cpp \
|
widgets/headercompletionpopup.cpp \
|
||||||
widgets/issuestable.cpp \
|
widgets/issuestable.cpp \
|
||||||
widgets/newprojectdialog.cpp \
|
widgets/newprojectdialog.cpp \
|
||||||
|
@ -196,6 +197,7 @@ HEADERS += \
|
||||||
widgets/consolewidget.h \
|
widgets/consolewidget.h \
|
||||||
widgets/custommakefileinfodialog.h \
|
widgets/custommakefileinfodialog.h \
|
||||||
widgets/filepropertiesdialog.h \
|
widgets/filepropertiesdialog.h \
|
||||||
|
widgets/functiontipwidget.h \
|
||||||
widgets/headercompletionpopup.h \
|
widgets/headercompletionpopup.h \
|
||||||
widgets/issuestable.h \
|
widgets/issuestable.h \
|
||||||
widgets/newprojectdialog.h \
|
widgets/newprojectdialog.h \
|
||||||
|
|
|
@ -377,7 +377,7 @@ void Editor::undoSymbolCompletion(int pos)
|
||||||
return;
|
return;
|
||||||
if (!pSettings->editor().removeSymbolPairs())
|
if (!pSettings->editor().removeSymbolPairs())
|
||||||
return;
|
return;
|
||||||
if (!GetHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr))
|
if (!getHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr))
|
||||||
return;
|
return;
|
||||||
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
||||||
return ;
|
return ;
|
||||||
|
@ -412,7 +412,7 @@ void Editor::undoSymbolCompletion(int pos)
|
||||||
(pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) ||
|
(pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) ||
|
||||||
(pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) ||
|
(pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) ||
|
||||||
(pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) {
|
(pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) {
|
||||||
CommandProcessor(SynEditorCommand::ecDeleteChar);
|
commandProcessor(SynEditorCommand::ecDeleteChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +730,7 @@ bool Editor::event(QEvent *event)
|
||||||
int line ;
|
int line ;
|
||||||
if (reason == TipType::Error) {
|
if (reason == TipType::Error) {
|
||||||
pError = getSyntaxIssueAtPosition(p);
|
pError = getSyntaxIssueAtPosition(p);
|
||||||
} else if (PointToLine(helpEvent->pos(),line)) {
|
} else if (pointToLine(helpEvent->pos(),line)) {
|
||||||
//it's on gutter
|
//it's on gutter
|
||||||
//see if its error;
|
//see if its error;
|
||||||
PSyntaxIssueList issues = getSyntaxIssuesAtLine(line);
|
PSyntaxIssueList issues = getSyntaxIssuesAtLine(line);
|
||||||
|
@ -750,7 +750,7 @@ bool Editor::event(QEvent *event)
|
||||||
s = lines()->getString(p.Line - 1);
|
s = lines()->getString(p.Line - 1);
|
||||||
isIncludeLine = mParser->isIncludeLine(s);
|
isIncludeLine = mParser->isIncludeLine(s);
|
||||||
if (!isIncludeLine)
|
if (!isIncludeLine)
|
||||||
s = WordAtRowCol(p);
|
s = wordAtRowCol(p);
|
||||||
break;
|
break;
|
||||||
case TipType::Identifier:
|
case TipType::Identifier:
|
||||||
if (pMainWindow->debugger()->executing())
|
if (pMainWindow->debugger()->executing())
|
||||||
|
@ -866,7 +866,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
||||||
&& (event->button() == Qt::LeftButton)) {
|
&& (event->button() == Qt::LeftButton)) {
|
||||||
|
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
if (PointToCharLine(event->pos(),p)) {
|
if (pointToCharLine(event->pos(),p)) {
|
||||||
QString s = lines()->getString(p.Line - 1);
|
QString s = lines()->getString(p.Line - 1);
|
||||||
if (mParser->isIncludeLine(s)) {
|
if (mParser->isIncludeLine(s)) {
|
||||||
QString filename = mParser->getHeaderFileName(mFilename,s);
|
QString filename = mParser->getHeaderFileName(mFilename,s);
|
||||||
|
@ -988,7 +988,7 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT
|
||||||
start = 1;
|
start = 1;
|
||||||
token = lines()->getString(line-1);
|
token = lines()->getString(line-1);
|
||||||
} else if (endChar < 1) {
|
} else if (endChar < 1) {
|
||||||
if (!GetHighlighterAttriAtRowColEx(p,token,tokenType,tokenKind,start,attr))
|
if (!getHighlighterAttriAtRowColEx(p,token,tokenType,tokenKind,start,attr))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
start = startChar;
|
start = startChar;
|
||||||
|
@ -1123,8 +1123,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
||||||
BufferCoord wordBegin,wordEnd,bb,be;
|
BufferCoord wordBegin,wordEnd,bb,be;
|
||||||
bb = blockBegin();
|
bb = blockBegin();
|
||||||
be = blockEnd();
|
be = blockEnd();
|
||||||
wordBegin = WordStartEx(bb);
|
wordBegin = wordStartEx(bb);
|
||||||
wordEnd = WordEndEx(be);
|
wordEnd = wordEndEx(be);
|
||||||
if (wordBegin.Line == bb.Line
|
if (wordBegin.Line == bb.Line
|
||||||
&& wordBegin.Char == bb.Char
|
&& wordBegin.Char == bb.Char
|
||||||
&& wordEnd.Line == be.Line
|
&& wordEnd.Line == be.Line
|
||||||
|
@ -1277,7 +1277,7 @@ bool Editor::handleSymbolCompletion(QChar key)
|
||||||
QString Token;
|
QString Token;
|
||||||
bool tokenFinished;
|
bool tokenFinished;
|
||||||
SynHighlighterTokenType tokenType;
|
SynHighlighterTokenType tokenType;
|
||||||
if (GetHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) {
|
if (getHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) {
|
||||||
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
||||||
return false;
|
return false;
|
||||||
if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished)
|
if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished)
|
||||||
|
@ -1362,9 +1362,9 @@ bool Editor::handleParentheseCompletion()
|
||||||
QuoteStatus status = getQuoteStatus();
|
QuoteStatus status = getQuoteStatus();
|
||||||
if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'(');
|
commandProcessor(SynEditorCommand::ecChar,'(');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,')');
|
commandProcessor(SynEditorCommand::ecChar,')');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1400,9 +1400,9 @@ bool Editor::handleBracketCompletion()
|
||||||
// QuoteStatus status = getQuoteStatus();
|
// QuoteStatus status = getQuoteStatus();
|
||||||
// if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
// if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'[');
|
commandProcessor(SynEditorCommand::ecChar,'[');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,']');
|
commandProcessor(SynEditorCommand::ecChar,']');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1425,10 +1425,10 @@ bool Editor::handleMultilineCommentCompletion()
|
||||||
{
|
{
|
||||||
if (((caretX() > 1) && (caretX()-1 < lineText().length())) && (lineText()[caretX() - 1] == '/')) {
|
if (((caretX() > 1) && (caretX()-1 < lineText().length())) && (lineText()[caretX() - 1] == '/')) {
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'*');
|
commandProcessor(SynEditorCommand::ecChar,'*');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'*');
|
commandProcessor(SynEditorCommand::ecChar,'*');
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'/');
|
commandProcessor(SynEditorCommand::ecChar,'/');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1445,9 +1445,9 @@ bool Editor::handleBraceCompletion()
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'{');
|
commandProcessor(SynEditorCommand::ecChar,'{');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'}');
|
commandProcessor(SynEditorCommand::ecChar,'}');
|
||||||
if (
|
if (
|
||||||
( (s.startsWith("struct")
|
( (s.startsWith("struct")
|
||||||
|| s.startsWith("class")
|
|| s.startsWith("class")
|
||||||
|
@ -1458,7 +1458,7 @@ bool Editor::handleBraceCompletion()
|
||||||
|| s.startsWith("enum") )
|
|| s.startsWith("enum") )
|
||||||
&& !s.contains(';')
|
&& !s.contains(';')
|
||||||
) || s.endsWith('=')) {
|
) || s.endsWith('=')) {
|
||||||
CommandProcessor(SynEditorCommand::ecChar,';');
|
commandProcessor(SynEditorCommand::ecChar,';');
|
||||||
}
|
}
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
|
@ -1473,7 +1473,7 @@ bool Editor::handleBraceSkip()
|
||||||
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,'}');
|
||||||
setInsertMode(oldInsertMode);
|
setInsertMode(oldInsertMode);
|
||||||
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
|
@ -1495,9 +1495,9 @@ bool Editor::handleSingleQuoteCompletion()
|
||||||
if (ch == 0 || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
if (ch == 0 || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
||||||
// insert ''
|
// insert ''
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'\'');
|
commandProcessor(SynEditorCommand::ecChar,'\'');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'\'');
|
commandProcessor(SynEditorCommand::ecChar,'\'');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1521,9 +1521,9 @@ bool Editor::handleDoubleQuoteCompletion()
|
||||||
if ((ch == 0) || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
if ((ch == 0) || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
||||||
// insert ""
|
// insert ""
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'"');
|
commandProcessor(SynEditorCommand::ecChar,'"');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'"');
|
commandProcessor(SynEditorCommand::ecChar,'"');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1541,9 +1541,9 @@ bool Editor::handleGlobalIncludeCompletion()
|
||||||
if (!s.startsWith("include")) //it's not #include
|
if (!s.startsWith("include")) //it's not #include
|
||||||
return false;
|
return false;
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'<');
|
commandProcessor(SynEditorCommand::ecChar,'<');
|
||||||
BufferCoord oldCaret = caretXY();
|
BufferCoord oldCaret = caretXY();
|
||||||
CommandProcessor(SynEditorCommand::ecChar,'>');
|
commandProcessor(SynEditorCommand::ecChar,'>');
|
||||||
setCaretXY(oldCaret);
|
setCaretXY(oldCaret);
|
||||||
endUpdate();
|
endUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1753,7 +1753,7 @@ void Editor::showCompletion(bool autoComplete)
|
||||||
bool tokenFinished;
|
bool tokenFinished;
|
||||||
SynHighlighterTokenType tokenType;
|
SynHighlighterTokenType tokenType;
|
||||||
BufferCoord pBeginPos, pEndPos;
|
BufferCoord pBeginPos, pEndPos;
|
||||||
if (GetHighlighterAttriAtRowCol(
|
if (getHighlighterAttriAtRowCol(
|
||||||
BufferCoord{caretX() - 1,
|
BufferCoord{caretX() - 1,
|
||||||
caretY()}, s, tokenFinished,tokenType, attr)) {
|
caretY()}, s, tokenFinished,tokenType, attr)) {
|
||||||
if (tokenType == SynHighlighterTokenType::PreprocessDirective) {//Preprocessor
|
if (tokenType == SynHighlighterTokenType::PreprocessDirective) {//Preprocessor
|
||||||
|
@ -1777,7 +1777,7 @@ void Editor::showCompletion(bool autoComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position it at the top of the next line
|
// Position it at the top of the next line
|
||||||
QPoint p = RowColumnToPixels(displayXY());
|
QPoint p = rowColumnToPixels(displayXY());
|
||||||
p+=QPoint(0,textHeight()+2);
|
p+=QPoint(0,textHeight()+2);
|
||||||
mCompletionPopup->move(mapToGlobal(p));
|
mCompletionPopup->move(mapToGlobal(p));
|
||||||
|
|
||||||
|
@ -1830,7 +1830,7 @@ void Editor::showHeaderCompletion(bool autoComplete)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Position it at the top of the next line
|
// Position it at the top of the next line
|
||||||
QPoint p = RowColumnToPixels(displayXY());
|
QPoint p = rowColumnToPixels(displayXY());
|
||||||
p.setY(p.y() + textHeight() + 2);
|
p.setY(p.y() + textHeight() + 2);
|
||||||
mHeaderCompletionPopup->move(mapToGlobal(p));
|
mHeaderCompletionPopup->move(mapToGlobal(p));
|
||||||
|
|
||||||
|
@ -1931,8 +1931,8 @@ void Editor::completionInsert(bool appendFunc)
|
||||||
QString funcAddOn = "";
|
QString funcAddOn = "";
|
||||||
|
|
||||||
// delete the part of the word that's already been typed ...
|
// delete the part of the word that's already been typed ...
|
||||||
BufferCoord p = WordEnd();
|
BufferCoord p = wordEnd();
|
||||||
setBlockBegin(WordStart());
|
setBlockBegin(wordStart());
|
||||||
setBlockEnd(p);
|
setBlockEnd(p);
|
||||||
|
|
||||||
// if we are inserting a function,
|
// if we are inserting a function,
|
||||||
|
@ -2125,7 +2125,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
||||||
Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
||||||
{
|
{
|
||||||
// Only allow in the text area...
|
// Only allow in the text area...
|
||||||
if (PointToCharLine(point, pos)) {
|
if (pointToCharLine(point, pos)) {
|
||||||
if (!pMainWindow->debugger()->executing()
|
if (!pMainWindow->debugger()->executing()
|
||||||
&& getSyntaxIssueAtPosition(pos)) {
|
&& getSyntaxIssueAtPosition(pos)) {
|
||||||
return TipType::Error;
|
return TipType::Error;
|
||||||
|
@ -2135,12 +2135,12 @@ Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
||||||
QString s;
|
QString s;
|
||||||
|
|
||||||
// Only allow hand tips in highlighted areas
|
// Only allow hand tips in highlighted areas
|
||||||
if (GetHighlighterAttriAtRowCol(pos,s,attr)) {
|
if (getHighlighterAttriAtRowCol(pos,s,attr)) {
|
||||||
// Only allow Identifiers, Preprocessor directives, and selection
|
// Only allow Identifiers, Preprocessor directives, and selection
|
||||||
if (attr) {
|
if (attr) {
|
||||||
if (selAvail()) {
|
if (selAvail()) {
|
||||||
// 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 (attr->name() == SYNS_AttrIdentifier)
|
} else if (attr->name() == SYNS_AttrIdentifier)
|
||||||
return TipType::Identifier;
|
return TipType::Identifier;
|
||||||
|
|
|
@ -1735,7 +1735,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos)
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
mEditorContextMenuPos = pos;
|
mEditorContextMenuPos = pos;
|
||||||
if (editor->GetPositionOfMouse(p)) {
|
if (editor->getPositionOfMouse(p)) {
|
||||||
//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);
|
||||||
|
@ -1769,7 +1769,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos)
|
||||||
} else {
|
} else {
|
||||||
//mouse on gutter
|
//mouse on gutter
|
||||||
int line;
|
int line;
|
||||||
if (!editor->GetLineOfMouse(line))
|
if (!editor->getLineOfMouse(line))
|
||||||
line=-1;
|
line=-1;
|
||||||
menu.addAction(ui->actionToggle_Breakpoint);
|
menu.addAction(ui->actionToggle_Breakpoint);
|
||||||
menu.addAction(ui->actionBreakpoint_property);
|
menu.addAction(ui->actionBreakpoint_property);
|
||||||
|
@ -2657,7 +2657,7 @@ void MainWindow::on_actionAdd_Watch_triggered()
|
||||||
if (e->selAvail()) {
|
if (e->selAvail()) {
|
||||||
s = e->selText();
|
s = e->selText();
|
||||||
} else {
|
} else {
|
||||||
s = e->WordAtCursor();
|
s = e->wordAtCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool isOk;
|
bool isOk;
|
||||||
|
@ -2757,7 +2757,7 @@ void MainWindow::on_actionFind_triggered()
|
||||||
if (mSearchDialog==nullptr) {
|
if (mSearchDialog==nullptr) {
|
||||||
mSearchDialog = new SearchDialog(this);
|
mSearchDialog = new SearchDialog(this);
|
||||||
}
|
}
|
||||||
QString s = e->WordAtCursor();
|
QString s = e->wordAtCursor();
|
||||||
mSearchDialog->find(s);
|
mSearchDialog->find(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2768,7 +2768,7 @@ void MainWindow::on_actionFind_in_files_triggered()
|
||||||
}
|
}
|
||||||
Editor *e = mEditorList->getEditor();
|
Editor *e = mEditorList->getEditor();
|
||||||
if (e) {
|
if (e) {
|
||||||
QString s = e->WordAtCursor();
|
QString s = e->wordAtCursor();
|
||||||
mSearchDialog->findInFiles(s);
|
mSearchDialog->findInFiles(s);
|
||||||
} else {
|
} else {
|
||||||
mSearchDialog->findInFiles("");
|
mSearchDialog->findInFiles("");
|
||||||
|
@ -2783,7 +2783,7 @@ void MainWindow::on_actionReplace_triggered()
|
||||||
if (mSearchDialog==nullptr) {
|
if (mSearchDialog==nullptr) {
|
||||||
mSearchDialog = new SearchDialog(this);
|
mSearchDialog = new SearchDialog(this);
|
||||||
}
|
}
|
||||||
QString s = e->WordAtCursor();
|
QString s = e->wordAtCursor();
|
||||||
mSearchDialog->replace(s,s);
|
mSearchDialog->replace(s,s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2977,7 +2977,7 @@ void MainWindow::on_actionToggle_Breakpoint_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
int line;
|
int line;
|
||||||
if (editor && editor->PointToLine(mEditorContextMenuPos,line))
|
if (editor && editor->pointToLine(mEditorContextMenuPos,line))
|
||||||
editor->toggleBreakpoint(line);
|
editor->toggleBreakpoint(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3001,7 +3001,7 @@ void MainWindow::on_actionBreakpoint_property_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
int line;
|
int line;
|
||||||
if (editor && editor->PointToLine(mEditorContextMenuPos,line)) {
|
if (editor && editor->pointToLine(mEditorContextMenuPos,line)) {
|
||||||
if (editor->hasBreakpoint(line))
|
if (editor->hasBreakpoint(line))
|
||||||
editor->modifyBreakpointProperty(line);
|
editor->modifyBreakpointProperty(line);
|
||||||
}
|
}
|
||||||
|
@ -3013,7 +3013,7 @@ void MainWindow::on_actionGoto_Declaration_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
BufferCoord pos;
|
BufferCoord pos;
|
||||||
if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) {
|
if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) {
|
||||||
editor->gotoDeclaration(pos);
|
editor->gotoDeclaration(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3023,7 +3023,7 @@ void MainWindow::on_actionGoto_Definition_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
BufferCoord pos;
|
BufferCoord pos;
|
||||||
if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) {
|
if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) {
|
||||||
editor->gotoDefinition(pos);
|
editor->gotoDefinition(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3033,7 +3033,7 @@ void MainWindow::on_actionFind_references_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
BufferCoord pos;
|
BufferCoord pos;
|
||||||
if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) {
|
if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) {
|
||||||
CppRefacter refactor;
|
CppRefacter refactor;
|
||||||
refactor.findOccurence(editor,pos);
|
refactor.findOccurence(editor,pos);
|
||||||
ui->tabMessages->setCurrentWidget(ui->tabSearch);
|
ui->tabMessages->setCurrentWidget(ui->tabSearch);
|
||||||
|
|
|
@ -326,14 +326,14 @@ int SynEdit::maxScrollWidth() const
|
||||||
return std::max(mLines->lengthOfLongestLine()-mCharsInWindow+1, 1);
|
return std::max(mLines->lengthOfLongestLine()-mCharsInWindow+1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, PSynHighlighterAttribute &Attri)
|
bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, PSynHighlighterAttribute &Attri)
|
||||||
{
|
{
|
||||||
SynHighlighterTokenType TmpType;
|
SynHighlighterTokenType TmpType;
|
||||||
int TmpKind, TmpStart;
|
int TmpKind, TmpStart;
|
||||||
return GetHighlighterAttriAtRowColEx(XY, Token, TmpType, TmpKind,TmpStart, Attri);
|
return getHighlighterAttriAtRowColEx(XY, Token, TmpType, TmpKind,TmpStart, Attri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, bool &tokenFinished, SynHighlighterTokenType &TokenType, PSynHighlighterAttribute &Attri)
|
bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, bool &tokenFinished, SynHighlighterTokenType &TokenType, PSynHighlighterAttribute &Attri)
|
||||||
{
|
{
|
||||||
int PosX, PosY, endPos, Start;
|
int PosX, PosY, endPos, Start;
|
||||||
QString Line;
|
QString Line;
|
||||||
|
@ -374,7 +374,7 @@ bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::GetHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Token, SynHighlighterTokenType &TokenType, SynTokenKind &TokenKind, int &Start, PSynHighlighterAttribute &Attri)
|
bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Token, SynHighlighterTokenType &TokenType, SynTokenKind &TokenKind, int &Start, PSynHighlighterAttribute &Attri)
|
||||||
{
|
{
|
||||||
int PosX, PosY, endPos;
|
int PosX, PosY, endPos;
|
||||||
QString Line;
|
QString Line;
|
||||||
|
@ -468,7 +468,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
||||||
p.Char = PosX;
|
p.Char = PosX;
|
||||||
p.Line = PosY;
|
p.Line = PosY;
|
||||||
if ((Test == BracketInc) || (Test == BracketDec)) {
|
if ((Test == BracketInc) || (Test == BracketDec)) {
|
||||||
if (GetHighlighterAttriAtRowCol(p, vDummy, attr))
|
if (getHighlighterAttriAtRowCol(p, vDummy, attr))
|
||||||
isCommentOrStringOrChar =
|
isCommentOrStringOrChar =
|
||||||
(attr == mHighlighter->stringAttribute()) ||
|
(attr == mHighlighter->stringAttribute()) ||
|
||||||
(attr == mHighlighter->commentAttribute()) ||
|
(attr == mHighlighter->commentAttribute()) ||
|
||||||
|
@ -503,7 +503,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
||||||
p.Char = PosX;
|
p.Char = PosX;
|
||||||
p.Line = PosY;
|
p.Line = PosY;
|
||||||
if ((Test == BracketInc) || (Test == BracketDec)) {
|
if ((Test == BracketInc) || (Test == BracketDec)) {
|
||||||
if (GetHighlighterAttriAtRowCol(p, vDummy, attr))
|
if (getHighlighterAttriAtRowCol(p, vDummy, attr))
|
||||||
isCommentOrStringOrChar =
|
isCommentOrStringOrChar =
|
||||||
(attr == mHighlighter->stringAttribute()) ||
|
(attr == mHighlighter->stringAttribute()) ||
|
||||||
(attr == mHighlighter->commentAttribute()) ||
|
(attr == mHighlighter->commentAttribute()) ||
|
||||||
|
@ -537,21 +537,21 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
||||||
return BufferCoord{0,0};
|
return BufferCoord{0,0};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::GetPositionOfMouse(BufferCoord &aPos)
|
bool SynEdit::getPositionOfMouse(BufferCoord &aPos)
|
||||||
{
|
{
|
||||||
QPoint point = QCursor::pos();
|
QPoint point = QCursor::pos();
|
||||||
point = mapFromGlobal(point);
|
point = mapFromGlobal(point);
|
||||||
return PointToCharLine(point,aPos);
|
return pointToCharLine(point,aPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::GetLineOfMouse(int &line)
|
bool SynEdit::getLineOfMouse(int &line)
|
||||||
{
|
{
|
||||||
QPoint point = QCursor::pos();
|
QPoint point = QCursor::pos();
|
||||||
point = mapFromGlobal(point);
|
point = mapFromGlobal(point);
|
||||||
return PointToLine(point,line);
|
return pointToLine(point,line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::PointToCharLine(const QPoint &point, BufferCoord &coord)
|
bool SynEdit::pointToCharLine(const QPoint &point, BufferCoord &coord)
|
||||||
{
|
{
|
||||||
// Make sure it fits within the SynEdit bounds (and on the gutter)
|
// Make sure it fits within the SynEdit bounds (and on the gutter)
|
||||||
if ((point.x() < gutterWidth() + clientLeft())
|
if ((point.x() < gutterWidth() + clientLeft())
|
||||||
|
@ -565,7 +565,7 @@ bool SynEdit::PointToCharLine(const QPoint &point, BufferCoord &coord)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::PointToLine(const QPoint &point, int &line)
|
bool SynEdit::pointToLine(const QPoint &point, int &line)
|
||||||
{
|
{
|
||||||
// Make sure it fits within the SynEdit bounds
|
// Make sure it fits within the SynEdit bounds
|
||||||
if ((point.x() < clientLeft())
|
if ((point.x() < clientLeft())
|
||||||
|
@ -661,7 +661,7 @@ DisplayCoord SynEdit::pixelsToRowColumn(int aX, int aY) const
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint SynEdit::RowColumnToPixels(const DisplayCoord &coord) const
|
QPoint SynEdit::rowColumnToPixels(const DisplayCoord &coord) const
|
||||||
{
|
{
|
||||||
QPoint result;
|
QPoint result;
|
||||||
result.setX((coord.Column - 1) * mCharWidth + textOffset());
|
result.setX((coord.Column - 1) * mCharWidth + textOffset());
|
||||||
|
@ -705,6 +705,84 @@ BufferCoord SynEdit::displayToBufferPos(const DisplayCoord &p) const
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NormalizedBufferCoord SynEdit::moveBufferPos(const BufferCoord &p, int delta) const
|
||||||
|
{
|
||||||
|
return normalizeBufferPos(p.Char+delta,p.Line);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NormalizedBufferCoord SynEdit::moveBufferPos(const NormalizedBufferCoord &p, int delta) const
|
||||||
|
{
|
||||||
|
return normalizeBufferPos(p.Char+delta,p.Line);
|
||||||
|
}
|
||||||
|
|
||||||
|
NormalizedBufferCoord SynEdit::normalizeBufferPos(const BufferCoord &p) const
|
||||||
|
{
|
||||||
|
return normalizeBufferPos(p.Char,p.Line);
|
||||||
|
}
|
||||||
|
|
||||||
|
NormalizedBufferCoord SynEdit::normalizeBufferPos(int aChar, int aLine) const
|
||||||
|
{
|
||||||
|
if (mLines->count()==0) {
|
||||||
|
return NormalizedBufferCoord{0,0};
|
||||||
|
}
|
||||||
|
int line = aLine-1;
|
||||||
|
int lineCount = mLines->count();
|
||||||
|
if (line>=lineCount) {
|
||||||
|
return NormalizedBufferCoord{
|
||||||
|
mLines->getString(lineCount-1).length()+1
|
||||||
|
,lineCount};
|
||||||
|
}
|
||||||
|
if (line<0) {
|
||||||
|
return NormalizedBufferCoord{0,0};
|
||||||
|
}
|
||||||
|
if (aChar<1) {
|
||||||
|
while (true) {
|
||||||
|
line--;
|
||||||
|
if (line < 0) {
|
||||||
|
return NormalizedBufferCoord{0,0};
|
||||||
|
}
|
||||||
|
QString s =mLines->getString(line);
|
||||||
|
int len = s.length();
|
||||||
|
aChar+=len+1;
|
||||||
|
if (aChar>=1) {
|
||||||
|
return NormalizedBufferCoord{aChar,line+1};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
QString s =mLines->getString(line);
|
||||||
|
int len = s.length();
|
||||||
|
if (aChar<=len+1 ) {
|
||||||
|
return NormalizedBufferCoord{aChar,line+1};
|
||||||
|
}
|
||||||
|
if (line == lineCount-1) {
|
||||||
|
return NormalizedBufferCoord{1,lineCount+1};
|
||||||
|
}
|
||||||
|
aChar -= len+1;
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QChar SynEdit::charAtNormalizedBufferPos(const NormalizedBufferCoord &p) const
|
||||||
|
{
|
||||||
|
if (p.Line < 1) {
|
||||||
|
return QChar('\0');
|
||||||
|
}
|
||||||
|
if (p.Line > mLines->count()) {
|
||||||
|
return QChar('\0');
|
||||||
|
}
|
||||||
|
if (p.Char == 0) {
|
||||||
|
return QChar('\n');
|
||||||
|
}
|
||||||
|
QString s = mLines->getString(p.Line-1);
|
||||||
|
if (p.Char > p.Line+1) {
|
||||||
|
return QChar('\n');
|
||||||
|
}
|
||||||
|
return s[p.Char-1];
|
||||||
|
}
|
||||||
|
|
||||||
int SynEdit::leftSpaces(const QString &line) const
|
int SynEdit::leftSpaces(const QString &line) const
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -971,12 +1049,12 @@ bool SynEdit::selAvail() const
|
||||||
((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn));
|
((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SynEdit::WordAtCursor()
|
QString SynEdit::wordAtCursor()
|
||||||
{
|
{
|
||||||
return WordAtRowCol(caretXY());
|
return wordAtRowCol(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SynEdit::WordAtRowCol(const BufferCoord &XY)
|
QString SynEdit::wordAtRowCol(const BufferCoord &XY)
|
||||||
{
|
{
|
||||||
if ((XY.Line >= 1) && (XY.Line <= mLines->count())) {
|
if ((XY.Line >= 1) && (XY.Line <= mLines->count())) {
|
||||||
QString line = mLines->getString(XY.Line - 1);
|
QString line = mLines->getString(XY.Line - 1);
|
||||||
|
@ -1056,7 +1134,7 @@ void SynEdit::clearUndo()
|
||||||
mRedoList->Clear();
|
mRedoList->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y)
|
BufferCoord SynEdit::getPreviousLeftBracket(int x, int y)
|
||||||
{
|
{
|
||||||
QChar Test;
|
QChar Test;
|
||||||
QString vDummy;
|
QString vDummy;
|
||||||
|
@ -1088,7 +1166,7 @@ BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y)
|
||||||
p.Char = PosX;
|
p.Char = PosX;
|
||||||
p.Line = PosY;
|
p.Line = PosY;
|
||||||
if (Test=='{' || Test == '}') {
|
if (Test=='{' || Test == '}') {
|
||||||
if (GetHighlighterAttriAtRowCol(p, vDummy, attr)) {
|
if (getHighlighterAttriAtRowCol(p, vDummy, attr)) {
|
||||||
isCommentOrStringOrChar =
|
isCommentOrStringOrChar =
|
||||||
(attr == mHighlighter->stringAttribute()) ||
|
(attr == mHighlighter->stringAttribute()) ||
|
||||||
(attr == mHighlighter->commentAttribute()) ||
|
(attr == mHighlighter->commentAttribute()) ||
|
||||||
|
@ -1143,7 +1221,7 @@ void SynEdit::hideCaret()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEdit::IsPointInSelection(const BufferCoord &Value) const
|
bool SynEdit::isPointInSelection(const BufferCoord &Value) const
|
||||||
{
|
{
|
||||||
BufferCoord ptBegin = blockBegin();
|
BufferCoord ptBegin = blockBegin();
|
||||||
BufferCoord ptEnd = blockEnd();
|
BufferCoord ptEnd = blockEnd();
|
||||||
|
@ -1165,12 +1243,12 @@ bool SynEdit::IsPointInSelection(const BufferCoord &Value) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::NextWordPos()
|
BufferCoord SynEdit::nextWordPos()
|
||||||
{
|
{
|
||||||
return NextWordPosEx(caretXY());
|
return nextWordPosEx(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::NextWordPosEx(const BufferCoord &XY)
|
BufferCoord SynEdit::nextWordPosEx(const BufferCoord &XY)
|
||||||
{
|
{
|
||||||
int CX = XY.Char;
|
int CX = XY.Char;
|
||||||
int CY = XY.Line;
|
int CY = XY.Line;
|
||||||
|
@ -1211,12 +1289,12 @@ BufferCoord SynEdit::NextWordPosEx(const BufferCoord &XY)
|
||||||
return BufferCoord{CX,CY};
|
return BufferCoord{CX,CY};
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::WordStart()
|
BufferCoord SynEdit::wordStart()
|
||||||
{
|
{
|
||||||
return WordStartEx(caretXY());
|
return wordStartEx(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::WordStartEx(const BufferCoord &XY)
|
BufferCoord SynEdit::wordStartEx(const BufferCoord &XY)
|
||||||
{
|
{
|
||||||
int CX = XY.Char;
|
int CX = XY.Char;
|
||||||
int CY = XY.Line;
|
int CY = XY.Line;
|
||||||
|
@ -1232,12 +1310,12 @@ BufferCoord SynEdit::WordStartEx(const BufferCoord &XY)
|
||||||
return BufferCoord{CX,CY};
|
return BufferCoord{CX,CY};
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::WordEnd()
|
BufferCoord SynEdit::wordEnd()
|
||||||
{
|
{
|
||||||
return WordEndEx(caretXY());
|
return wordEndEx(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::WordEndEx(const BufferCoord &XY)
|
BufferCoord SynEdit::wordEndEx(const BufferCoord &XY)
|
||||||
{
|
{
|
||||||
int CX = XY.Char;
|
int CX = XY.Char;
|
||||||
int CY = XY.Line;
|
int CY = XY.Line;
|
||||||
|
@ -1254,12 +1332,12 @@ BufferCoord SynEdit::WordEndEx(const BufferCoord &XY)
|
||||||
return BufferCoord{CX,CY};
|
return BufferCoord{CX,CY};
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::PrevWordPos()
|
BufferCoord SynEdit::prevWordPos()
|
||||||
{
|
{
|
||||||
return PrevWordPosEx(caretXY());
|
return prevWordPosEx(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord SynEdit::PrevWordPosEx(const BufferCoord &XY)
|
BufferCoord SynEdit::prevWordPosEx(const BufferCoord &XY)
|
||||||
{
|
{
|
||||||
int CX = XY.Char;
|
int CX = XY.Char;
|
||||||
int CY = XY.Line;
|
int CY = XY.Line;
|
||||||
|
@ -1295,12 +1373,12 @@ BufferCoord SynEdit::PrevWordPosEx(const BufferCoord &XY)
|
||||||
return BufferCoord{CX,CY};
|
return BufferCoord{CX,CY};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::SetSelWord()
|
void SynEdit::setSelWord()
|
||||||
{
|
{
|
||||||
SetWordBlock(caretXY());
|
setWordBlock(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::SetWordBlock(BufferCoord Value)
|
void SynEdit::setWordBlock(BufferCoord Value)
|
||||||
{
|
{
|
||||||
// if (mOptions.testFlag(eoScrollPastEol))
|
// if (mOptions.testFlag(eoScrollPastEol))
|
||||||
// Value.Char =
|
// Value.Char =
|
||||||
|
@ -1314,8 +1392,8 @@ void SynEdit::SetWordBlock(BufferCoord Value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCoord v_WordStart = WordStartEx(Value);
|
BufferCoord v_WordStart = wordStartEx(Value);
|
||||||
BufferCoord v_WordEnd = WordEndEx(Value);
|
BufferCoord v_WordEnd = wordEndEx(Value);
|
||||||
if ((v_WordStart.Line == v_WordEnd.Line) && (v_WordStart.Char < v_WordEnd.Char))
|
if ((v_WordStart.Line == v_WordEnd.Line) && (v_WordStart.Char < v_WordEnd.Char))
|
||||||
setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd);
|
setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd);
|
||||||
}
|
}
|
||||||
|
@ -1488,7 +1566,7 @@ void SynEdit::doDeleteLastChar()
|
||||||
});
|
});
|
||||||
// try
|
// try
|
||||||
if (selAvail()) {
|
if (selAvail()) {
|
||||||
SetSelectedTextEmpty();
|
setSelectedTextEmpty();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString Temp = lineText();
|
QString Temp = lineText();
|
||||||
|
@ -1575,7 +1653,7 @@ void SynEdit::doDeleteLastChar()
|
||||||
helper = Temp.mid(newCaretX - 1, mCaretX - newCaretX);
|
helper = Temp.mid(newCaretX - 1, mCaretX - newCaretX);
|
||||||
Temp.remove(newCaretX-1,mCaretX - newCaretX);
|
Temp.remove(newCaretX-1,mCaretX - newCaretX);
|
||||||
// }
|
// }
|
||||||
ProperSetLine(mCaretY - 1, Temp);
|
properSetLine(mCaretY - 1, Temp);
|
||||||
setCaretX(newCaretX);
|
setCaretX(newCaretX);
|
||||||
updateLastCaretX();
|
updateLastCaretX();
|
||||||
mStateFlags.setFlag(SynStateFlag::sfCaretChanged);
|
mStateFlags.setFlag(SynStateFlag::sfCaretChanged);
|
||||||
|
@ -1588,7 +1666,7 @@ void SynEdit::doDeleteLastChar()
|
||||||
// vTabTrim := CharIndex2CaretPos(CaretX, TabWidth, Temp);
|
// vTabTrim := CharIndex2CaretPos(CaretX, TabWidth, Temp);
|
||||||
helper = Temp[mCaretX-1];
|
helper = Temp[mCaretX-1];
|
||||||
Temp.remove(mCaretX-1,1);
|
Temp.remove(mCaretX-1,1);
|
||||||
ProperSetLine(mCaretY - 1, Temp);
|
properSetLine(mCaretY - 1, Temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Caret.Char != mCaretX) || (Caret.Line != mCaretY)) {
|
if ((Caret.Char != mCaretX) || (Caret.Line != mCaretY)) {
|
||||||
|
@ -1604,7 +1682,7 @@ void SynEdit::doDeleteCurrentChar()
|
||||||
if (!mReadOnly) {
|
if (!mReadOnly) {
|
||||||
doOnPaintTransient(SynTransientType::ttBefore);
|
doOnPaintTransient(SynTransientType::ttBefore);
|
||||||
if (selAvail())
|
if (selAvail())
|
||||||
SetSelectedTextEmpty();
|
setSelectedTextEmpty();
|
||||||
else {
|
else {
|
||||||
// Call UpdateLastCaretX. Even though the caret doesn't move, the
|
// Call UpdateLastCaretX. Even though the caret doesn't move, the
|
||||||
// current caret position should "stick" whenever text is modified.
|
// current caret position should "stick" whenever text is modified.
|
||||||
|
@ -1617,11 +1695,11 @@ void SynEdit::doDeleteCurrentChar()
|
||||||
Caret.Char = mCaretX + 1;
|
Caret.Char = mCaretX + 1;
|
||||||
Caret.Line = mCaretY;
|
Caret.Line = mCaretY;
|
||||||
Temp.remove(mCaretX-1, 1);
|
Temp.remove(mCaretX-1, 1);
|
||||||
ProperSetLine(mCaretY - 1, Temp);
|
properSetLine(mCaretY - 1, Temp);
|
||||||
} else {
|
} else {
|
||||||
// join line with the line after
|
// join line with the line after
|
||||||
if (mCaretY < mLines->count()) {
|
if (mCaretY < mLines->count()) {
|
||||||
ProperSetLine(mCaretY - 1, Temp + mLines->getString(mCaretY));
|
properSetLine(mCaretY - 1, Temp + mLines->getString(mCaretY));
|
||||||
Caret.Char = 1;
|
Caret.Char = 1;
|
||||||
Caret.Line = mCaretY + 1;
|
Caret.Line = mCaretY + 1;
|
||||||
helper = lineBreak();
|
helper = lineBreak();
|
||||||
|
@ -1646,32 +1724,32 @@ void SynEdit::doDeleteWord()
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BufferCoord start = WordStart();
|
BufferCoord start = wordStart();
|
||||||
BufferCoord end = WordEnd();
|
BufferCoord end = wordEnd();
|
||||||
DeleteFromTo(start,end);
|
deleteFromTo(start,end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::doDeleteToEOL()
|
void SynEdit::doDeleteToEOL()
|
||||||
{
|
{
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return;
|
return;
|
||||||
DeleteFromTo(caretXY(),BufferCoord{lineText().length()+1,mCaretY});
|
deleteFromTo(caretXY(),BufferCoord{lineText().length()+1,mCaretY});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::doDeleteLastWord()
|
void SynEdit::doDeleteLastWord()
|
||||||
{
|
{
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return;
|
return;
|
||||||
BufferCoord start = PrevWordPos();
|
BufferCoord start = prevWordPos();
|
||||||
BufferCoord end = WordEndEx(start);
|
BufferCoord end = wordEndEx(start);
|
||||||
DeleteFromTo(start,end);
|
deleteFromTo(start,end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::doDeleteFromBOL()
|
void SynEdit::doDeleteFromBOL()
|
||||||
{
|
{
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return;
|
return;
|
||||||
DeleteFromTo(BufferCoord{1,mCaretY},caretXY());
|
deleteFromTo(BufferCoord{1,mCaretY},caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::doDeleteLine()
|
void SynEdit::doDeleteLine()
|
||||||
|
@ -1833,7 +1911,7 @@ void SynEdit::insertLine(bool moveCaret)
|
||||||
helper = selText();
|
helper = selText();
|
||||||
BufferCoord iUndoBegin = mBlockBegin;
|
BufferCoord iUndoBegin = mBlockBegin;
|
||||||
BufferCoord iUndoEnd = mBlockEnd;
|
BufferCoord iUndoEnd = mBlockEnd;
|
||||||
SetSelTextPrimitive("");
|
setSelTextPrimitive("");
|
||||||
mUndoList->AddChange(SynChangeReason::crDelete, iUndoBegin, iUndoEnd, helper,
|
mUndoList->AddChange(SynChangeReason::crDelete, iUndoBegin, iUndoEnd, helper,
|
||||||
mActiveSelectionMode);
|
mActiveSelectionMode);
|
||||||
}
|
}
|
||||||
|
@ -1863,11 +1941,11 @@ void SynEdit::insertLine(bool moveCaret)
|
||||||
int indentSpacesOfLeftLineText = leftSpaces(leftLineText);
|
int indentSpacesOfLeftLineText = leftSpaces(leftLineText);
|
||||||
int indentSpaces = indentSpacesOfLeftLineText;
|
int indentSpaces = indentSpacesOfLeftLineText;
|
||||||
bool notInComment=true;
|
bool notInComment=true;
|
||||||
ProperSetLine(mCaretY-1,leftLineText);
|
properSetLine(mCaretY-1,leftLineText);
|
||||||
if (mOptions.testFlag(eoAutoIndent)) {
|
if (mOptions.testFlag(eoAutoIndent)) {
|
||||||
rightLineText=TrimLeft(rightLineText);
|
rightLineText=TrimLeft(rightLineText);
|
||||||
}
|
}
|
||||||
if (GetHighlighterAttriAtRowCol(BufferCoord{leftLineText.length(), mCaretY},
|
if (getHighlighterAttriAtRowCol(BufferCoord{leftLineText.length(), mCaretY},
|
||||||
leftLineText, Attr)) {
|
leftLineText, Attr)) {
|
||||||
notInComment = (Attr != mHighlighter->commentAttribute());
|
notInComment = (Attr != mHighlighter->commentAttribute());
|
||||||
}
|
}
|
||||||
|
@ -1917,7 +1995,7 @@ void SynEdit::insertLine(bool moveCaret)
|
||||||
QString Temp4=GetLeftSpacing(SpaceCount2,true);
|
QString Temp4=GetLeftSpacing(SpaceCount2,true);
|
||||||
if (SpaceCount2 > 0) {
|
if (SpaceCount2 > 0) {
|
||||||
}
|
}
|
||||||
if (mOptions.testFlag(eoAddIndent) && GetHighlighterAttriAtRowCol(BufferCoord{Temp.length(), mCaretY},
|
if (mOptions.testFlag(eoAddIndent) && getHighlighterAttriAtRowCol(BufferCoord{Temp.length(), mCaretY},
|
||||||
Temp, Attr)) { // only add indent to source files
|
Temp, Attr)) { // only add indent to source files
|
||||||
if (Attr != mHighlighter->commentAttribute()) { // and outside of comments
|
if (Attr != mHighlighter->commentAttribute()) { // and outside of comments
|
||||||
Temp = Temp.trimmed();
|
Temp = Temp.trimmed();
|
||||||
|
@ -1962,7 +2040,7 @@ void SynEdit::insertLine(bool moveCaret)
|
||||||
void SynEdit::doTabKey()
|
void SynEdit::doTabKey()
|
||||||
{
|
{
|
||||||
// Provide Visual Studio like block indenting
|
// Provide Visual Studio like block indenting
|
||||||
if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) {
|
if (mOptions.testFlag(eoTabIndent) && canDoBlockIndent()) {
|
||||||
doBlockIndent();
|
doBlockIndent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1978,7 +2056,7 @@ void SynEdit::doTabKey()
|
||||||
mBlockEnd,
|
mBlockEnd,
|
||||||
selText(),
|
selText(),
|
||||||
mActiveSelectionMode);
|
mActiveSelectionMode);
|
||||||
SetSelTextPrimitive("");
|
setSelTextPrimitive("");
|
||||||
}
|
}
|
||||||
BufferCoord StartOfBlock = caretXY();
|
BufferCoord StartOfBlock = caretXY();
|
||||||
QString Spaces;
|
QString Spaces;
|
||||||
|
@ -1993,7 +2071,7 @@ void SynEdit::doTabKey()
|
||||||
NewCaretX = mCaretX + 1;
|
NewCaretX = mCaretX + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelTextPrimitive(Spaces);
|
setSelTextPrimitive(Spaces);
|
||||||
// Undo is already handled in SetSelText when SelectionMode is Column
|
// Undo is already handled in SetSelText when SelectionMode is Column
|
||||||
if (mActiveSelectionMode != SynSelectionMode::smColumn) {
|
if (mActiveSelectionMode != SynSelectionMode::smColumn) {
|
||||||
mUndoList->AddChange(SynChangeReason::crInsert, StartOfBlock,
|
mUndoList->AddChange(SynChangeReason::crInsert, StartOfBlock,
|
||||||
|
@ -2010,7 +2088,7 @@ 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) && CanDoBlockIndent()) {
|
if (mOptions.testFlag(eoTabIndent) && canDoBlockIndent()) {
|
||||||
doBlockUnindent();
|
doBlockUnindent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2050,7 +2128,7 @@ void SynEdit::doShiftTabKey()
|
||||||
setBlockEnd(caretXY());
|
setBlockEnd(caretXY());
|
||||||
|
|
||||||
QString OldSelText = selText();
|
QString OldSelText = selText();
|
||||||
SetSelTextPrimitive("");
|
setSelTextPrimitive("");
|
||||||
|
|
||||||
mUndoList->AddChange(
|
mUndoList->AddChange(
|
||||||
SynChangeReason::crSilentDelete, BufferCoord{NewX, mCaretY},
|
SynChangeReason::crSilentDelete, BufferCoord{NewX, mCaretY},
|
||||||
|
@ -2060,7 +2138,7 @@ void SynEdit::doShiftTabKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SynEdit::CanDoBlockIndent()
|
bool SynEdit::canDoBlockIndent()
|
||||||
{
|
{
|
||||||
BufferCoord BB;
|
BufferCoord BB;
|
||||||
BufferCoord BE;
|
BufferCoord BE;
|
||||||
|
@ -2304,7 +2382,7 @@ void SynEdit::doAddChar(QChar AChar)
|
||||||
QString temp = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
|
QString temp = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
|
||||||
// and the first nonblank char is this new }
|
// and the first nonblank char is this new }
|
||||||
if (temp.trimmed().isEmpty()) {
|
if (temp.trimmed().isEmpty()) {
|
||||||
BufferCoord MatchBracketPos = GetPreviousLeftBracket(oldCaretX, oldCaretY);
|
BufferCoord MatchBracketPos = getPreviousLeftBracket(oldCaretX, oldCaretY);
|
||||||
if (MatchBracketPos.Line > 0) {
|
if (MatchBracketPos.Line > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QString matchline = mLines->getString(MatchBracketPos.Line-1);
|
QString matchline = mLines->getString(MatchBracketPos.Line-1);
|
||||||
|
@ -2418,7 +2496,7 @@ void SynEdit::doPasteFromClipboard()
|
||||||
BufferCoord vEndOfBlock = blockEnd();
|
BufferCoord vEndOfBlock = blockEnd();
|
||||||
mBlockBegin = vStartOfBlock;
|
mBlockBegin = vStartOfBlock;
|
||||||
mBlockEnd = vEndOfBlock;
|
mBlockEnd = vEndOfBlock;
|
||||||
SetSelTextPrimitive(clipboard->text());
|
setSelTextPrimitive(clipboard->text());
|
||||||
if (mActiveSelectionMode != SynSelectionMode::smColumn) {
|
if (mActiveSelectionMode != SynSelectionMode::smColumn) {
|
||||||
mUndoList->AddChange(
|
mUndoList->AddChange(
|
||||||
SynChangeReason::crPaste,
|
SynChangeReason::crPaste,
|
||||||
|
@ -2583,7 +2661,7 @@ void SynEdit::insertBlock(const BufferCoord &BB, const BufferCoord &BE, const QS
|
||||||
{
|
{
|
||||||
setCaretAndSelection(BB, BB, BE);
|
setCaretAndSelection(BB, BB, BE);
|
||||||
setActiveSelectionMode(SynSelectionMode::smColumn);
|
setActiveSelectionMode(SynSelectionMode::smColumn);
|
||||||
SetSelTextPrimitiveEx(SynSelectionMode::smColumn, ChangeStr, AddToUndoList);
|
setSelTextPrimitiveEx(SynSelectionMode::smColumn, ChangeStr, AddToUndoList);
|
||||||
setStatusChanged(SynStatusChange::scSelection);
|
setStatusChanged(SynStatusChange::scSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2655,7 +2733,7 @@ void SynEdit::updateCaret()
|
||||||
{
|
{
|
||||||
mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false);
|
mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false);
|
||||||
DisplayCoord coord = displayXY();
|
DisplayCoord coord = displayXY();
|
||||||
QPoint caretPos = RowColumnToPixels(coord);
|
QPoint caretPos = rowColumnToPixels(coord);
|
||||||
int caretWidth=mCharWidth;
|
int caretWidth=mCharWidth;
|
||||||
//qDebug()<<"caret"<<mCaretX<<mCaretY;
|
//qDebug()<<"caret"<<mCaretX<<mCaretY;
|
||||||
if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) {
|
if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) {
|
||||||
|
@ -3282,7 +3360,7 @@ void SynEdit::onSizeOrFontChanged(bool bFont)
|
||||||
|
|
||||||
void SynEdit::onChanged()
|
void SynEdit::onChanged()
|
||||||
{
|
{
|
||||||
emit Changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::onScrolled(int)
|
void SynEdit::onScrolled(int)
|
||||||
|
@ -3610,7 +3688,7 @@ void SynEdit::doUndoItem()
|
||||||
Item->changeStartPos(),
|
Item->changeStartPos(),
|
||||||
Item->changeEndPos());
|
Item->changeEndPos());
|
||||||
QString TmpStr = selText();
|
QString TmpStr = selText();
|
||||||
SetSelTextPrimitiveEx(
|
setSelTextPrimitiveEx(
|
||||||
Item->changeSelMode(),
|
Item->changeSelMode(),
|
||||||
Item->changeStr(),
|
Item->changeStr(),
|
||||||
false);
|
false);
|
||||||
|
@ -3648,7 +3726,7 @@ void SynEdit::doUndoItem()
|
||||||
mLines->add("");
|
mLines->add("");
|
||||||
}
|
}
|
||||||
setCaretXY(TmpPos);
|
setCaretXY(TmpPos);
|
||||||
SetSelTextPrimitiveEx(
|
setSelTextPrimitiveEx(
|
||||||
Item->changeSelMode(),
|
Item->changeSelMode(),
|
||||||
Item->changeStr(),
|
Item->changeStr(),
|
||||||
false);
|
false);
|
||||||
|
@ -3683,7 +3761,7 @@ void SynEdit::doUndoItem()
|
||||||
QString TmpStr = mLines->getString(mCaretY - 1);
|
QString TmpStr = mLines->getString(mCaretY - 1);
|
||||||
if ( (mCaretX > TmpStr.length() + 1) && (leftSpaces(Item->changeStr()) == 0))
|
if ( (mCaretX > TmpStr.length() + 1) && (leftSpaces(Item->changeStr()) == 0))
|
||||||
TmpStr = TmpStr + QString(mCaretX - 1 - TmpStr.length(), ' ');
|
TmpStr = TmpStr + QString(mCaretX - 1 - TmpStr.length(), ' ');
|
||||||
ProperSetLine(mCaretY - 1, TmpStr + Item->changeStr());
|
properSetLine(mCaretY - 1, TmpStr + Item->changeStr());
|
||||||
mLines->deleteAt(mCaretY);
|
mLines->deleteAt(mCaretY);
|
||||||
doLinesDeleted(mCaretY, 1);
|
doLinesDeleted(mCaretY, 1);
|
||||||
}
|
}
|
||||||
|
@ -3852,7 +3930,7 @@ void SynEdit::doRedoItem()
|
||||||
Item->changeStartPos(),
|
Item->changeStartPos(),
|
||||||
Item->changeStartPos(),
|
Item->changeStartPos(),
|
||||||
Item->changeStartPos());
|
Item->changeStartPos());
|
||||||
SetSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(), false);
|
setSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(), false);
|
||||||
internalSetCaretXY(Item->changeEndPos());
|
internalSetCaretXY(Item->changeEndPos());
|
||||||
mUndoList->AddChange(Item->changeReason(),
|
mUndoList->AddChange(Item->changeReason(),
|
||||||
Item->changeStartPos(),
|
Item->changeStartPos(),
|
||||||
|
@ -3870,7 +3948,7 @@ void SynEdit::doRedoItem()
|
||||||
setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(),
|
setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(),
|
||||||
Item->changeEndPos());
|
Item->changeEndPos());
|
||||||
QString TempString = selText();
|
QString TempString = selText();
|
||||||
SetSelTextPrimitiveEx(Item->changeSelMode(),
|
setSelTextPrimitiveEx(Item->changeSelMode(),
|
||||||
Item->changeStr(),false);
|
Item->changeStr(),false);
|
||||||
mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(),
|
mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(),
|
||||||
Item->changeEndPos(), TempString, Item->changeSelMode());
|
Item->changeEndPos(), TempString, Item->changeSelMode());
|
||||||
|
@ -3882,7 +3960,7 @@ void SynEdit::doRedoItem()
|
||||||
setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(),
|
setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(),
|
||||||
Item->changeEndPos());
|
Item->changeEndPos());
|
||||||
QString TempString = selText();
|
QString TempString = selText();
|
||||||
SetSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(),false);
|
setSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(),false);
|
||||||
mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(),
|
mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(),
|
||||||
Item->changeEndPos(),TempString,
|
Item->changeEndPos(),TempString,
|
||||||
Item->changeSelMode());
|
Item->changeSelMode());
|
||||||
|
@ -3892,7 +3970,7 @@ void SynEdit::doRedoItem()
|
||||||
case SynChangeReason::crLineBreak: {
|
case SynChangeReason::crLineBreak: {
|
||||||
BufferCoord CaretPt = Item->changeStartPos();
|
BufferCoord CaretPt = Item->changeStartPos();
|
||||||
setCaretAndSelection(CaretPt, CaretPt, CaretPt);
|
setCaretAndSelection(CaretPt, CaretPt, CaretPt);
|
||||||
CommandProcessor(SynEditorCommand::ecLineBreak);
|
commandProcessor(SynEditorCommand::ecLineBreak);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SynChangeReason::crIndent:
|
case SynChangeReason::crIndent:
|
||||||
|
@ -4071,7 +4149,7 @@ SynEditCodeFolding &SynEdit::codeFolding()
|
||||||
return mCodeFolding;
|
return mCodeFolding;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SynEdit::lineText()
|
QString SynEdit::lineText() const
|
||||||
{
|
{
|
||||||
if (mCaretY >= 1 && mCaretY <= mLines->count())
|
if (mCaretY >= 1 && mCaretY <= mLines->count())
|
||||||
return mLines->getString(mCaretY - 1);
|
return mLines->getString(mCaretY - 1);
|
||||||
|
@ -4118,7 +4196,7 @@ bool SynEdit::empty()
|
||||||
return mLines->empty();
|
return mLines->empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::CommandProcessor(SynEditorCommand Command, QChar AChar, void *pData)
|
void SynEdit::commandProcessor(SynEditorCommand Command, QChar AChar, void *pData)
|
||||||
{
|
{
|
||||||
// first the program event handler gets a chance to process the command
|
// first the program event handler gets a chance to process the command
|
||||||
onProcessCommand(Command, AChar, pData);
|
onProcessCommand(Command, AChar, pData);
|
||||||
|
@ -4127,7 +4205,7 @@ void SynEdit::CommandProcessor(SynEditorCommand Command, QChar AChar, void *pDat
|
||||||
onCommandProcessed(Command, AChar, pData);
|
onCommandProcessed(Command, AChar, pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::MoveCaretHorz(int DX, bool isSelection)
|
void SynEdit::moveCaretHorz(int DX, bool isSelection)
|
||||||
{
|
{
|
||||||
BufferCoord ptO = caretXY();
|
BufferCoord ptO = caretXY();
|
||||||
BufferCoord ptDst = ptO;
|
BufferCoord ptDst = ptO;
|
||||||
|
@ -4151,10 +4229,10 @@ void SynEdit::MoveCaretHorz(int DX, bool isSelection)
|
||||||
ptDst.Char = std::min(ptDst.Char, nLineLen + 1);
|
ptDst.Char = std::min(ptDst.Char, nLineLen + 1);
|
||||||
}
|
}
|
||||||
// set caret and block begin / end
|
// set caret and block begin / end
|
||||||
MoveCaretAndSelection(mBlockBegin, ptDst, isSelection);
|
moveCaretAndSelection(mBlockBegin, ptDst, isSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::MoveCaretVert(int DY, bool isSelection)
|
void SynEdit::moveCaretVert(int DY, bool isSelection)
|
||||||
{
|
{
|
||||||
DisplayCoord ptO = displayXY();
|
DisplayCoord ptO = displayXY();
|
||||||
DisplayCoord ptDst = ptO;
|
DisplayCoord ptDst = ptO;
|
||||||
|
@ -4178,7 +4256,7 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection)
|
||||||
|
|
||||||
// set caret and block begin / end
|
// set caret and block begin / end
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
MoveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
|
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
|
|
||||||
// Set fMBCSStepAside and restore fLastCaretX after moving caret, since
|
// Set fMBCSStepAside and restore fLastCaretX after moving caret, since
|
||||||
|
@ -4188,7 +4266,7 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection)
|
||||||
mLastCaretColumn = 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)
|
||||||
{
|
{
|
||||||
if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && mUndoList->CanUndo())
|
if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && mUndoList->CanUndo())
|
||||||
mUndoList->AddGroupBreak();
|
mUndoList->AddGroupBreak();
|
||||||
|
@ -4204,7 +4282,7 @@ void SynEdit::MoveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoo
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::MoveCaretToLineStart(bool isSelection)
|
void SynEdit::moveCaretToLineStart(bool isSelection)
|
||||||
{
|
{
|
||||||
int newX;
|
int newX;
|
||||||
// home key enhancement
|
// home key enhancement
|
||||||
|
@ -4225,10 +4303,10 @@ void SynEdit::MoveCaretToLineStart(bool isSelection)
|
||||||
newX = 1;
|
newX = 1;
|
||||||
} else
|
} else
|
||||||
newX = 1;
|
newX = 1;
|
||||||
MoveCaretAndSelection(caretXY(), BufferCoord{newX, mCaretY}, isSelection);
|
moveCaretAndSelection(caretXY(), BufferCoord{newX, mCaretY}, isSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::MoveCaretToLineEnd(bool isSelection)
|
void SynEdit::moveCaretToLineEnd(bool isSelection)
|
||||||
{
|
{
|
||||||
int vNewX;
|
int vNewX;
|
||||||
if (mOptions.testFlag(SynEditorOption::eoEnhanceEndKey)) {
|
if (mOptions.testFlag(SynEditorOption::eoEnhanceEndKey)) {
|
||||||
|
@ -4246,15 +4324,15 @@ void SynEdit::MoveCaretToLineEnd(bool isSelection)
|
||||||
} else
|
} else
|
||||||
vNewX = lineText().length() + 1;
|
vNewX = lineText().length() + 1;
|
||||||
|
|
||||||
MoveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection);
|
moveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::SetSelectedTextEmpty()
|
void SynEdit::setSelectedTextEmpty()
|
||||||
{
|
{
|
||||||
BufferCoord vUndoBegin = mBlockBegin;
|
BufferCoord vUndoBegin = mBlockBegin;
|
||||||
BufferCoord vUndoEnd = mBlockEnd;
|
BufferCoord vUndoEnd = mBlockEnd;
|
||||||
QString vSelText = selText();
|
QString vSelText = selText();
|
||||||
SetSelTextPrimitive("");
|
setSelTextPrimitive("");
|
||||||
if ((vUndoBegin.Line < vUndoEnd.Line) || (
|
if ((vUndoBegin.Line < vUndoEnd.Line) || (
|
||||||
(vUndoBegin.Line == vUndoEnd.Line) && (vUndoBegin.Char < vUndoEnd.Char))) {
|
(vUndoBegin.Line == vUndoEnd.Line) && (vUndoBegin.Char < vUndoEnd.Char))) {
|
||||||
mUndoList->AddChange(SynChangeReason::crDelete, vUndoBegin, vUndoEnd, vSelText,
|
mUndoList->AddChange(SynChangeReason::crDelete, vUndoBegin, vUndoEnd, vSelText,
|
||||||
|
@ -4265,12 +4343,12 @@ void SynEdit::SetSelectedTextEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::SetSelTextPrimitive(const QString &aValue)
|
void SynEdit::setSelTextPrimitive(const QString &aValue)
|
||||||
{
|
{
|
||||||
SetSelTextPrimitiveEx(mActiveSelectionMode, aValue, true);
|
setSelTextPrimitiveEx(mActiveSelectionMode, aValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::SetSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &Value, bool AddToUndoList)
|
void SynEdit::setSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &Value, bool AddToUndoList)
|
||||||
{
|
{
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
mLines->beginUpdate();
|
mLines->beginUpdate();
|
||||||
|
@ -4281,11 +4359,11 @@ void SynEdit::SetSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &V
|
||||||
BufferCoord BB = blockBegin();
|
BufferCoord BB = blockBegin();
|
||||||
BufferCoord BE = blockEnd();
|
BufferCoord BE = blockEnd();
|
||||||
if (selAvail()) {
|
if (selAvail()) {
|
||||||
DeleteSelection(BB,BE);
|
deleteSelection(BB,BE);
|
||||||
internalSetCaretXY(BB);
|
internalSetCaretXY(BB);
|
||||||
}
|
}
|
||||||
if (!Value.isEmpty()) {
|
if (!Value.isEmpty()) {
|
||||||
InsertText(Value,PasteMode,AddToUndoList);
|
insertText(Value,PasteMode,AddToUndoList);
|
||||||
}
|
}
|
||||||
if (mCaretY < 1)
|
if (mCaretY < 1)
|
||||||
internalSetCaretY(1);
|
internalSetCaretY(1);
|
||||||
|
@ -4307,7 +4385,7 @@ void SynEdit::setSelText(const QString &Value)
|
||||||
BufferCoord EndOfBlock = blockEnd();
|
BufferCoord EndOfBlock = blockEnd();
|
||||||
mBlockBegin = StartOfBlock;
|
mBlockBegin = StartOfBlock;
|
||||||
mBlockEnd = EndOfBlock;
|
mBlockEnd = EndOfBlock;
|
||||||
SetSelTextPrimitive(Value);
|
setSelTextPrimitive(Value);
|
||||||
if (!Value.isEmpty() && (mActiveSelectionMode !=SynSelectionMode::smColumn))
|
if (!Value.isEmpty() && (mActiveSelectionMode !=SynSelectionMode::smColumn))
|
||||||
mUndoList->AddChange(
|
mUndoList->AddChange(
|
||||||
SynChangeReason::crInsert,
|
SynChangeReason::crInsert,
|
||||||
|
@ -4511,7 +4589,7 @@ void SynEdit::doLinesInserted(int firstLine, int count)
|
||||||
// end;
|
// end;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::ProperSetLine(int ALine, const QString &ALineText)
|
void SynEdit::properSetLine(int ALine, const QString &ALineText)
|
||||||
{
|
{
|
||||||
if (mOptions.testFlag(eoTrimTrailingSpaces))
|
if (mOptions.testFlag(eoTrimTrailingSpaces))
|
||||||
mLines->putString(ALine,TrimRight(ALineText));
|
mLines->putString(ALine,TrimRight(ALineText));
|
||||||
|
@ -4519,7 +4597,7 @@ void SynEdit::ProperSetLine(int ALine, const QString &ALineText)
|
||||||
mLines->putString(ALine,ALineText);
|
mLines->putString(ALine,ALineText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE)
|
void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE)
|
||||||
{
|
{
|
||||||
bool UpdateMarks = false;
|
bool UpdateMarks = false;
|
||||||
int MarkOffset = 0;
|
int MarkOffset = 0;
|
||||||
|
@ -4533,7 +4611,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE)
|
||||||
+ mLines->getString(BE.Line - 1).mid(BE.Char-1);
|
+ mLines->getString(BE.Line - 1).mid(BE.Char-1);
|
||||||
// Delete all lines in the selection range.
|
// Delete all lines in the selection range.
|
||||||
mLines->deleteLines(BB.Line, BE.Line - BB.Line);
|
mLines->deleteLines(BB.Line, BE.Line - BB.Line);
|
||||||
ProperSetLine(BB.Line-1,TempString);
|
properSetLine(BB.Line-1,TempString);
|
||||||
UpdateMarks = true;
|
UpdateMarks = true;
|
||||||
internalSetCaretXY(BB);
|
internalSetCaretXY(BB);
|
||||||
}
|
}
|
||||||
|
@ -4552,7 +4630,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE)
|
||||||
int r = columnToChar(i,ColTo-1);
|
int r = columnToChar(i,ColTo-1);
|
||||||
QString s = mLines->getString(i);
|
QString s = mLines->getString(i);
|
||||||
s.remove(l-1,r-l);
|
s.remove(l-1,r-l);
|
||||||
ProperSetLine(i,s);
|
properSetLine(i,s);
|
||||||
}
|
}
|
||||||
// Lines never get deleted completely, so keep caret at end.
|
// Lines never get deleted completely, so keep caret at end.
|
||||||
internalSetCaretXY(BB);
|
internalSetCaretXY(BB);
|
||||||
|
@ -4578,7 +4656,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE)
|
||||||
doLinesDeleted(BB.Line, BE.Line - BB.Line + MarkOffset);
|
doLinesDeleted(BB.Line, BE.Line - BB.Line + MarkOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool AddToUndoList)
|
void SynEdit::insertText(const QString &Value, SynSelectionMode PasteMode,bool AddToUndoList)
|
||||||
{
|
{
|
||||||
if (Value.isEmpty())
|
if (Value.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -4588,13 +4666,13 @@ void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool A
|
||||||
int InsertedLines = 0;
|
int InsertedLines = 0;
|
||||||
switch(PasteMode){
|
switch(PasteMode){
|
||||||
case SynSelectionMode::smNormal:
|
case SynSelectionMode::smNormal:
|
||||||
InsertedLines = InsertTextByNormalMode(Value);
|
InsertedLines = insertTextByNormalMode(Value);
|
||||||
break;
|
break;
|
||||||
case SynSelectionMode::smColumn:
|
case SynSelectionMode::smColumn:
|
||||||
InsertedLines = InsertTextByColumnMode(Value,AddToUndoList);
|
InsertedLines = insertTextByColumnMode(Value,AddToUndoList);
|
||||||
break;
|
break;
|
||||||
case SynSelectionMode::smLine:
|
case SynSelectionMode::smLine:
|
||||||
InsertedLines = InsertTextByLineMode(Value);
|
InsertedLines = insertTextByLineMode(Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// We delete selected based on the current selection mode, but paste
|
// We delete selected based on the current selection mode, but paste
|
||||||
|
@ -4608,7 +4686,7 @@ void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool A
|
||||||
ensureCursorPosVisible();
|
ensureCursorPosVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::InsertTextByNormalMode(const QString &Value)
|
int SynEdit::insertTextByNormalMode(const QString &Value)
|
||||||
{
|
{
|
||||||
QString sLeftSide;
|
QString sLeftSide;
|
||||||
QString sRightSide;
|
QString sRightSide;
|
||||||
|
@ -4636,11 +4714,11 @@ int SynEdit::InsertTextByNormalMode(const QString &Value)
|
||||||
P = GetEOL(Value,Start);
|
P = GetEOL(Value,Start);
|
||||||
if (P<Value.length()) {
|
if (P<Value.length()) {
|
||||||
Str = sLeftSide + Value.mid(0, P - Start);
|
Str = sLeftSide + Value.mid(0, P - Start);
|
||||||
ProperSetLine(mCaretY - 1, Str);
|
properSetLine(mCaretY - 1, Str);
|
||||||
mLines->InsertLines(mCaretY, CountLines(Value,P));
|
mLines->InsertLines(mCaretY, CountLines(Value,P));
|
||||||
} else {
|
} else {
|
||||||
Str = sLeftSide + Value + sRightSide;
|
Str = sLeftSide + Value + sRightSide;
|
||||||
ProperSetLine(mCaretY - 1, Str);
|
properSetLine(mCaretY - 1, Str);
|
||||||
}
|
}
|
||||||
// step2: insert remaining lines of Value
|
// step2: insert remaining lines of Value
|
||||||
while (P < Value.length()) {
|
while (P < Value.length()) {
|
||||||
|
@ -4663,7 +4741,7 @@ int SynEdit::InsertTextByNormalMode(const QString &Value)
|
||||||
Str += sRightSide;
|
Str += sRightSide;
|
||||||
}
|
}
|
||||||
Str = GetLeftSpacing(SpaceCount, true)+Str;
|
Str = GetLeftSpacing(SpaceCount, true)+Str;
|
||||||
ProperSetLine(mCaretY - 1, Str);
|
properSetLine(mCaretY - 1, Str);
|
||||||
Result++;
|
Result++;
|
||||||
}
|
}
|
||||||
bChangeScroll = !mOptions.testFlag(eoScrollPastEol);
|
bChangeScroll = !mOptions.testFlag(eoScrollPastEol);
|
||||||
|
@ -4679,7 +4757,7 @@ int SynEdit::InsertTextByNormalMode(const QString &Value)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList)
|
int SynEdit::insertTextByColumnMode(const QString &Value, bool AddToUndoList)
|
||||||
{
|
{
|
||||||
QString Str;
|
QString Str;
|
||||||
QString TempString;
|
QString TempString;
|
||||||
|
@ -4719,7 +4797,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList)
|
||||||
TempString.insert(insertPos-1,Str);
|
TempString.insert(insertPos-1,Str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProperSetLine(mCaretY - 1, TempString);
|
properSetLine(mCaretY - 1, TempString);
|
||||||
// Add undo change here from PasteFromClipboard
|
// Add undo change here from PasteFromClipboard
|
||||||
if (AddToUndoList) {
|
if (AddToUndoList) {
|
||||||
mUndoList->AddChange(SynChangeReason::crPaste, BufferCoord{mCaretX, mCaretY},
|
mUndoList->AddChange(SynChangeReason::crPaste, BufferCoord{mCaretX, mCaretY},
|
||||||
|
@ -4740,7 +4818,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::InsertTextByLineMode(const QString &Value)
|
int SynEdit::insertTextByLineMode(const QString &Value)
|
||||||
{
|
{
|
||||||
int Start;
|
int Start;
|
||||||
int P;
|
int P;
|
||||||
|
@ -4760,7 +4838,7 @@ int SynEdit::InsertTextByLineMode(const QString &Value)
|
||||||
mLines->Insert(mCaretY - 1, "");
|
mLines->Insert(mCaretY - 1, "");
|
||||||
Result++;
|
Result++;
|
||||||
}
|
}
|
||||||
ProperSetLine(mCaretY - 1, Str);
|
properSetLine(mCaretY - 1, Str);
|
||||||
mCaretY++;
|
mCaretY++;
|
||||||
mStatusChanges.setFlag(SynStatusChange::scCaretY);
|
mStatusChanges.setFlag(SynStatusChange::scCaretY);
|
||||||
if (P<Value.length() && Value[P]=='\r')
|
if (P<Value.length() && Value[P]=='\r')
|
||||||
|
@ -4772,7 +4850,7 @@ int SynEdit::InsertTextByLineMode(const QString &Value)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::DeleteFromTo(const BufferCoord &start, const BufferCoord &end)
|
void SynEdit::deleteFromTo(const BufferCoord &start, const BufferCoord &end)
|
||||||
{
|
{
|
||||||
if (mReadOnly)
|
if (mReadOnly)
|
||||||
return;
|
return;
|
||||||
|
@ -4782,7 +4860,7 @@ void SynEdit::DeleteFromTo(const BufferCoord &start, const BufferCoord &end)
|
||||||
setBlockEnd(end);
|
setBlockEnd(end);
|
||||||
setActiveSelectionMode(SynSelectionMode::smNormal);
|
setActiveSelectionMode(SynSelectionMode::smNormal);
|
||||||
QString helper = selText();
|
QString helper = selText();
|
||||||
SetSelTextPrimitive("");
|
setSelTextPrimitive("");
|
||||||
mUndoList->AddChange(SynChangeReason::crSilentDeleteAfterCursor, start, end,
|
mUndoList->AddChange(SynChangeReason::crSilentDeleteAfterCursor, start, end,
|
||||||
helper, SynSelectionMode::smNormal);
|
helper, SynSelectionMode::smNormal);
|
||||||
internalSetCaretXY(start);
|
internalSetCaretXY(start);
|
||||||
|
@ -4841,36 +4919,36 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
||||||
//horizontal caret movement or selection
|
//horizontal caret movement or selection
|
||||||
case SynEditorCommand::ecLeft:
|
case SynEditorCommand::ecLeft:
|
||||||
case SynEditorCommand::ecSelLeft:
|
case SynEditorCommand::ecSelLeft:
|
||||||
MoveCaretHorz(-1, Command == SynEditorCommand::ecSelLeft);
|
moveCaretHorz(-1, Command == SynEditorCommand::ecSelLeft);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecRight:
|
case SynEditorCommand::ecRight:
|
||||||
case SynEditorCommand::ecSelRight:
|
case SynEditorCommand::ecSelRight:
|
||||||
MoveCaretHorz(1, Command == SynEditorCommand::ecSelRight);
|
moveCaretHorz(1, Command == SynEditorCommand::ecSelRight);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecPageLeft:
|
case SynEditorCommand::ecPageLeft:
|
||||||
case SynEditorCommand::ecSelPageLeft:
|
case SynEditorCommand::ecSelPageLeft:
|
||||||
MoveCaretHorz(-mCharsInWindow, Command == SynEditorCommand::ecSelPageLeft);
|
moveCaretHorz(-mCharsInWindow, Command == SynEditorCommand::ecSelPageLeft);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecPageRight:
|
case SynEditorCommand::ecPageRight:
|
||||||
case SynEditorCommand::ecSelPageRight:
|
case SynEditorCommand::ecSelPageRight:
|
||||||
MoveCaretHorz(mCharsInWindow, Command == SynEditorCommand::ecSelPageRight);
|
moveCaretHorz(mCharsInWindow, Command == SynEditorCommand::ecSelPageRight);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecLineStart:
|
case SynEditorCommand::ecLineStart:
|
||||||
case SynEditorCommand::ecSelLineStart:
|
case SynEditorCommand::ecSelLineStart:
|
||||||
MoveCaretToLineStart(Command == SynEditorCommand::ecSelLineStart);
|
moveCaretToLineStart(Command == SynEditorCommand::ecSelLineStart);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecLineEnd:
|
case SynEditorCommand::ecLineEnd:
|
||||||
case SynEditorCommand::ecSelLineEnd:
|
case SynEditorCommand::ecSelLineEnd:
|
||||||
MoveCaretToLineEnd(Command == SynEditorCommand::ecSelLineEnd);
|
moveCaretToLineEnd(Command == SynEditorCommand::ecSelLineEnd);
|
||||||
break;
|
break;
|
||||||
// vertical caret movement or selection
|
// vertical caret movement or selection
|
||||||
case SynEditorCommand::ecUp:
|
case SynEditorCommand::ecUp:
|
||||||
case SynEditorCommand::ecSelUp:
|
case SynEditorCommand::ecSelUp:
|
||||||
MoveCaretVert(-1, Command == SynEditorCommand::ecSelUp);
|
moveCaretVert(-1, Command == SynEditorCommand::ecSelUp);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecDown:
|
case SynEditorCommand::ecDown:
|
||||||
case SynEditorCommand::ecSelDown:
|
case SynEditorCommand::ecSelDown:
|
||||||
MoveCaretVert(1, Command == SynEditorCommand::ecSelDown);
|
moveCaretVert(1, Command == SynEditorCommand::ecSelDown);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecPageUp:
|
case SynEditorCommand::ecPageUp:
|
||||||
case SynEditorCommand::ecSelPageUp:
|
case SynEditorCommand::ecSelPageUp:
|
||||||
|
@ -4888,49 +4966,49 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData)
|
||||||
if (Command == SynEditorCommand::ecPageUp || Command == SynEditorCommand::ecSelPageUp) {
|
if (Command == SynEditorCommand::ecPageUp || Command == SynEditorCommand::ecSelPageUp) {
|
||||||
counter = -counter;
|
counter = -counter;
|
||||||
}
|
}
|
||||||
MoveCaretVert(counter, Command == SynEditorCommand::ecSelPageUp || Command == SynEditorCommand::ecSelPageDown);
|
moveCaretVert(counter, Command == SynEditorCommand::ecSelPageUp || Command == SynEditorCommand::ecSelPageDown);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SynEditorCommand::ecPageTop:
|
case SynEditorCommand::ecPageTop:
|
||||||
case SynEditorCommand::ecSelPageTop:
|
case SynEditorCommand::ecSelPageTop:
|
||||||
MoveCaretVert(mTopLine-mCaretY, Command == SynEditorCommand::ecSelPageTop);
|
moveCaretVert(mTopLine-mCaretY, Command == SynEditorCommand::ecSelPageTop);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecPageBottom:
|
case SynEditorCommand::ecPageBottom:
|
||||||
case SynEditorCommand::ecSelPageBottom:
|
case SynEditorCommand::ecSelPageBottom:
|
||||||
MoveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == SynEditorCommand::ecSelPageBottom);
|
moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == SynEditorCommand::ecSelPageBottom);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecEditorTop:
|
case SynEditorCommand::ecEditorTop:
|
||||||
case SynEditorCommand::ecSelEditorTop:
|
case SynEditorCommand::ecSelEditorTop:
|
||||||
MoveCaretVert(1-mCaretY, Command == SynEditorCommand::ecSelEditorTop);
|
moveCaretVert(1-mCaretY, Command == SynEditorCommand::ecSelEditorTop);
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecEditorBottom:
|
case SynEditorCommand::ecEditorBottom:
|
||||||
case SynEditorCommand::ecSelEditorBottom:
|
case SynEditorCommand::ecSelEditorBottom:
|
||||||
if (!mLines->empty())
|
if (!mLines->empty())
|
||||||
MoveCaretVert(mLines->count()-mCaretY, Command == SynEditorCommand::ecSelEditorBottom);
|
moveCaretVert(mLines->count()-mCaretY, Command == SynEditorCommand::ecSelEditorBottom);
|
||||||
break;
|
break;
|
||||||
// goto special line / column position
|
// goto special line / column position
|
||||||
case SynEditorCommand::ecGotoXY:
|
case SynEditorCommand::ecGotoXY:
|
||||||
case SynEditorCommand::ecSelGotoXY:
|
case SynEditorCommand::ecSelGotoXY:
|
||||||
if (pData)
|
if (pData)
|
||||||
MoveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == SynEditorCommand::ecSelGotoXY);
|
moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == SynEditorCommand::ecSelGotoXY);
|
||||||
break;
|
break;
|
||||||
// word selection
|
// word selection
|
||||||
case SynEditorCommand::ecWordLeft:
|
case SynEditorCommand::ecWordLeft:
|
||||||
case SynEditorCommand::ecSelWordLeft:
|
case SynEditorCommand::ecSelWordLeft:
|
||||||
{
|
{
|
||||||
BufferCoord CaretNew = PrevWordPos();
|
BufferCoord CaretNew = prevWordPos();
|
||||||
MoveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordLeft);
|
moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordLeft);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SynEditorCommand::ecWordRight:
|
case SynEditorCommand::ecWordRight:
|
||||||
case SynEditorCommand::ecSelWordRight:
|
case SynEditorCommand::ecSelWordRight:
|
||||||
{
|
{
|
||||||
BufferCoord CaretNew = NextWordPos();
|
BufferCoord CaretNew = nextWordPos();
|
||||||
MoveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordRight);
|
moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordRight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SynEditorCommand::ecSelWord:
|
case SynEditorCommand::ecSelWord:
|
||||||
SetSelWord();
|
setSelWord();
|
||||||
break;
|
break;
|
||||||
case SynEditorCommand::ecSelectAll:
|
case SynEditorCommand::ecSelectAll:
|
||||||
doSelectAll();
|
doSelectAll();
|
||||||
|
@ -5282,7 +5360,7 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
//Get the invalidated rect.
|
//Get the invalidated rect.
|
||||||
QRect rcClip = event->rect();
|
QRect rcClip = event->rect();
|
||||||
DisplayCoord coord = displayXY();
|
DisplayCoord coord = displayXY();
|
||||||
QPoint caretPos = RowColumnToPixels(coord);
|
QPoint caretPos = rowColumnToPixels(coord);
|
||||||
int caretWidth=mCharWidth;
|
int caretWidth=mCharWidth;
|
||||||
if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) {
|
if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) {
|
||||||
caretWidth = charColumns(mLines->getString(mCaretY-1)[mCaretX-1])*mCharWidth;
|
caretWidth = charColumns(mLines->getString(mCaretY-1)[mCaretX-1])*mCharWidth;
|
||||||
|
@ -5393,12 +5471,12 @@ void SynEdit::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers());
|
SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers());
|
||||||
if (cmd!=SynEditorCommand::ecNone) {
|
if (cmd!=SynEditorCommand::ecNone) {
|
||||||
CommandProcessor(cmd,QChar(),nullptr);
|
commandProcessor(cmd,QChar(),nullptr);
|
||||||
event->accept();
|
event->accept();
|
||||||
} else if (!event->text().isEmpty()) {
|
} else if (!event->text().isEmpty()) {
|
||||||
QChar c = event->text().at(0);
|
QChar c = event->text().at(0);
|
||||||
if (c=='\t' || c.isPrint()) {
|
if (c=='\t' || c.isPrint()) {
|
||||||
CommandProcessor(SynEditorCommand::ecChar,c,nullptr);
|
commandProcessor(SynEditorCommand::ecChar,c,nullptr);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5424,7 +5502,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
||||||
|
|
||||||
if (button == Qt::RightButton) {
|
if (button == Qt::RightButton) {
|
||||||
if (mOptions.testFlag(eoRightMouseMovesCursor) &&
|
if (mOptions.testFlag(eoRightMouseMovesCursor) &&
|
||||||
( (selAvail() && ! IsPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))))
|
( (selAvail() && ! isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))))
|
||||||
|| ! selAvail())) {
|
|| ! selAvail())) {
|
||||||
invalidateSelection();
|
invalidateSelection();
|
||||||
mBlockEnd=mBlockBegin;
|
mBlockEnd=mBlockBegin;
|
||||||
|
@ -5449,7 +5527,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
||||||
//if mousedown occurred in selected block begin drag operation
|
//if mousedown occurred in selected block begin drag operation
|
||||||
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
|
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
|
||||||
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
||||||
&& (mSelectionMode == SynSelectionMode::smNormal) && IsPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
|
&& (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
|
||||||
bStartDrag = true;
|
bStartDrag = true;
|
||||||
}
|
}
|
||||||
if (bStartDrag) {
|
if (bStartDrag) {
|
||||||
|
@ -5540,7 +5618,7 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
QPoint ptMouse = event->pos();
|
QPoint ptMouse = event->pos();
|
||||||
if (ptMouse.x() >= mGutterWidth + 2) {
|
if (ptMouse.x() >= mGutterWidth + 2) {
|
||||||
if (!mOptions.testFlag(eoNoSelection))
|
if (!mOptions.testFlag(eoNoSelection))
|
||||||
SetWordBlock(caretXY());
|
setWordBlock(caretXY());
|
||||||
mStateFlags.setFlag(SynStateFlag::sfDblClicked);
|
mStateFlags.setFlag(SynStateFlag::sfDblClicked);
|
||||||
//MouseCapture := FALSE;
|
//MouseCapture := FALSE;
|
||||||
}
|
}
|
||||||
|
@ -5550,7 +5628,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event)
|
||||||
{
|
{
|
||||||
QString s = event->commitString();
|
QString s = event->commitString();
|
||||||
if (!s.isEmpty()) {
|
if (!s.isEmpty()) {
|
||||||
CommandProcessor(SynEditorCommand::ecImeStr,QChar(),&s);
|
commandProcessor(SynEditorCommand::ecImeStr,QChar(),&s);
|
||||||
// for (QChar ch:s) {
|
// for (QChar ch:s) {
|
||||||
// CommandProcessor(SynEditorCommand::ecChar,ch);
|
// CommandProcessor(SynEditorCommand::ecChar,ch);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -162,9 +162,17 @@ public:
|
||||||
void invalidateGutterLines(int FirstLine, int LastLine);
|
void invalidateGutterLines(int FirstLine, int LastLine);
|
||||||
DisplayCoord pixelsToNearestRowColumn(int aX, int aY) const;
|
DisplayCoord pixelsToNearestRowColumn(int aX, int aY) const;
|
||||||
DisplayCoord pixelsToRowColumn(int aX, int aY) const;
|
DisplayCoord pixelsToRowColumn(int aX, int aY) const;
|
||||||
QPoint RowColumnToPixels(const DisplayCoord& coord) const;
|
QPoint rowColumnToPixels(const DisplayCoord& coord) const;
|
||||||
DisplayCoord bufferToDisplayPos(const BufferCoord& p) const;
|
DisplayCoord bufferToDisplayPos(const BufferCoord& p) const;
|
||||||
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
||||||
|
|
||||||
|
|
||||||
|
NormalizedBufferCoord moveBufferPos(const BufferCoord&p, int delta) const;
|
||||||
|
NormalizedBufferCoord moveBufferPos(const NormalizedBufferCoord &p, int delta) const;
|
||||||
|
NormalizedBufferCoord normalizeBufferPos(const BufferCoord& p) const;
|
||||||
|
NormalizedBufferCoord normalizeBufferPos(int aChar, int aLine) const;
|
||||||
|
QChar charAtNormalizedBufferPos(const NormalizedBufferCoord& p) const;
|
||||||
|
|
||||||
int leftSpaces(const QString& line) const;
|
int leftSpaces(const QString& line) const;
|
||||||
QString GetLeftSpacing(int charCount,bool wantTabs) const;
|
QString GetLeftSpacing(int charCount,bool wantTabs) const;
|
||||||
int charToColumn(int aLine, int aChar) const;
|
int charToColumn(int aLine, int aChar) const;
|
||||||
|
@ -185,21 +193,21 @@ public:
|
||||||
void lockPainter();
|
void lockPainter();
|
||||||
void unlockPainter();
|
void unlockPainter();
|
||||||
bool selAvail() const;
|
bool selAvail() const;
|
||||||
QString WordAtCursor();
|
QString wordAtCursor();
|
||||||
QString WordAtRowCol(const BufferCoord& XY);
|
QString wordAtRowCol(const BufferCoord& XY);
|
||||||
|
|
||||||
int charColumns(QChar ch) const;
|
int charColumns(QChar ch) const;
|
||||||
double dpiFactor() const;
|
double dpiFactor() const;
|
||||||
bool IsPointInSelection(const BufferCoord& Value) const;
|
bool isPointInSelection(const BufferCoord& Value) const;
|
||||||
BufferCoord NextWordPos();
|
BufferCoord nextWordPos();
|
||||||
BufferCoord NextWordPosEx(const BufferCoord& XY);
|
BufferCoord nextWordPosEx(const BufferCoord& XY);
|
||||||
BufferCoord WordStart();
|
BufferCoord wordStart();
|
||||||
BufferCoord WordStartEx(const BufferCoord& XY);
|
BufferCoord wordStartEx(const BufferCoord& XY);
|
||||||
BufferCoord WordEnd();
|
BufferCoord wordEnd();
|
||||||
BufferCoord WordEndEx(const BufferCoord& XY);
|
BufferCoord wordEndEx(const BufferCoord& XY);
|
||||||
BufferCoord PrevWordPos();
|
BufferCoord prevWordPos();
|
||||||
BufferCoord PrevWordPosEx(const BufferCoord& XY);
|
BufferCoord prevWordPosEx(const BufferCoord& XY);
|
||||||
void CommandProcessor(SynEditorCommand Command, QChar AChar = QChar(), void * pData = nullptr);
|
void commandProcessor(SynEditorCommand Command, QChar AChar = QChar(), void * pData = nullptr);
|
||||||
//Caret
|
//Caret
|
||||||
void showCaret();
|
void showCaret();
|
||||||
void hideCaret();
|
void hideCaret();
|
||||||
|
@ -223,37 +231,37 @@ public:
|
||||||
int maxScrollWidth() const;
|
int maxScrollWidth() const;
|
||||||
int maxScrollHeight() const;
|
int maxScrollHeight() const;
|
||||||
|
|
||||||
bool GetHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token,
|
bool getHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token,
|
||||||
PSynHighlighterAttribute& Attri);
|
PSynHighlighterAttribute& Attri);
|
||||||
bool GetHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token,
|
bool getHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token,
|
||||||
bool& tokenFinished, SynHighlighterTokenType& TokenType,
|
bool& tokenFinished, SynHighlighterTokenType& TokenType,
|
||||||
PSynHighlighterAttribute& Attri);
|
PSynHighlighterAttribute& Attri);
|
||||||
bool GetHighlighterAttriAtRowColEx(const BufferCoord& XY, QString& Token,
|
bool getHighlighterAttriAtRowColEx(const BufferCoord& XY, QString& Token,
|
||||||
SynHighlighterTokenType& TokenType, SynTokenKind &TokenKind, int &Start,
|
SynHighlighterTokenType& TokenType, SynTokenKind &TokenKind, int &Start,
|
||||||
PSynHighlighterAttribute& Attri);
|
PSynHighlighterAttribute& Attri);
|
||||||
|
|
||||||
//Commands
|
//Commands
|
||||||
virtual void cutToClipboard() { CommandProcessor(SynEditorCommand::ecCut);}
|
virtual void cutToClipboard() { commandProcessor(SynEditorCommand::ecCut);}
|
||||||
virtual void copyToClipboard() { CommandProcessor(SynEditorCommand::ecCopy);}
|
virtual void copyToClipboard() { commandProcessor(SynEditorCommand::ecCopy);}
|
||||||
virtual void pasteFromClipboard() { CommandProcessor(SynEditorCommand::ecPaste);}
|
virtual void pasteFromClipboard() { commandProcessor(SynEditorCommand::ecPaste);}
|
||||||
virtual void undo() { CommandProcessor(SynEditorCommand::ecUndo);}
|
virtual void undo() { commandProcessor(SynEditorCommand::ecUndo);}
|
||||||
virtual void redo() { CommandProcessor(SynEditorCommand::ecRedo);}
|
virtual void redo() { commandProcessor(SynEditorCommand::ecRedo);}
|
||||||
virtual void zoomIn() { CommandProcessor(SynEditorCommand::ecZoomIn);}
|
virtual void zoomIn() { commandProcessor(SynEditorCommand::ecZoomIn);}
|
||||||
virtual void zoomOut() { CommandProcessor(SynEditorCommand::ecZoomOut);}
|
virtual void zoomOut() { commandProcessor(SynEditorCommand::ecZoomOut);}
|
||||||
virtual void selectAll() { CommandProcessor(SynEditorCommand::ecSelectAll);}
|
virtual void selectAll() { commandProcessor(SynEditorCommand::ecSelectAll);}
|
||||||
virtual void tab() { CommandProcessor(SynEditorCommand::ecTab);}
|
virtual void tab() { commandProcessor(SynEditorCommand::ecTab);}
|
||||||
virtual void untab() { CommandProcessor(SynEditorCommand::ecShiftTab);}
|
virtual void untab() { commandProcessor(SynEditorCommand::ecShiftTab);}
|
||||||
virtual void toggleComment() { CommandProcessor(SynEditorCommand::ecToggleComment);}
|
virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);}
|
||||||
|
|
||||||
virtual void beginUpdate();
|
virtual void beginUpdate();
|
||||||
virtual void endUpdate();
|
virtual void endUpdate();
|
||||||
virtual BufferCoord getMatchingBracket();
|
virtual BufferCoord getMatchingBracket();
|
||||||
virtual BufferCoord getMatchingBracketEx(BufferCoord APoint);
|
virtual BufferCoord getMatchingBracketEx(BufferCoord APoint);
|
||||||
|
|
||||||
bool GetPositionOfMouse(BufferCoord& aPos);
|
bool getPositionOfMouse(BufferCoord& aPos);
|
||||||
bool GetLineOfMouse(int& line);
|
bool getLineOfMouse(int& line);
|
||||||
bool PointToCharLine(const QPoint& point, BufferCoord& coord);
|
bool pointToCharLine(const QPoint& point, BufferCoord& coord);
|
||||||
bool PointToLine(const QPoint& point, int& line);
|
bool pointToLine(const QPoint& point, int& line);
|
||||||
bool isIdentChar(const QChar& ch);
|
bool isIdentChar(const QChar& ch);
|
||||||
|
|
||||||
void setRainbowAttrs(const PSynHighlighterAttribute &attr0,
|
void setRainbowAttrs(const PSynHighlighterAttribute &attr0,
|
||||||
|
@ -295,7 +303,7 @@ public:
|
||||||
|
|
||||||
SynEditCodeFolding & codeFolding();
|
SynEditCodeFolding & codeFolding();
|
||||||
|
|
||||||
QString lineText();
|
QString lineText() const;
|
||||||
void setLineText(const QString s);
|
void setLineText(const QString s);
|
||||||
|
|
||||||
PSynEditStringList lines() const;
|
PSynEditStringList lines() const;
|
||||||
|
@ -366,25 +374,25 @@ signals:
|
||||||
void linesDeleted(int FirstLine, int Count);
|
void linesDeleted(int FirstLine, int Count);
|
||||||
void linesInserted(int FirstLine, int Count);
|
void linesInserted(int FirstLine, int Count);
|
||||||
|
|
||||||
void Changed();
|
void changed();
|
||||||
|
|
||||||
void ChainUndoAdded();
|
// void chainUndoAdded();
|
||||||
void ChainRedoAdded();
|
// void chainRedoAdded();
|
||||||
void ChainLinesChanging();
|
// void chainLinesChanging();
|
||||||
void ChainLinesChanged();
|
// void chainLinesChanged();
|
||||||
void ChainListCleared();
|
// void chainListCleared();
|
||||||
|
|
||||||
void ChainListDeleted(int Index, int Count);
|
// void chainListDeleted(int Index, int Count);
|
||||||
void ChainListInserted(int Index, int Count);
|
// void chainListInserted(int Index, int Count);
|
||||||
void ChainListPutted(int Index, int Count);
|
// void chainListPutted(int Index, int Count);
|
||||||
|
|
||||||
void FilesDropped(int X,int Y, const QStringList& AFiles);
|
// void filesDropped(int X,int Y, const QStringList& AFiles);
|
||||||
void gutterClicked(Qt::MouseButton button, int x, int y, int line);
|
void gutterClicked(Qt::MouseButton button, int x, int y, int line);
|
||||||
void ImeInputed(const QString& s);
|
// void imeInputed(const QString& s);
|
||||||
|
|
||||||
void contextHelp(const QString& word);
|
// void contextHelp(const QString& word);
|
||||||
|
|
||||||
void scrolled(SynScrollBarKind ScrollBar);
|
// void scrolled(SynScrollBarKind ScrollBar);
|
||||||
void statusChanged(SynStatusChanges changes);
|
void statusChanged(SynStatusChanges changes);
|
||||||
|
|
||||||
void fontChanged();
|
void fontChanged();
|
||||||
|
@ -466,34 +474,34 @@ private:
|
||||||
* @param DX
|
* @param DX
|
||||||
* @param SelectionCommand
|
* @param SelectionCommand
|
||||||
*/
|
*/
|
||||||
void MoveCaretHorz(int DX, bool isSelection);
|
void moveCaretHorz(int DX, bool isSelection);
|
||||||
void MoveCaretVert(int DY, bool isSelection);
|
void moveCaretVert(int DY, bool isSelection);
|
||||||
void MoveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter,
|
void moveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter,
|
||||||
bool isSelection);
|
bool isSelection);
|
||||||
void MoveCaretToLineStart(bool isSelection);
|
void moveCaretToLineStart(bool isSelection);
|
||||||
void MoveCaretToLineEnd(bool isSelection);
|
void moveCaretToLineEnd(bool isSelection);
|
||||||
void SetSelectedTextEmpty();
|
void setSelectedTextEmpty();
|
||||||
void SetSelTextPrimitive(const QString& aValue);
|
void setSelTextPrimitive(const QString& aValue);
|
||||||
void SetSelTextPrimitiveEx(SynSelectionMode PasteMode,
|
void setSelTextPrimitiveEx(SynSelectionMode PasteMode,
|
||||||
const QString& Value, bool AddToUndoList);
|
const QString& Value, bool AddToUndoList);
|
||||||
void doLinesDeleted(int FirstLine, int Count);
|
void doLinesDeleted(int FirstLine, int Count);
|
||||||
void doLinesInserted(int FirstLine, int Count);
|
void doLinesInserted(int FirstLine, int Count);
|
||||||
void ProperSetLine(int ALine, const QString& ALineText);
|
void properSetLine(int ALine, const QString& ALineText);
|
||||||
void DeleteSelection(const BufferCoord& BB, const BufferCoord& BE);
|
void deleteSelection(const BufferCoord& BB, const BufferCoord& BE);
|
||||||
void InsertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
|
void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList);
|
||||||
int InsertTextByNormalMode(const QString& Value);
|
int insertTextByNormalMode(const QString& Value);
|
||||||
int InsertTextByColumnMode(const QString& Value,bool AddToUndoList);
|
int insertTextByColumnMode(const QString& Value,bool AddToUndoList);
|
||||||
int InsertTextByLineMode(const QString& Value);
|
int insertTextByLineMode(const QString& Value);
|
||||||
void DeleteFromTo(const BufferCoord& start, const BufferCoord& end);
|
void deleteFromTo(const BufferCoord& start, const BufferCoord& end);
|
||||||
void SetSelWord();
|
void setSelWord();
|
||||||
void SetWordBlock(BufferCoord Value);
|
void setWordBlock(BufferCoord Value);
|
||||||
|
|
||||||
|
|
||||||
void processGutterClick(QMouseEvent* event);
|
void processGutterClick(QMouseEvent* event);
|
||||||
|
|
||||||
void clearUndo();
|
void clearUndo();
|
||||||
BufferCoord GetPreviousLeftBracket(int x,int y);
|
BufferCoord getPreviousLeftBracket(int x,int y);
|
||||||
bool CanDoBlockIndent();
|
bool canDoBlockIndent();
|
||||||
|
|
||||||
//Commands
|
//Commands
|
||||||
void doDeleteLastChar();
|
void doDeleteLastChar();
|
||||||
|
|
|
@ -12,6 +12,17 @@ struct BufferCoord {
|
||||||
int Line;
|
int Line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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')
|
||||||
|
*/
|
||||||
|
struct NormalizedBufferCoord {
|
||||||
|
int Char;
|
||||||
|
int Line;
|
||||||
|
};
|
||||||
|
|
||||||
struct DisplayCoord {
|
struct DisplayCoord {
|
||||||
int Column;
|
int Column;
|
||||||
int Row;
|
int Row;
|
||||||
|
|
|
@ -279,7 +279,7 @@ void SynEditCppHighlighter::ansiCppProc()
|
||||||
if ( isSpaceChar(mLine[mRun]) ) {
|
if ( isSpaceChar(mLine[mRun]) ) {
|
||||||
mRange.spaceState = mRange.state;
|
mRange.spaceState = mRange.state;
|
||||||
mRange.state = RangeState::rsSpace;
|
mRange.state = RangeState::rsSpace;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
mRun+=1;
|
mRun+=1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ void FilePropertiesDialog::calcFile(Editor *editor,
|
||||||
j++;
|
j++;
|
||||||
QString token;
|
QString token;
|
||||||
PSynHighlighterAttribute attr;
|
PSynHighlighterAttribute attr;
|
||||||
if (editor->GetHighlighterAttriAtRowCol(BufferCoord{j+1,i+1},
|
if (editor->getHighlighterAttriAtRowCol(BufferCoord{j+1,i+1},
|
||||||
token,attr)) {
|
token,attr)) {
|
||||||
// if it is preprocessor...
|
// if it is preprocessor...
|
||||||
if (attr->name() == SYNS_AttrPreprocessor) {
|
if (attr->name() == SYNS_AttrPreprocessor) {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "functiontipwidget.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
FunctionTipWidget::FunctionTipWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::ToolTip);
|
||||||
|
|
||||||
|
mLabel = new QLabel(this);
|
||||||
|
mLabel->setText("Test");
|
||||||
|
this->setLayout(new QHBoxLayout());
|
||||||
|
this->layout()->addWidget(mLabel);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef FUNCTIONTIPWIDGET_H
|
||||||
|
#define FUNCTIONTIPWIDGET_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class Editor;
|
||||||
|
class FunctionTipWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit FunctionTipWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
private:
|
||||||
|
QLabel* mLabel;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FUNCTIONTIPWIDGET_H
|
Loading…
Reference in New Issue