diff --git a/meson.build b/meson.build index 812cc428..69439aca 100644 --- a/meson.build +++ b/meson.build @@ -67,7 +67,6 @@ gtk_layer_shell = dependency('gtk-layer-shell-0', fallback : ['gtk-layer-shell', 'gtk_layer_shell_dep']) systemd = dependency('systemd', required: get_option('systemd')) tz_dep = dependency('date', default_options : [ 'use_system_tzdb=true' ], fallback: [ 'date', 'tz_dep' ]) -utfcpp = dependency('utfcpp', fallback: [ 'utfcpp', 'utfcpp_dep' ]) prefix = get_option('prefix') conf_data = configuration_data() @@ -169,8 +168,7 @@ executable( libudev, libmpdclient, gtk_layer_shell, - tz_dep, - utfcpp + tz_dep ], include_directories: [include_directories('include')], install: true, diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index f9181378..5efca403 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -1,6 +1,5 @@ #include "modules/clock.hpp" #include -#include using zoned_time = date::zoned_time; @@ -11,31 +10,18 @@ struct waybar_time { namespace { -size_t utf8_strlen(const std::string& s) { - return utf8::distance(s.begin(), s.end()); -} - -std::string utf8_substr(const std::string s, size_t len) { - utf8::iterator it(s.begin(), s.begin(), s.end()); - for (size_t i = 0; i < len; ++i) { - ++it; - } - int byte_count = it.base() - s.begin(); - return s.substr(0, byte_count); -} - void weekdays_header(const std::locale& locale, const date::weekday& first_dow, std::ostream& os) { auto wd = first_dow; do { if (wd != first_dow) os << ' '; - auto wd_string = date::format(locale, "%a", wd); - auto wd_string_len = utf8_strlen(wd_string); - if (wd_string_len > 2) { - wd_string = utf8_substr(wd_string, 2); - wd_string_len = 2; + Glib::ustring wd_ustring(date::format(locale, "%a", wd)); + auto wd_len = wd_ustring.length(); + if (wd_len > 2) { + wd_ustring = wd_ustring.substr(0, 2); + wd_len = 2; } - const std::string pad(2 - wd_string_len, ' '); - os << pad << wd_string; + const std::string pad(2 - wd_len, ' '); + os << pad << wd_ustring; } while (++wd != first_dow); os << "\n"; } diff --git a/subprojects/utfcpp.wrap b/subprojects/utfcpp.wrap deleted file mode 100644 index 51cf131b..00000000 --- a/subprojects/utfcpp.wrap +++ /dev/null @@ -1,9 +0,0 @@ -[wrap-file] -directory = utfcpp-2.3.5 -source_url = https://github.com/nemtrif/utfcpp/archive/v2.3.5.zip -source_filename = utfcpp-2.3.5.zip -source_hash = 1d5cb7d908202d734ec35b84087400013f352ffb4612e978ffb948986b76df14 - -patch_url = https://github.com/mesonbuild/utfcpp/releases/download/2.3.5-1/utfcpp.zip -patch_filename = utfcpp-2.3.5-1-wrap.zip -patch_hash = 5f504de947b34bb5995fcdb66a1ea1392288076a9400ead829da79e73441a13f