fixes #281: Wrong syntax highlighting for #include lines that contains multiple '>' chars.
This commit is contained in:
parent
852a451976
commit
e7129241e9
|
@ -1138,7 +1138,7 @@ bool trySetIncludeUnderline(const QString& lineText, const QChar& quoteStartChar
|
||||||
QSynedit::EditingAreaList &areaList
|
QSynedit::EditingAreaList &areaList
|
||||||
) {
|
) {
|
||||||
int pos1=lineText.indexOf(quoteStartChar);
|
int pos1=lineText.indexOf(quoteStartChar);
|
||||||
int pos2=lineText.lastIndexOf(quoteEndChar);
|
int pos2=lineText.indexOf(quoteEndChar,pos1+1);
|
||||||
if (pos1>=0 && pos2>=0 && pos1 < pos2 ) {
|
if (pos1>=0 && pos2>=0 && pos1 < pos2 ) {
|
||||||
QSynedit::PEditingArea p=std::make_shared<QSynedit::EditingArea>();
|
QSynedit::PEditingArea p=std::make_shared<QSynedit::EditingArea>();
|
||||||
p->beginX = pos1+2;
|
p->beginX = pos1+2;
|
||||||
|
@ -1235,7 +1235,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
if (mParser->isIncludeLine(lineText)) {
|
if (mParser->isIncludeLine(lineText)) {
|
||||||
// #include header names (<>)
|
// #include header names (<>)
|
||||||
int pos1=lineText.indexOf("<")+1;
|
int pos1=lineText.indexOf("<")+1;
|
||||||
int pos2=lineText.lastIndexOf(">")+1;
|
int pos2=lineText.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();
|
||||||
|
|
|
@ -473,9 +473,9 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
|
||||||
rc.setBottom(rc.bottom()-1);
|
rc.setBottom(rc.bottom()-1);
|
||||||
setDrawingColors(false);
|
setDrawingColors(false);
|
||||||
for (const PEditingArea& p:areaList) {
|
for (const PEditingArea& p:areaList) {
|
||||||
int penWidth = std::max(1,mEdit->font().pixelSize() / 15);
|
int penWidth = std::max(1.0,std::round(mEdit->font().pixelSize() / 15.0));
|
||||||
if (p->type == EditingAreaType::eatWaveUnderLine)
|
if (p->type == EditingAreaType::eatWaveUnderLine)
|
||||||
penWidth = std::max(1,mEdit->font().pixelSize() / 21);
|
penWidth = std::max(1.0,std::round(mEdit->font().pixelSize() / 21.0));
|
||||||
if (p->beginX > mRight)
|
if (p->beginX > mRight)
|
||||||
continue;
|
continue;
|
||||||
if (p->endX < mLeft)
|
if (p->endX < mLeft)
|
||||||
|
@ -502,7 +502,10 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
|
||||||
mPainter->drawRect(rc);
|
mPainter->drawRect(rc);
|
||||||
break;
|
break;
|
||||||
case EditingAreaType::eatUnderLine: {
|
case EditingAreaType::eatUnderLine: {
|
||||||
mPainter->drawLine(rc.left(),rc.bottom()-pen.width(),rc.right(),rc.bottom()-pen.width());
|
int lineHeight = rc.height();
|
||||||
|
int fontHeight = mPainter->fontMetrics().descent() + mPainter->fontMetrics().ascent();
|
||||||
|
int linePadding = (lineHeight - fontHeight) / 2;
|
||||||
|
mPainter->drawLine(rc.left(),rc.bottom()-linePadding-pen.width(),rc.right(),rc.bottom()-linePadding-pen.width());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EditingAreaType::eatWaveUnderLine: {
|
case EditingAreaType::eatWaveUnderLine: {
|
||||||
|
|
Loading…
Reference in New Issue