refactor: painter for qsyneditor : member Namespace
Spaces in disabled lines use the same color as in other places.
This commit is contained in:
parent
ae535a0f1b
commit
8c889a3a1b
|
@ -1318,8 +1318,9 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
if (mParser) {
|
if (mParser) {
|
||||||
// ifdef lines
|
// ifdef lines
|
||||||
if (!mParser->isLineVisible(mFilename, line)) {
|
if (!mParser->isLineVisible(mFilename, line)) {
|
||||||
foreground = syntaxer()->commentAttribute()->foreground();
|
|
||||||
background = syntaxer()->commentAttribute()->background();
|
background = syntaxer()->commentAttribute()->background();
|
||||||
|
if (attr->tokenType() != QSynedit::TokenType::Space)
|
||||||
|
foreground = syntaxer()->commentAttribute()->foreground();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString sLine = lineText(line);
|
QString sLine = lineText(line);
|
||||||
|
|
|
@ -313,17 +313,17 @@ void QSynEditPainter::computeSelectionInfo()
|
||||||
void QSynEditPainter::getDrawingColors(bool selected, QColor &foreground, QColor &background)
|
void QSynEditPainter::getDrawingColors(bool selected, QColor &foreground, QColor &background)
|
||||||
{
|
{
|
||||||
if (selected) {
|
if (selected) {
|
||||||
if (colSelFG.isValid())
|
if (mSelectionForeground.isValid())
|
||||||
foreground = colSelFG;
|
foreground = mSelectionForeground;
|
||||||
else
|
else
|
||||||
foreground = colFG;
|
foreground = mForeground;
|
||||||
if (colSelBG.isValid())
|
if (mSelectionBackground.isValid())
|
||||||
background = colSelBG;
|
background = mSelectionBackground;
|
||||||
else
|
else
|
||||||
background = colBG;
|
background = mBackground;
|
||||||
} else {
|
} else {
|
||||||
foreground = colFG;
|
foreground = mForeground;
|
||||||
background = colBG;
|
background = mBackground;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,14 +596,8 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
|
||||||
// Any token chars accumulated?
|
// Any token chars accumulated?
|
||||||
if (mTokenAccu.width > 0) {
|
if (mTokenAccu.width > 0) {
|
||||||
// Initialize the colors and the font style.
|
// Initialize the colors and the font style.
|
||||||
colBG = mTokenAccu.background;
|
mBackground = mTokenAccu.background;
|
||||||
colFG = mTokenAccu.foreground;
|
mForeground = mTokenAccu.foreground;
|
||||||
if (mIsSpecialLine) {
|
|
||||||
if (colSpFG.isValid())
|
|
||||||
colFG = colSpFG;
|
|
||||||
if (colSpBG.isValid())
|
|
||||||
colBG = colSpBG;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (bSpecialLine && mEdit->mOptions.testFlag(eoSpecialLineDefaultFg))
|
// if (bSpecialLine && mEdit->mOptions.testFlag(eoSpecialLineDefaultFg))
|
||||||
// colFG = TokenAccu.FG;
|
// colFG = TokenAccu.FG;
|
||||||
|
@ -674,10 +668,10 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
|
||||||
|
|
||||||
// Fill the background to the end of this line if necessary.
|
// Fill the background to the end of this line if necessary.
|
||||||
if (bFillToEOL && mRcToken.left() < mRcLine.right()) {
|
if (bFillToEOL && mRcToken.left() < mRcLine.right()) {
|
||||||
if (mIsSpecialLine && colSpBG.isValid())
|
if (mIsSpecialLine && mSpecialLineBackground.isValid())
|
||||||
colBG = colSpBG;
|
mBackground = mSpecialLineBackground;
|
||||||
else
|
else
|
||||||
colBG = colEditorBG();
|
mBackground = colEditorBG();
|
||||||
QColor foreground,background;
|
QColor foreground,background;
|
||||||
if (mHasSelectionInLine) {
|
if (mHasSelectionInLine) {
|
||||||
getDrawingColors(mIsLineEndSelected,foreground,background);
|
getDrawingColors(mIsLineEndSelected,foreground,background);
|
||||||
|
@ -736,8 +730,8 @@ void QSynEditPainter::addHighlightToken(
|
||||||
background = attri->background();
|
background = attri->background();
|
||||||
style = attri->styles();
|
style = attri->styles();
|
||||||
} else {
|
} else {
|
||||||
foreground = colFG;
|
foreground = mForeground;
|
||||||
background = colBG;
|
background = mBackground;
|
||||||
style = getFontStyles(mEdit->font());
|
style = getFontStyles(mEdit->font());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,6 +749,14 @@ void QSynEditPainter::addHighlightToken(
|
||||||
foreground = mEdit->mForegroundColor;
|
foreground = mEdit->mForegroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mIsSpecialLine) {
|
||||||
|
QColor oldForeground = foreground;
|
||||||
|
if (mSpecialLineForeground.isValid())
|
||||||
|
foreground = mSpecialLineForeground;
|
||||||
|
if (mSpecialLineBackground.isValid())
|
||||||
|
background = mSpecialLineBackground;
|
||||||
|
}
|
||||||
|
|
||||||
// Do we have to paint the old chars first, or can we just append?
|
// Do we have to paint the old chars first, or can we just append?
|
||||||
bool bCanAppend = false;
|
bool bCanAppend = false;
|
||||||
bool bInitFont = (mTokenAccu.width==0);
|
bool bInitFont = (mTokenAccu.width==0);
|
||||||
|
@ -989,14 +991,14 @@ void QSynEditPainter::paintLines()
|
||||||
}
|
}
|
||||||
// Initialize the text and background colors, maybe the line should
|
// Initialize the text and background colors, maybe the line should
|
||||||
// use special values for them.
|
// use special values for them.
|
||||||
colFG = mEdit->mForegroundColor;
|
mForeground = mEdit->mForegroundColor;
|
||||||
colBG = colEditorBG();
|
mBackground = colEditorBG();
|
||||||
colSpFG = QColor();
|
mSpecialLineForeground = QColor();
|
||||||
colSpBG = QColor();
|
mSpecialLineBackground = QColor();
|
||||||
mIsSpecialLine = mEdit->onGetSpecialLineColors(vLine, colSpFG, colSpBG);
|
mIsSpecialLine = mEdit->onGetSpecialLineColors(vLine, mSpecialLineForeground, mSpecialLineBackground);
|
||||||
|
|
||||||
colSelFG = mEdit->mSelectedForeground;
|
mSelectionForeground = mEdit->mSelectedForeground;
|
||||||
colSelBG = mEdit->mSelectedBackground;
|
mSelectionBackground = mEdit->mSelectedBackground;
|
||||||
mEdit->onGetEditingAreas(vLine, areaList);
|
mEdit->onGetEditingAreas(vLine, areaList);
|
||||||
// Get the information about the line selection. Three different parts
|
// Get the information about the line selection. Three different parts
|
||||||
// are possible (unselected before, selected, unselected after), only
|
// are possible (unselected before, selected, unselected after), only
|
||||||
|
@ -1237,7 +1239,7 @@ void QSynEditPainter::paintLines()
|
||||||
if (preeditAttr) {
|
if (preeditAttr) {
|
||||||
area->color = preeditAttr->foreground();
|
area->color = preeditAttr->foreground();
|
||||||
} else {
|
} else {
|
||||||
area->color = colFG;
|
area->color = mForeground;
|
||||||
}
|
}
|
||||||
areaList.append(area);
|
areaList.append(area);
|
||||||
|
|
||||||
|
|
|
@ -118,9 +118,9 @@ private:
|
||||||
DisplayCoord mSelEnd; // end of selected area
|
DisplayCoord mSelEnd; // end of selected area
|
||||||
// info about normal and selected text and background colors
|
// info about normal and selected text and background colors
|
||||||
bool mIsSpecialLine, mIsCurrentLine, mIsLineEndSelected;
|
bool mIsSpecialLine, mIsCurrentLine, mIsLineEndSelected;
|
||||||
QColor colFG, colBG;
|
QColor mForeground, mBackground;
|
||||||
QColor colSelFG, colSelBG;
|
QColor mSelectionForeground, mSelectionBackground;
|
||||||
QColor colSpFG, colSpBG;
|
QColor mSpecialLineForeground, mSpecialLineBackground;
|
||||||
// info about selection of the current line
|
// info about selection of the current line
|
||||||
int mLineSelStart, mLineSelEnd;
|
int mLineSelStart, mLineSelEnd;
|
||||||
bool mHasSelectionInLine;
|
bool mHasSelectionInLine;
|
||||||
|
|
Loading…
Reference in New Issue