Fixed invalid output after console spinner #122 #132

Merged
edraft merged 1 commits from #122 into 2022.12 2022-12-03 23:31:21 +01:00
2 changed files with 28 additions and 23 deletions
Showing only changes of commit e4aedb354b - Show all commits

View File

@ -500,7 +500,7 @@ class Console:
return return
if cls._hold_back: if cls._hold_back:
cls._hold_back_calls.append(ConsoleCall(cls.write, args)) cls._hold_back_calls.append(ConsoleCall(cls.write, *args))
return return
string = ' '.join(map(str, args)) string = ' '.join(map(str, args))
@ -523,7 +523,7 @@ class Console:
return return
if cls._hold_back: if cls._hold_back:
cls._hold_back_calls.append(ConsoleCall(cls.write_at, x, y, args)) cls._hold_back_calls.append(ConsoleCall(cls.write_at, x, y, *args))
return return
string = ' '.join(map(str, args)) string = ' '.join(map(str, args))
@ -542,7 +542,7 @@ class Console:
return return
if cls._hold_back: if cls._hold_back:
cls._hold_back_calls.append(ConsoleCall(cls.write_line, args)) cls._hold_back_calls.append(ConsoleCall(cls.write_line, *args))
return return
string = ' '.join(map(str, args)) string = ' '.join(map(str, args))
@ -567,7 +567,7 @@ class Console:
return return
if cls._hold_back: if cls._hold_back:
cls._hold_back_calls.append(ConsoleCall(cls.write_line_at, x, y, args)) cls._hold_back_calls.append(ConsoleCall(cls.write_line_at, x, y, *args))
return return
string = ' '.join(map(str, args)) string = ' '.join(map(str, args))

View File

@ -3,7 +3,12 @@ from cpl_core.console import Console, ForegroundColorEnum
def test_spinner(): def test_spinner():
Console.write_line('test1')
Console.write_line('test2', 2)
Console.write_line('test3', 2, 3)
Console.write_line('test4', 2, 3, 4)
time.sleep(2) time.sleep(2)
Console.write_line('test5')
def test_console(): def test_console():
@ -17,22 +22,22 @@ def test_console():
if __name__ == '__main__': if __name__ == '__main__':
Console.write_line('Hello World\n') Console.write_line('Hello World\n')
# Console.spinner('Test:', test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color='green') Console.spinner('Test:', test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color='green')
opts = [ # opts = [
'Option 1', # 'Option 1',
'Option 2', # 'Option 2',
'Option 3', # 'Option 3',
'Option 4' # 'Option 4'
] # ]
selected = Console.select( # selected = Console.select(
'>', # '>',
'Select item:', # 'Select item:',
opts, # opts,
header_foreground_color=ForegroundColorEnum.blue, # header_foreground_color=ForegroundColorEnum.blue,
option_foreground_color=ForegroundColorEnum.green, # option_foreground_color=ForegroundColorEnum.green,
cursor_foreground_color=ForegroundColorEnum.red # cursor_foreground_color=ForegroundColorEnum.red
) # )
Console.write_line(f'You selected: {selected}') # Console.write_line(f'You selected: {selected}')
# test_console() # # test_console()
#
Console.write_line() # Console.write_line()