Skip to content

Commit

Permalink
feat: Implemented debugger launch configurations for workspaces, vari…
Browse files Browse the repository at this point in the history
…ables panel redone #373 (nightly) from tomlin7/debugger-manager

Debugger manager
  • Loading branch information
tomlin7 authored Jul 7, 2024
2 parents 614b56e + 5558957 commit 05e1028
Show file tree
Hide file tree
Showing 37 changed files with 1,109 additions and 226 deletions.
12 changes: 12 additions & 0 deletions .biscuit/launch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[config]
name = "Python: Debug Biscuit"
language = "python"
program = "main.py"
cwd = "{workspace}/src"

[config2]
name = "Python: Launch CLI"
language = "python"
program = "cli.py"
cwd = "{workspace}/src"

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "biscuit-editor"
version = "2.99.18"
version = "2.99.22"
description = "A lightweight, fast, and extensible code editor with a growing community"
authors = ["Billy <billydevbusiness@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/biscuit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.99.18"
__version__ = "2.99.22"
__version_info__ = tuple([int(num) for num in __version__.split(".")])

from .main import *
1 change: 1 addition & 0 deletions src/biscuit/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .cli import run

run()

32 changes: 27 additions & 5 deletions src/biscuit/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from biscuit.common.classdrill import *

if typing.TYPE_CHECKING:
from .. import App
from .app import App


class Commands:
Expand Down Expand Up @@ -73,8 +73,7 @@ def save_file_as(self, *_) -> None:
if editor.content and editor.content.editable:
if path := asksaveasfilename(
title="Save As...",
defaultextension=".txt",
initialfile=("Untitled"),
initialfile=(editor.filename or "Untitled.txt"),
):
editor.save(path)

Expand All @@ -84,8 +83,7 @@ def save_all(self, *_) -> None:
if not editor.content.exists:
if path := asksaveasfilename(
title="Save As...",
defaultextension=".txt",
initialfile=("Untitled"),
initialfile=(editor.filename or "Untitled.txt"),
):
return editor.save(path)
if editor.content.editable:
Expand Down Expand Up @@ -250,6 +248,30 @@ def rename_symbol(self, *_) -> None:
def restart_extension_server(self, *_) -> None:
self.base.extensions_manager.restart_server()

def debugger_toggle_pause(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.continue_pause()

def debugger_step_over(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.step_over()

def debugger_step_into(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.step_in()

def debugger_step_out(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.step_out()

def debugger_restart(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.restart()

def debugger_stop(self, *_):
if self.base.debugger_manager.latest:
self.base.debugger_manager.latest.stop()

def show_explorer(self, *_) -> None:
self.base.drawer.show_explorer()

Expand Down
79 changes: 45 additions & 34 deletions src/biscuit/common/menu/dropdown.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import tkinter as tk
from turtle import width

from ..codicon import get_codicon
from ..ui.icons import IconButton
Expand All @@ -21,22 +20,28 @@ class Dropdown(Frame):
def __init__(
self,
master,
selected: str = None,
items: list = None,
icon=None,
selected="",
items=[],
icon="",
callback=lambda *_: None,
iconside=tk.LEFT,
padx=5,
pady=1,
fg=None,
bg=None,
hfg=None,
hbg=None,
fg="",
bg="",
hfg="",
hbg="",
iconfg="",
iconbg="",
iconhfg="",
iconhbg="",
empty_message="No items",
*args,
**kwargs
) -> None:
super().__init__(master, padx=padx, pady=pady, *args, **kwargs)
self.callback = callback
self.empty_message = empty_message

self.bg, self.fg, self.hbg, self.hfg = (
self.base.theme.utils.iconlabelbutton.values()
Expand All @@ -50,57 +55,63 @@ def __init__(
if hbg:
self.hbg = hbg

self.iconfg = iconfg or self.fg
self.iconbg = iconbg or self.bg
self.iconhfg = iconhfg or self.hfg
self.iconhbg = iconhbg or self.hbg

self.config(bg=self.bg)
self.text = selected
self.text = selected or empty_message
self.icon = icon

self.icon_label = None
self.text_label = None

self.selected = None
self.menu = _DropdownMenu(self)
for i in items:
self.add_command(i)
self.set_items(items)

if icon:
self.icon_label = tk.Label(
self,
text=get_codicon(self.icon),
anchor=tk.CENTER,
bg=self.bg,
fg=self.fg,
bg=self.iconbg,
fg=self.iconfg,
font=("codicon", 12),
)
self.icon_label.pack(side=iconside, fill=tk.BOTH)

if selected:
self.text_label = tk.Label(
self,
text=self.text,
anchor=tk.CENTER,
pady=2,
bg=self.bg,
fg=self.fg,
font=("Segoe UI", 10),
)
self.text_label.pack(side=iconside, fill=tk.BOTH, expand=True)
self.text_label = tk.Label(
self,
text=self.text,
anchor=tk.CENTER,
pady=2,
bg=self.bg,
fg=self.fg,
font=("Segoe UI", 10),
)
self.text_label.pack(side=iconside, fill=tk.BOTH, expand=True)

self.close_btn = IconButton(self, "chevron-down", self.menu.show)
self.close_btn.config(bg=self.bg, fg=self.fg)
self.close_btn.pack(side=tk.RIGHT, fill=tk.BOTH)
self.dropdown_btn = IconButton(self, "chevron-down", self.menu.show)
self.dropdown_btn.config(bg=self.bg, fg=self.fg)
self.dropdown_btn.pack(side=tk.RIGHT, fill=tk.BOTH)

self.config_bindings()
self.visible = False

def add_command(self, text) -> None:
"""Add a command to the dropdown menu"""

self.menu.add_command(text, lambda: self.choose(text))
self.menu.add_command(text, lambda text=text: self.choose(text))

def set_items(self, items: list[str]) -> None:
self.menu.clear()
for i in items:
self.add_command(i)
if not items:
self.add_command(self.empty_message)
else:
for i in items:
self.add_command(i)

def config_bindings(self) -> None:
self.bind("<Enter>", self.on_enter)
Expand All @@ -117,16 +128,16 @@ def on_enter(self, *_) -> None:
if self.text:
self.text_label.config(bg=self.hbg, fg=self.hfg)
if self.icon:
self.icon_label.config(bg=self.hbg, fg=self.hfg)
self.close_btn.config(bg=self.hbg, fg=self.hfg)
self.icon_label.config(bg=self.iconhbg, fg=self.iconhfg)
self.dropdown_btn.config(bg=self.hbg, fg=self.hfg)

def on_leave(self, *_) -> None:
self.config(bg=self.bg)
if self.text:
self.text_label.config(bg=self.bg, fg=self.fg)
if self.icon:
self.icon_label.config(bg=self.bg, fg=self.fg)
self.close_btn.config(bg=self.bg, fg=self.fg)
self.icon_label.config(bg=self.iconbg, fg=self.iconfg)
self.dropdown_btn.config(bg=self.bg, fg=self.fg)

def change_text(self, text) -> None:
"""Change the text of the item"""
Expand Down
2 changes: 1 addition & 1 deletion src/biscuit/common/notifications/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
pady=10,
**self.base.theme.utils.iconbutton,
)
self.label.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)
self.label.pack(side=tk.LEFT, expand=1, fill=tk.BOTH, anchor=tk.W)

close_button = IconButton(top, "close", self.delete)
close_button.pack(fill=tk.BOTH)
Expand Down
16 changes: 12 additions & 4 deletions src/biscuit/common/ui/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,22 @@ def onclick(self, *args) -> None:
self.event(*args)
except:
self.event()
if not self.icon2:
return

self.switch = not self.switch
self.config(text=get_codicon(self.icons[self.switch]))
self.v_onclick()
self.toggle_icon()

def v_onclick(self) -> None: ...

def set_icon(self, icon) -> None:
self.config(text=get_codicon(icon))

def toggle_icon(self) -> None:
if not self.icon2:
return

self.switch = not self.switch
self.config(text=get_codicon(self.icons[self.switch]))

def reset_icon(self) -> None:
self.switch = False
self.config(text=get_codicon(self.icons[self.switch]))
41 changes: 34 additions & 7 deletions src/biscuit/common/ui/tree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tkinter as tk
import tkinter.ttk as ttk
import typing

from .native import Frame
from .scrollbar import Scrollbar
Expand All @@ -23,8 +24,9 @@ def __init__(
doubleclick=lambda _: None,
singleclick=lambda _: None,
columns=("fullpath", "type"),
style="",
*args,
**kwargs
**kwargs,
) -> None:
super().__init__(master, *args, **kwargs)
self.config(**self.base.theme.utils.tree)
Expand All @@ -41,6 +43,7 @@ def __init__(
show="tree",
columns=columns,
displaycolumns="",
style=style,
selectmode=tk.BROWSE,
)
self.tree.grid(row=0, column=0, sticky=tk.NSEW)
Expand Down Expand Up @@ -86,10 +89,13 @@ def bind(self, *args, **kwargs) -> None:
self.tree.bind(*args, **kwargs)

def check_singleclick(self, _) -> None:
if self.item_type(self.focus()) == "file":
if self.singleclick:
self.singleclick(self.item_fullpath(self.focus()))
else:
try:
if self.item_type(self.focus()) == "file":
if self.singleclick:
self.singleclick(self.item_fullpath(self.focus()))
else:
self.toggle_node(self.focus())
except:
self.toggle_node(self.focus())

def clear_node(self, node) -> None:
Expand Down Expand Up @@ -144,6 +150,9 @@ def parent_selected(self):
def selected_parent_path(self):
return self.item_fullpath(self.parent_selected())

def selection(self, *args, **kwargs):
return self.tree.selection(*args, **kwargs)

def selection_set(self, *args, **kwargs):
return self.tree.selection_set(*args, **kwargs)

Expand All @@ -162,10 +171,28 @@ def is_directory_selected(self):
def set(self, *args, **kwargs):
return self.tree.set(*args, **kwargs)

def __getattr__(self, name) -> typing.Any:
"""For methods that are not in this class, assume it is present in tree widget
and delegate the call to the `tree` widget."""

text_methods = set(dir(self.tree))
if name in text_methods:
attr = getattr(self.tree, name)
return attr
raise AttributeError(
f"'{self.__class__.__name__}' object has no attribute '{name}'"
)

def toggle_node(self, node) -> None:
if self.item_type(node) == "directory":
try:
if self.item_type(node) == "directory":
if self.is_open(node):
self.tree.item(node, open=False)
else:
self.tree.item(node, open=True)
self.tree.event_generate("<<Open>>")
except:
if self.is_open(node):
self.tree.item(node, open=False)
else:
self.tree.item(node, open=True)
self.tree.event_generate("<<Open>>")
2 changes: 2 additions & 0 deletions src/biscuit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .binder import Binder
from .commands import Commands
from .common import GameManager, SysInfo
from .debugger import DebuggerManager
from .execution import ExecutionManager
from .extensions import ExtensionManager
from .git import Git
Expand Down Expand Up @@ -68,6 +69,7 @@ def setup_configs(self) -> None:
self.game_manager = GameManager(self)
self.language_server_manager = LanguageServerManager(self)
self.execution_manager = ExecutionManager(self)
self.debugger_manager = DebuggerManager(self)

def setup_path(self, appdir: str) -> None:
"""Sets up the application paths and directories."""
Expand Down
Loading

0 comments on commit 05e1028

Please sign in to comment.