fix(awful: hotkeys): compute length of the line correctly

This commit is contained in:
actionless 2016-02-11 01:04:54 +01:00
parent 64bd09d38d
commit 3a9f7a1cee
1 changed files with 2 additions and 1 deletions

View File

@ -257,14 +257,15 @@ local function create_wibox(s, available_groups)
local max_label_content = "" local max_label_content = ""
local joined_labels = "" local joined_labels = ""
for i, key in ipairs(_keys) do for i, key in ipairs(_keys) do
local length = string.len(key.key or '') + string.len(key.description or '')
local modifiers = key.mod local modifiers = key.mod
if not modifiers or modifiers == "none" then if not modifiers or modifiers == "none" then
modifiers = "" modifiers = ""
else else
length = length + string.len(modifiers) + 1 -- +1 for "+" character
modifiers = markup.fg(widget.modifiers_color, modifiers.."+") modifiers = markup.fg(widget.modifiers_color, modifiers.."+")
end end
local hotkey = modifiers .. (key.key or '') local hotkey = modifiers .. (key.key or '')
local length = string.len(hotkey) + string.len(key.description)
local rendered_hotkey = markup.font(widget.title_font, hotkey.." ") .. local rendered_hotkey = markup.font(widget.title_font, hotkey.." ") ..
(markup.font(widget.description_font, key.description) or "") (markup.font(widget.description_font, key.description) or "")
if length > max_label_width then if length > max_label_width then