File indexing completed on 2024-05-19 05:28:17

0001 // SPDX-FileCopyrightText: Markus Kuhn
0002 // SPDX-License-Identifier: CC0-1.0
0003 
0004 #pragma once
0005 
0006 #include <QStringView>
0007 
0008 inline int konsole_wcwidth(QChar ucs)
0009 {
0010     return wcwidth(ucs.unicode());
0011 }
0012 
0013 // single byte char: +1, multi byte char: +2
0014 inline int string_width(QStringView str)
0015 {
0016     int w = 0;
0017     for (auto c : str) {
0018         w += konsole_wcwidth(c);
0019     }
0020     return w;
0021 }