From dba600cc89675b0fd94873c33759d5c91f625b3e Mon Sep 17 00:00:00 2001 From: Azalea Date: Thu, 1 Jun 2023 23:19:14 -0700 Subject: [PATCH] [O] Allow press enter to continue --- hyfetch/pride_month.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/hyfetch/pride_month.py b/hyfetch/pride_month.py index e0ce9f10..79881ad0 100644 --- a/hyfetch/pride_month.py +++ b/hyfetch/pride_month.py @@ -3,10 +3,21 @@ from time import sleep from hyfetch import presets from hyfetch.color_util import RGB, color +from hyfetch.constants import IS_WINDOWS from hyfetch.neofetch_util import term_size from hyfetch.presets import PRESETS +def key_pressed(): + if IS_WINDOWS: + import msvcrt + return msvcrt.kbhit() # Non-blocking check for key press + else: + import select + import sys + return select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []) + + def start_animation(): text = r""" .======================================================. @@ -40,8 +51,7 @@ def start_animation(): colors = [c for preset in PRESETS.values() for c in preset.colors] black = RGB(0, 0, 0) - white = RGB(255, 255, 255) - gold = RGB.from_hex("#FFE09B") + fg = RGB.from_hex("#FFE09B") def draw_frame(): buf = "" @@ -50,7 +60,7 @@ def start_animation(): for y in range(h): # Print the starting color buf += colors[((frame + y) // block_width) % len(colors)].to_ansi_rgb(foreground=False) - buf += gold.to_ansi_rgb(foreground=True) + buf += fg.to_ansi_rgb(foreground=True) # Loop over the width x = 0 @@ -92,9 +102,14 @@ def start_animation(): draw_frame() frame += speed sleep(frame_delay) + + if key_pressed(): + break except KeyboardInterrupt: - # Clear the screen - print("\033[2J\033[H", end="") + pass + + # Clear the screen + print("\033[2J\033[H", end="") if __name__ == '__main__':