basic works

This commit is contained in:
Roy Qu 2024-01-19 19:41:45 +08:00
parent bb43e0e062
commit 14913d664e
1 changed files with 24 additions and 4 deletions

View File

@ -793,18 +793,38 @@ int Document::stringColumns(const QString &line, int colsBefore) const
{
int columns = std::max(0,colsBefore);
int charCols;
QString token;
for (int i=0;i<line.length();i++) {
QChar ch = line[i];
if (ch == '\t') {
charCols = mTabWidth - columns % mTabWidth;
if (ch.unicode()<0xFF) {
if (!token.isEmpty()) {
columns += tokenColumns(token);
token="";
}
if (ch == '\t') {
charCols = mTabWidth - columns % mTabWidth;
} else if (ch.unicode()<=32) {
charCols +=1;
} else {
width = mFontMetrics.horizontalAdvance(ch);
charCols += std::ceil(width / (double)mCharWidth);
}
columns+=charCols;
} else {
charCols = charColumns(ch);
token+=ch;
}
columns+=charCols;
}
if (!token.isEmpty()) {
columns += tokenColumns(token);
}
return columns-colsBefore;
}
int Document::tokenColumns(const QString &token) const
{
}
int Document::charColumns(QChar ch) const
{
if (ch.unicode()<=32)