Use battery_full and battery_empty for displaying hearts

Red hearts for battery full are still more optimal in case white hearts are for
empty (though I do not understand why they have to be red). Cannot agree about
per cents though: red is better for empty then white is if there are no related
parts to compare.
This commit is contained in:
ZyX 2014-07-07 19:57:28 +04:00
parent 2f7c44c29c
commit a0a5b44173
3 changed files with 18 additions and 9 deletions

View File

@ -25,6 +25,8 @@
"environment": { "fg": "gray8", "bg": "gray0" },
"battery": { "fg": "gray8", "bg": "gray0" },
"battery_gradient": { "fg": "white_red", "bg": "gray0" },
"battery_full": { "fg": "red", "bg": "gray0" },
"battery_empty": { "fg": "white", "bg": "gray0" },
"now_playing": { "fg": "gray10", "bg": "black" }
}
}

View File

@ -1140,14 +1140,21 @@ def battery(pl, format='{capacity:3.0%}', steps=5, gamify=False, full_heart='♥
Number of discrete steps to show between 0% and 100% capacity if gamify
is True.
:param bool gamify:
Measure in hearts () instead of percentages.
Measure in hearts () instead of percentages. For full hearts
``battery_full`` highlighting group is preferred, for empty hearts there
is ``battery_empty``.
:param str full_heart:
Heart displayed for full part of battery.
:param str empty_heart:
Heart displayed for used part of battery. It is also displayed using
another gradient level, so it is OK for it to be the same as full_heart.
another gradient level and highlighting group, so it is OK for it to be
the same as full_heart as long as necessary highlighting groups are
defined.
Highlight groups used: ``battery_gradient`` (gradient), ``battery``.
``battery_gradient`` and ``battery`` groups are used in any case, first is
preferred.
Highlight groups used: ``battery_full`` or ``battery_gradient`` (gradient) or ``battery``, ``battery_empty`` or ``battery_gradient`` (gradient) or ``battery``.
'''
try:
capacity = _get_capacity(pl)
@ -1161,14 +1168,14 @@ def battery(pl, format='{capacity:3.0%}', steps=5, gamify=False, full_heart='♥
ret.append({
'contents': full_heart * numer,
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_full', 'battery_gradient', 'battery'],
# Using zero as “nothing to worry about”: it is least alert color.
'gradient_level': 0,
})
ret.append({
'contents': empty_heart * (denom - numer),
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_empty', 'battery_gradient', 'battery'],
# Using a hundred as it is most alert color.
'gradient_level': 100,
})

View File

@ -549,13 +549,13 @@ class TestCommon(TestCase):
{
'contents': '♥♥♥♥',
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_full', 'battery_gradient', 'battery'],
'gradient_level': 0
},
{
'contents': '',
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_empty', 'battery_gradient', 'battery'],
'gradient_level': 100
}
])
@ -563,13 +563,13 @@ class TestCommon(TestCase):
{
'contents': '++++++++',
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_full', 'battery_gradient', 'battery'],
'gradient_level': 0
},
{
'contents': '--',
'draw_inner_divider': False,
'highlight_group': ['battery_gradient', 'battery'],
'highlight_group': ['battery_empty', 'battery_gradient', 'battery'],
'gradient_level': 100
}
])