From f80797b7341f70008251e46590ee046fc4f1befe Mon Sep 17 00:00:00 2001 From: Billy Date: Wed, 15 May 2024 12:08:57 +0530 Subject: [PATCH] fix: Open new terminals in working directory (or $home if no directory opened), add a terminal instance when panel is toggled (active terminal type, otherwise the default configured) --- .../core/components/views/panel/terminal/terminal.py | 2 +- .../components/views/sidebar/extensions/extension.py | 2 +- biscuit/core/layout/base/content/__init__.py | 3 +++ biscuit/core/utils/python_dialog.py | 6 +++++- biscuit/core/utils/sysinfo.py | 12 ++++++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/biscuit/core/components/views/panel/terminal/terminal.py b/biscuit/core/components/views/panel/terminal/terminal.py index e87409cd..09b9d3a8 100644 --- a/biscuit/core/components/views/panel/terminal/terminal.py +++ b/biscuit/core/components/views/panel/terminal/terminal.py @@ -63,7 +63,7 @@ def start_service(self, *_) -> None: self.alive = True self.last_command = None - self.p = PTY.spawn([self.shell]) + self.p = PTY.spawn([self.shell], cwd=self.cwd) Thread(target=self.write_loop, daemon=True).start() def destroy(self, *_) -> None: diff --git a/biscuit/core/components/views/sidebar/extensions/extension.py b/biscuit/core/components/views/sidebar/extensions/extension.py index 872a2bc2..ec0e85b1 100644 --- a/biscuit/core/components/views/sidebar/extensions/extension.py +++ b/biscuit/core/components/views/sidebar/extensions/extension.py @@ -16,7 +16,7 @@ def __init__(self, master, name: str, data: list, *args, **kwargs) -> None: self.name = name self.file = os.path.join(self.base.extensionsdir, data[0]) self.author = data[1] - self.description = data[2] + self.description = data[2][:35] + "..." if len(data[2]) > 30 else data[2] self.url = f"{master.repo_url}extensions/{data[0]}" self.installed = os.path.isfile(self.file) diff --git a/biscuit/core/layout/base/content/__init__.py b/biscuit/core/layout/base/content/__init__.py index 9180b2ec..32446f82 100644 --- a/biscuit/core/layout/base/content/__init__.py +++ b/biscuit/core/layout/base/content/__init__.py @@ -55,6 +55,9 @@ def toggle_panel(self, *_) -> None: self.editorspane.pack_forget() else: self.panel.pack(fill=tk.BOTH, pady=(1, 0)) + + if not self.panel.terminals.active_terminal: + self.panel.terminals.open_terminal() self._panel_enabled = not self._panel_enabled diff --git a/biscuit/core/utils/python_dialog.py b/biscuit/core/utils/python_dialog.py index bb57cfda..4dd6d44f 100644 --- a/biscuit/core/utils/python_dialog.py +++ b/biscuit/core/utils/python_dialog.py @@ -1,3 +1,4 @@ +import os import subprocess as sp import webbrowser from tkinter import messagebox @@ -13,7 +14,10 @@ def show_python_not_installed_message(): def check_python_installation(): try: - sp.check_call(["python", "--version"]) + if os.name == "nt": + sp.check_call(["python", "--version"]) + else: + sp.check_call(["python3", "--version"]) reqs = sp.check_output(['pip', 'freeze']) # install python language server diff --git a/biscuit/core/utils/sysinfo.py b/biscuit/core/utils/sysinfo.py index 3f516d29..ad236f7d 100644 --- a/biscuit/core/utils/sysinfo.py +++ b/biscuit/core/utils/sysinfo.py @@ -27,6 +27,18 @@ def __init__(self, base: App) -> None: self.processor = platform.processor() self.python_version = sys.version self.tk_version = tk.TclVersion + + @property + def is_windows(self) -> bool: + return self.os == "Windows" + + @property + def is_linux(self) -> bool: + return self.os == "Linux" + + @property + def is_macos(self) -> bool: + return self.os == "Darwin" def get_current_stats(self) -> str: """Get current CPU and Memory usage"""