refactor: extract utf8 truncation logic to utility
Move the UTF-8 visual-width measurement and truncation helper functions from the mpris module to a common utility (include/util/utf8_string.hpp and src/util/utf8_string.cpp). This decouples string truncation and width measurement from the mpris module, allowing other modules (like mpd) to reuse. The helper function `utf8_truncate` (formerly `truncate` in mpris) and `utf8_width` is exported under the `waybar::util` namespace, while the low-level `measure_and_truncate` (formerly `utf8_truncate`) is encapsulated in an anonymous namespace in src/util/utf8_string.cpp to avoid unnecessary API exposure. No functional changes were made to the mpris module's behavior.
This commit is contained in:
+2
-1
@@ -186,7 +186,8 @@ src_files = files(
|
||||
'src/util/icon_loader.cpp',
|
||||
'src/util/regex_collection.cpp',
|
||||
'src/util/css_reload_helper.cpp',
|
||||
'src/util/transform_8bit_to_rgba.cpp'
|
||||
'src/util/transform_8bit_to_rgba.cpp',
|
||||
'src/util/utf8_string.cpp'
|
||||
)
|
||||
|
||||
man_files = files(
|
||||
|
||||
Reference in New Issue
Block a user