forked from qt-creator/qt-creator
ClangFormat: Refactor code
Reorder some functions, remove code duplication. Change-Id: I33e118e567dee7db622bbc99e6a7c500db54e5c5 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -165,5 +165,27 @@ int utf8NthLineOffset(const QTextDocument *textDocument, const QByteArray &buffe
|
||||
return utf8Offset;
|
||||
}
|
||||
|
||||
LineColumn utf16LineColumn(const QByteArray &utf8Buffer, int utf8Offset)
|
||||
{
|
||||
Utils::LineColumn lineColumn;
|
||||
lineColumn.line = static_cast<int>(
|
||||
std::count(utf8Buffer.begin(), utf8Buffer.begin() + utf8Offset, '\n'))
|
||||
+ 1;
|
||||
const int startOfLineOffset = utf8Buffer.lastIndexOf('\n', utf8Offset - 1) + 1;
|
||||
lineColumn.column = QString::fromUtf8(
|
||||
utf8Buffer.mid(startOfLineOffset, utf8Offset - startOfLineOffset))
|
||||
.length()
|
||||
+ 1;
|
||||
return lineColumn;
|
||||
}
|
||||
|
||||
QString utf16LineTextInUtf8Buffer(const QByteArray &utf8Buffer, int currentUtf8Offset)
|
||||
{
|
||||
const int lineStartUtf8Offset = utf8Buffer.lastIndexOf('\n', currentUtf8Offset - 1) + 1;
|
||||
const int lineEndUtf8Offset = utf8Buffer.indexOf('\n', currentUtf8Offset);
|
||||
return QString::fromUtf8(
|
||||
utf8Buffer.mid(lineStartUtf8Offset, lineEndUtf8Offset - lineStartUtf8Offset));
|
||||
}
|
||||
|
||||
} // Text
|
||||
} // Utils
|
||||
|
||||
Reference in New Issue
Block a user