From e4aedb354bb0fb6d8259550101826ca2fcc8caf2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 3 Dec 2022 23:30:54 +0100 Subject: [PATCH] Fixed invalid output after console spinner #122 --- src/cpl_core/console/console.py | 8 +++--- tests/custom/console/main.py | 43 ++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/cpl_core/console/console.py b/src/cpl_core/console/console.py index 3475b64d..c10b3590 100644 --- a/src/cpl_core/console/console.py +++ b/src/cpl_core/console/console.py @@ -500,7 +500,7 @@ class Console: return if cls._hold_back: - cls._hold_back_calls.append(ConsoleCall(cls.write, args)) + cls._hold_back_calls.append(ConsoleCall(cls.write, *args)) return string = ' '.join(map(str, args)) @@ -523,7 +523,7 @@ class Console: return 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 string = ' '.join(map(str, args)) @@ -542,7 +542,7 @@ class Console: return 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 string = ' '.join(map(str, args)) @@ -567,7 +567,7 @@ class Console: return 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 string = ' '.join(map(str, args)) diff --git a/tests/custom/console/main.py b/tests/custom/console/main.py index 12889c57..dc2fcb5b 100644 --- a/tests/custom/console/main.py +++ b/tests/custom/console/main.py @@ -3,7 +3,12 @@ from cpl_core.console import Console, ForegroundColorEnum 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) + Console.write_line('test5') def test_console(): @@ -17,22 +22,22 @@ def test_console(): if __name__ == '__main__': Console.write_line('Hello World\n') - # Console.spinner('Test:', test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color='green') - opts = [ - 'Option 1', - 'Option 2', - 'Option 3', - 'Option 4' - ] - selected = Console.select( - '>', - 'Select item:', - opts, - header_foreground_color=ForegroundColorEnum.blue, - option_foreground_color=ForegroundColorEnum.green, - cursor_foreground_color=ForegroundColorEnum.red - ) - Console.write_line(f'You selected: {selected}') - # test_console() - - Console.write_line() + Console.spinner('Test:', test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color='green') + # opts = [ + # 'Option 1', + # 'Option 2', + # 'Option 3', + # 'Option 4' + # ] + # selected = Console.select( + # '>', + # 'Select item:', + # opts, + # header_foreground_color=ForegroundColorEnum.blue, + # option_foreground_color=ForegroundColorEnum.green, + # cursor_foreground_color=ForegroundColorEnum.red + # ) + # Console.write_line(f'You selected: {selected}') + # # test_console() + # + # Console.write_line() -- 2.45.2