From ac8653783dd939829c55054c760d60f7cd1c67d4 Mon Sep 17 00:00:00 2001 From: Nicholas Dyer Date: Thu, 21 Dec 2023 12:43:38 -0500 Subject: [PATCH] added temp title --- terminal/__main__.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/terminal/__main__.py b/terminal/__main__.py index ef35535..2245f29 100644 --- a/terminal/__main__.py +++ b/terminal/__main__.py @@ -2,6 +2,9 @@ import keyboard import time import os +HIGHLIGHTED = '\033[38;5;0m\033[48;5;2m' +REGULAR = '\033[38;5;2m' + def put_cursor(line, col): return f'\033[{int(line)};{int(col)}f' @@ -35,19 +38,22 @@ class Menu: for i, option in enumerate(self.options): print(f'{put_cursor(self.start_line + i, 0)}\033[2;0;0m', end='') - print(' ' * term_size.columns, end='\r') + print('' * term_size.columns, end='\r') if i == self.selected: - print(f'{self.highlight}•{option}') + print(f'{self.highlight}• {option}') else: - print(f'{self.regular}•{option}') - + print(f'{self.regular}• {option}') def main(): os.system('clear') - print('\033[?25l', end='\r') - print('\033[8m', end='\r') - selected_item = 0 + os.system('stty -echo') + term_size = os.get_terminal_size() + + print('\033[?25l', end='') + title = '[Interactive Text Menu]' + title_col_start = int((term_size.columns / 2) - (len(title) / 2)) + print(f'{put_cursor(0, title_col_start)}{REGULAR}{title}', end='\n') menu = Menu(10) menu.draw() while True: