mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 04:30:06 +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:
|
||||
color = COLOR_RED
|
||||
reset = COLOR_RESET
|
||||
|
||||
if isinstance(delta.x, int) and isinstance(delta.y, int):
|
||||
string = "{} {}{:+4d}/{:+4d} {}".format(
|
||||
direction, color, delta.x, delta.y, reset
|
||||
)
|
||||
coords = f"{delta.x:+4d}/{delta.y:+4d}"
|
||||
else:
|
||||
string = "{} {}{:+3.2f}/{:+03.2f}{}".format(
|
||||
direction, color, delta.x, delta.y, reset
|
||||
)
|
||||
coords = f"{delta.x:+3.2f}/{delta.y:+03.2f}"
|
||||
components = [
|
||||
f"{direction}",
|
||||
f"{color}",
|
||||
coords,
|
||||
f"{reset}",
|
||||
]
|
||||
|
||||
string = " ".join(components)
|
||||
else:
|
||||
x, y = slot.position.x, slot.position.y
|
||||
string = "{} {}{:4d}/{:4d}{}".format(direction, color, x, y, reset)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue