From 70d2029a9f56307f214c7113b517381bd7b37105 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Mon, 21 Jul 2025 15:31:56 +0200 Subject: [PATCH] smart newlines --- kglobe.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kglobe.py b/kglobe.py index 340e182..7d76f92 100644 --- a/kglobe.py +++ b/kglobe.py @@ -128,15 +128,20 @@ def main(): kitty.hide_cursor() y, x = kitty.get_position() - print("\n" * 25, end="") + height, width = kitty.get_terminal_size_pixel() + h_pix, w_pix = kitty.get_terminal_cell_size() + + # the image requires height/cell_height lines + needed_lines = round(height/h_pix) + print("\n" * needed_lines, end="") try: if not args.external: while True: pl.camera.Azimuth(1) buf: BytesIO = BytesIO() - pl.screenshot(buf, transparent_background=True, window_size=(512, 512)) - kitty.set_position(y - 25, x) + pl.screenshot(buf, transparent_background=True, window_size=(height, width)) + kitty.set_position(y - needed_lines, 0) kitty.draw_to_terminal(buf) else: pl.show()