refactor
This commit is contained in:
parent
72481d7de8
commit
4b0772d994
|
@ -14,15 +14,16 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <QFile>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <qsynedit/document.h>
|
||||||
#include "cpprefacter.h"
|
#include "cpprefacter.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "editorlist.h"
|
#include "editorlist.h"
|
||||||
#include <QFile>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include "syntaxermanager.h"
|
#include "syntaxermanager.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
|
@ -238,7 +239,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
||||||
}
|
}
|
||||||
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
||||||
int posY = 0;
|
int posY = 0;
|
||||||
while (posY < editor.document()->count()) {
|
while (posY < editor.lineCount()) {
|
||||||
QString line = editor.document()->getLine(posY);
|
QString line = editor.document()->getLine(posY);
|
||||||
if (line.isEmpty()) {
|
if (line.isEmpty()) {
|
||||||
posY++;
|
posY++;
|
||||||
|
@ -299,7 +300,7 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
||||||
oldEditor->clearSelection();
|
oldEditor->clearSelection();
|
||||||
oldEditor->addGroupBreak();
|
oldEditor->addGroupBreak();
|
||||||
oldEditor->beginEditing();
|
oldEditor->beginEditing();
|
||||||
while (posY < oldEditor->document()->count()) {
|
while (posY < oldEditor->lineCount()) {
|
||||||
QString line = oldEditor->document()->getLine(posY);
|
QString line = oldEditor->document()->getLine(posY);
|
||||||
if (posY == 0) {
|
if (posY == 0) {
|
||||||
syntaxer->resetState();
|
syntaxer->resetState();
|
||||||
|
@ -351,7 +352,7 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
||||||
|
|
||||||
QStringList newContents;
|
QStringList newContents;
|
||||||
int posY = 0;
|
int posY = 0;
|
||||||
while (posY < editor.document()->count()) {
|
while (posY < editor.lineCount()) {
|
||||||
QString line = editor.document()->getLine(posY);
|
QString line = editor.document()->getLine(posY);
|
||||||
if (posY == 0) {
|
if (posY == 0) {
|
||||||
editor.syntaxer()->resetState();
|
editor.syntaxer()->resetState();
|
||||||
|
|
|
@ -1145,7 +1145,7 @@ void GDBMIDebuggerClient::setBreakpointCondition(PBreakpoint breakpoint)
|
||||||
QString("%1").arg(breakpoint->number));
|
QString("%1").arg(breakpoint->number));
|
||||||
} else {
|
} else {
|
||||||
postCommand("-break-condition",
|
postCommand("-break-condition",
|
||||||
QString("%1 \"%2\"").arg(breakpoint->number).arg(condition));
|
QString("%1 %2").arg(breakpoint->number).arg(condition));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,22 +21,6 @@
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <memory>
|
|
||||||
#include "settings.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "systemconsts.h"
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMimeData>
|
|
||||||
#include <QTemporaryFile>
|
|
||||||
#include "qsynedit/syntaxer/cpp.h"
|
|
||||||
#include "qsynedit/syntaxer/asm.h"
|
|
||||||
#include "syntaxermanager.h"
|
|
||||||
#include "qsynedit/exporter/rtfexporter.h"
|
|
||||||
#include "qsynedit/exporter/htmlexporter.h"
|
|
||||||
#include "qsynedit/exporter/qtsupportedhtmlexporter.h"
|
|
||||||
#include "qsynedit/constants.h"
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -49,6 +33,23 @@
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <memory>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <qsynedit/document.h>
|
||||||
|
#include <qsynedit/syntaxer/cpp.h>
|
||||||
|
#include <qsynedit/syntaxer/asm.h>
|
||||||
|
#include <qsynedit/exporter/rtfexporter.h>
|
||||||
|
#include <qsynedit/exporter/htmlexporter.h>
|
||||||
|
#include <qsynedit/exporter/qtsupportedhtmlexporter.h>
|
||||||
|
#include <qsynedit/constants.h>
|
||||||
|
#include "settings.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "systemconsts.h"
|
||||||
|
#include "syntaxermanager.h"
|
||||||
#include "iconsmanager.h"
|
#include "iconsmanager.h"
|
||||||
#include "debugger/debugger.h"
|
#include "debugger/debugger.h"
|
||||||
#include "editorlist.h"
|
#include "editorlist.h"
|
||||||
|
@ -864,12 +865,12 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
s=trimLeft(lineText());
|
s=trimLeft(lineText());
|
||||||
if (s.startsWith("* ")) {
|
if (s.startsWith("* ")) {
|
||||||
handled = true;
|
handled = true;
|
||||||
int right = document()->getLine(caretY()-1).length()-caretX();
|
int right = lineText(caretY()).length()-caretX();
|
||||||
s=lineBreak()+"* ";
|
s=lineBreak()+"* ";
|
||||||
insertString(s,false);
|
insertString(s,false);
|
||||||
QSynedit::BufferCoord p = caretXY();
|
QSynedit::BufferCoord p = caretXY();
|
||||||
p.line++;
|
p.line++;
|
||||||
p.ch = document()->getLine(p.line-1).length()+1;
|
p.ch = lineText(p.line).length()+1;
|
||||||
if (right>0) {
|
if (right>0) {
|
||||||
p.ch -=right+1;
|
p.ch -=right+1;
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1168,7 @@ void Editor::mouseMoveEvent(QMouseEvent *event)
|
||||||
QSynedit::BufferCoord p;
|
QSynedit::BufferCoord p;
|
||||||
TipType reason = getTipType(event->pos(),p);
|
TipType reason = getTipType(event->pos(),p);
|
||||||
if (reason == TipType::Preprocessor) {
|
if (reason == TipType::Preprocessor) {
|
||||||
QString s = document()->getLine(p.line - 1);
|
QString s = lineText(p.line);
|
||||||
if (mParser->isIncludeNextLine(s) || mParser->isIncludeLine(s))
|
if (mParser->isIncludeNextLine(s) || mParser->isIncludeLine(s))
|
||||||
updateHoverLink(p.line);
|
updateHoverLink(p.line);
|
||||||
} else if (reason == TipType::Identifier) {
|
} else if (reason == TipType::Identifier) {
|
||||||
|
@ -1269,17 +1270,17 @@ void Editor::onGetEditingAreas(int line, QSynedit::EditingAreaList &areaList)
|
||||||
areaList.append(p);
|
areaList.append(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString lineText = document()->getLine(line-1);
|
QString s = lineText(line);
|
||||||
if (mParser && mParser->isIncludeLine(lineText)) {
|
if (mParser && mParser->isIncludeLine(s)) {
|
||||||
if (line == mHoverModifiedLine) {
|
if (line == mHoverModifiedLine) {
|
||||||
int i=0;
|
int i=0;
|
||||||
while (i<lineText.length() && lineText[i]!='<' && lineText[i]!='\"')
|
while (i<s.length() && s[i]!='<' && s[i]!='\"')
|
||||||
i++;
|
i++;
|
||||||
if (i<lineText.length()) {
|
if (i<s.length()) {
|
||||||
if (lineText[i]=='<') {
|
if (s[i]=='<') {
|
||||||
setIncludeUnderline(lineText,i,'>',syntaxer(), foregroundColor(), areaList);
|
setIncludeUnderline(s,i,'>',syntaxer(), foregroundColor(), areaList);
|
||||||
} else {
|
} else {
|
||||||
setIncludeUnderline(lineText,i,'"',syntaxer(), foregroundColor(), areaList);
|
setIncludeUnderline(s,i,'"',syntaxer(), foregroundColor(), areaList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1322,11 +1323,11 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
background = syntaxer()->commentAttribute()->background();
|
background = syntaxer()->commentAttribute()->background();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString lineText = document()->getLine(line-1);
|
QString s = lineText(line);
|
||||||
if (mParser->isIncludeLine(lineText) && attr->tokenType() != QSynedit::TokenType::Comment) {
|
if (mParser->isIncludeLine(s) && attr->tokenType() != QSynedit::TokenType::Comment) {
|
||||||
// #include header names (<>)
|
// #include header names (<>)
|
||||||
int pos1=lineText.indexOf("<")+1;
|
int pos1=s.indexOf("<")+1;
|
||||||
int pos2=lineText.indexOf(">",pos1);
|
int pos2=s.indexOf(">",pos1);
|
||||||
if (pos1>0 && pos2>0 && pos1<aChar && aChar<pos2) {
|
if (pos1>0 && pos2>0 && pos1<aChar && aChar<pos2) {
|
||||||
style = syntaxer()->identifierAttribute()->styles();
|
style = syntaxer()->identifierAttribute()->styles();
|
||||||
foreground = syntaxer()->identifierAttribute()->foreground();
|
foreground = syntaxer()->identifierAttribute()->foreground();
|
||||||
|
@ -1356,8 +1357,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
|
||||||
if ((pEndPos.line>=1)
|
if ((pEndPos.line>=1)
|
||||||
&& (pEndPos.ch>=0)
|
&& (pEndPos.ch>=0)
|
||||||
&& (pEndPos.ch+1 < document()->getLine(pEndPos.line-1).length())
|
&& (pEndPos.ch+1 < lineText(pEndPos.line).length())
|
||||||
&& (document()->getLine(pEndPos.line-1)[pEndPos.ch+1] == '(')) {
|
&& (lineText(pEndPos.line)[pEndPos.ch+1] == '(')) {
|
||||||
kind = StatementKind::Function;
|
kind = StatementKind::Function;
|
||||||
} else {
|
} else {
|
||||||
kind = StatementKind::Variable;
|
kind = StatementKind::Variable;
|
||||||
|
@ -1488,7 +1489,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
||||||
QSynedit::BufferCoord p;
|
QSynedit::BufferCoord p;
|
||||||
if (mParser && pointToCharLine(event->pos(),p)) {
|
if (mParser && pointToCharLine(event->pos(),p)) {
|
||||||
cancelHoverLink();
|
cancelHoverLink();
|
||||||
QString s = document()->getLine(p.line - 1);
|
QString s = lineText(p.line);
|
||||||
if (mParser->isIncludeNextLine(s)) {
|
if (mParser->isIncludeNextLine(s)) {
|
||||||
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
QString filename = mParser->getHeaderFileName(mFilename,s, true);
|
||||||
pMainWindow->openFile(filename);
|
pMainWindow->openFile(filename);
|
||||||
|
@ -1748,20 +1749,20 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT
|
||||||
int start;
|
int start;
|
||||||
QSynedit::PTokenAttribute attr;
|
QSynedit::PTokenAttribute attr;
|
||||||
PSyntaxIssueList lst;
|
PSyntaxIssueList lst;
|
||||||
if ((line<1) || (line>document()->count()))
|
if ((line<1) || (line>lineCount()))
|
||||||
return;
|
return;
|
||||||
pError = std::make_shared<SyntaxIssue>();
|
pError = std::make_shared<SyntaxIssue>();
|
||||||
p.ch = startChar;
|
p.ch = startChar;
|
||||||
p.line = line;
|
p.line = line;
|
||||||
if (startChar >= document()->getLine(line-1).length()) {
|
if (startChar >= lineText(line).length()) {
|
||||||
start = 1;
|
start = 1;
|
||||||
token = document()->getLine(line-1);
|
token = lineText(line);
|
||||||
} else if (endChar < 1) {
|
} else if (endChar < 1) {
|
||||||
if (!getTokenAttriAtRowColEx(p,token,start,attr))
|
if (!getTokenAttriAtRowColEx(p,token,start,attr))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
start = startChar;
|
start = startChar;
|
||||||
token = document()->getLine(line-1).mid(start-1,endChar-startChar);
|
token = lineText(line).mid(start-1,endChar-startChar);
|
||||||
}
|
}
|
||||||
pError->startChar = start;
|
pError->startChar = start;
|
||||||
pError->endChar = start + token.length();
|
pError->endChar = start + token.length();
|
||||||
|
@ -1855,8 +1856,8 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
|
||||||
{
|
{
|
||||||
if ((!changes.testFlag(QSynedit::StatusChange::ReadOnly)
|
if ((!changes.testFlag(QSynedit::StatusChange::ReadOnly)
|
||||||
&& !changes.testFlag(QSynedit::StatusChange::InsertMode)
|
&& !changes.testFlag(QSynedit::StatusChange::InsertMode)
|
||||||
&& (document()->count()!=mLineCount)
|
&& (lineCount()!=mLineCount)
|
||||||
&& (document()->count()!=0) && ((mLineCount>0) || (document()->count()>1)))
|
&& (lineCount()!=0) && ((mLineCount>0) || (lineCount()>1)))
|
||||||
||
|
||
|
||||||
(mCurrentLineModified
|
(mCurrentLineModified
|
||||||
&& !changes.testFlag(QSynedit::StatusChange::ReadOnly)
|
&& !changes.testFlag(QSynedit::StatusChange::ReadOnly)
|
||||||
|
@ -1874,7 +1875,7 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
|
||||||
// reparse();
|
// reparse();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
mLineCount = document()->count();
|
mLineCount = lineCount();
|
||||||
if (changes.testFlag(QSynedit::StatusChange::ModifyChanged)) {
|
if (changes.testFlag(QSynedit::StatusChange::ModifyChanged)) {
|
||||||
updateCaption();
|
updateCaption();
|
||||||
}
|
}
|
||||||
|
@ -2109,7 +2110,7 @@ void Editor::onTooltipTimer()
|
||||||
case TipType::Preprocessor:
|
case TipType::Preprocessor:
|
||||||
// When hovering above a preprocessor line, determine if we want to show an include or a identifier hint
|
// When hovering above a preprocessor line, determine if we want to show an include or a identifier hint
|
||||||
if (mParser) {
|
if (mParser) {
|
||||||
s = document()->getLine(p.line - 1);
|
s = lineText(p.line);
|
||||||
isIncludeNextLine = mParser->isIncludeNextLine(s);
|
isIncludeNextLine = mParser->isIncludeNextLine(s);
|
||||||
if (!isIncludeNextLine)
|
if (!isIncludeNextLine)
|
||||||
isIncludeLine = mParser->isIncludeLine(s);
|
isIncludeLine = mParser->isIncludeLine(s);
|
||||||
|
@ -2146,7 +2147,7 @@ void Editor::onTooltipTimer()
|
||||||
QSynedit::PTokenAttribute attr;
|
QSynedit::PTokenAttribute attr;
|
||||||
int start;
|
int start;
|
||||||
if (getTokenAttriAtRowColEx(p,s,start,attr)) {
|
if (getTokenAttriAtRowColEx(p,s,start,attr)) {
|
||||||
QString line=document()->getLine(p.line-1);
|
QString line=lineText(p.line);
|
||||||
int idx=start-2;
|
int idx=start-2;
|
||||||
if (idx>=0 && idx<line.length() && line[idx]=='-')
|
if (idx>=0 && idx<line.length() && line[idx]=='-')
|
||||||
s='-'+s;
|
s='-'+s;
|
||||||
|
@ -2383,7 +2384,7 @@ QStringList Editor::getExpressionAtPosition(
|
||||||
LastSymbolType lastSymbolType=LastSymbolType::None;
|
LastSymbolType lastSymbolType=LastSymbolType::None;
|
||||||
QSynedit::CppSyntaxer syntaxer;
|
QSynedit::CppSyntaxer syntaxer;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (line>=document()->count() || line<0)
|
if (line>=lineCount() || line<0)
|
||||||
break;
|
break;
|
||||||
QStringList tokens;
|
QStringList tokens;
|
||||||
if (line==0) {
|
if (line==0) {
|
||||||
|
@ -2612,7 +2613,7 @@ QString Editor::getWordForCompletionSearch(const QSynedit::BufferCoord &pos,bool
|
||||||
QString result = "";
|
QString result = "";
|
||||||
QString s;
|
QString s;
|
||||||
|
|
||||||
s = document()->getLine(pos.line - 1);
|
s = lineText(pos.line);
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
|
||||||
int wordBegin = pos.ch - 1 - 1; //BufferCoord::Char starts with 1
|
int wordBegin = pos.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||||
|
@ -2797,10 +2798,10 @@ bool Editor::handleParentheseSkip()
|
||||||
if (status != QuoteStatus::NotQuote)
|
if (status != QuoteStatus::NotQuote)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (document()->count()==0)
|
if (lineCount()==0)
|
||||||
return false;
|
return false;
|
||||||
if (syntaxer()->supportBraceLevel()) {
|
if (syntaxer()->supportBraceLevel()) {
|
||||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(lineCount()-1);
|
||||||
if (lastLineState.parenthesisLevel==0) {
|
if (lastLineState.parenthesisLevel==0) {
|
||||||
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
|
@ -2844,10 +2845,10 @@ bool Editor::handleBracketSkip()
|
||||||
if (getCurrentChar() != ']')
|
if (getCurrentChar() != ']')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (document()->count()==0)
|
if (lineCount()==0)
|
||||||
return false;
|
return false;
|
||||||
if (syntaxer()->supportBraceLevel()) {
|
if (syntaxer()->supportBraceLevel()) {
|
||||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(lineCount()-1);
|
||||||
if (lastLineState.bracketLevel==0) {
|
if (lastLineState.bracketLevel==0) {
|
||||||
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over
|
||||||
return true;
|
return true;
|
||||||
|
@ -2920,10 +2921,10 @@ bool Editor::handleBraceCompletion()
|
||||||
QSynedit::BufferCoord oldSelEnd = blockEnd();
|
QSynedit::BufferCoord oldSelEnd = blockEnd();
|
||||||
bool shouldBreakLine = false;
|
bool shouldBreakLine = false;
|
||||||
bool shouldAddEndLine = false;
|
bool shouldAddEndLine = false;
|
||||||
QString s1=document()->getLine(oldSelBegin.line-1).left(oldSelBegin.ch-1).trimmed();
|
QString s1=lineText(oldSelBegin.line).left(oldSelBegin.ch-1).trimmed();
|
||||||
|
|
||||||
if (s1.isEmpty() ) {
|
if (s1.isEmpty() ) {
|
||||||
QString s2 = document()->getLine(oldSelEnd.line-1);
|
QString s2 = lineText(oldSelEnd.line);
|
||||||
if (s2.left(oldSelEnd.ch-1).trimmed().isEmpty()) {
|
if (s2.left(oldSelEnd.ch-1).trimmed().isEmpty()) {
|
||||||
shouldBreakLine = true;
|
shouldBreakLine = true;
|
||||||
} else if (oldSelEnd.ch > trimRight(s2).length()) {
|
} else if (oldSelEnd.ch > trimRight(s2).length()) {
|
||||||
|
@ -2957,11 +2958,11 @@ bool Editor::handleBraceSkip()
|
||||||
if (getCurrentChar() != '}')
|
if (getCurrentChar() != '}')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (document()->count()==0)
|
if (lineCount()==0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (syntaxer()->supportBraceLevel()) {
|
if (syntaxer()->supportBraceLevel()) {
|
||||||
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(document()->count()-1);
|
QSynedit::SyntaxState lastLineState = document()->getSyntaxState(lineCount()-1);
|
||||||
if (lastLineState.braceLevel==0) {
|
if (lastLineState.braceLevel==0) {
|
||||||
bool oldInsertMode = insertMode();
|
bool oldInsertMode = insertMode();
|
||||||
setInsertMode(false); //set mode to overwrite
|
setInsertMode(false); //set mode to overwrite
|
||||||
|
@ -4125,7 +4126,7 @@ Editor::TipType Editor::getTipType(QPoint point, QSynedit::BufferCoord& pos)
|
||||||
// do not allow when dragging selection
|
// do not allow when dragging selection
|
||||||
if (isPointInSelection(pos))
|
if (isPointInSelection(pos))
|
||||||
return TipType::Selection;
|
return TipType::Selection;
|
||||||
} else if (mParser && mParser->isIncludeLine(document()->getLine(pos.line-1))) {
|
} else if (mParser && mParser->isIncludeLine(lineText(pos.line))) {
|
||||||
return TipType::Preprocessor;
|
return TipType::Preprocessor;
|
||||||
} else if (attr->tokenType() == QSynedit::TokenType::Identifier) {
|
} else if (attr->tokenType() == QSynedit::TokenType::Identifier) {
|
||||||
return TipType::Identifier;
|
return TipType::Identifier;
|
||||||
|
@ -4273,7 +4274,7 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
int bracketLevel = 0;
|
int bracketLevel = 0;
|
||||||
int paramsCount = 1;
|
int paramsCount = 1;
|
||||||
int currentParamPos = 1;
|
int currentParamPos = 1;
|
||||||
if (currentLine>=document()->count())
|
if (currentLine>=lineCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QChar ch=lastNonSpaceChar(currentLine,currentChar);
|
QChar ch=lastNonSpaceChar(currentLine,currentChar);
|
||||||
|
@ -4398,7 +4399,7 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
|
|
||||||
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
||||||
int x = pWordBegin.ch-1-1;
|
int x = pWordBegin.ch-1-1;
|
||||||
QString line = document()->getLine(pWordBegin.line-1);
|
QString line = lineText(pWordBegin.line);
|
||||||
bool hasPreviousWord=false;
|
bool hasPreviousWord=false;
|
||||||
while (x>=0) {
|
while (x>=0) {
|
||||||
QChar ch=line[x];
|
QChar ch=line[x];
|
||||||
|
@ -4502,7 +4503,7 @@ void Editor::popUserCodeInTabStops()
|
||||||
tabStopBegin = mTabStopEnd + p->x;
|
tabStopBegin = mTabStopEnd + p->x;
|
||||||
tabStopEnd = mTabStopEnd + p->endX;
|
tabStopEnd = mTabStopEnd + p->endX;
|
||||||
} else {
|
} else {
|
||||||
int n=countLeadingWhitespaceChars(document()->getLine(caretY()-1+p->y));
|
int n=countLeadingWhitespaceChars(lineText(caretY()+p->y));
|
||||||
// qDebug()<<line<<n<<p->x;
|
// qDebug()<<line<<n<<p->x;
|
||||||
tabStopBegin = n+p->x+1;
|
tabStopBegin = n+p->x+1;
|
||||||
tabStopEnd = n+p->endX+1;
|
tabStopEnd = n+p->endX+1;
|
||||||
|
@ -4547,8 +4548,8 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
|
||||||
if (kind == StatementKind::Unknown) {
|
if (kind == StatementKind::Unknown) {
|
||||||
if ((pEndPos.line>=1)
|
if ((pEndPos.line>=1)
|
||||||
&& (pEndPos.ch>=0)
|
&& (pEndPos.ch>=0)
|
||||||
&& (pEndPos.ch < document()->getLine(pEndPos.line-1).length())
|
&& (pEndPos.ch < lineText(pEndPos.line).length())
|
||||||
&& (document()->getLine(pEndPos.line-1)[pEndPos.ch] == '(')) {
|
&& (lineText(pEndPos.line)[pEndPos.ch] == '(')) {
|
||||||
kind = StatementKind::Function;
|
kind = StatementKind::Function;
|
||||||
} else {
|
} else {
|
||||||
kind = StatementKind::Variable;
|
kind = StatementKind::Variable;
|
||||||
|
@ -4783,13 +4784,13 @@ QString getWordAtPosition(QSynedit::QSynEdit *editor, const QSynedit::BufferCoor
|
||||||
{
|
{
|
||||||
QString result = "";
|
QString result = "";
|
||||||
QString s;
|
QString s;
|
||||||
if ((p.line<1) || (p.line>editor->document()->count())) {
|
if ((p.line<1) || (p.line>editor->lineCount())) {
|
||||||
pWordBegin = p;
|
pWordBegin = p;
|
||||||
pWordEnd = p;
|
pWordEnd = p;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
s = editor->document()->getLine(p.line - 1);
|
s = editor->lineText(p.line);
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
|
||||||
int wordBegin = p.ch - 1 - 1; //BufferCoord::Char starts with 1
|
int wordBegin = p.ch - 1 - 1; //BufferCoord::Char starts with 1
|
||||||
|
@ -4972,7 +4973,7 @@ QString getWordAtPosition(QSynedit::QSynEdit *editor, const QSynedit::BufferCoor
|
||||||
if (i<0) {
|
if (i<0) {
|
||||||
line--;
|
line--;
|
||||||
if (line>=1) {
|
if (line>=1) {
|
||||||
s=editor->document()->getLine(line-1);
|
s=editor->lineText(line);
|
||||||
i=s.length();
|
i=s.length();
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else
|
||||||
|
@ -5023,12 +5024,12 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
|
||||||
{
|
{
|
||||||
hasTypeQualifier = false;
|
hasTypeQualifier = false;
|
||||||
QString result;
|
QString result;
|
||||||
if ((p.line<1) || (p.line>document()->count())) {
|
if ((p.line<1) || (p.line>lineCount())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
bool inFunc = testInFunc(p);
|
bool inFunc = testInFunc(p);
|
||||||
|
|
||||||
QString s = document()->getLine(p.line - 1);
|
QString s = lineText(p.line);
|
||||||
int wordBegin;
|
int wordBegin;
|
||||||
int wordEnd = p.ch-2;
|
int wordEnd = p.ch-2;
|
||||||
if (wordEnd >= s.length())
|
if (wordEnd >= s.length())
|
||||||
|
@ -5092,11 +5093,11 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
|
||||||
QString Editor::getPreviousWordAtPositionForCompleteFunctionDefinition(const QSynedit::BufferCoord &p)
|
QString Editor::getPreviousWordAtPositionForCompleteFunctionDefinition(const QSynedit::BufferCoord &p)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
if ((p.line<1) || (p.line>document()->count())) {
|
if ((p.line<1) || (p.line>lineCount())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString s = document()->getLine(p.line - 1);
|
QString s = lineText(p.line);
|
||||||
int wordBegin;
|
int wordBegin;
|
||||||
int wordEnd = p.ch-2;
|
int wordEnd = p.ch-2;
|
||||||
if (wordEnd >= s.length())
|
if (wordEnd >= s.length())
|
||||||
|
@ -5158,7 +5159,7 @@ void Editor::reformat(bool doReparse)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//we must remove all breakpoints and syntax issues
|
//we must remove all breakpoints and syntax issues
|
||||||
// onLinesDeleted(1,document()->count());
|
// onLinesDeleted(1,lineCount());
|
||||||
QByteArray content = text().toUtf8();
|
QByteArray content = text().toUtf8();
|
||||||
QStringList args = pSettings->codeFormatter().getArguments();
|
QStringList args = pSettings->codeFormatter().getArguments();
|
||||||
//qDebug()<<args;
|
//qDebug()<<args;
|
||||||
|
|
|
@ -14,6 +14,38 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
#include <QTcpSocket>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <QTextBlock>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QFileIconProvider>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
#include <QMimeType>
|
||||||
|
#include <QToolTip>
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "editorlist.h"
|
#include "editorlist.h"
|
||||||
|
@ -62,42 +94,10 @@
|
||||||
#include "widgets/projectalreadyopendialog.h"
|
#include "widgets/projectalreadyopendialog.h"
|
||||||
#include "widgets/searchdialog.h"
|
#include "widgets/searchdialog.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QDragEnterEvent>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QMimeData>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QStyleFactory>
|
|
||||||
#include <QTcpSocket>
|
|
||||||
#include <QTemporaryFile>
|
|
||||||
#include <QTextBlock>
|
|
||||||
#include <QTranslator>
|
|
||||||
#include <QFileIconProvider>
|
|
||||||
#include <QMimeDatabase>
|
|
||||||
#include <QMimeType>
|
|
||||||
#include <QToolTip>
|
|
||||||
#include <QCompleter>
|
|
||||||
#include <QUuid>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include <QScrollBar>
|
|
||||||
#include <QTextDocumentFragment>
|
|
||||||
|
|
||||||
#include "settingsdialog/settingsdialog.h"
|
#include "settingsdialog/settingsdialog.h"
|
||||||
#include "compiler/compilermanager.h"
|
#include "compiler/compilermanager.h"
|
||||||
#include <QGuiApplication>
|
#include <qsynedit/document.h>
|
||||||
#include <QClipboard>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include "cpprefacter.h"
|
#include "cpprefacter.h"
|
||||||
|
|
||||||
#include "widgets/newprojectunitdialog.h"
|
#include "widgets/newprojectunitdialog.h"
|
||||||
|
@ -689,7 +689,7 @@ void MainWindow::updateEditorActions(const Editor *e)
|
||||||
} else {
|
} else {
|
||||||
ui->actionCopy->setEnabled(true);
|
ui->actionCopy->setEnabled(true);
|
||||||
ui->actionCut->setEnabled(true);
|
ui->actionCut->setEnabled(true);
|
||||||
ui->actionFoldAll->setEnabled(e->document()->count()>0);
|
ui->actionFoldAll->setEnabled(e->lineCount()>0);
|
||||||
ui->actionIndent->setEnabled(!e->readOnly());
|
ui->actionIndent->setEnabled(!e->readOnly());
|
||||||
ui->actionPaste->setEnabled(!e->readOnly());
|
ui->actionPaste->setEnabled(!e->readOnly());
|
||||||
ui->actionRedo->setEnabled(e->canRedo());
|
ui->actionRedo->setEnabled(e->canRedo());
|
||||||
|
@ -699,17 +699,17 @@ void MainWindow::updateEditorActions(const Editor *e)
|
||||||
ui->actionExport_As_HTML->setEnabled(true);
|
ui->actionExport_As_HTML->setEnabled(true);
|
||||||
ui->actionExport_As_RTF->setEnabled(true);
|
ui->actionExport_As_RTF->setEnabled(true);
|
||||||
ui->actionPrint->setEnabled(true);
|
ui->actionPrint->setEnabled(true);
|
||||||
ui->actionToggleComment->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionToggleComment->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionToggle_Block_Comment->setEnabled(!e->readOnly() && e->selAvail());
|
ui->actionToggle_Block_Comment->setEnabled(!e->readOnly() && e->selAvail());
|
||||||
ui->actionUnIndent->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionUnIndent->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionUnfoldAll->setEnabled(e->document()->count()>0);
|
ui->actionUnfoldAll->setEnabled(e->lineCount()>0);
|
||||||
ui->actionDelete_Line->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_Line->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDelete_Word->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_Word->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDuplicate_Line->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDuplicate_Line->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDelete_to_BOL->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_to_BOL->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDelete_to_EOL->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_to_EOL->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDelete_to_Word_End->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_to_Word_End->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
ui->actionDelete_Last_Word->setEnabled(!e->readOnly() && e->document()->count()>0);
|
ui->actionDelete_Last_Word->setEnabled(!e->readOnly() && e->lineCount()>0);
|
||||||
|
|
||||||
ui->menuMove_Caret->setEnabled(true);
|
ui->menuMove_Caret->setEnabled(true);
|
||||||
ui->actionPage_Up->setEnabled(true);
|
ui->actionPage_Up->setEnabled(true);
|
||||||
|
@ -721,7 +721,7 @@ void MainWindow::updateEditorActions(const Editor *e)
|
||||||
ui->actionGoto_Page_Start->setEnabled(true);
|
ui->actionGoto_Page_Start->setEnabled(true);
|
||||||
ui->actionGoto_Page_End->setEnabled(true);
|
ui->actionGoto_Page_End->setEnabled(true);
|
||||||
|
|
||||||
ui->actionSelectAll->setEnabled(e->document()->count()>0);
|
ui->actionSelectAll->setEnabled(e->lineCount()>0);
|
||||||
ui->actionSelect_Word->setEnabled(true);
|
ui->actionSelect_Word->setEnabled(true);
|
||||||
ui->actionMove_Selection_Up->setEnabled(true);
|
ui->actionMove_Selection_Up->setEnabled(true);
|
||||||
ui->actionMove_Selection_Down->setEnabled(true);
|
ui->actionMove_Selection_Down->setEnabled(true);
|
||||||
|
@ -747,7 +747,7 @@ void MainWindow::updateEditorActions(const Editor *e)
|
||||||
ui->actionClose_Others->setEnabled(mEditorList->pageCount()>1);
|
ui->actionClose_Others->setEnabled(mEditorList->pageCount()>1);
|
||||||
|
|
||||||
int line = e->caretY();
|
int line = e->caretY();
|
||||||
ui->actionAdd_bookmark->setEnabled(e->document()->count()>0 && !e->hasBookmark(line));
|
ui->actionAdd_bookmark->setEnabled(e->lineCount()>0 && !e->hasBookmark(line));
|
||||||
ui->actionRemove_Bookmark->setEnabled(e->hasBookmark(line));
|
ui->actionRemove_Bookmark->setEnabled(e->hasBookmark(line));
|
||||||
ui->actionModify_Bookmark_Description->setEnabled(e->hasBookmark(line));
|
ui->actionModify_Bookmark_Description->setEnabled(e->hasBookmark(line));
|
||||||
|
|
||||||
|
@ -1598,27 +1598,27 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
||||||
if (e->selAvail()) {
|
if (e->selAvail()) {
|
||||||
msg = tr("Line: %1/%2 Col: %3 Sel: %4")
|
msg = tr("Line: %1/%2 Col: %3 Sel: %4")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(e->document()->count())
|
.arg(e->lineCount())
|
||||||
.arg(col)
|
.arg(col)
|
||||||
.arg(e->selCount());
|
.arg(e->selCount());
|
||||||
} else {
|
} else {
|
||||||
msg = tr("Line: %1/%2 Col: %3")
|
msg = tr("Line: %1/%2 Col: %3")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(e->document()->count())
|
.arg(e->lineCount())
|
||||||
.arg(col);
|
.arg(col);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (e->selAvail()) {
|
if (e->selAvail()) {
|
||||||
msg = tr("Line: %1/%2 Char: %3/%4 Sel: %5")
|
msg = tr("Line: %1/%2 Char: %3/%4 Sel: %5")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(e->document()->count())
|
.arg(e->lineCount())
|
||||||
.arg(e->caretX())
|
.arg(e->caretX())
|
||||||
.arg(e->lineText().length())
|
.arg(e->lineText().length())
|
||||||
.arg(e->selCount());
|
.arg(e->selCount());
|
||||||
} else {
|
} else {
|
||||||
msg = tr("Line: %1/%2 Char: %3/%4")
|
msg = tr("Line: %1/%2 Char: %3/%4")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(e->document()->count())
|
.arg(e->lineCount())
|
||||||
.arg(e->caretX())
|
.arg(e->caretX())
|
||||||
.arg(e->lineText().length());
|
.arg(e->lineText().length());
|
||||||
}
|
}
|
||||||
|
@ -5215,7 +5215,7 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
|
||||||
ui->actionLocate_in_Files_View->setEnabled(!editor->isNew());
|
ui->actionLocate_in_Files_View->setEnabled(!editor->isNew());
|
||||||
ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line));
|
ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line));
|
||||||
ui->actionAdd_bookmark->setEnabled(
|
ui->actionAdd_bookmark->setEnabled(
|
||||||
line>=0 && editor->document()->count()>0
|
line>=0 && editor->lineCount()>0
|
||||||
&& !editor->hasBookmark(line)
|
&& !editor->hasBookmark(line)
|
||||||
);
|
);
|
||||||
ui->actionRemove_Bookmark->setEnabled(editor->hasBookmark(line));
|
ui->actionRemove_Bookmark->setEnabled(editor->hasBookmark(line));
|
||||||
|
@ -5949,11 +5949,11 @@ void MainWindow::onCompileIssue(PCompileIssue issue)
|
||||||
Editor* e = mEditorList->getOpenedEditorByFilename(issue->filename);
|
Editor* e = mEditorList->getOpenedEditorByFilename(issue->filename);
|
||||||
if (e!=nullptr && (issue->line>0)) {
|
if (e!=nullptr && (issue->line>0)) {
|
||||||
int line = issue->line;
|
int line = issue->line;
|
||||||
if (line > e->document()->count())
|
if (line > e->lineCount())
|
||||||
return;
|
return;
|
||||||
int col = std::min(issue->column,e->document()->getLine(line-1).length()+1);
|
int col = std::min(issue->column,e->lineText(line).length()+1);
|
||||||
if (col < 1)
|
if (col < 1)
|
||||||
col = e->document()->getLine(line-1).length()+1;
|
col = e->lineText(line).length()+1;
|
||||||
e->addSyntaxIssues(line,col,issue->endColumn,issue->type,issue->description);
|
e->addSyntaxIssues(line,col,issue->endColumn,issue->type,issue->description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6075,8 +6075,8 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
|
||||||
int line = e->caretY();
|
int line = e->caretY();
|
||||||
int startLine = 1;
|
int startLine = 1;
|
||||||
QString s = "# "+e->filename()+":";
|
QString s = "# "+e->filename()+":";
|
||||||
for(int i=0;i<editor->document()->count();i++) {
|
for(int i=1;i<=editor->lineCount();i++) {
|
||||||
QString t=editor->document()->getLine(i).trimmed();
|
QString t=editor->lineText(i).trimmed();
|
||||||
if (t.startsWith(s,PATH_SENSITIVITY)) {
|
if (t.startsWith(s,PATH_SENSITIVITY)) {
|
||||||
t=t.mid(s.length());
|
t=t.mid(s.length());
|
||||||
int pos = t.indexOf(":");
|
int pos = t.indexOf(":");
|
||||||
|
@ -6086,7 +6086,7 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
|
||||||
int l=numstring.toInt(&isOk);
|
int l=numstring.toInt(&isOk);
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
if (l<=line)
|
if (l<=line)
|
||||||
startLine=i+1;
|
startLine=i;
|
||||||
if (l>=line)
|
if (l>=line)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8380,7 +8380,7 @@ void MainWindow::on_btnReplace_clicked()
|
||||||
while (!selections.isEmpty()) {
|
while (!selections.isEmpty()) {
|
||||||
const PSearchResultTreeItem& item = selections.back();
|
const PSearchResultTreeItem& item = selections.back();
|
||||||
selections.pop_back();
|
selections.pop_back();
|
||||||
QString line = editor->document()->getLine(item->line-1);
|
QString line = editor->lineText(item->line);
|
||||||
if (line.mid(item->start-1,results->keyword.length())!=results->keyword) {
|
if (line.mid(item->start-1,results->keyword.length())!=results->keyword) {
|
||||||
QMessageBox::critical(editor,
|
QMessageBox::critical(editor,
|
||||||
tr("Replace Error"),
|
tr("Replace Error"),
|
||||||
|
@ -8534,11 +8534,11 @@ void MainWindow::on_actionAdd_bookmark_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->document()->count()<=0)
|
if (editor->lineCount()<=0)
|
||||||
return;
|
return;
|
||||||
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
|
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
|
||||||
tr("Description:"),QLineEdit::Normal,
|
tr("Description:"),QLineEdit::Normal,
|
||||||
editor->document()->getLine(line-1).trimmed());
|
editor->lineText(line).trimmed());
|
||||||
desc = desc.trimmed();
|
desc = desc.trimmed();
|
||||||
editor->addBookmark(line);
|
editor->addBookmark(line);
|
||||||
mBookmarkModel->addBookmark(editor->filename(),line,desc,editor->inProject());
|
mBookmarkModel->addBookmark(editor->filename(),line,desc,editor->inProject());
|
||||||
|
@ -9836,7 +9836,7 @@ void MainWindow::on_actionGo_to_Line_triggered()
|
||||||
return;
|
return;
|
||||||
bool ok;
|
bool ok;
|
||||||
int lineNo=QInputDialog::getInt(e,tr("Go to Line"),tr("Line"),
|
int lineNo=QInputDialog::getInt(e,tr("Go to Line"),tr("Line"),
|
||||||
e->caretY(),1,e->document()->count(),
|
e->caretY(),1,e->lineCount(),
|
||||||
1,&ok);
|
1,&ok);
|
||||||
if (ok && lineNo!=e->caretY()) {
|
if (ok && lineNo!=e->caretY()) {
|
||||||
e->setCaretPosition(lineNo,1);
|
e->setCaretPosition(lineNo,1);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <qsynedit/document.h>
|
||||||
|
|
||||||
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||||
SettingsWidget(name,group,parent),
|
SettingsWidget(name,group,parent),
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <qsynedit/document.h>
|
||||||
#include "editorsnippetwidget.h"
|
#include "editorsnippetwidget.h"
|
||||||
#include "ui_editorsnippetwidget.h"
|
#include "ui_editorsnippetwidget.h"
|
||||||
#include "../mainwindow.h"
|
#include "../mainwindow.h"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <qsynedit/document.h>
|
||||||
#include "formattergeneralwidget.h"
|
#include "formattergeneralwidget.h"
|
||||||
#include "ui_formattergeneralwidget.h"
|
#include "ui_formattergeneralwidget.h"
|
||||||
#include "../settings.h"
|
#include "../settings.h"
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <qsynedit/document.h>
|
||||||
#include "cpudialog.h"
|
#include "cpudialog.h"
|
||||||
#include "ui_cpudialog.h"
|
#include "ui_cpudialog.h"
|
||||||
#include "../syntaxermanager.h"
|
#include "../syntaxermanager.h"
|
||||||
|
|
|
@ -46,7 +46,7 @@ void FilePropertiesDialog::calcFile(Editor *editor,
|
||||||
int &includeLines,
|
int &includeLines,
|
||||||
int &charCounts)
|
int &charCounts)
|
||||||
{
|
{
|
||||||
totalLines = editor->document()->count();
|
totalLines = editor->lineCount();
|
||||||
codeLines = 0;
|
codeLines = 0;
|
||||||
commentLines = 0;
|
commentLines = 0;
|
||||||
emptyLines = 0;
|
emptyLines = 0;
|
||||||
|
@ -54,14 +54,14 @@ void FilePropertiesDialog::calcFile(Editor *editor,
|
||||||
charCounts = 0;
|
charCounts = 0;
|
||||||
int lineBreakerLen = QString(LINE_BREAKER).length();
|
int lineBreakerLen = QString(LINE_BREAKER).length();
|
||||||
// iterate through all lines of file
|
// iterate through all lines of file
|
||||||
for (int i=0;i<editor->document()->count();i++) {
|
for (int i=1;i<=editor->lineCount();i++) {
|
||||||
QString line = editor->document()->getLine(i);
|
QString line = editor->lineText(i);
|
||||||
charCounts+=line.length()+lineBreakerLen;
|
charCounts+=line.length()+lineBreakerLen;
|
||||||
// while (j<line.length() && (line[j]=='\t' || line[j]==' '))
|
// while (j<line.length() && (line[j]=='\t' || line[j]==' '))
|
||||||
// j++;
|
// j++;
|
||||||
QString token;
|
QString token;
|
||||||
QSynedit::PTokenAttribute attr;
|
QSynedit::PTokenAttribute attr;
|
||||||
if (editor->getTokenAttriAtRowCol(QSynedit::BufferCoord{1,i+1},
|
if (editor->getTokenAttriAtRowCol(QSynedit::BufferCoord{1,i},
|
||||||
token,attr)) {
|
token,attr)) {
|
||||||
// if it is preprocessor...
|
// if it is preprocessor...
|
||||||
if (attr->name() == SYNS_AttrPreprocessor) {
|
if (attr->name() == SYNS_AttrPreprocessor) {
|
||||||
|
@ -136,7 +136,7 @@ void FilePropertiesDialog::on_cbFiles_currentIndexChanged(int index)
|
||||||
ui->txtProject->setText("-");
|
ui->txtProject->setText("-");
|
||||||
ui->txtPath->setText(editor->filename());
|
ui->txtPath->setText(editor->filename());
|
||||||
ui->txtRelativeToProject->setText("_");
|
ui->txtRelativeToProject->setText("_");
|
||||||
ui->txtLines->setText(QString("%1").arg(editor->document()->count()));
|
ui->txtLines->setText(QString("%1").arg(editor->lineCount()));
|
||||||
|
|
||||||
int totalLines, codeLines,emptyLines,commentLines,includeLines, charCounts;
|
int totalLines, codeLines,emptyLines,commentLines,includeLines, charCounts;
|
||||||
calcFile(editor,totalLines,commentLines,emptyLines,codeLines,includeLines,charCounts);
|
calcFile(editor,totalLines,commentLines,emptyLines,codeLines,includeLines,charCounts);
|
||||||
|
|
|
@ -17,21 +17,21 @@
|
||||||
#include "searchinfiledialog.h"
|
#include "searchinfiledialog.h"
|
||||||
#include "ui_searchinfiledialog.h"
|
#include "ui_searchinfiledialog.h"
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include "../editor.h"
|
|
||||||
#include "../mainwindow.h"
|
|
||||||
#include "../editorlist.h"
|
|
||||||
#include <qsynedit/searcher/basicsearcher.h>
|
|
||||||
#include <qsynedit/searcher/regexsearcher.h>
|
|
||||||
#include "../project.h"
|
|
||||||
#include "../settings.h"
|
|
||||||
#include "../systemconsts.h"
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <qsynedit/document.h>
|
||||||
|
#include <qsynedit/searcher/basicsearcher.h>
|
||||||
|
#include <qsynedit/searcher/regexsearcher.h>
|
||||||
|
#include "../editor.h"
|
||||||
|
#include "../mainwindow.h"
|
||||||
|
#include "../editorlist.h"
|
||||||
|
#include "../project.h"
|
||||||
|
#include "../settings.h"
|
||||||
|
#include "../systemconsts.h"
|
||||||
|
|
||||||
SearchInFileDialog::SearchInFileDialog(QWidget *parent) :
|
SearchInFileDialog::SearchInFileDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -378,14 +378,14 @@ std::shared_ptr<SearchResultTreeItem> SearchInFileDialog::batchFindInEditor(QSyn
|
||||||
parentItem->parent = nullptr;
|
parentItem->parent = nullptr;
|
||||||
execute(e,keyword,"",
|
execute(e,keyword,"",
|
||||||
[e,&parentItem, filename](const QString&,
|
[e,&parentItem, filename](const QString&,
|
||||||
const QString&, int Line, int ch, int wordLen){
|
const QString&, int line, int ch, int wordLen){
|
||||||
PSearchResultTreeItem item = std::make_shared<SearchResultTreeItem>();
|
PSearchResultTreeItem item = std::make_shared<SearchResultTreeItem>();
|
||||||
item->filename = filename;
|
item->filename = filename;
|
||||||
item->line = Line;
|
item->line = line;
|
||||||
item->start = ch;
|
item->start = ch;
|
||||||
item->len = wordLen;
|
item->len = wordLen;
|
||||||
item->parent = parentItem.get();
|
item->parent = parentItem.get();
|
||||||
item->text = e->document()->getLine(Line-1);
|
item->text = e->lineText(line);
|
||||||
item->text.replace('\t',' ');
|
item->text.replace('\t',' ');
|
||||||
parentItem->results.append(item);
|
parentItem->results.append(item);
|
||||||
return QSynedit::SearchAction::Skip;
|
return QSynedit::SearchAction::Skip;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "qsynedit.h"
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "qt_utils/charsetinfo.h"
|
#include "qt_utils/charsetinfo.h"
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#define SYNEDITSTRINGLIST_H
|
#define SYNEDITSTRINGLIST_H
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "syntaxer/syntaxer.h"
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "exporter.h"
|
#include "exporter.h"
|
||||||
|
#include "../document.h"
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QPalette>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
namespace QSynedit {
|
namespace QSynedit {
|
||||||
|
|
|
@ -18,9 +18,24 @@
|
||||||
#define EXPORTER_H
|
#define EXPORTER_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "../qsynedit.h"
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QMap>
|
||||||
|
#include "qt_utils/utils.h"
|
||||||
|
#include "../types.h"
|
||||||
|
|
||||||
|
|
||||||
namespace QSynedit {
|
namespace QSynedit {
|
||||||
|
class Document;
|
||||||
|
using PDocument = std::shared_ptr<Document>;
|
||||||
|
class Syntaxer;
|
||||||
|
using PSyntaxer = std::shared_ptr<Syntaxer>;
|
||||||
|
class TokenAttribute;
|
||||||
|
using PTokenAttribute = std::shared_ptr<TokenAttribute>;
|
||||||
|
|
||||||
using FormatTokenHandler = std::function<void(PSyntaxer syntaxHighlighter, int line, int column, const QString& token,
|
using FormatTokenHandler = std::function<void(PSyntaxer syntaxHighlighter, int line, int column, const QString& token,
|
||||||
PTokenAttribute& attr)>;
|
PTokenAttribute& attr)>;
|
||||||
class Exporter
|
class Exporter
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "rtfexporter.h"
|
#include "rtfexporter.h"
|
||||||
|
|
||||||
|
#include <QFontMetrics>
|
||||||
namespace QSynedit {
|
namespace QSynedit {
|
||||||
|
|
||||||
RTFExporter::RTFExporter(int tabSize, const QByteArray charset):Exporter(tabSize,charset)
|
RTFExporter::RTFExporter(int tabSize, const QByteArray charset):Exporter(tabSize,charset)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "cppformatter.h"
|
#include "cppformatter.h"
|
||||||
#include "../qsynedit.h"
|
#include "../qsynedit.h"
|
||||||
|
#include "../document.h"
|
||||||
#include "../syntaxer/cpp.h"
|
#include "../syntaxer/cpp.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -18,14 +19,14 @@ namespace QSynedit {
|
||||||
QSynEdit *editor)
|
QSynEdit *editor)
|
||||||
{
|
{
|
||||||
Q_ASSERT(editor!=nullptr);
|
Q_ASSERT(editor!=nullptr);
|
||||||
line = std::min(line, editor->document()->count()+1);
|
line = std::min(line, editor->lineCount()+1);
|
||||||
if (line<=1)
|
if (line<=1)
|
||||||
return 0;
|
return 0;
|
||||||
// find the first non-empty preceeding line
|
// find the first non-empty preceeding line
|
||||||
int startLine = line-1;
|
int startLine = line-1;
|
||||||
QString startLineText;
|
QString startLineText;
|
||||||
while (startLine>=1) {
|
while (startLine>=1) {
|
||||||
startLineText = editor->document()->getLine(startLine-1);
|
startLineText = editor->lineText(startLine);
|
||||||
if (!startLineText.startsWith('#') && !startLineText.trimmed().isEmpty()) {
|
if (!startLineText.startsWith('#') && !startLineText.trimmed().isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,31 +88,31 @@ namespace QSynedit {
|
||||||
// the line the comment beginning , and add 1 additional space
|
// the line the comment beginning , and add 1 additional space
|
||||||
int commentStartLine = findCommentStartLine(startLine-1,editor);
|
int commentStartLine = findCommentStartLine(startLine-1,editor);
|
||||||
SyntaxState range;
|
SyntaxState range;
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(commentStartLine-1))+1;
|
indentSpaces = editor->leftSpaces(editor->lineText(commentStartLine))+1;
|
||||||
range = editor->document()->getSyntaxState(commentStartLine-1);
|
range = editor->document()->getSyntaxState(commentStartLine-1);
|
||||||
} else {
|
} else {
|
||||||
//indents according to the beginning of the comment and 2 additional space
|
//indents according to the beginning of the comment and 2 additional space
|
||||||
int commentStartLine = findCommentStartLine(startLine-1,editor);
|
int commentStartLine = findCommentStartLine(startLine-1,editor);
|
||||||
SyntaxState range;
|
SyntaxState range;
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(commentStartLine-1))+2;
|
indentSpaces = editor->leftSpaces(editor->lineText(commentStartLine))+2;
|
||||||
range = editor->document()->getSyntaxState(commentStartLine-1);
|
range = editor->document()->getSyntaxState(commentStartLine-1);
|
||||||
}
|
}
|
||||||
} else if (rangeAfterFirstToken.lastUnindent.type!=IndentType::None
|
} else if (rangeAfterFirstToken.lastUnindent.type!=IndentType::None
|
||||||
&& firstToken=="}") {
|
&& firstToken=="}") {
|
||||||
IndentInfo matchingIndents = rangeAfterFirstToken.lastUnindent;
|
IndentInfo matchingIndents = rangeAfterFirstToken.lastUnindent;
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line));
|
indentSpaces = editor->leftSpaces(editor->lineText(matchingIndents.line+1));
|
||||||
} else if (firstToken=="{") {
|
} else if (firstToken=="{") {
|
||||||
IndentInfo matchingIndents = rangeAfterFirstToken.getLastIndent();
|
IndentInfo matchingIndents = rangeAfterFirstToken.getLastIndent();
|
||||||
if (matchingIndents.line!=line-1) {
|
if (matchingIndents.line!=line-1) {
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line));
|
indentSpaces = editor->leftSpaces(editor->lineText(matchingIndents.line+1));
|
||||||
} else if (rangeAfterFirstToken.indents.count()>=2){
|
} else if (rangeAfterFirstToken.indents.count()>=2){
|
||||||
IndentInfo info = rangeAfterFirstToken.indents[rangeAfterFirstToken.indents.count()-2];
|
IndentInfo info = rangeAfterFirstToken.indents[rangeAfterFirstToken.indents.count()-2];
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(info.line))+editor->tabSize();
|
indentSpaces = editor->leftSpaces(editor->lineText(info.line+1))+editor->tabSize();
|
||||||
} else
|
} else
|
||||||
indentSpaces = 0;
|
indentSpaces = 0;
|
||||||
} else if (rangePreceeding.getLastIndentType()!=IndentType::None) {
|
} else if (rangePreceeding.getLastIndentType()!=IndentType::None) {
|
||||||
IndentInfo matchingIndents = rangePreceeding.getLastIndent();
|
IndentInfo matchingIndents = rangePreceeding.getLastIndent();
|
||||||
indentSpaces = editor->leftSpaces(editor->document()->getLine(matchingIndents.line))+editor->tabSize();
|
indentSpaces = editor->leftSpaces(editor->lineText(matchingIndents.line+1))+editor->tabSize();
|
||||||
} else {
|
} else {
|
||||||
indentSpaces = 0;
|
indentSpaces = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
*/
|
*/
|
||||||
#include "painter.h"
|
#include "painter.h"
|
||||||
#include "qsynedit.h"
|
#include "qsynedit.h"
|
||||||
|
#include "document.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
#include "syntaxer/syntaxer.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -847,7 +849,7 @@ void QSynEditPainter::paintFoldAttributes()
|
||||||
lastNonBlank = vLine - 1;
|
lastNonBlank = vLine - 1;
|
||||||
while (lastNonBlank + 1 < mEdit->mDocument->count() && mEdit->mDocument->getLine(lastNonBlank).isEmpty())
|
while (lastNonBlank + 1 < mEdit->mDocument->count() && mEdit->mDocument->getLine(lastNonBlank).isEmpty())
|
||||||
lastNonBlank++;
|
lastNonBlank++;
|
||||||
if (lastNonBlank>=mEdit->document()->count())
|
if (lastNonBlank>=mEdit->lineCount())
|
||||||
continue;
|
continue;
|
||||||
lineIndent = mEdit->getLineIndent(mEdit->mDocument->getLine(lastNonBlank));
|
lineIndent = mEdit->getLineIndent(mEdit->mDocument->getLine(lastNonBlank));
|
||||||
int braceLevel = mEdit->mDocument->getSyntaxState(lastNonBlank).braceLevel;
|
int braceLevel = mEdit->mDocument->getSyntaxState(lastNonBlank).braceLevel;
|
||||||
|
@ -1158,9 +1160,7 @@ void QSynEditPainter::paintLines()
|
||||||
tokenLeft+=tokenWidth;
|
tokenLeft+=tokenWidth;
|
||||||
//We don't need to calculate line width,
|
//We don't need to calculate line width,
|
||||||
//So we just quit if already out of the right edge of the editor
|
//So we just quit if already out of the right edge of the editor
|
||||||
if (
|
if (lineWidthValid && (tokenLeft>mRight))
|
||||||
(!calculateGlyphPositions || lineTextChanged)
|
|
||||||
&& (tokenLeft>mRight))
|
|
||||||
break;
|
break;
|
||||||
// Let the highlighter scan the next token.
|
// Let the highlighter scan the next token.
|
||||||
mEdit->mSyntaxer->next();
|
mEdit->mSyntaxer->next();
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "syntaxer/syntaxer.h"
|
|
||||||
#include "gutter.h"
|
|
||||||
|
|
||||||
namespace QSynedit {
|
namespace QSynedit {
|
||||||
struct TokenTextInfo {
|
struct TokenTextInfo {
|
||||||
|
@ -39,6 +37,10 @@ struct TokenBackgroundInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Syntaxer;
|
||||||
|
using PSyntaxer = std::shared_ptr<Syntaxer>;
|
||||||
|
class TokenAttribute;
|
||||||
|
using PTokenAttribute = std::shared_ptr<TokenAttribute>;
|
||||||
class QSynEdit;
|
class QSynEdit;
|
||||||
class QSynEditPainter
|
class QSynEditPainter
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "qsynedit.h"
|
#include "qsynedit.h"
|
||||||
#include "syntaxer/cpp.h"
|
#include "document.h"
|
||||||
|
#include "syntaxer/syntaxer.h""
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -173,6 +174,11 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
||||||
setScrollBars(ScrollStyle::Both);
|
setScrollBars(ScrollStyle::Both);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QSynEdit::lineCount() const
|
||||||
|
{
|
||||||
|
return mDocument->count();
|
||||||
|
}
|
||||||
|
|
||||||
int QSynEdit::displayLineCount() const
|
int QSynEdit::displayLineCount() const
|
||||||
{
|
{
|
||||||
if (mDocument->empty()) {
|
if (mDocument->empty()) {
|
||||||
|
@ -4019,12 +4025,16 @@ void QSynEdit::setTabSize(int newTabSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QSynEdit::tabWidth() const
|
||||||
|
{
|
||||||
|
return mDocument->tabWidth();
|
||||||
|
}
|
||||||
|
|
||||||
EditorOptions QSynEdit::getOptions() const
|
EditorOptions QSynEdit::getOptions() const
|
||||||
{
|
{
|
||||||
return mOptions;
|
return mOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool sameEditorOption(const EditorOptions& value1, const EditorOptions& value2, EditorOption flag) {
|
static bool sameEditorOption(const EditorOptions& value1, const EditorOptions& value2, EditorOption flag) {
|
||||||
return value1.testFlag(flag)==value2.testFlag(flag);
|
return value1.testFlag(flag)==value2.testFlag(flag);
|
||||||
}
|
}
|
||||||
|
@ -4061,6 +4071,11 @@ void QSynEdit::setOptions(const EditorOptions &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QSynEdit::tabSize() const
|
||||||
|
{
|
||||||
|
return mDocument->tabSize();
|
||||||
|
}
|
||||||
|
|
||||||
void QSynEdit::doAddStr(const QString &s)
|
void QSynEdit::doAddStr(const QString &s)
|
||||||
{
|
{
|
||||||
if (mInserting == false && !selAvail()) {
|
if (mInserting == false && !selAvail()) {
|
||||||
|
@ -4656,6 +4671,11 @@ QString QSynEdit::lineText() const
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QSynEdit::lineText(int line) const
|
||||||
|
{
|
||||||
|
return mDocument->getLine(line-1);
|
||||||
|
}
|
||||||
|
|
||||||
void QSynEdit::setLineText(const QString s)
|
void QSynEdit::setLineText(const QString s)
|
||||||
{
|
{
|
||||||
if (mCaretY >= 1 && mCaretY <= mDocument->count())
|
if (mCaretY >= 1 && mCaretY <= mDocument->count())
|
||||||
|
@ -4890,7 +4910,7 @@ void QSynEdit::moveCaretToLineEnd(bool isSelection, bool ensureCaretVisible)
|
||||||
|
|
||||||
void QSynEdit::doGotoBlockStart(bool isSelection)
|
void QSynEdit::doGotoBlockStart(bool isSelection)
|
||||||
{
|
{
|
||||||
if (mCaretY<0 || mCaretY>document()->count())
|
if (mCaretY<0 || mCaretY>lineCount())
|
||||||
return;
|
return;
|
||||||
SyntaxState state = document()->getSyntaxState(mCaretY-1);
|
SyntaxState state = document()->getSyntaxState(mCaretY-1);
|
||||||
//todo: handle block other than {}
|
//todo: handle block other than {}
|
||||||
|
@ -4913,7 +4933,7 @@ void QSynEdit::doGotoBlockStart(bool isSelection)
|
||||||
|
|
||||||
void QSynEdit::doGotoBlockEnd(bool isSelection)
|
void QSynEdit::doGotoBlockEnd(bool isSelection)
|
||||||
{
|
{
|
||||||
if (mCaretY<0 || mCaretY>document()->count())
|
if (mCaretY<0 || mCaretY>lineCount())
|
||||||
return;
|
return;
|
||||||
SyntaxState state = document()->getSyntaxState(mCaretY-1);
|
SyntaxState state = document()->getSyntaxState(mCaretY-1);
|
||||||
//todo: handle block other than {}
|
//todo: handle block other than {}
|
||||||
|
@ -4921,7 +4941,7 @@ void QSynEdit::doGotoBlockEnd(bool isSelection)
|
||||||
doGotoEditorEnd(isSelection);
|
doGotoEditorEnd(isSelection);
|
||||||
} else if (document()->blockEnded(mCaretY-1)==0){
|
} else if (document()->blockEnded(mCaretY-1)==0){
|
||||||
int line=mCaretY+1;
|
int line=mCaretY+1;
|
||||||
while (line<=document()->count()) {
|
while (line<=lineCount()) {
|
||||||
if (document()->blockEnded(line-1)>document()->blockStarted(line-1)) {
|
if (document()->blockEnded(line-1)>document()->blockStarted(line-1)) {
|
||||||
moveCaretVert(line-1-mCaretY, isSelection);
|
moveCaretVert(line-1-mCaretY, isSelection);
|
||||||
moveCaretToLineStart(isSelection);
|
moveCaretToLineStart(isSelection);
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "gutter.h"
|
#include "gutter.h"
|
||||||
#include "codefolding.h"
|
#include "codefolding.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "document.h"
|
|
||||||
#include "keystrokes.h"
|
#include "keystrokes.h"
|
||||||
#include "searcher/baseseacher.h"
|
#include "searcher/baseseacher.h"
|
||||||
#include "formatter/formatter.h"
|
#include "formatter/formatter.h"
|
||||||
|
@ -85,11 +84,11 @@ enum class EditorOption {
|
||||||
AutoHideScrollbars = 0x00000200, //if enabled, then the scrollbars will only show when necessary. If you have ScrollPastEOL, then it the horizontal bar will always be there (it uses MaxLength instead)
|
AutoHideScrollbars = 0x00000200, //if enabled, then the scrollbars will only show when necessary. If you have ScrollPastEOL, then it the horizontal bar will always be there (it uses MaxLength instead)
|
||||||
KeepCaretX = 0x00000400 , //When moving through lines w/o Cursor Past EOL, keeps the X position of the cursor
|
KeepCaretX = 0x00000400 , //When moving through lines w/o Cursor Past EOL, keeps the X position of the cursor
|
||||||
RightMouseMovesCursor= 0x00000800, //When clicking with the right mouse for a popup menu, move the cursor to that location
|
RightMouseMovesCursor= 0x00000800, //When clicking with the right mouse for a popup menu, move the cursor to that location
|
||||||
// eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less
|
// ScrollByOneLess = 0x00001000, //Forces scrolling to be one less
|
||||||
ScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker
|
ScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker
|
||||||
ScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line
|
ScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line
|
||||||
InvertMouseScroll = 0x00008000, //Shows the special Characters
|
InvertMouseScroll = 0x00008000, //Shows the special Characters
|
||||||
// eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event
|
// SpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event
|
||||||
TabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
TabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
||||||
TabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters
|
TabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters
|
||||||
ShowRainbowColor = 0x00080000,
|
ShowRainbowColor = 0x00080000,
|
||||||
|
@ -135,6 +134,18 @@ struct GlyphPostionsListCache {
|
||||||
class QSynEdit;
|
class QSynEdit;
|
||||||
using PSynEdit = std::shared_ptr<QSynEdit>;
|
using PSynEdit = std::shared_ptr<QSynEdit>;
|
||||||
|
|
||||||
|
class TokenAttribute;
|
||||||
|
using PTokenAttribute = std::shared_ptr<TokenAttribute>;
|
||||||
|
class Document;
|
||||||
|
using PDocument = std::shared_ptr<Document>;
|
||||||
|
class SyntaxState;
|
||||||
|
class Syntaxer;
|
||||||
|
using PSyntaxer = std::shared_ptr<Syntaxer>;
|
||||||
|
class UndoList;
|
||||||
|
class RedoList;
|
||||||
|
using PUndoList = std::shared_ptr<UndoList>;
|
||||||
|
using PRedoList = std::shared_ptr<RedoList>;
|
||||||
|
|
||||||
class QSynEdit : public QAbstractScrollArea
|
class QSynEdit : public QAbstractScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -143,6 +154,8 @@ public:
|
||||||
QSynEdit(const QSynEdit&)=delete;
|
QSynEdit(const QSynEdit&)=delete;
|
||||||
QSynEdit& operator=(const QSynEdit&)=delete;
|
QSynEdit& operator=(const QSynEdit&)=delete;
|
||||||
|
|
||||||
|
|
||||||
|
int lineCount() const;
|
||||||
/**
|
/**
|
||||||
* Returns how many rows are there in the editor
|
* Returns how many rows are there in the editor
|
||||||
* @return
|
* @return
|
||||||
|
@ -361,9 +374,7 @@ public:
|
||||||
|
|
||||||
QString displayLineText();
|
QString displayLineText();
|
||||||
QString lineText() const;
|
QString lineText() const;
|
||||||
QString lineText(int line) const {
|
QString lineText(int line) const;
|
||||||
return mDocument->getLine(line-1);
|
|
||||||
}
|
|
||||||
void setLineText(const QString s);
|
void setLineText(const QString s);
|
||||||
|
|
||||||
const PDocument& document() const;
|
const PDocument& document() const;
|
||||||
|
@ -380,9 +391,9 @@ public:
|
||||||
EditorOptions getOptions() const;
|
EditorOptions getOptions() const;
|
||||||
void setOptions(const EditorOptions &Value);
|
void setOptions(const EditorOptions &Value);
|
||||||
|
|
||||||
int tabSize() const { return mDocument->tabSize(); }
|
int tabSize() const;
|
||||||
void setTabSize(int tabSize);
|
void setTabSize(int tabSize);
|
||||||
int tabWidth() const { return mDocument->tabWidth(); }
|
int tabWidth() const;
|
||||||
|
|
||||||
QColor caretColor() const;
|
QColor caretColor() const;
|
||||||
void setCaretColor(const QColor &caretColor);
|
void setCaretColor(const QColor &caretColor);
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
TokenType mTokenType;
|
TokenType mTokenType;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<TokenAttribute> PTokenAttribute;
|
using PTokenAttribute = std::shared_ptr<TokenAttribute> ;
|
||||||
|
|
||||||
class Syntaxer {
|
class Syntaxer {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue