[O] Allow press enter to continue

This commit is contained in:
Azalea 2023-06-01 23:19:14 -07:00
parent cdbf8a6b24
commit dba600cc89

View file

@ -3,10 +3,21 @@ from time import sleep
from hyfetch import presets from hyfetch import presets
from hyfetch.color_util import RGB, color from hyfetch.color_util import RGB, color
from hyfetch.constants import IS_WINDOWS
from hyfetch.neofetch_util import term_size from hyfetch.neofetch_util import term_size
from hyfetch.presets import PRESETS 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(): def start_animation():
text = r""" text = r"""
.======================================================. .======================================================.
@ -40,8 +51,7 @@ def start_animation():
colors = [c for preset in PRESETS.values() for c in preset.colors] colors = [c for preset in PRESETS.values() for c in preset.colors]
black = RGB(0, 0, 0) black = RGB(0, 0, 0)
white = RGB(255, 255, 255) fg = RGB.from_hex("#FFE09B")
gold = RGB.from_hex("#FFE09B")
def draw_frame(): def draw_frame():
buf = "" buf = ""
@ -50,7 +60,7 @@ def start_animation():
for y in range(h): for y in range(h):
# Print the starting color # Print the starting color
buf += colors[((frame + y) // block_width) % len(colors)].to_ansi_rgb(foreground=False) 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 # Loop over the width
x = 0 x = 0
@ -92,9 +102,14 @@ def start_animation():
draw_frame() draw_frame()
frame += speed frame += speed
sleep(frame_delay) sleep(frame_delay)
if key_pressed():
break
except KeyboardInterrupt: except KeyboardInterrupt:
# Clear the screen pass
print("\033[2J\033[H", end="")
# Clear the screen
print("\033[2J\033[H", end="")
if __name__ == '__main__': if __name__ == '__main__':