From a5acb077fc35bf6fb763477d8b1cd7ac600d8661 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Wed, 20 Oct 2021 20:15:16 +0800 Subject: [PATCH] - fix: correctly handle integer with 'L' suffix in #if directives ( so can be correctly parsed ) - fix: correctly fill indents if it's not multiples of tab width --- NEWS.md | 1 + RedPandaIDE/parser/cpppreprocessor.cpp | 20 +++++++++++++++++++- RedPandaIDE/qsynedit/TextPainter.cpp | 12 ++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index c30665c5..09f3a0c5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ Version 0.7.0 - fix: when an editor is created, its caret will be displayed even it doesn't have focus - enhancement: set mouse wheel scroll speed in the editor general option tab ( 3 lines by default) - fix: don't highlight '#' with spaces preceeding it as error + - fix: correctly handle integer with 'L' suffix in #if directives ( so can be correctly parsed ) Version 0.6.8 - enhancement: add link to cppreference in the help menu diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 25b08821..78ee0c0e 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -1317,7 +1317,25 @@ bool CppPreprocessor::evalNumber(const QString &expr, int &result, int &pos) pos++; } bool ok; - result = s.toInt(&ok,0); + + if (s.endsWith("LL",Qt::CaseInsensitive)) { + s.remove(s.length()-2,2); + result = s.toLongLong(&ok,0); + } else if (s.endsWith("L",Qt::CaseInsensitive)) { + s.remove(s.length()-1,1); + result = s.toLong(&ok,0); + } else if (s.endsWith("ULL",Qt::CaseInsensitive)) { + s.remove(s.length()-3,3); + result = s.toULongLong(&ok,0); + } else if (s.endsWith("UL",Qt::CaseInsensitive)) { + s.remove(s.length()-2,2); + result = s.toULong(&ok,0); + } else if (s.endsWith("U",Qt::CaseInsensitive)) { + s.remove(s.length()-1,1); + result = s.toUInt(&ok,0); + } else { + result = s.toInt(&ok,0); + } return ok; } diff --git a/RedPandaIDE/qsynedit/TextPainter.cpp b/RedPandaIDE/qsynedit/TextPainter.cpp index 522034a6..36d903e8 100644 --- a/RedPandaIDE/qsynedit/TextPainter.cpp +++ b/RedPandaIDE/qsynedit/TextPainter.cpp @@ -708,13 +708,17 @@ void SynEditTextPainter::PaintFoldAttributes() } } if (edit->mCodeFolding.fillIndents) { - int X1=TabSteps * edit->mCharWidth + edit->textOffset() - 2; + int X1; + if (TabSteps>LineIndent) + X1 = LineIndent * edit->mCharWidth + edit->textOffset() - 2; + else + X1 = TabSteps * edit->mCharWidth + edit->textOffset() - 2; gradientStart.setAlpha(20); gradientEnd.setAlpha(10); QLinearGradient gradient(X,Y,X1,Y); - gradient.setColorAt(0,gradientStart); - gradient.setColorAt(1,gradientEnd); - painter->fillRect(X,Y,edit->mTabWidth * edit->mCharWidth,edit->mTextHeight,gradient); + gradient.setColorAt(1,gradientStart); + gradient.setColorAt(0,gradientEnd); + painter->fillRect(X,Y,(X1-X),edit->mTextHeight,gradient); } // Move to top of vertical line