diff --git a/NEWS.md b/NEWS.md index a827adff..dcfc35d9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,8 @@ Red Panda C++ Version 2.27 - change: Force use utf8 as the exec encoding for fmtlib in the auto link options page. - fix: After spaces in comments and strings, symbol completion for '{' and '(' are wrong. - fix: Issue #230 Crash when input " in the txt files. + - enhancement: Unique look&feel for the underline shown while ctrl+mouse over #include line. + - enhancement: Better look&feel for the wave underline shown for syntax errors. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 6a621146..853f8236 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1141,10 +1141,10 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y) } } -void Editor::onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) +void Editor::onGetEditingAreas(int line, QSynedit::EditingAreaList &areaList) { areaList.clear(); - if (mTabStopBegin>=0 && mTabStopY == Line) { + if (mTabStopBegin>=0 && mTabStopY == line) { QSynedit::PEditingArea p = std::make_shared(); p->type = QSynedit::EditingAreaType::eatRectangleBorder; // int spaceCount = leftSpaces(mLineBeforeTabStop); @@ -1154,7 +1154,7 @@ void Editor::onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) p->color = syntaxer()->stringAttribute()->foreground(); areaList.append(p); } - PSyntaxIssueList lst = getSyntaxIssuesAtLine(Line); + PSyntaxIssueList lst = getSyntaxIssuesAtLine(line); if (lst) { for (const PSyntaxIssue& issue: *lst) { QSynedit::PEditingArea p=std::make_shared(); @@ -1169,6 +1169,20 @@ void Editor::onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) areaList.append(p); } } + QString lineText = document()->getLine(line-1); + if (mParser && mParser->isIncludeLine(lineText)) { + if (line == mHoverModifiedLine) { + int pos1=std::max(lineText.indexOf("<"),lineText.indexOf("\"")); + int pos2=std::max(lineText.lastIndexOf(">"),lineText.lastIndexOf("\"")); + if (pos1>=0 && pos2>=0 && pos1 < pos2) { + QSynedit::PEditingArea p=std::make_shared(); + p->beginX = pos1+2; + p->endX = pos2+1; + p->type = QSynedit::EditingAreaType::eatUnderLine; + areaList.append(p); + } + } + } } bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor) @@ -1210,15 +1224,6 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to } QString lineText = document()->getLine(line-1); if (mParser->isIncludeLine(lineText)) { - if (line == mHoverModifiedLine) { - int pos1=std::max(lineText.indexOf("<"),lineText.indexOf("\"")); - int pos2=std::max(lineText.lastIndexOf(">"),lineText.lastIndexOf("\"")); - pos1++; - pos2++; - if (pos1>0 && pos2>0 && pos1enabled() && attr->tokenType() == QSynedit::TokenType::Identifier) { QSynedit::BufferCoord p{aChar,line}; // BufferCoord pBeginPos,pEndPos; diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index 4e02c73f..aa4baf75 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -341,7 +341,6 @@ void QSynEditPainter::paintToken( const QFont& font, bool showGlyphs) { bool startPaint; - int nX; bool fontInited = false; int tokenRight = tokenWidth+tokenLeft; @@ -351,7 +350,8 @@ void QSynEditPainter::paintToken( // qDebug()<= first && mRcToken.right() > mRcToken.left()) { - nX = fixXValue(first); + int nX = fixXValue(first); + int nY = mRcToken.bottom()-mPainter->fontMetrics().descent(); first -= tokenLeft; last -= tokenLeft; QRect rcTokenBack = mRcToken; @@ -413,7 +413,7 @@ void QSynEditPainter::paintToken( mPainter->setFont(font); fontInited = true; } - mPainter->drawText(nX,mRcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint); + mPainter->drawText(nX, nY, textToPaint); drawed = true; } } @@ -440,7 +440,7 @@ void QSynEditPainter::paintToken( fontInited = true; } //qDebug()<<"Drawing"<drawText(nX+padding,mRcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint); + mPainter->drawText(nX+padding, nY, textToPaint); } } drawed = true; @@ -461,12 +461,12 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList) { QRect rc; int x1,x2; - int offset; //painter->setClipRect(rcLine); rc=mRcLine; rc.setBottom(rc.bottom()-1); setDrawingColors(false); for (const PEditingArea& p:areaList) { + int penWidth = std::max(1,mEdit->font().pixelSize() / 15); if (p->beginX > mRight) continue; if (p->endX < mLeft) @@ -481,30 +481,41 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList) x2 = p->endX; rc.setLeft(fixXValue(x1)); rc.setRight(fixXValue(x2)); - mPainter->setPen(p->color); + QPen pen; + pen.setColor(p->color); + pen.setWidth(penWidth); + mPainter->setPen(pen); mPainter->setBrush(Qt::NoBrush); switch(p->type) { case EditingAreaType::eatRectangleBorder: mPainter->drawRect(rc); break; - case EditingAreaType::eatUnderLine: - mPainter->drawLine(rc.left(),rc.bottom(),rc.right(),rc.bottom()); + case EditingAreaType::eatUnderLine: { + mPainter->drawLine(rc.left(),rc.bottom()-pen.width(),rc.right(),rc.bottom()-pen.width()); + } break; - case EditingAreaType::eatWaveUnderLine: - offset=3; + case EditingAreaType::eatWaveUnderLine: { + int maxOffset = 2*penWidth; + int offset = maxOffset; int lastX=rc.left(); int lastY=rc.bottom()-offset; int t = rc.left(); while (trc.right()) + t+=maxOffset; + if (t>=rc.right()) { + int diff = t - rc.right(); + offset = (offset==0)?(maxOffset-diff):diff; t = rc.right(); - offset = 3 - offset; - mPainter->drawLine(lastX,lastY,t,rc.bottom()-offset); + mPainter->drawLine(lastX,lastY,t,rc.bottom()-offset); + } else { + offset = maxOffset - offset; + mPainter->drawLine(lastX,lastY,t,rc.bottom()-offset); + } lastX = t; lastY = rc.bottom()-offset; } - + } + break; } } }