- fix: Fallback font doesn't apply before restart

- fix: first indent line doesn't show
 = fix: Selection background not correctly drawn
This commit is contained in:
Roy Qu 2024-02-29 19:17:14 +08:00
parent 7c379509bf
commit 30ed2fac79
8 changed files with 86 additions and 86 deletions

View File

@ -5334,6 +5334,7 @@ void Editor::applySettings()
codeFolding().fillIndents = pSettings->editor().fillIndents(); codeFolding().fillIndents = pSettings->editor().fillIndents();
QFont f=QFont(); QFont f=QFont();
f.setFamily(pSettings->editor().fontName());
f.setFamilies(pSettings->editor().fontFamilies()); f.setFamilies(pSettings->editor().fontFamilies());
f.setPixelSize(pointToPixel(pSettings->editor().fontSize())); f.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
f.setStyleStrategy(QFont::PreferAntialias); f.setStyleStrategy(QFont::PreferAntialias);
@ -5418,6 +5419,7 @@ static QSynedit::PTokenAttribute createRainbowAttribute(const QString& attrName,
} }
return QSynedit::PTokenAttribute(); return QSynedit::PTokenAttribute();
} }
void Editor::applyColorScheme(const QString& schemeName) void Editor::applyColorScheme(const QString& schemeName)
{ {
QSynedit::EditorOptions options = getOptions(); QSynedit::EditorOptions options = getOptions();

View File

@ -718,6 +718,7 @@ void Settings::Editor::setUseFallbackFont3(bool useFont) {
QStringList Settings::Editor::fontFamilies() const QStringList Settings::Editor::fontFamilies() const
{ {
QStringList result { QStringList result {
//QString("%1 [%2]").arg(mFontName,mFallbackFontName),
mFontName, mFontName,
mFallbackFontName, mFallbackFontName,
}; };

View File

@ -125,6 +125,7 @@ void EditorFontWidget::doSave()
pSettings->editor().setGutterFontSize(ui->spinGutterFontSize->value()); pSettings->editor().setGutterFontSize(ui->spinGutterFontSize->value());
pSettings->editor().save(); pSettings->editor().save();
QFont::cleanup();
pMainWindow->updateEditorSettings(); pMainWindow->updateEditorSettings();
} }

View File

@ -52,13 +52,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>*Needs restart</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_10"> <spacer name="horizontalSpacer_10">
<property name="orientation"> <property name="orientation">
@ -135,13 +128,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>*Needs restart</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_9"> <spacer name="horizontalSpacer_9">
<property name="orientation"> <property name="orientation">
@ -269,13 +255,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>*Needs restart</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">

View File

@ -148,9 +148,10 @@ void CPUDialog::resetEditorFont(float dpi)
pSettings->editor().forceFixedFontWidth()); pSettings->editor().forceFixedFontWidth());
ui->txtCode->setOptions(options); ui->txtCode->setOptions(options);
QFont f=QFont(); QFont f=QFont();
f.setFamily(pSettings->editor().fontName());
f.setFamilies(pSettings->editor().fontFamilies()); f.setFamilies(pSettings->editor().fontFamilies());
f.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi)); f.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi));
f.setStyleStrategy(QFont::PreferAntialias); f.setStyleStrategy(QFont::NoFontMerging);
ui->txtCode->setFont(f); ui->txtCode->setFont(f);
} }

View File

@ -32,7 +32,7 @@ QSynEditPainter::QSynEditPainter(QSynEdit *edit, QPainter *painter, int firstRow
{ {
} }
void QSynEditPainter::paintTextLines(const QRect& clip) void QSynEditPainter::paintEditingArea(const QRect& clip)
{ {
mPainter->fillRect(clip, mEdit->mBackgroundColor); mPainter->fillRect(clip, mEdit->mBackgroundColor);
mClip = clip; mClip = clip;
@ -63,25 +63,25 @@ void QSynEditPainter::paintTextLines(const QRect& clip)
// If anything of the two pixel space before the text area is visible, then // If anything of the two pixel space before the text area is visible, then
// fill it with the component background color. // fill it with the component background color.
if (mClip.left() <mEdit->mGutterWidth + 2) { if (mClip.left() <mEdit->mGutterWidth + 2) {
rcToken = mClip; mRcToken = mClip;
rcToken.setLeft( std::max(mClip.left(), mEdit->mGutterWidth)); mRcToken.setLeft( std::max(mClip.left(), mEdit->mGutterWidth));
rcToken.setRight(mEdit->mGutterWidth + 2); mRcToken.setRight(mEdit->mGutterWidth + 2);
// Paint whole left edge of the text with same color. // Paint whole left edge of the text with same color.
// (value of WhiteAttribute can vary in e.g. MultiSyn) // (value of WhiteAttribute can vary in e.g. MultiSyn)
mPainter->fillRect(rcToken,colEditorBG()); mPainter->fillRect(mRcToken,colEditorBG());
// Adjust the invalid area to not include this area. // Adjust the invalid area to not include this area.
mClip.setLeft(rcToken.right()); mClip.setLeft(mRcToken.right());
} }
// If there is anything visible below the last line, then fill this as well. // If there is anything visible below the last line, then fill this as well.
rcToken = mClip; mRcToken = mClip;
rcToken.setTop((mLastRow - mEdit->mTopLine + 1) * mEdit->mTextHeight); mRcToken.setTop((mLastRow - mEdit->mTopLine + 1) * mEdit->mTextHeight);
if (rcToken.top() < rcToken.bottom()) { if (mRcToken.top() < mRcToken.bottom()) {
mPainter->fillRect(rcToken,colEditorBG()); mPainter->fillRect(mRcToken,colEditorBG());
// Draw the right edge if necessary. // Draw the right edge if necessary.
if (bDoRightEdge) { if (bDoRightEdge) {
QPen pen(mEdit->mRightEdgeColor,1); QPen pen(mEdit->mRightEdgeColor,1);
mPainter->setPen(pen); mPainter->setPen(pen);
mPainter->drawLine(nRightEdge, rcToken.top(),nRightEdge, rcToken.bottom() + 1); mPainter->drawLine(nRightEdge, mRcToken.top(),nRightEdge, mRcToken.bottom() + 1);
} }
} }
@ -350,11 +350,11 @@ void QSynEditPainter::paintToken(
// qDebug()<<glyphStartPositionList; // qDebug()<<glyphStartPositionList;
// qDebug()<<startGlyph<<endGlyph; // qDebug()<<startGlyph<<endGlyph;
if (last >= first && rcToken.right() > rcToken.left()) { if (last >= first && mRcToken.right() > mRcToken.left()) {
nX = fixXValue(first); nX = fixXValue(first);
first -= tokenLeft; first -= tokenLeft;
last -= tokenLeft; last -= tokenLeft;
QRect rcTokenBack = rcToken; QRect rcTokenBack = mRcToken;
mPainter->fillRect(rcTokenBack,mPainter->brush()); mPainter->fillRect(rcTokenBack,mPainter->brush());
if (first > tokenWidth) { if (first > tokenWidth) {
} else { } else {
@ -399,7 +399,7 @@ void QSynEditPainter::paintToken(
break; break;
int glyph2Width = calcSegmentInterval(glyphStartPositionList, tokenRight, i+1); int glyph2Width = calcSegmentInterval(glyphStartPositionList, tokenRight, i+1);
if (mEdit->mOptions.testFlag(eoForceMonospace)) { if (mEdit->mOptions.testFlag(eoForceMonospace)) {
if (glyphWidth+glyph2Width != mPainter->fontMetrics().horizontalAdvance(textToPaint+glyph2)) { if (glyph2Width != mPainter->fontMetrics().horizontalAdvance(glyph2)) {
break; break;
} }
} }
@ -414,7 +414,7 @@ void QSynEditPainter::paintToken(
fontInited = true; fontInited = true;
} }
//qDebug()<<"paint 1:"<<textToPaint; //qDebug()<<"paint 1:"<<textToPaint;
mPainter->drawText(nX,rcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint); mPainter->drawText(nX,mRcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint);
drawed = true; drawed = true;
} }
} }
@ -441,7 +441,7 @@ void QSynEditPainter::paintToken(
fontInited = true; fontInited = true;
} }
//qDebug()<<"Drawing"<<textToPaint; //qDebug()<<"Drawing"<<textToPaint;
mPainter->drawText(nX+padding,rcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint); mPainter->drawText(nX+padding,mRcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint);
} }
} }
drawed = true; drawed = true;
@ -454,7 +454,7 @@ void QSynEditPainter::paintToken(
} }
} }
rcToken.setLeft(rcToken.right()+1); mRcToken.setLeft(mRcToken.right()+1);
} }
} }
@ -464,7 +464,7 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
int x1,x2; int x1,x2;
int offset; int offset;
//painter->setClipRect(rcLine); //painter->setClipRect(rcLine);
rc=rcLine; rc=mRcLine;
rc.setBottom(rc.bottom()-1); rc.setBottom(rc.bottom()-1);
setDrawingColors(false); setDrawingColors(false);
for (const PEditingArea& p:areaList) { for (const PEditingArea& p:areaList) {
@ -512,7 +512,8 @@ void QSynEditPainter::paintEditAreas(const EditingAreaList &areaList)
void QSynEditPainter::paintHighlightToken(const QString& lineText, void QSynEditPainter::paintHighlightToken(const QString& lineText,
const QList<int> &glyphStartCharList, const QList<int> &glyphStartCharList,
const QList<int> &glyphStartPositionsList) const QList<int> &glyphStartPositionsList,
bool bFillToEOL)
{ {
bool isComplexToken; bool isComplexToken;
int nC1, nC2, nC1Sel, nC2Sel; int nC1, nC2, nC1Sel, nC2Sel;
@ -553,7 +554,7 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
// first unselected part of the token // first unselected part of the token
if (bU1) { if (bU1) {
setDrawingColors(false); setDrawingColors(false);
rcToken.setRight(fixXValue(mLineSelStart)); mRcToken.setRight(fixXValue(mLineSelStart));
paintToken( paintToken(
lineText, lineText,
glyphStartCharList, glyphStartCharList,
@ -567,7 +568,7 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
setDrawingColors(true); setDrawingColors(true);
nC1Sel = std::max(mLineSelStart, nC1); nC1Sel = std::max(mLineSelStart, nC1);
nC2Sel = std::min(mLineSelEnd, nC2); nC2Sel = std::min(mLineSelEnd, nC2);
rcToken.setRight(fixXValue(nC2Sel)); mRcToken.setRight(fixXValue(nC2Sel));
paintToken( paintToken(
lineText, lineText,
glyphStartCharList, glyphStartCharList,
@ -579,7 +580,7 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
// second unselected part of the token // second unselected part of the token
if (bU2) { if (bU2) {
setDrawingColors(false); setDrawingColors(false);
rcToken.setRight(fixXValue(nC2)); mRcToken.setRight(fixXValue(nC2));
paintToken( paintToken(
lineText, lineText,
glyphStartCharList, glyphStartCharList,
@ -591,7 +592,7 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
} }
} else { } else {
setDrawingColors(bSel); setDrawingColors(bSel);
rcToken.setRight(fixXValue(nC2)); mRcToken.setRight(fixXValue(nC2));
paintToken( paintToken(
lineText, lineText,
glyphStartCharList, glyphStartCharList,
@ -602,6 +603,23 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
mTokenAccu.font, mTokenAccu.showSpecialGlyphs); mTokenAccu.font, mTokenAccu.showSpecialGlyphs);
} }
} }
// Fill the background to the end of this line if necessary.
if (bFillToEOL && mRcToken.left() < mRcLine.right()) {
if (mIsSpecialLine && colSpBG.isValid())
colBG = colSpBG;
else
colBG = colEditorBG();
if (mIsComplexLine) {
setDrawingColors(mRcToken.left() < mLineSelEnd);
mRcToken.setRight(mRcLine.right());
mPainter->fillRect(mRcToken,mPainter->brush());
} else {
setDrawingColors(mIsLineSelected);
mRcToken.setRight(mRcLine.right());
mPainter->fillRect(mRcToken,mPainter->brush());
}
}
} }
// Store the token chars with the attributes in the TokenAccu // Store the token chars with the attributes in the TokenAccu
@ -663,7 +681,7 @@ void QSynEditPainter::addHighlightToken(
} }
// If we can't append it, then we have to paint the old token chars first. // If we can't append it, then we have to paint the old token chars first.
if (!bCanAppend) if (!bCanAppend)
paintHighlightToken(lineText, glyphStartCharList, glyphStartPositionList); paintHighlightToken(lineText, glyphStartCharList, glyphStartPositionList, false);
} }
if (bInitFont) { if (bInitFont) {
mTokenAccu.style = style; mTokenAccu.style = style;
@ -708,7 +726,7 @@ void QSynEditPainter::addHighlightToken(
void QSynEditPainter::paintFoldAttributes() void QSynEditPainter::paintFoldAttributes()
{ {
int tabSteps, lineIndent, lastNonBlank, X, Y; int tabSteps, lineIndent, lastNonBlank;
// Paint indent guides. Use folds to determine indent value of these // Paint indent guides. Use folds to determine indent value of these
// Use a separate loop so we can use a custom pen // Use a separate loop so we can use a custom pen
// Paint indent guides using custom pen // Paint indent guides using custom pen
@ -728,8 +746,9 @@ void QSynEditPainter::paintFoldAttributes()
int vLine = mEdit->rowToLine(row); int vLine = mEdit->rowToLine(row);
if (vLine > mEdit->mDocument->count() && mEdit->mDocument->count() > 0) if (vLine > mEdit->mDocument->count() && mEdit->mDocument->count() > 0)
break; break;
int X;
// Set vertical coord // Set vertical coord
Y = (row - mEdit->mTopLine) * mEdit->mTextHeight; // limit inside clip rect int Y = (row - mEdit->mTopLine) * mEdit->mTextHeight; // limit inside clip rect
if (mEdit->mTextHeight % 2 == 1 && vLine % 2 == 0) { if (mEdit->mTextHeight % 2 == 1 && vLine % 2 == 0) {
Y++; Y++;
} }
@ -742,15 +761,10 @@ void QSynEditPainter::paintFoldAttributes()
lineIndent = mEdit->getLineIndent(mEdit->mDocument->getLine(lastNonBlank)); lineIndent = mEdit->getLineIndent(mEdit->mDocument->getLine(lastNonBlank));
int braceLevel = mEdit->mDocument->getSyntaxState(lastNonBlank).braceLevel; int braceLevel = mEdit->mDocument->getSyntaxState(lastNonBlank).braceLevel;
int indentLevel = braceLevel ; int indentLevel = braceLevel ;
if (mEdit->tabSize()>0)
indentLevel = lineIndent / mEdit->tabSize();
// Step horizontal coord
//TabSteps = edit->mTabWidth;
tabSteps = 0; tabSteps = 0;
indentLevel = 0; indentLevel = 0;
while (tabSteps < lineIndent) { while (tabSteps < lineIndent) {
X = tabSteps * mEdit->mCharWidth + mEdit->textOffset() - 2; X = tabSteps * mEdit->mCharWidth + mEdit->textOffset() - 1;
tabSteps+=mEdit->tabSize(); tabSteps+=mEdit->tabSize();
indentLevel++ ; indentLevel++ ;
if (mEdit->mSyntaxer) { if (mEdit->mSyntaxer) {
@ -771,9 +785,9 @@ void QSynEditPainter::paintFoldAttributes()
if (mEdit->mCodeFolding.fillIndents) { if (mEdit->mCodeFolding.fillIndents) {
int X1; int X1;
if (tabSteps>lineIndent) if (tabSteps>lineIndent)
X1 = lineIndent * mEdit->mCharWidth + mEdit->textOffset() - 2; X1 = lineIndent * mEdit->mCharWidth + mEdit->textOffset() - 1;
else else
X1 = tabSteps * mEdit->mCharWidth + mEdit->textOffset() - 2; X1 = tabSteps * mEdit->mCharWidth + mEdit->textOffset() - 1;
gradientStart.setAlpha(20); gradientStart.setAlpha(20);
gradientEnd.setAlpha(10); gradientEnd.setAlpha(10);
QLinearGradient gradient(X,Y,X1,Y); QLinearGradient gradient(X,Y,X1,Y);
@ -805,7 +819,7 @@ void QSynEditPainter::paintFoldAttributes()
if (range->collapsed && !range->parentCollapsed() && if (range->collapsed && !range->parentCollapsed() &&
(range->fromLine <= mLastLine) && (range->fromLine >= mFirstLine) ) { (range->fromLine <= mLastLine) && (range->fromLine >= mFirstLine) ) {
// Get starting and end points // Get starting and end points
Y = (mEdit->lineToRow(range->fromLine) - mEdit->mTopLine + 1) * mEdit->mTextHeight - 1; int Y = (mEdit->lineToRow(range->fromLine) - mEdit->mTopLine + 1) * mEdit->mTextHeight - 1;
mPainter->drawLine(mClip.left(),Y, mClip.right(),Y); mPainter->drawLine(mClip.left(),Y, mClip.right(),Y);
} }
} }
@ -850,8 +864,8 @@ void QSynEditPainter::paintLines()
// Initialize rcLine for drawing. Note that Top and Bottom are updated // Initialize rcLine for drawing. Note that Top and Bottom are updated
// inside the loop. Get only the starting point for this. // inside the loop. Get only the starting point for this.
rcLine = mClip; mRcLine = mClip;
rcLine.setBottom((mFirstRow - mEdit->mTopLine) * mEdit->mTextHeight); mRcLine.setBottom((mFirstRow - mEdit->mTopLine) * mEdit->mTextHeight);
mTokenAccu.width = 0; mTokenAccu.width = 0;
mTokenAccu.left = 0; mTokenAccu.left = 0;
mTokenAccu.style = FontStyle::fsNone; mTokenAccu.style = FontStyle::fsNone;
@ -904,7 +918,7 @@ void QSynEditPainter::paintLines()
mLineSelEnd = mRight + 1; mLineSelEnd = mRight + 1;
if ((mEdit->mActiveSelectionMode == SelectionMode::Column) || if ((mEdit->mActiveSelectionMode == SelectionMode::Column) ||
((mEdit->mActiveSelectionMode == SelectionMode::Normal) && (row == mSelStart.row)) ) { ((mEdit->mActiveSelectionMode == SelectionMode::Normal) && (row == mSelStart.row)) ) {
int xpos = mEdit->xposToGlyphLeft(vLine,mSelStart.x); int xpos = mSelStart.x;
if (xpos > mRight) { if (xpos > mRight) {
mLineSelStart = 0; mLineSelStart = 0;
mLineSelEnd = 0; mLineSelEnd = 0;
@ -915,7 +929,7 @@ void QSynEditPainter::paintLines()
} }
if ( (mEdit->mActiveSelectionMode == SelectionMode::Column) || if ( (mEdit->mActiveSelectionMode == SelectionMode::Column) ||
((mEdit->mActiveSelectionMode == SelectionMode::Normal) && (row == mSelEnd.row)) ) { ((mEdit->mActiveSelectionMode == SelectionMode::Normal) && (row == mSelEnd.row)) ) {
int xpos = mEdit->xposToGlyphLeft(vLine,mSelEnd.x); int xpos = mSelEnd.x;
if (xpos < mLeft) { if (xpos < mLeft) {
mLineSelStart = 0; mLineSelStart = 0;
mLineSelEnd = 0; mLineSelEnd = 0;
@ -931,19 +945,19 @@ void QSynEditPainter::paintLines()
// Update the rcLine rect to this line. // Update the rcLine rect to this line.
// rcLine.setTop(rcLine.bottom()); // rcLine.setTop(rcLine.bottom());
// rcLine.setBottom(rcLine.bottom()+edit->mTextHeight); // rcLine.setBottom(rcLine.bottom()+edit->mTextHeight);
rcLine.setTop((row - mEdit->mTopLine) * mEdit->mTextHeight); mRcLine.setTop((row - mEdit->mTopLine) * mEdit->mTextHeight);
rcLine.setHeight(mEdit->mTextHeight); mRcLine.setHeight(mEdit->mTextHeight);
mIsLineSelected = (!mIsComplexLine) && (mLineSelStart > 0); mIsLineSelected = (!mIsComplexLine) && (mLineSelStart > 0);
if (mIsSpecialLine && colSpBG.isValid()) // if (mIsSpecialLine && colSpBG.isValid())
colBG = colSpBG; // colBG = colSpBG;
else // else
colBG = colEditorBG(); // colBG = colEditorBG();
setDrawingColors(selToEnd); // setDrawingColors(selToEnd);
mPainter->fillRect(rcLine,mPainter->brush()); // mPainter->fillRect(rcLine,mPainter->brush());
rcToken = rcLine; mRcToken = mRcLine;
int lineWidth; int lineWidth;
QList<int> glyphStartCharList = mEdit->mDocument->getGlyphStartCharList(vLine-1,sLine); QList<int> glyphStartCharList = mEdit->mDocument->getGlyphStartCharList(vLine-1,sLine);
@ -961,8 +975,8 @@ void QSynEditPainter::paintLines()
} }
if (mIsComplexLine) { if (mIsComplexLine) {
setDrawingColors(true); setDrawingColors(true);
rcToken.setLeft(std::max(rcLine.left(), fixXValue(mLineSelStart))); mRcToken.setLeft(std::max(mRcLine.left(), fixXValue(mLineSelStart)));
rcToken.setRight(std::min(rcLine.right(), fixXValue(mLineSelEnd))); mRcToken.setRight(std::min(mRcLine.right(), fixXValue(mLineSelEnd)));
paintToken( paintToken(
sLine, sLine,
glyphStartCharList, glyphStartCharList,
@ -972,8 +986,8 @@ void QSynEditPainter::paintLines()
tokenWidth, 0, mLineSelStart, mLineSelEnd, tokenWidth, 0, mLineSelStart, mLineSelEnd,
mEdit->font(),false); mEdit->font(),false);
setDrawingColors(false); setDrawingColors(false);
rcToken.setLeft(std::max(rcLine.left(), fixXValue(mLeft))); mRcToken.setLeft(std::max(mRcLine.left(), fixXValue(mLeft)));
rcToken.setRight(std::min(rcLine.right(), fixXValue(mLineSelStart))); mRcToken.setRight(std::min(mRcLine.right(), fixXValue(mLineSelStart)));
paintToken( paintToken(
sLine, sLine,
glyphStartCharList, glyphStartCharList,
@ -982,8 +996,8 @@ void QSynEditPainter::paintLines()
glyphStartCharList.length(), glyphStartCharList.length(),
tokenWidth, 0, mLeft, mLineSelStart, tokenWidth, 0, mLeft, mLineSelStart,
mEdit->font(), false); mEdit->font(), false);
rcToken.setLeft(std::max(rcLine.left(), fixXValue(mLineSelEnd))); mRcToken.setLeft(std::max(mRcLine.left(), fixXValue(mLineSelEnd)));
rcToken.setRight(std::min(rcLine.right(), fixXValue(mRight))); mRcToken.setRight(std::min(mRcLine.right(), fixXValue(mRight)));
paintToken( paintToken(
sLine, sLine,
glyphStartCharList, glyphStartCharList,
@ -1153,7 +1167,7 @@ void QSynEditPainter::paintLines()
} }
// Draw anything that's left in the TokenAccu record. Fill to the end // Draw anything that's left in the TokenAccu record. Fill to the end
// of the invalid area with the correct colors. // of the invalid area with the correct colors.
paintHighlightToken(sLine, glyphStartCharList, glyphStartPositionsList); paintHighlightToken(sLine, glyphStartCharList, glyphStartPositionsList, true);
//Paint editingAreaBorders //Paint editingAreaBorders
foreach (const PEditingArea& area, areaList) { foreach (const PEditingArea& area, areaList) {
@ -1200,7 +1214,7 @@ void QSynEditPainter::paintLines()
// calls to ExtTextOut. // calls to ExtTextOut.
if (bDoRightEdge) { if (bDoRightEdge) {
mPainter->setPen(mEdit->mRightEdgeColor); mPainter->setPen(mEdit->mRightEdgeColor);
mPainter->drawLine(nRightEdge, rcLine.top(),nRightEdge,rcLine.bottom()+1); mPainter->drawLine(nRightEdge, mRcLine.top(),nRightEdge,mRcLine.bottom()+1);
} }
mIsCurrentLine = false; mIsCurrentLine = false;
} }

View File

@ -49,7 +49,7 @@ public:
QSynEditPainter(const QSynEditPainter&)=delete; QSynEditPainter(const QSynEditPainter&)=delete;
QSynEditPainter& operator=(const QSynEditPainter&)=delete; QSynEditPainter& operator=(const QSynEditPainter&)=delete;
void paintTextLines(const QRect& clip); void paintEditingArea(const QRect& clip);
void paintGutter(const QRect& clip); void paintGutter(const QRect& clip);
private: private:
@ -69,7 +69,8 @@ private:
void paintEditAreas(const EditingAreaList& areaList); void paintEditAreas(const EditingAreaList& areaList);
void paintHighlightToken(const QString& lineText, void paintHighlightToken(const QString& lineText,
const QList<int> &glyphStartCharList, const QList<int> &glyphStartCharList,
const QList<int> &glyphStartPositionsList); const QList<int> &glyphStartPositionsList,
bool bFillToEOL);
void addHighlightToken( void addHighlightToken(
const QString& lineText, const QString& lineText,
const QString& token, int tokenLeft, const QString& token, int tokenLeft,
@ -103,7 +104,7 @@ private:
int mLineSelStart, mLineSelEnd; int mLineSelStart, mLineSelEnd;
bool mIsComplexLine; bool mIsComplexLine;
// painting the background and the text // painting the background and the text
QRect rcLine, rcToken; QRect mRcLine, mRcToken;
int mFirstLine, mLastLine; int mFirstLine, mLastLine;
QRect mClip; QRect mClip;

View File

@ -3761,7 +3761,7 @@ void QSynEdit::paintCaret(QPainter &painter, const QRect rcClip)
int QSynEdit::textOffset() const int QSynEdit::textOffset() const
{ {
return mGutterWidth + 2 - mLeftPos; return mGutterWidth + 2 - mLeftPos ;
} }
EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers) EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
@ -6049,7 +6049,8 @@ void QSynEdit::paintEvent(QPaintEvent *event)
nX1 = mLeftPos; nX1 = mLeftPos;
if (rcClip.left() > mGutterWidth + 2 ) if (rcClip.left() > mGutterWidth + 2 )
nX1 += (rcClip.left() - mGutterWidth - 2 ) ; nX1 += (rcClip.left() - mGutterWidth - 2 ) ;
nX2 = mLeftPos + (rcClip.right() - mGutterWidth - 2); // nX2 = mLeftPos + (rcClip.right() - mGutterWidth - 2);
nX2 = rcClip.right();
// lines // lines
nL1 = minMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount()); nL1 = minMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
nL2 = minMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount()); nL2 = minMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
@ -6064,7 +6065,7 @@ void QSynEdit::paintEvent(QPaintEvent *event)
if (rcClip.right() > mGutterWidth ) { if (rcClip.right() > mGutterWidth ) {
rcDraw = rcClip; rcDraw = rcClip;
rcDraw.setLeft( std::max(rcDraw.left(), mGutterWidth)); rcDraw.setLeft( std::max(rcDraw.left(), mGutterWidth));
textPainter.paintTextLines(rcDraw); textPainter.paintEditingArea(rcDraw);
} }
// Then the gutter area if it was (partly) invalidated. // Then the gutter area if it was (partly) invalidated.