Page 1 of 1

CC: Draw bar & place text on it

Posted: 27 Apr 2026 11:35
by highend
It would be cool if we could additionally place text (centered) in a custom column with format = icon e.g. for perfect age columns...

Like this:
onecommander_pages-number_file-age-colour_1.png
Taken from: viewtopic.php?t=29617

Sample script (without text ofc):

Code: Select all

    $modified = property("#date.m", "<cc_item>");
    $diff     = datediff($modified, , "n"); // Difference in minutes
    switch (true) {
        case $diff == 0:    return ''; // draw nothing
        case $diff < 1440:  return '>draw.bar ' . 100 . ', 66CC66, BBEEBB'; // less than a day
        case $diff < 2880:  return '>draw.bar ' . 100 . ', FFBB00, FFEE88'; // 1 day
        case $diff < 10080: return '>draw.bar ' . 100 . ', DD4444, FFAAAA'; // 2 - 7 days
        // ...
        default:            return '>draw.bar ' . 100 . ', DD44AA, FFAADD';
    }

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 14:27
by admin
Do you have a suggestion for the syntax? It would at least need the text and the text color.

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 14:32
by highend
Maybe:

Code: Select all

>draw.bar [percentage=50], [colorleft], [colorright], [opacity=224], [borderwidth=0]|[text]|[colortext]
A "," for the delimiter between [text] and [colortext] wouldn't make sense, so why not use two bars?

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 14:40
by admin
Because the text may contain a comma?

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 14:41
by highend
Exactly

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 14:49
by admin
Looks doable. :)

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 16:07
by highend
:tup:

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 18:18
by highend
Very cool! One minor request though (if it's still possible and not too much work):

Code: Select all

>draw.bar [percentage=50], [colorleft], [colorright], [opacity=224], [borderwidth=0]|[text]|[colortext]|[horizontalalignment]
Alignments:
c = center
l = left
r = left
If [alignment] is left out, it's c by default

The vertical alignment should imho be always centered

Re: CC: Draw bar & place text on it

Posted: 27 Apr 2026 18:27
by admin
Tomorrow. :)

Re: CC: Draw bar & place text on it

Posted: 28 Apr 2026 16:45
by highend
Thanks, great addition!

Re: CC: Draw bar & place text on it

Posted: 28 Apr 2026 17:03
by admin
I agree, thanks for the idea! :tup: