spreadsheet

terminal spreadsheet application
git clone https://git.ce9e.org/spreadsheet.git

commit
9a95b8616bc9d416e42323be15663f3dbc65c999
parent
16f9704678f35fb1a7555a8b2cce5314ddbe0328
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-07-20 12:30
higher resolution bar graph

Diffstat

M sheet/sheet.py 9 ++++++---

1 files changed, 6 insertions, 3 deletions


diff --git a/sheet/sheet.py b/sheet/sheet.py

@@ -2,15 +2,18 @@
    2     2 from .expression import ParseError
    3     3 from .expression import parse
    4     4 
   -1     5 BLOCKS = [' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█']
   -1     6 
    5     7 
    6     8 class Bar:
    7     9     def __init__(self, value):
    8    10         self.value = value
    9    11 
   10    12     def render(self, width):
   11    -1         x = int(self.value * width)
   12    -1         x = max(0, min(x, width))
   13    -1         return '#' * x + ' ' * (width - x)
   -1    13         value = max(0, min(1, self.value))
   -1    14         x = int(value * width * (len(BLOCKS) - 1))
   -1    15         a, b = divmod(x, len(BLOCKS) - 1)
   -1    16         return a * BLOCKS[-1] + BLOCKS[b] + (width - a - 1) * BLOCKS[0]
   14    17 
   15    18 
   16    19 def iter_range(cell1, cell2):