From 8d6bf6aa057aee888d0deda999200814abb74cc6 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 2 Sep 2012 22:03:00 +0200 Subject: [PATCH] menu: duplicate temporarily function to restore functionality --- src/song.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/song.cpp b/src/song.cpp index 1c2c2e09..2311f0e8 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -38,6 +38,19 @@ size_t calc_hash(const char* s, unsigned seed = 0) return hash; } +// temporary hack, it won't work properly with wide characters +std::string Shorten(const std::basic_string &s, size_t max_length) +{ + if (s.length() <= max_length) + return TO_STRING(s); + if (max_length < 2) + return ""; + std::basic_string result(s, 0, max_length/2-!(max_length%2)); + result += U(".."); + result += s.substr(s.length()-max_length/2+1); + return TO_STRING(result); +} + } namespace MPD {// @@ -360,9 +373,9 @@ std::string Song::ParseFormat(std::string::const_iterator &it, const std::string { if (delimiter) { - /*const std::basic_string &s = TO_WSTRING(tag); - if (NCurses::Window::Length(s) > delimiter) - tag = Shorten(s, delimiter);*/ + const std::basic_string &s = TO_WSTRING(tag); + if (NC::Window::Length(s) > delimiter) + tag = Shorten(s, delimiter); } has_some_tags = 1; result += tag;