diff options
| -rw-r--r-- | widgets/cache.lua | 6 | ||||
| -rw-r--r-- | widgets/disks.lua | 28 |
2 files changed, 25 insertions, 9 deletions
diff --git a/widgets/cache.lua b/widgets/cache.lua index 0aeb016..af20347 100644 --- a/widgets/cache.lua +++ b/widgets/cache.lua @@ -42,9 +42,9 @@ function M.draw(cr, rect, colors) local items = c.items or {} local names = {} for i, e in ipairs(items) do - local name = e.name - if #name > 18 then name = name:sub(1, 17) .. '\u{2026}' end - names[i] = name + -- By character, not byte: a cache directory can carry an accented name and + -- a byte slice cuts one in half, which Cairo draws as a replacement box. + names[i] = card.truncate(e.name, 18) end local row_n = #items diff --git a/widgets/disks.lua b/widgets/disks.lua index c5fec1e..3b0f221 100644 --- a/widgets/disks.lua +++ b/widgets/disks.lua @@ -67,7 +67,9 @@ function M.draw(cr, rect, colors) local n = #fs local per_row = n local cell_w = inner.w / per_row - local r = math.min(cell_w * 0.34, avail_h * 0.30) + -- 0.27 rather than 0.30: two rows sit under each ring now, not one, and the + -- radius is what gives up the height. + local r = math.min(cell_w * 0.34, avail_h * 0.27) if r >= 18 then for i, e in ipairs(fs) do @@ -104,12 +106,26 @@ function M.draw(cr, rect, colors) card.text(cr, cx - sw_ / 2, cy + r * 0.55, sub) end - -- The percentage sits under the ring, in the threshold colour. - card.font(cr, card.FONT_MONO, label_size, false) + -- Free on top, total beneath, both centred under the ring. + -- + -- The percentage that used to sit here is gone: the ring already draws + -- it as an angle, and a number repeating it costs a row in a column + -- about 75px wide. Free carries the threshold colour because it is the + -- measured quantity; the total is fixed, so it stays in `value`. One + -- coloured number per column, as the rest of the board reads. + local free_size = label_size + local total_size = label_size * 0.88 + card.font(cr, card.FONT_MONO, free_size, false) card.rgba(cr, colour) - local pct = string.format('%d%%', e.pct) - local pw = card.measure(cr, pct) - card.text(cr, cx - pw / 2, cy + r + label_size * 1.7, pct) + local free_txt = card.human(e.avail) .. ' free' + local fw = card.measure(cr, free_txt) + card.text(cr, cx - fw / 2, cy + r + free_size * 1.7, free_txt) + + card.font(cr, card.FONT_MONO, total_size, false) + card.rgba(cr, colors.value) + local total_txt = card.human(e.size) + local tw = card.measure(cr, total_txt) + card.text(cr, cx - tw / 2, cy + r + free_size * 1.7 + total_size * 1.4, total_txt) end else local step = label_size * 2.6 |
