From c3f84c22f0a498532d202654c527743fc6ac9ee0 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 31 Aug 2016 17:39:51 +0200 Subject: [PATCH] feat: Label maxlen property label-NAME-maxlen = N label-NAME-ellipsis = bool Fixes jaagr/lemonbuddy#49 --- README.md | 6 +++++- include/drawtypes/label.hpp | 6 ++++-- src/drawtypes/label.cpp | 6 ++++-- src/services/builder.cpp | 11 ++++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1b7cfe84..1fa17bc6 100644 --- a/README.md +++ b/README.md @@ -281,7 +281,7 @@ The configuration syntax is based on the `ini` file format. ; ; The rest of the drawtypes follow the same pattern. ; - ; label-NAME[-(foreground|background|(under|over)line|font|padding)] = ? + ; label-NAME[-(foreground|background|(under|over)line|font|padding|maxlen|ellipsis)] = ? ; icon-NAME[-(foreground|background|(under|over)line|font|padding)] = ? ; ramp-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ? ; animation-NAME-[0-9]+[-(foreground|background|(under|over)line|font|padding)] = ? @@ -300,6 +300,10 @@ The configuration syntax is based on the `ini` file format. format-offline = format-offline-offset = -8 + ; Cap the song label without trailing ellipsis + label-song-maxlen = 30 + label-song-ellipsis = false + ; By only specifying alpha value, it will be applied to the bar's default foreground label-time-foreground = #66 diff --git a/include/drawtypes/label.hpp b/include/drawtypes/label.hpp index 9825e43a..39721e00 100644 --- a/include/drawtypes/label.hpp +++ b/include/drawtypes/label.hpp @@ -9,11 +9,13 @@ namespace drawtypes { std::string text, fg, bg, ul, ol; int font = 0, padding = 0, margin = 0; + size_t maxlen = 0; + bool ellipsis = true; Label(std::string text, int font) : text(text), font(font){} - Label(std::string text, std::string fg = "", std::string bg = "", std::string ul = "", std::string ol = "", int font = 0, int padding = 0, int margin = 0) - : text(text), fg(fg), bg(bg), ul(ul), ol(ol), font(font), padding(padding), margin(margin){} + Label(std::string text, std::string fg = "", std::string bg = "", std::string ul = "", std::string ol = "", int font = 0, int padding = 0, int margin = 0, size_t maxlen = 0, bool ellipsis = true) + : text(text), fg(fg), bg(bg), ul(ul), ol(ol), font(font), padding(padding), margin(margin), maxlen(maxlen), ellipsis(ellipsis){} operator bool() { return !this->text.empty(); diff --git a/src/drawtypes/label.cpp b/src/drawtypes/label.cpp index 7811f7c4..caa231ac 100644 --- a/src/drawtypes/label.cpp +++ b/src/drawtypes/label.cpp @@ -6,7 +6,7 @@ namespace drawtypes { std::unique_ptr