diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 47a6cde7..c52859bb 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -69,6 +69,7 @@ SOURCES += \ utils.cpp \ widgets/coloredit.cpp \ widgets/consolewidget.cpp \ + widgets/elidedlabel.cpp \ widgets/issuestable.cpp \ widgets/qconsole.cpp \ widgets/qpatchedcombobox.cpp \ @@ -134,6 +135,7 @@ HEADERS += \ common.h \ widgets/coloredit.h \ widgets/consolewidget.h \ + widgets/elidedlabel.h \ widgets/issuestable.h \ widgets/qconsole.h \ widgets/qpatchedcombobox.h \ diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index cae802fc..e04f6805 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -1620,6 +1620,7 @@ static int getWatchIndex(WatchVar* var, const QList list) { return i; } } + return -1; } QModelIndex WatchModel::parent(const QModelIndex &index) const diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 86c75917..f4c557f2 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -741,7 +741,7 @@ void Editor::onStatusChanged(SynStatusChanges changes) pMainWindow->checkSyntaxInBack(this); } mLineCount = lines()->count(); -// if (not (scOpenFile in Changes)) and (fText.Lines.Count <> fLineCount) + // if (not (scOpenFile in Changes)) and (fText.Lines.Count <> fLineCount) // and (fText.Lines.Count <> 0) and ((fLineCount>0) or (fText.Lines.Count>1)) then begin // if devCodeCompletion.Enabled // and SameStr(mainForm.ClassBrowser.CurrentFile,FileName) // Don't reparse twice diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 3f232f08..075805b4 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -43,15 +43,12 @@ MainWindow::MainWindow(QWidget *parent) mFileInfoStatus=new QLabel(); mFileEncodingStatus = new QLabel(); mFileModeStatus = new QLabel(); - mParsingInfoStatus = new QLabel(); mFileInfoStatus->setStyleSheet("margin-left:10px; margin-right:10px"); mFileEncodingStatus->setStyleSheet("margin-left:10px; margin-right:10px"); mFileModeStatus->setStyleSheet("margin-left:10px; margin-right:10px"); - mParsingInfoStatus->setStyleSheet("margin-left:10px; margin-right:10px"); - ui->statusbar->addWidget(mFileInfoStatus); - ui->statusbar->addWidget(mFileEncodingStatus); - ui->statusbar->addWidget(mFileModeStatus); - ui->statusbar->addWidget(mParsingInfoStatus); + ui->statusbar->insertPermanentWidget(0,mFileModeStatus); + ui->statusbar->insertPermanentWidget(0,mFileEncodingStatus); + ui->statusbar->insertPermanentWidget(0,mFileInfoStatus); mEditorList = new EditorList(ui->EditorTabsLeft, ui->EditorTabsRight, ui->splitterEditorPanel, @@ -463,7 +460,7 @@ void MainWindow::updateForStatusbarModeInfo() void MainWindow::updateStatusBarForParsing(const QString &s) { - mParsingInfoStatus->setText(s); + ui->statusbar->showMessage(s); } void MainWindow::openFiles(const QStringList &files) diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 1e9e1b83..f8d63e0a 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -5,6 +5,7 @@ #include "common.h" #include "widgets/searchresultview.h" #include "widgets/classbrowser.h" +#include "widgets/elidedlabel.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -220,7 +221,6 @@ private: QLabel *mFileInfoStatus; QLabel *mFileEncodingStatus; QLabel *mFileModeStatus; - QLabel *mParsingInfoStatus; QMenu *mMenuEncoding; QMenu *mMenuEncodingList; QMenu *mMenuRecentFiles; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 5f664bc1..8acb543f 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -77,7 +77,7 @@ - 1 + 0 0 @@ -85,7 +85,7 @@ QTabWidget::West - 2 + 1 true @@ -168,7 +168,7 @@ - 2 + 1 0 @@ -190,6 +190,12 @@ + + + 0 + 0 + + Qt::Horizontal @@ -197,6 +203,12 @@ 1 + + + 0 + 0 + + -1 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index a57da2a0..4cb566a1 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2929,15 +2929,13 @@ void CppParser::internalParse(const QString &fileName) // mPreprocessor.setIncludePaths(mIncludePaths); // mPreprocessor.setProjectIncludePaths(mProjectIncludePaths); mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders); - logToFile("preprocess + 1:","f:\\log.txt"); mPreprocessor.preprocess(fileName, buffer); - StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); + // Tokenize the preprocessed buffer file mTokenizer.tokenize(mPreprocessor.result()); if (mTokenizer.tokenCount() == 0) return; - mTokenizer.dumpTokens("f:\\tokens.txt"); // Process the token list mCurrentScope.clear(); @@ -2952,10 +2950,16 @@ void CppParser::internalParse(const QString &fileName) if (!handleStatement()) break; } -// mPreprocessor.dumpDefinesTo("f:\\defines.txt"); -// mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); +//#ifdef QT_DEBUG + StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt"); + mPreprocessor.dumpDefinesTo("f:\\defines.txt"); + mPreprocessor.dumpIncludesListTo("f:\\includes.txt"); mStatementList.dump("f:\\stats.txt"); -// mStatementList.dumpAll("f:\\all-stats.txt"); + mTokenizer.dumpTokens("f:\\tokens.txt"); +//#endif +#ifdef QT_DEBUG + mStatementList.dumpAll("f:\\all-stats.txt"); +#endif } } @@ -3120,8 +3124,6 @@ PStatement CppParser::doFindStatementInScope(const QString &name, const QString void CppParser::internalInvalidateFile(const QString &fileName) { - logToFile(QString("invalidate %1 start:").arg(fileName),"f:\\log.txt"); - if (fileName.isEmpty()) return; @@ -3140,10 +3142,8 @@ void CppParser::internalInvalidateFile(const QString &fileName) mNamespaces.remove(key); } } - logToFile(QString("invalidate %1 1:").arg(fileName),"f:\\log.txt"); // delete it from scannedfiles mPreprocessor.scannedFiles().remove(fileName); - logToFile(QString("invalidate %1 2:").arg(fileName),"f:\\log.txt"); // remove its include files list PFileIncludes p = findFileIncludes(fileName, true); @@ -3160,12 +3160,10 @@ void CppParser::internalInvalidateFile(const QString &fileName) statement->hasDefinition = false; } } - logToFile(QString("invalidate %1 3:").arg(fileName),"f:\\log.txt"); for (PStatement statement:p->declaredStatements) { mStatementList.deleteStatement(statement); } - logToFile(QString("invalidate %1 4:").arg(fileName),"f:\\log.txt"); //p->declaredStatements.clear(); //p->statements.clear(); @@ -3173,15 +3171,11 @@ void CppParser::internalInvalidateFile(const QString &fileName) //p->dependedFiles.clear(); //p->dependingFiles.clear(); } - logToFile(QString("invalidate %1 10:").arg(fileName),"f:\\log.txt"); - - logToFile(QString("invalidate %1 end:").arg(fileName),"f:\\log.txt"); - } void CppParser::internalInvalidateFiles(const QSet &files) { - for (QString file:files) + for (const QString& file:files) internalInvalidateFile(file); } diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index bc4330c8..12af512c 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -215,7 +215,6 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const QString CppPreprocessor::getNextPreprocessor() { - logToFile("next preprocessor:","f:\\log.txt"); skipToPreprocessor(); // skip until # at start of line int preProcFrom = mIndex; if (preProcFrom >= mBuffer.count()) @@ -229,7 +228,7 @@ QString CppPreprocessor::getNextPreprocessor() // Assemble whole line, convert newlines to space QString result; for (int i=preProcFrom;i<=preProcTo;i++) { - if (mBuffer[i].endsWith('/')) { + if (mBuffer[i].endsWith('\\')) { result+=mBuffer[i].mid(0,mBuffer[i].size()-1)+' '; } else { result+=mBuffer[i]+' '; @@ -736,67 +735,112 @@ void CppPreprocessor::parseArgs(PDefine define) define->argList[i]=define->argList[i].trimmed(); define->argUsed.append(false); } - QStringList tokens = tokenizeValue(define->value); + QList tokens = tokenizeValue(define->value); QString formatStr = ""; - QString lastToken = "##"; - for (QString token: tokens) { - if (lastToken != "##" && token!="##") { - formatStr += ' '; - } - int index = define->argList.indexOf(token); - if (index>=0) { - define->argUsed[index] = true; - if (lastToken == "#") { - formatStr+= "\"%"+QString("%1").arg(index+1)+"\""; - } else { - formatStr+= "%"+QString("%1").arg(index+1); + DefineArgTokenType lastTokenType=DefineArgTokenType::Other; + int index; + for (PDefineArgToken token: tokens) { + switch(token->type) { + case DefineArgTokenType::Identifier: + index = define->argList.indexOf(token->value); + if (index>=0) { + define->argUsed[index] = true; + if (lastTokenType == DefineArgTokenType::Sharp) { + formatStr+= "\"%"+QString("%1").arg(index+1)+"\""; + break; + } else { + formatStr+= "%"+QString("%1").arg(index+1); + break; + } } - } else if (token == "%"){ - formatStr+="%%"; - } else if (token!="##" && token!="#"){ - formatStr+=token; + formatStr += token->value; + break; + case DefineArgTokenType::DSharp: + case DefineArgTokenType::Sharp: + break; + case DefineArgTokenType::Space: + case DefineArgTokenType::Symbol: + formatStr+=token->value; + break; } - lastToken = token; + lastTokenType = token->type; } define->formatValue = formatStr; } -QStringList CppPreprocessor::tokenizeValue(const QString &value) +QList CppPreprocessor::tokenizeValue(const QString &value) { int i=0; - QString token; - QStringList tokens; + PDefineArgToken token = std::make_shared(); + token->type = DefineArgTokenType::Other; + QList tokens; + bool skipSpaces=false; while (itype==DefineArgTokenType::Other) { + token->value = " "; + token->type = DefineArgTokenType::Space; + } else if (token->type!=DefineArgTokenType::Space) { tokens.append(token); - token = ""; + token = std::make_shared(); + token->value = " "; + token->type = DefineArgTokenType::Space; + } i++; } else if (ch=='#') { - if(!token.isEmpty()) + if (token->type!=DefineArgTokenType::Other + && token->type!=DefineArgTokenType::Space) { tokens.append(token); - token = ""; + token = std::make_shared(); + } if ((i+1value = "##"; + token->type = DefineArgTokenType::DSharp; } else { i++; - tokens.append("#"); + token->value = "#"; + token->type = DefineArgTokenType::Sharp; } + skipSpaces=true; + tokens.append(token); + token = std::make_shared(); + token->value = ""; + token->type = DefineArgTokenType::Other; } else if (isWordChar(ch)) { - token+=ch; + if (token->type==DefineArgTokenType::Other) { + token->value = ch ; + token->type = DefineArgTokenType::Identifier; + } else if (token->type==DefineArgTokenType::Identifier) { + token->value+=ch; + } else if (skipSpaces && token->type==DefineArgTokenType::Space) { + //dont use space; + token->value = ch ; + token->type = DefineArgTokenType::Identifier; + } else { + tokens.append(token); + token = std::make_shared(); + token->value = ch ; + token->type = DefineArgTokenType::Identifier; + } + skipSpaces=false; i++; } else { - if(!token.isEmpty()) + if (skipSpaces && token->type==DefineArgTokenType::Space) { + //dont use space; + } else if (token->type!=DefineArgTokenType::Other) { tokens.append(token); - token = ""; - tokens.append(ch); + token = std::make_shared(); + } + skipSpaces=false; + token->value = ch ; + token->type = DefineArgTokenType::Symbol; i++; } } - if(!token.isEmpty()) + if(token->type!=DefineArgTokenType::Other) tokens.append(token); return tokens; } @@ -901,7 +945,11 @@ QStringList CppPreprocessor::removeComments(const QStringList &text) ch = line[pos]; s+=ch; } + break; + default: + s+=ch; } + break; default: s+=ch; } @@ -940,17 +988,13 @@ void CppPreprocessor::skipToEndOfPreprocessor() void CppPreprocessor::skipToPreprocessor() { - logToFile("skip:","f:\\log.txt"); // Increment until a line begins with a # while ((mIndex < mBuffer.count()) && !mBuffer[mIndex].startsWith('#')) { - logToFile(QString("tt %1 tt").arg(mIndex),"f:\\log.txt"); - logToFile(QString("tt %1 tt").arg(mBuffer[mIndex]),"f:\\log.txt"); -// if (getCurrentBranch()) // if not skipping, expand current macros -// mResult.append(expandMacros(mBuffer[mIndex],1)); -// else // If skipping due to a failed branch, clear line -// mResult.append(""); - mResult.append(mBuffer[mIndex]); + if (getCurrentBranch()) // if not skipping, expand current macros + mResult.append(expandMacros(mBuffer[mIndex],1)); + else // If skipping due to a failed branch, clear line + mResult.append(""); mIndex++; } } @@ -1163,11 +1207,8 @@ QString CppPreprocessor::expandFunction(PDefine define, QString args) { // Replace function by this string QString result = define->formatValue; - if (args.startsWith('(')) { - args.remove(0,1); - } - if (args.endsWith(')')) { - args.remove(args.length()-1,1); + if (args.startsWith('(') && args.endsWith(')')) { + args = args.mid(1,args.length()-2); } QStringList argValues = args.split(","); diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 9c5e85b2..660143e9 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -6,6 +6,19 @@ #include "parserutils.h" #define MAX_DEFINE_EXPAND_DEPTH 20 +enum class DefineArgTokenType{ + Symbol, + Identifier, + Space, + Sharp, + DSharp, + Other +}; +struct DefineArgToken { + QString value; + DefineArgTokenType type; +}; +using PDefineArgToken = std::shared_ptr; struct ParsedFile { int index; // 0-based for programming convenience @@ -91,7 +104,7 @@ private: void addDefinesInFile(const QString& fileName); void parseArgs(PDefine define); - QStringList tokenizeValue(const QString& value); + QList tokenizeValue(const QString& value); QStringList removeComments(const QStringList& text); /* diff --git a/RedPandaIDE/parser/statementmodel.cpp b/RedPandaIDE/parser/statementmodel.cpp index 51bed8ce..b49cbba2 100644 --- a/RedPandaIDE/parser/statementmodel.cpp +++ b/RedPandaIDE/parser/statementmodel.cpp @@ -114,7 +114,6 @@ int StatementModel::deleteMember(StatementMap &map, PStatement statement) { if (!statement) return 0; - //return map.remove(statement->command,statement); return map.remove(statement->command,statement); } diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 1ce79309..5fb67a75 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) @@ -1291,7 +1292,7 @@ void SynEdit::doSelectAll() } setCaretAndSelection(caretXY(), BufferCoord{1, 1}, LastPt); // Selection should have changed... - statusChanged(SynStatusChange::scSelection); + emit statusChanged(SynStatusChange::scSelection); } void SynEdit::doComment() @@ -2494,7 +2495,7 @@ void SynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle) } } -void SynEdit::scrollWindow(int dx, int dy) +void SynEdit::scrollWindow(int , int ) { // int nx = horizontalScrollBar()->value()+dx; // int ny = verticalScrollBar()->value()+dy; @@ -3886,6 +3887,7 @@ QString SynEdit::selText() } } } + return ""; } QString SynEdit::lineBreak() @@ -4213,7 +4215,6 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS searchEngine->setOptions(sOptions); searchEngine->setPattern(sSearch); // search while the current search position is inside of the search range - int nReplaceLen = 0; bool dobatchReplace = false; doOnPaintTransient(SynTransientType::ttBefore); { @@ -5162,7 +5163,7 @@ void SynEdit::paintEvent(QPaintEvent *event) paintCaret(painter, rcCaret); } -void SynEdit::resizeEvent(QResizeEvent *) +void SynEdit::resizeEvent(QResizeEvent *e) { //resize the cache image std::shared_ptr image = std::make_shared(clientWidth(),clientHeight(), @@ -5402,11 +5403,11 @@ void SynEdit::wheelEvent(QWheelEvent *event) bool SynEdit::viewportEvent(QEvent * event) { - switch (event->type()) { - case QEvent::Resize: - sizeOrFontChanged(false); - break; - } +// switch (event->type()) { +// case QEvent::Resize: +// sizeOrFontChanged(false); +// break; +// } return QAbstractScrollArea::viewportEvent(event); } diff --git a/RedPandaIDE/qsynedit/exporter/synexporter.cpp b/RedPandaIDE/qsynedit/exporter/synexporter.cpp index a0b48ae9..578c6e96 100644 --- a/RedPandaIDE/qsynedit/exporter/synexporter.cpp +++ b/RedPandaIDE/qsynedit/exporter/synexporter.cpp @@ -378,4 +378,5 @@ QString SynExporter::lineBreak() case FileEndingType::Mac: return "\r"; } + return "\n"; }