mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 02:20:05 +01:00
tools/per-slot-delta: refactor the printing of a slot
This makes it easier to optionally print extra components of that slot. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1101>
This commit is contained in:
parent
5df1d26aa2
commit
5f8f715017
1 changed files with 11 additions and 6 deletions
|
|
@ -113,14 +113,19 @@ class SlotFormatter:
|
||||||
if self.threshold is not None and dist >= self.threshold:
|
if self.threshold is not None and dist >= self.threshold:
|
||||||
color = COLOR_RED
|
color = COLOR_RED
|
||||||
reset = COLOR_RESET
|
reset = COLOR_RESET
|
||||||
|
|
||||||
if isinstance(delta.x, int) and isinstance(delta.y, int):
|
if isinstance(delta.x, int) and isinstance(delta.y, int):
|
||||||
string = "{} {}{:+4d}/{:+4d} {}".format(
|
coords = f"{delta.x:+4d}/{delta.y:+4d}"
|
||||||
direction, color, delta.x, delta.y, reset
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
string = "{} {}{:+3.2f}/{:+03.2f}{}".format(
|
coords = f"{delta.x:+3.2f}/{delta.y:+03.2f}"
|
||||||
direction, color, delta.x, delta.y, reset
|
components = [
|
||||||
)
|
f"{direction}",
|
||||||
|
f"{color}",
|
||||||
|
coords,
|
||||||
|
f"{reset}",
|
||||||
|
]
|
||||||
|
|
||||||
|
string = " ".join(components)
|
||||||
else:
|
else:
|
||||||
x, y = slot.position.x, slot.position.y
|
x, y = slot.position.x, slot.position.y
|
||||||
string = "{} {}{:4d}/{:4d}{}".format(direction, color, x, y, reset)
|
string = "{} {}{:4d}/{:4d}{}".format(direction, color, x, y, reset)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue