mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 15:28:07 +02:00
tools: use box-drawing characters for the table in touchpad-pressure
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1394>
This commit is contained in:
parent
82cbbdab78
commit
49624ace16
1 changed files with 15 additions and 11 deletions
|
|
@ -51,35 +51,38 @@ class TableFormatter(object):
|
||||||
return sum(self.colwidths) + 1
|
return sum(self.colwidths) + 1
|
||||||
|
|
||||||
def headers(self, args):
|
def headers(self, args):
|
||||||
s = "|"
|
s = "│"
|
||||||
align = self.ALIGNMENT - 1 # account for |
|
align = self.ALIGNMENT - 1 # account for │
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
# +2 because we want space left/right of text
|
# +2 because we want space left/right of text
|
||||||
w = ((len(arg) + 2 + align) // align) * align
|
w = ((len(arg) + 2 + align) // align) * align
|
||||||
self.colwidths.append(w + 1)
|
self.colwidths.append(w + 1)
|
||||||
s += " {:^{width}s} |".format(arg, width=w - 2)
|
s += " {:^{width}s} │".format(arg, width=w - 2)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def values(self, args):
|
def values(self, args):
|
||||||
s = "|"
|
s = "│"
|
||||||
for w, arg in zip(self.colwidths, args):
|
for w, arg in zip(self.colwidths, args):
|
||||||
w -= 1 # width includes | separator
|
w -= 1 # width includes │ separator
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
# We want space margins for strings
|
# We want space margins for strings
|
||||||
s += " {:{width}s} |".format(arg, width=w - 2)
|
s += " {:{width}s} │".format(arg, width=w - 2)
|
||||||
elif isinstance(arg, bool):
|
elif isinstance(arg, bool):
|
||||||
s += "{:^{width}s}|".format("x" if arg else " ", width=w)
|
s += "{:^{width}s}│".format("x" if arg else " ", width=w)
|
||||||
else:
|
else:
|
||||||
s += "{:^{width}d}|".format(arg, width=w)
|
s += "{:^{width}d}│".format(arg, width=w)
|
||||||
|
|
||||||
if len(args) < len(self.colwidths):
|
if len(args) < len(self.colwidths):
|
||||||
s += "|".rjust(self.width - len(s), " ")
|
s += "│".rjust(self.width - len(s), " ")
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def header(self):
|
||||||
|
return "┌" + "─" * (self.width - 2) + "┐"
|
||||||
|
|
||||||
def separator(self):
|
def separator(self):
|
||||||
return "+" + "-" * (self.width - 2) + "+"
|
return "├" + "─" * (self.width - 2) + "┤"
|
||||||
|
|
||||||
|
|
||||||
fmt = TableFormatter()
|
fmt = TableFormatter()
|
||||||
|
|
@ -354,7 +357,8 @@ def loop(device):
|
||||||
headers = fmt.headers(
|
headers = fmt.headers(
|
||||||
["Touch", "down", "up", "palm", "thumb", "min", "max", "p", "avg", "median"]
|
["Touch", "down", "up", "palm", "thumb", "min", "max", "p", "avg", "median"]
|
||||||
)
|
)
|
||||||
print(fmt.separator())
|
|
||||||
|
print(fmt.header())
|
||||||
print(fmt.values(["Thresh", device.down, device.up, device.palm, device.thumb]))
|
print(fmt.values(["Thresh", device.down, device.up, device.palm, device.thumb]))
|
||||||
print(fmt.separator())
|
print(fmt.separator())
|
||||||
print(headers)
|
print(headers)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue