From 3c76e0ddd2083db5074e3cce644270cb84098c60 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Wed, 5 Aug 2009 22:11:11 +0200 Subject: Introduced the truncate helper. Function takes two arguments, the text to be truncated and the max lenght. Last three characters will be replaced by "...". Mbox and MPD widgets that previously did it them selves are now using this helper. --- mpd.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'mpd.lua') diff --git a/mpd.lua b/mpd.lua index f8c0400..bb193b5 100644 --- a/mpd.lua +++ b/mpd.lua @@ -34,12 +34,22 @@ function worker(format) nowplaying = helpers.escape(np) -- Don't abuse the wibox, truncate - if nowplaying:len() > 30 then - nowplaying = nowplaying:sub(1, 27) .. "..." - end + nowplaying = helpers.truncate(nowplaying, 30) return {nowplaying} end -- }}} setmetatable(_M, { __call = function(_, ...) return worker(...) end }) + + + + + + + + + + + + -- cgit v1.2.3