mpris: don't put ellipsis after whitespace
parent
e5524d5059
commit
0cfd1c7094
|
@ -39,8 +39,8 @@ class Mpris : public ALabel {
|
|||
std::optional<std::string> artist;
|
||||
std::optional<std::string> album;
|
||||
std::optional<std::string> title;
|
||||
std::optional<std::string> length; // as HH:MM:SS
|
||||
std::optional<std::string> position; // same format
|
||||
std::optional<std::string> length; // as HH:MM:SS
|
||||
std::optional<std::string> position; // same format
|
||||
};
|
||||
|
||||
auto getPlayerInfo() -> std::optional<PlayerInfo>;
|
||||
|
|
|
@ -50,30 +50,30 @@ The *mpris* module displays currently playing media via libplayerctl.
|
|||
*artist-len*: ++
|
||||
typeof: integer ++
|
||||
Maximum length of the Artist tag (Wide/Fullwidth Unicode characters
|
||||
count as two).
|
||||
count as two). Set to zero to hide the artist in `{dynamic}` tag.
|
||||
|
||||
*album-len*: ++
|
||||
typeof: integer ++
|
||||
Maximum length of the Album tag (Wide/Fullwidth Unicode characters count
|
||||
as two).
|
||||
as two). Set to zero to hide the album in `{dynamic}` tag.
|
||||
|
||||
*title-len*: ++
|
||||
typeof: integer ++
|
||||
Maximum length of the Title tag (Wide/Fullwidth Unicode characters count
|
||||
as two).
|
||||
as two). Set to zero to hide the title in `{dynamic}` tag.
|
||||
|
||||
*dynamic-len*: ++
|
||||
typeof: integer ++
|
||||
Maximum length of the Dynamic tag (Wide/Fullwidth Unicode characters
|
||||
count as two). The dynamic tag will not truncate any tags beyond their
|
||||
set length limits, instead, it will attempt to fit as much of the
|
||||
available tags as possible. It is recommended you set title-len to
|
||||
something less than or equal to this value, so the title will always be
|
||||
Maximum length of the Dynamic tag (Wide/Fullwidth Unicode characters ++
|
||||
count as two). The dynamic tag will not truncate any tags beyond their ++
|
||||
set length limits, instead, it will attempt to fit as much of the ++
|
||||
available tags as possible. It is recommended you set title-len to ++
|
||||
something less than or equal to this value, so the title will always be ++
|
||||
displayed.
|
||||
|
||||
*dynamic-priority* ++
|
||||
*dynamic-priority*: ++
|
||||
typeof: []string ++
|
||||
default: ["title", "length", "position", "artist", "album"]
|
||||
default: ["title", "length", "position", "artist", "album"] ++
|
||||
Priority of the tags when truncating the Dynamic tag (absence in this
|
||||
list means force inclusion).
|
||||
|
||||
|
@ -108,7 +108,8 @@ The *mpris* module displays currently playing media via libplayerctl.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned.
|
||||
If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
@ -126,11 +127,11 @@ The *mpris* module displays currently playing media via libplayerctl.
|
|||
Overwrite default action toggles.
|
||||
|
||||
*player-icons*: ++
|
||||
typeof: map[string]string
|
||||
typeof: map[string]string ++
|
||||
Allows setting _{player-icon}_ based on player-name property.
|
||||
|
||||
*status-icons*: ++
|
||||
typeof: map[string]string
|
||||
typeof: map[string]string ++
|
||||
Allows setting _{status-icon}_ based on player status (playing, paused,
|
||||
stopped).
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
|
|||
player_("playerctld"),
|
||||
manager(),
|
||||
player() {
|
||||
|
||||
if (config_["format-playing"].isString()) {
|
||||
format_playing_ = config_["format-playing"].asString();
|
||||
}
|
||||
|
@ -192,12 +191,13 @@ size_t utf8_truncate(std::string& str, size_t width = std::string::npos) {
|
|||
return str.length();
|
||||
} else if (g_unichar_iswide(c)) {
|
||||
total_width += 2;
|
||||
} else if (!g_unichar_iszerowidth(c) && c != 0xAD) { // neither zero-width nor soft hyphen
|
||||
} else if (!g_unichar_iszerowidth(c) && c != 0xAD) { // neither zero-width nor soft hyphen
|
||||
total_width += 1;
|
||||
}
|
||||
|
||||
data = g_utf8_find_next_char(data, end);
|
||||
if (width != std::string::npos && total_width <= width) trunc_end = data;
|
||||
if (width != std::string::npos && total_width <= width && !g_unichar_isspace(c))
|
||||
trunc_end = data;
|
||||
}
|
||||
|
||||
if (trunc_end) str.resize(trunc_end - str.data());
|
||||
|
|
Loading…
Reference in New Issue