diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index 077a94e1..f9032030 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -837,6 +837,22 @@ QString Document::glyphAt(int line, int charPos) return mLines[line]->glyph(glyphIdx); } +int Document::charToGlyphStartChar(int line, int charPos) +{ + QMutexLocker locker(&mMutex); + QList glyphPositions = mLines[line]->glyphPositions(); + int glyphIdx = charToGlyphIndex(glyphPositions, charPos); + return mLines[line]->glyphStart(glyphIdx); +} + +// int Document::columnToGlyphStartColumn(int line, int charPos) +// { +// QMutexLocker locker(&mMutex); +// QList glyphColumnsList = mLines[line]->glyphColumnsList(); +// int glyphIdx = columnToGlyphIndex(glyphColumnsList, charPos); +// return mLines[line]->glyphStartColumn(glyphIdx); +// } + QList calcGlyphPositions(const QString &text) { QList glyphPositions; @@ -847,10 +863,15 @@ QList calcGlyphPositions(const QString &text) QChar ch = text[i]; if (ch.isHighSurrogate() && i+1=0xE0100 && ucs4 <= 0xE01EF) { + //variation selector + } else { if (!consecutive) glyphPositions.append(i); + consecutive = false; } i+=2; continue; @@ -858,13 +879,17 @@ QList calcGlyphPositions(const QString &text) consecutive = true; } else if (ch.combiningClass()!=0 && !glyphPositions.isEmpty()) { //a Combining character + } else if (ch.unicode()>=0xFE00 && ch.unicode()<=0xFE0F) { + //variation selector } else { + //qDebug("%x %d", ch.unicode(), ch.combiningClass()); if (!consecutive) glyphPositions.append(i); consecutive = false; } i++; } + //qDebug()<0 && (modular <= (mCharWidth/5)) ) + glyphCols--; + //qDebug()< glyphPositions = calcGlyphPositions(token); + qDebug()<<"painting:"<document()->glyphColumns(glyph, columnsBefore+tokenColLen); - //qDebug()<=first) { if (!startPaint && (tokenColLen+1!=first)) { nX-= (first - tokenColLen - 1) * edit->mCharWidth; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 005e8ec9..516698ef 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -726,11 +726,9 @@ DisplayCoord QSynEdit::pixelsToNearestRowColumn(int aX, int aY) const DisplayCoord QSynEdit::pixelsToRowColumn(int aX, int aY) const { - return { - std::max(1, (int)(mLeftChar + (aX - mGutterWidth - 2.0) / mCharWidth)), - std::max(1, mTopLine + (aY / mTextHeight)) - }; - + int line = std::max(1, mTopLine + (aY / mTextHeight)); + int col = std::max(1, (int)(mLeftChar + (aX - mGutterWidth - 2.0) / mCharWidth)); + return DisplayCoord{col, line}; } QPoint QSynEdit::rowColumnToPixels(const DisplayCoord &coord) const @@ -864,7 +862,7 @@ int QSynEdit::columnToChar(int aLine, int aColumn) const //Q_ASSERT( (aLine <= mDocument->count()) && (aLine >= 1)); if (aLine <= mDocument->count()) { QString s = getDisplayStringAtLine(aLine); - return mDocument->columnToChar(aLine,s,aColumn)+1; + return mDocument->columnToChar(aLine-1,s,aColumn)+1; } return aColumn; } @@ -872,7 +870,7 @@ int QSynEdit::columnToChar(int aLine, int aColumn) const int QSynEdit::columnToChar(int aLine, const QString &s, int aColumn) const { if (aLine <= mDocument->count()) { - return mDocument->columnToChar(aLine,s,aColumn)+1; + return mDocument->columnToChar(aLine-1,s,aColumn)+1; } return aColumn; }