From d6fa17cdd94511317982ed254fcb8b7ea4f319b3 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 22 Feb 2024 14:24:29 +0800 Subject: [PATCH] work save --- libs/qsynedit/qsynedit/document.cpp | 47 ++++++++++++++++++------ libs/qsynedit/qsynedit/document.h | 57 ++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 17 deletions(-) diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index e69f2220..6a4da3ff 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -833,7 +833,8 @@ QList calcGlyphPositions(const QString &text) if (ch.isHighSurrogate() && i+1 glyphPositions = calcGlyphPositions(str); int totalColumns; calcGlyphColumns(str,glyphPositions,colsBefore, totalColumns); - return totalColumns; + return totalColumns - colsBefore; +} + +int Document::charToColumn(int line, int charPos) +{ + QMutexLocker locker(&mMutex); + QList glyphPositions = mLines[line]->glyphPositions(); + } int Document::charToColumn(const QString &lineText, int charPos) const { + QMutexLocker locker(&mMutex); QList glyphPositions = calcGlyphPositions(lineText); return charToColumn(lineText, glyphPositions, charPos); } @@ -984,19 +993,33 @@ DocumentLine::DocumentLine(): { } -QStringRef DocumentLine::getGlyph(int i) const +int DocumentLine::glyphEnd(int i) const { - Q_ASSERT(i>=0 && i=0 && i=0); + Q_ASSERT(i>=0 && i& glyphColumns() const { return mGlyphColumns; } + + /** + * @brief get start index of the chars representing the specified glyph. + * @param i index of the glyph of the line (starting from 0) + * @return + */ + int glyphStart(int i) const { + Q_ASSERT(i>=0 && i=0); + Q_ASSERT(i>=0 && i