fix: ending glyph not correctly drawed after editing
This commit is contained in:
parent
9672ebd079
commit
fda9a424c4
|
@ -1756,6 +1756,8 @@ int Document::updateGlyphStartPositionList(
|
||||||
glyphStartPositionList[i] = right;
|
glyphStartPositionList[i] = right;
|
||||||
right += gWidth;
|
right += gWidth;
|
||||||
}
|
}
|
||||||
|
if (endGlyph<glyphStartPositionList.length())
|
||||||
|
glyphStartPositionList[endGlyph] = right;
|
||||||
return right-left;
|
return right-left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ void QSynEditPainter::paintToken(
|
||||||
bool fontInited = false;
|
bool fontInited = false;
|
||||||
int tokenRight = tokenWidth+tokenLeft;
|
int tokenRight = tokenWidth+tokenLeft;
|
||||||
|
|
||||||
//qDebug()<<"Paint token"<<lineText<<tokenWidth<<tokenLeft<<first<<last<<rcToken;
|
// qDebug()<<"Paint token"<<lineText<<tokenWidth<<tokenLeft<<first<<last<<rcToken;
|
||||||
// qDebug()<<glyphStartCharList;
|
// qDebug()<<glyphStartCharList;
|
||||||
// qDebug()<<glyphStartPositionList;
|
// qDebug()<<glyphStartPositionList;
|
||||||
// qDebug()<<startGlyph<<endGlyph;
|
// qDebug()<<startGlyph<<endGlyph;
|
||||||
|
@ -389,7 +389,7 @@ void QSynEditPainter::paintToken(
|
||||||
int glyphLen = calcSegmentInterval(glyphStartCharList,lineText.length(),i);
|
int glyphLen = calcSegmentInterval(glyphStartCharList,lineText.length(),i);
|
||||||
QString glyph = lineText.mid(glyphStart,glyphLen);
|
QString glyph = lineText.mid(glyphStart,glyphLen);
|
||||||
int glyphWidth = calcSegmentInterval(glyphStartPositionList, tokenRight, i);
|
int glyphWidth = calcSegmentInterval(glyphStartPositionList, tokenRight, i);
|
||||||
// qDebug()<<"painting:"<<glyph<<glyphWidth<<tokenWidth+glyphWidth<<first<<last;
|
// qDebug()<<"painting:"<<glyph<<glyphWidth<<tokenWidth+glyphWidth<<first<<last;
|
||||||
if (tokenWidth+glyphWidth>first) {
|
if (tokenWidth+glyphWidth>first) {
|
||||||
if (!startPaint ) {
|
if (!startPaint ) {
|
||||||
nX-= (first - tokenWidth - 1) ;
|
nX-= (first - tokenWidth - 1) ;
|
||||||
|
@ -435,7 +435,7 @@ void QSynEditPainter::paintToken(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i+=1;
|
i+=1;
|
||||||
glyphWidth += calcSegmentInterval(glyphStartPositionList, tokenLeft+tokenWidth, i);
|
glyphWidth += calcSegmentInterval(glyphStartPositionList, tokenRight, i);
|
||||||
textToPaint+=glyph2;
|
textToPaint+=glyph2;
|
||||||
if (tokenWidth + glyphWidth > last )
|
if (tokenWidth + glyphWidth > last )
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1908,7 +1908,7 @@ void QSynEdit::doDeleteLastChar()
|
||||||
Q_ASSERT(glyphIndex>0);
|
Q_ASSERT(glyphIndex>0);
|
||||||
int oldCaretX = mCaretX;
|
int oldCaretX = mCaretX;
|
||||||
int newCaretX = mDocument->glyphStartChar(mCaretY-1, glyphIndex-1)+1;
|
int newCaretX = mDocument->glyphStartChar(mCaretY-1, glyphIndex-1)+1;
|
||||||
qDebug()<<"delete last char:"<<oldCaretX<<newCaretX<<glyphIndex<<mCaretY;
|
//qDebug()<<"delete last char:"<<oldCaretX<<newCaretX<<glyphIndex<<mCaretY;
|
||||||
QString s = tempStr.mid(newCaretX-1, oldCaretX-newCaretX);
|
QString s = tempStr.mid(newCaretX-1, oldCaretX-newCaretX);
|
||||||
internalSetCaretX(newCaretX);
|
internalSetCaretX(newCaretX);
|
||||||
if (s==' ' || s=='\t')
|
if (s==' ' || s=='\t')
|
||||||
|
@ -6096,6 +6096,8 @@ void QSynEdit::paintEvent(QPaintEvent *event)
|
||||||
cacheRC.setWidth(rcClip.width()*dpr);
|
cacheRC.setWidth(rcClip.width()*dpr);
|
||||||
cacheRC.setHeight(rcClip.height()*dpr);
|
cacheRC.setHeight(rcClip.height()*dpr);
|
||||||
painter.drawImage(rcClip,*mContentImage,cacheRC);
|
painter.drawImage(rcClip,*mContentImage,cacheRC);
|
||||||
|
//glyph positions may be updated while painting, so we need to recalc here.
|
||||||
|
rcCaret = calculateCaretRect();
|
||||||
}
|
}
|
||||||
paintCaret(painter, rcCaret);
|
paintCaret(painter, rcCaret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue