diff --git a/main.py b/main.py index edafcdc..7111f98 100644 --- a/main.py +++ b/main.py @@ -45,6 +45,7 @@ class Berry(App): id="file-tabs" ) yield TextArea.code_editor(placeholder="This file is empty.", language="python", theme="css", id="code-editor", disabled=True) + with Vertical(id="console-container"): yield RichLog(id="console") yield Input(placeholder="> ", id="console-input") @@ -62,8 +63,18 @@ class Berry(App): console = self.query_one("#console") console.write(f"> {command}") - result = subprocess.check_output(command, shell=True, text=True) - console.write(result) + + if command == "clear" or command == "cls": + console.clear() + else: + try: + result = subprocess.check_output(command, shell=True, text=True) + console.write(result) + except subprocess.CalledProcessError as e: + console.write(e.stdout) + + + self.query_one("#console-input").focus() def action_find(self): try: @@ -177,6 +188,8 @@ class Berry(App): code_editor.language = None code_editor.disabled = False + code_editor.focus() + @on(Window.Minimized) def window_minimized(self, event: Window.Minimized):