From 83116306a957cb7662a8f90dfe4d5eff853874de Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Mon, 16 Aug 2021 23:17:48 +0800 Subject: [PATCH] work save --- RedPandaIDE/colorscheme.cpp | 4 +-- RedPandaIDE/debugger.cpp | 16 +++++----- RedPandaIDE/editorlist.cpp | 1 - RedPandaIDE/mainwindow.cpp | 2 +- RedPandaIDE/parser/cppparser.cpp | 7 ++--- RedPandaIDE/parser/cpptokenizer.cpp | 31 +++++++++---------- RedPandaIDE/parser/parserutils.cpp | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 12 +++---- RedPandaIDE/qsynedit/TextBuffer.cpp | 1 + RedPandaIDE/qsynedit/TextPainter.cpp | 4 +-- RedPandaIDE/qsynedit/highlighter/asm.cpp | 6 ++-- RedPandaIDE/qsynedit/highlighter/cpp.cpp | 6 ++-- .../environmentappearencewidget.cpp | 2 +- RedPandaIDE/utils.cpp | 2 +- RedPandaIDE/utils.h | 2 -- RedPandaIDE/widgets/qconsole.cpp | 8 ++--- 16 files changed, 50 insertions(+), 55 deletions(-) diff --git a/RedPandaIDE/colorscheme.cpp b/RedPandaIDE/colorscheme.cpp index 349c8bc3..7098fc65 100644 --- a/RedPandaIDE/colorscheme.cpp +++ b/RedPandaIDE/colorscheme.cpp @@ -598,8 +598,8 @@ PColorSchemeItem ColorManager::getItem(const QString &schemeName, const QString bool ColorManager::isValidName(const QString &name) { for (QChar ch:name) { - if (!((ch == ' ') or (ch>='a' && ch<='z') or (ch>='A' && ch <= 'Z') - or (ch>='0' && ch<='9') or (ch == '-') )) + if (!((ch == ' ') || (ch>='a' && ch<='z') || (ch>='A' && ch <= 'Z') + || (ch>='0' && ch<='9') || (ch == '-') )) return false; } return true; diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index b416d8de..5d88419b 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -707,10 +707,10 @@ AnnotationType DebugReader::getNextAnnotation() QString DebugReader::getNextFilledLine() { // Walk up to an enter sequence - while (mIndex=mOutput.length()) return ""; // Skip ONE enter sequence (CRLF, CR, LF, etc.) - if ((mOutput[mIndex] == 13) && (mOutput[mIndex] == 10)) // DOS + if ((mOutput[mIndex] == '\r') && (mOutput[mIndex] == '\n')) // DOS mIndex+=2; - else if (mOutput[mIndex] == 13) // UNIX + else if (mOutput[mIndex] == '\r') // UNIX mIndex++; - else if (mOutput[mIndex] == 10) // MAC + else if (mOutput[mIndex] == '\n') // MAC mIndex++; // Return next line return getRemainingLine(); @@ -756,7 +756,7 @@ QString DebugReader::getRemainingLine() QString Result; // Return part of line still ahead of us - while (mIndextxtLocals()->document()->lineCount()>0) { + if (nobreakLine && pMainWindow->txtLocals()->document()->lineCount()>0) { emit addLocalWithoutLinebreak(s); } else { emit addLocalWithLinebreak(s); diff --git a/RedPandaIDE/editorlist.cpp b/RedPandaIDE/editorlist.cpp index 0e987f15..2de955c1 100644 --- a/RedPandaIDE/editorlist.cpp +++ b/RedPandaIDE/editorlist.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include "settings.h" diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 87c31809..fb523d90 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -376,7 +376,7 @@ void MainWindow::rebuildOpenedFileHisotryMenu() for (QString filename: pSettings->history().openedFiles()) { QAction* action = new QAction(); action->setText(filename); - connect(action, &QAction::triggered, [=,this](bool checked = false){ + connect(action, &QAction::triggered, [filename,this](bool checked = false){ this->openFile(filename); }); mRecentFileActions.append(action); diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 766605d2..7abfe280 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -564,12 +564,9 @@ PStatement CppParser::doFindStatementInScope(const QString &name, const QString if (statementMap.isEmpty()) return PStatement(); - PStatementList statementList = statementMap.values(name,PStatementList()); + QList statementList = statementMap.values(name); - if (!statementList) - return PStatement(); - - for (PStatement statement: *statementList) { + for (PStatement statement: statementList) { if (statement->kind == kind && statement->noNameArgs == noNameArgs) { return statement; } diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index 17726ed3..14df0b84 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -23,7 +23,6 @@ void CppTokenizer::tokenize(const QStringList &buffer) if (mBuffer.isEmpty()) return; mBufferStr = mBuffer[0]; - int i=1; for (int i=1;i'))) { // skip '.' and '->' - while ( !( *mCurrent == '\0' + while ( !( *mCurrent == 0 || *mCurrent == '(' || *mCurrent == ';' || *mCurrent == '{' @@ -141,7 +140,7 @@ QString CppTokenizer::getNextToken(bool bSkipParenthesis, bool bSkipArray, bool bool done = false; while (true) { skipToNextToken(); - if (*mCurrent == '\0') + if (*mCurrent == 0) break; if (isPreprocessor()) { countLines(); @@ -172,7 +171,7 @@ QString CppTokenizer::getNextToken(bool bSkipParenthesis, bool bSkipArray, bool done = (result != ""); } else { switch((*mCurrent).unicode()) { - case '\0': + case 0: done = true; break; case '/': @@ -422,7 +421,7 @@ void CppTokenizer::skipAssignment() || *mCurrent ==';' || *mCurrent ==')' || *mCurrent =='}' - || *mCurrent =='\0') + || *mCurrent ==0) break; } } @@ -430,13 +429,13 @@ void CppTokenizer::skipAssignment() void CppTokenizer::skipDoubleQuotes() { mCurrent++; - while (!(*mCurrent=='"' || *mCurrent == '\0')) { + while (!(*mCurrent=='"' || *mCurrent == 0)) { if (*mCurrent == '\\') mCurrent+=2; // skip escaped char else mCurrent++; } - if (*mCurrent!='\0') { + if (*mCurrent!=0) { mCurrent++; } } @@ -444,7 +443,7 @@ void CppTokenizer::skipDoubleQuotes() void CppTokenizer::skipPair(const QChar &cStart, const QChar cEnd, const QSet& failChars) { mCurrent++; - while (*mCurrent != '\0') { + while (*mCurrent != 0) { if ((*mCurrent == '(') && !failChars.contains('(')) { skipPair('(', ')', failChars); } else if ((*mCurrent == '[') && !failChars.contains('[')) { @@ -493,25 +492,25 @@ void CppTokenizer::skipRawString() noEscape = false; break; } - if (*mCurrent == '\0') + if (*mCurrent == 0) break; if ((*mCurrent == '"') && !noEscape) break; } - if (*mCurrent!='\0') + if (*mCurrent!=0) mCurrent++; } void CppTokenizer::skipSingleQuote() { mCurrent++; - while (!(*mCurrent=='\'' || *mCurrent == '\0')) { + while (!(*mCurrent=='\'' || *mCurrent == 0)) { if (*mCurrent == '\\') mCurrent+=2; // skip escaped char else mCurrent++; } - if (*mCurrent!='\0') { + if (*mCurrent!=0) { mCurrent++; } } @@ -543,10 +542,10 @@ void CppTokenizer::skipTemplateArgs() void CppTokenizer::skipToEOL() { while (true) { - while (!isLineChar(*mCurrent) && (*mCurrent!='\0')) { + while (!isLineChar(*mCurrent) && (*mCurrent!=0)) { mCurrent++; } - if (*mCurrent=='\0') + if (*mCurrent==0) return; bool splitLine = (*(mCurrent - 1) == '\\'); @@ -554,7 +553,7 @@ void CppTokenizer::skipToEOL() while (isLineChar(*mCurrent)) mCurrent++; - if (!splitLine || *mCurrent=='\0') + if (!splitLine || *mCurrent==0) break; } } diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index 611893c9..8ae73591 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -272,6 +272,7 @@ QString getHeaderFileName(const QString &relativeTo, const QString &line, } } } + return result; } QString getLocalHeaderFileName(const QString &relativeTo, const QString &fileName) diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index f433435e..eabfe12f 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -453,7 +453,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint) if (Test == Brackets[i]) { // this is the bracket, get the matching one and the direction BracketInc = Brackets[i]; - BracketDec = Brackets[i xor 1]; // 0 -> 1, 1 -> 0, ... + BracketDec = Brackets[i ^ 1]; // 0 -> 1, 1 -> 0, ... // search for the matching bracket (that is until NumBrackets = 0) NumBrackets = 1; if (i%2==1) { @@ -602,16 +602,16 @@ DisplayCoord SynEdit::pixelsToNearestRowColumn(int aX, int aY) const aY = 0; } return { - .Column = std::max(1, (int)(leftChar() + round(f))), - .Row = std::max(1, mTopLine + (aY / mTextHeight)) + std::max(1, (int)(leftChar() + round(f))), + std::max(1, mTopLine + (aY / mTextHeight)) }; } DisplayCoord SynEdit::pixelsToRowColumn(int aX, int aY) const { return { - .Column = std::max(1, mLeftChar + ((aX - mGutterWidth - 2) / mCharWidth)), - .Row = std::max(1, mTopLine + (aY / mTextHeight)) + std::max(1, mLeftChar + ((aX - mGutterWidth - 2) / mCharWidth)), + std::max(1, mTopLine + (aY / mTextHeight)) }; } @@ -1223,7 +1223,7 @@ BufferCoord SynEdit::PrevWordPosEx(const BufferCoord &XY) int CX = XY.Char; int CY = XY.Line; // valid line? - if ((CY >= 1) and (CY <= mLines->count())) { + if ((CY >= 1) && (CY <= mLines->count())) { QString Line = mLines->getString(CY - 1); CX = std::min(CX, Line.length()); if (CX <= 1) { diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index 410830eb..decd8d56 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -100,6 +100,7 @@ QString SynEditStringList::lineBreak() case FileEndingType::Mac: return "\r"; } + return "\n"; } SynRangeState SynEditStringList::ranges(int Index) diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp index a270ab14..5cca71df 100644 --- a/RedPandaIDE/qsynedit/TextPainter.cpp +++ b/RedPandaIDE/qsynedit/TextPainter.cpp @@ -307,7 +307,7 @@ void SynEditTextPainter::ComputeSelectionInfo() // intersection with the area to be painted. if (bAnySelection) { // Don't care if the selection is not visible. - bAnySelection = (vEnd.Line >= vFirstLine) and (vStart.Line <= vLastLine); + bAnySelection = (vEnd.Line >= vFirstLine) && (vStart.Line <= vLastLine); if (bAnySelection) { // Transform the selection from text space into screen space vSelStart = edit->bufferToDisplayPos(vStart); @@ -448,7 +448,7 @@ void SynEditTextPainter::PaintHighlightToken(bool bFillToEOL) bU1 = (nC1 < nLineSelStart); bSel = (nC1 < nLineSelEnd) && (nC2 >= nLineSelStart); bU2 = (nC2 >= nLineSelEnd); - bComplexToken = bSel && (bU1 or bU2); + bComplexToken = bSel && (bU1 || bU2); } else { bSel = bLineSelected; bComplexToken = false; diff --git a/RedPandaIDE/qsynedit/highlighter/asm.cpp b/RedPandaIDE/qsynedit/highlighter/asm.cpp index 635d5735..694aac12 100644 --- a/RedPandaIDE/qsynedit/highlighter/asm.cpp +++ b/RedPandaIDE/qsynedit/highlighter/asm.cpp @@ -74,7 +74,7 @@ void SynEditASMHighlighter::CRProc() { mTokenID = TokenKind::Space; mRun++; - if (mLine[mRun] == 10) + if (mLine[mRun] == '\n') mRun++; } @@ -283,10 +283,10 @@ void SynEditASMHighlighter::next() case 0: NullProc(); break; - case 10: + case '\n': LFProc(); break; - case 13: + case '\r': CRProc(); break; case '\"': diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.cpp b/RedPandaIDE/qsynedit/highlighter/cpp.cpp index 49c3d532..3a6b84ad 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.cpp +++ b/RedPandaIDE/qsynedit/highlighter/cpp.cpp @@ -307,7 +307,7 @@ void SynEditCppHighlighter::ansiCProc() } else if (mRange.state == RangeState::rsAnsiCAsmBlock){ mRange.state = RangeState::rsAsmBlock; } else if (mRange.state == RangeState::rsDirectiveComment && - mLine[mRun] != 0 && mLine[mRun]!=13 && mLine[mRun]!=10) { + mLine[mRun] != 0 && mLine[mRun]!='\r' && mLine[mRun]!='\n') { mRange.state = RangeState::rsMultiLineDirective; } else { mRange.state = RangeState::rsUnknown; @@ -680,7 +680,7 @@ void SynEditCppHighlighter::numberProc() case 'e': case 'E': if (mTokenId!=TokenKind::Hex) { - if (mLine[mRun-1]>='0' || mLine[mRun-1]<=9 ) {//exponent + if (mLine[mRun-1]>='0' || mLine[mRun-1]<='9' ) {//exponent for (int i=idx1;i=0 && mLine[mRun+1]<=9) { + } else if (mLine[mRun+1]>=0 && mLine[mRun+1]<='9') { numberProc(); } else { mRun+=1; diff --git a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp index 4cb5b85d..d784274a 100644 --- a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp @@ -20,7 +20,7 @@ EnvironmentAppearenceWidget::EnvironmentAppearenceWidget(const QString& name, co ui->cbTheme->addItem(name); } ui->cbLanguage->addItem("English","en"); - ui->cbLanguage->addItem("简体中文","zh_CN"); + ui->cbLanguage->addItem(tr("Simplified Chinese"),"zh_CN"); } EnvironmentAppearenceWidget::~EnvironmentAppearenceWidget() diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 264b688a..3bade542 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -115,7 +115,7 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const bool isNonPrintableAsciiChar(char ch) { - return (ch<=32) and (ch>=0); + return (ch<=32) && (ch>=0); } bool fileExists(const QString &file) diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index 1140b3a3..8ac7f271 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -9,8 +9,6 @@ #include class QByteArray; -class QString; -class QStringList; class QTextStream; class QTextCodec; diff --git a/RedPandaIDE/widgets/qconsole.cpp b/RedPandaIDE/widgets/qconsole.cpp index 0c712c25..e3233701 100644 --- a/RedPandaIDE/widgets/qconsole.cpp +++ b/RedPandaIDE/widgets/qconsole.cpp @@ -252,8 +252,8 @@ void QConsole::paintRows(QPainter &painter, int row1, int row2) RowColumn selBeginRC = mContents.lineCharToRowColumn(selectionBegin()); RowColumn selEndRC = mContents.lineCharToRowColumn(selectionEnd()); LineChar editBegin = { - .ch = mContents.getLastLine().length() - mCurrentEditableLine.length(), - .line = mContents.lines()-1 + mContents.getLastLine().length() - mCurrentEditableLine.length(), + mContents.lines()-1 }; RowColumn editBeginRC = mContents.lineCharToRowColumn(editBegin); bool isSelection = false; @@ -836,8 +836,8 @@ RowColumn QConsole::pixelsToNearestRowColumn(int x, int y) y = 0; } return { - .column = std::max(0, (x - 2) / mColumnWidth), - .row = mTopRow + (y / mRowHeight)-1 + std::max(0, (x - 2) / mColumnWidth), + mTopRow + (y / mRowHeight)-1 }; }