fix #284 : selection not correctly displayed.
This commit is contained in:
parent
22b8ee814e
commit
63db2e5179
|
@ -545,13 +545,13 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
|
|||
// Compute some helper variables.
|
||||
nC1 = std::max(mLeft, mTokenAccu.left);
|
||||
nC2 = std::min(mRight, mTokenAccu.left + mTokenAccu.width);
|
||||
if (mIsComplexLine) {
|
||||
if (mHasSelectionInLine) {
|
||||
bU1 = (nC1 < mLineSelStart);
|
||||
bSel = (nC1 < mLineSelEnd) && (nC2 >= mLineSelStart);
|
||||
bU2 = (nC2 >= mLineSelEnd);
|
||||
isComplexToken = bSel && (bU1 || bU2);
|
||||
} else {
|
||||
bSel = mIsLineSelected;
|
||||
bSel = false;
|
||||
isComplexToken = false;
|
||||
bU1 = false;
|
||||
bU2 = false;
|
||||
|
@ -633,12 +633,12 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
|
|||
colBG = colSpBG;
|
||||
else
|
||||
colBG = colEditorBG();
|
||||
if (mIsComplexLine) {
|
||||
setDrawingColors(mRcToken.left() < mLineSelEnd);
|
||||
if (mHasSelectionInLine) {
|
||||
setDrawingColors(mIsLineEndSelected);
|
||||
mRcToken.setRight(mRcLine.right());
|
||||
mPainter->fillRect(mRcToken,mPainter->brush());
|
||||
} else {
|
||||
setDrawingColors(mIsLineSelected);
|
||||
setDrawingColors(false);
|
||||
mRcToken.setRight(mRcLine.right());
|
||||
mPainter->fillRect(mRcToken,mPainter->brush());
|
||||
}
|
||||
|
@ -926,14 +926,16 @@ void QSynEditPainter::paintLines()
|
|||
// are possible (unselected before, selected, unselected after), only
|
||||
// unselected or only selected means bComplexLine will be FALSE. Start
|
||||
// with no selection, compute based on the visible columns.
|
||||
mIsComplexLine = false;
|
||||
mHasSelectionInLine = false;
|
||||
mLineSelStart = 0;
|
||||
mLineSelEnd = 0;
|
||||
mIsLineEndSelected = false;
|
||||
|
||||
// Does the selection intersect the visible area?
|
||||
if (bAnySelection && (row >= mSelStart.row) && (row <= mSelEnd.row)) {
|
||||
// Default to a fully selected line. This is correct for the smLine
|
||||
// selection mode and a good start for the smNormal mode.
|
||||
mHasSelectionInLine = true;
|
||||
mLineSelStart = mLeft;
|
||||
mLineSelEnd = mRight + 1;
|
||||
if ((mEdit->mActiveSelectionMode == SelectionMode::Column) ||
|
||||
|
@ -942,9 +944,9 @@ void QSynEditPainter::paintLines()
|
|||
if (xpos > mRight) {
|
||||
mLineSelStart = 0;
|
||||
mLineSelEnd = 0;
|
||||
mHasSelectionInLine = false;
|
||||
} else if (xpos > mLeft) {
|
||||
mLineSelStart = xpos;
|
||||
mIsComplexLine = true;
|
||||
}
|
||||
}
|
||||
if ( (mEdit->mActiveSelectionMode == SelectionMode::Column) ||
|
||||
|
@ -953,11 +955,14 @@ void QSynEditPainter::paintLines()
|
|||
if (xpos < mLeft) {
|
||||
mLineSelStart = 0;
|
||||
mLineSelEnd = 0;
|
||||
mHasSelectionInLine = false;
|
||||
} else if (xpos < mRight) {
|
||||
mLineSelEnd = xpos;
|
||||
mIsComplexLine = true;
|
||||
}
|
||||
}
|
||||
if (mEdit->mActiveSelectionMode == SelectionMode::Normal) {
|
||||
mIsLineEndSelected = (row>=mSelStart.row && row < mSelEnd.row);
|
||||
}
|
||||
} //endif bAnySelection
|
||||
|
||||
// Update the rcLine rect to this line.
|
||||
|
@ -966,8 +971,6 @@ void QSynEditPainter::paintLines()
|
|||
mRcLine.setTop((row - mEdit->mTopLine) * mEdit->mTextHeight);
|
||||
mRcLine.setHeight(mEdit->mTextHeight);
|
||||
|
||||
mIsLineSelected = (!mIsComplexLine) && (mLineSelStart > 0);
|
||||
|
||||
// if (mIsSpecialLine && colSpBG.isValid())
|
||||
// colBG = colSpBG;
|
||||
// else
|
||||
|
|
|
@ -96,13 +96,13 @@ private:
|
|||
DisplayCoord mSelStart; // start of selected area
|
||||
DisplayCoord mSelEnd; // end of selected area
|
||||
// info about normal and selected text and background colors
|
||||
bool mIsSpecialLine, mIsLineSelected, mIsCurrentLine;
|
||||
bool mIsSpecialLine, mIsCurrentLine, mIsLineEndSelected;
|
||||
QColor colFG, colBG;
|
||||
QColor colSelFG, colSelBG;
|
||||
QColor colSpFG, colSpBG;
|
||||
// info about selection of the current line
|
||||
int mLineSelStart, mLineSelEnd;
|
||||
bool mIsComplexLine;
|
||||
bool mHasSelectionInLine;
|
||||
// painting the background and the text
|
||||
QRect mRcLine, mRcToken;
|
||||
int mFirstLine, mLastLine;
|
||||
|
|
Loading…
Reference in New Issue