Skip to content

Commit

Permalink
fix: Panel views (terminal, logs, inspect, etc.) will now use seconda…
Browse files Browse the repository at this point in the history
…ry colors
  • Loading branch information
tomlin7 committed Nov 2, 2024
1 parent 89f94d0 commit eca7ada
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 61 deletions.
8 changes: 4 additions & 4 deletions src/biscuit/layout/panel/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def __init__(self, master: Content, *args, **kwargs) -> None:
self.grid_columnconfigure(0, weight=1)

self.grid_propagate(False)
self.config(height=300, **self.base.theme.layout.content.panel)
self.config(height=300, bg=self.base.theme.border)

self.panelbar = PanelBar(self)
self.panelbar.grid(row=0, column=0, sticky=tk.EW)
self.panelbar.grid(row=0, column=0, sticky=tk.EW, pady=(0, 1))

self.views: list[PanelView] = []

self.default_views = [Problems(self), Logs(self), Control(self), Terminal(self)]
self.default_views = [Problems(self), Logs(self), Inspect(self), Terminal(self)]
self.add_views(self.default_views)

def add_views(self, views: list[PanelView]) -> None:
Expand Down Expand Up @@ -81,7 +81,7 @@ def logger(self) -> Logs:
return self.default_views[1]

@property
def control(self) -> Control:
def control(self) -> Inspect:
return self.default_views[2]

@property
Expand Down
14 changes: 8 additions & 6 deletions src/biscuit/layout/panel/panelbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def __init__(self, master: Panel, *args, **kwargs) -> None:
super().__init__(master, *args, **kwargs)
content: Content = master.master

self.config(**self.base.theme.layout.content.panel.bar)
self.config(**self.base.theme.layout.content.editors.bar)

self.tab_container = Frame(self, **self.base.theme.layout.content.panel.bar)
self.tab_container.pack(fill=tk.X, side=tk.LEFT, expand=True)
self.tab_container = Frame(self, bg=self.base.theme.border)
self.tab_container.pack(fill=tk.Y, side=tk.LEFT)

self.active_tabs: list[Tab] = []
self.active_tab = None
Expand All @@ -43,7 +43,9 @@ def __init__(self, master: Panel, *args, **kwargs) -> None:
)

for button in self.default_actions:
IconButton(self, *button).pack(side=tk.RIGHT)
IconButton(
self, *button, **self.base.theme.layout.content.editors.bar.tab
).pack(side=tk.RIGHT)

def add_actions(self, buttons: list[IconButton]) -> None:
"""Add the buttons to the control buttons
Expand All @@ -52,7 +54,7 @@ def add_actions(self, buttons: list[IconButton]) -> None:
buttons (list[IconButton]): buttons to be added"""

for button in buttons:
button.pack(side=tk.LEFT)
button.pack(side=tk.RIGHT)
self.actions.append(button)

def replace_actions(self, buttons: list[IconButton]) -> None:
Expand All @@ -76,7 +78,7 @@ def add_tab(self, view: PanelView) -> None:
view (PanelView): panel view to be added to the tabs"""

tab = Tab(self, view)
tab.pack(fill=tk.Y, side=tk.LEFT, in_=self.tab_container)
tab.pack(fill=tk.Y, side=tk.LEFT, padx=(0, 1), in_=self.tab_container)
self.active_tabs.append(tab)

tab.select()
Expand Down
10 changes: 7 additions & 3 deletions src/biscuit/layout/panel/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ def __init__(self, master: PanelBar, view: PanelView, *args, **kwargs) -> None:
padx=5,
pady=5,
font=self.base.settings.uifont,
**self.base.theme.layout.content.panel.bar.tab,
**self.base.theme.layout.content.editors.bar.tab,
)

self.bind("<Button-1>", self.select)

def deselect(self, *_) -> None:
if self.selected:
self.view.grid_remove()
self.config(fg=self.base.theme.layout.content.panel.bar.tab.foreground)
self.config(
fg=self.base.theme.layout.content.editors.bar.tab.foreground,
bg=self.base.theme.layout.content.editors.bar.tab.background,
)
self.selected = False

def select(self, *_) -> None:
if not self.selected:
self.master.set_active_tab(self)
self.view.grid(column=0, row=1, sticky=tk.NSEW)
self.config(
fg=self.base.theme.layout.content.panel.bar.tab.selectedforeground
fg=self.base.theme.layout.content.editors.bar.tab.selectedforeground,
bg=self.base.theme.layout.content.editors.bar.tab.selectedbackground,
)
self.selected = True
4 changes: 2 additions & 2 deletions src/biscuit/layout/secondary_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def __init__(

self.default_views = {
"Outline": Outline(self),
"Source Control": SourceControl(self),
"AI": AI(self),
"GitHub": GitHub(self),
"Extensions": Extensions(self),
"AI": AI(self),
"Source Control": SourceControl(self),
}
self.add_views(self.default_views.values())

Expand Down
38 changes: 22 additions & 16 deletions src/biscuit/layout/statusbar/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ def __init__(self, master: Frame, *args, **kwargs) -> None:
"Change indentation",
"indent:",
[
("2 Spaces", lambda e=None: self.base.set_tab_spaces(2)),
("4 Spaces", lambda e=None: self.base.set_tab_spaces(4)),
("Custom: {} spaces", self.change_custom_indentation),
("2 spaces", lambda e=None: self.base.set_tab_spaces(2)),
("4 spaces", lambda e=None: self.base.set_tab_spaces(4)),
("8 spaces", lambda e=None: self.base.set_tab_spaces(8)),
],
pinned=[
["custom: {} spaces", self.change_custom_indentation],
],
)
self.indentation = self.add_button(
text=f"Spaces: {self.base.tab_spaces}",
text=f"{self.base.tab_spaces}sp",
callback=self.base.commands.change_indentation_level,
description="Select indentation",
description="Change indentation",
side=tk.RIGHT,
)

Expand All @@ -100,7 +103,7 @@ def __init__(self, master: Frame, *args, **kwargs) -> None:
self.encoding = self.add_button(
text="UTF-8",
callback=self.base.commands.change_encoding,
description="Select encoding",
description="Change encoding",
side=tk.RIGHT,
)

Expand All @@ -113,7 +116,7 @@ def __init__(self, master: Frame, *args, **kwargs) -> None:
self.eol = self.add_button(
text="CRLF",
callback=self.base.commands.change_end_of_line_character,
description="Select End of Line sequence",
description="Change End of Line sequence",
side=tk.RIGHT,
)

Expand All @@ -129,14 +132,14 @@ def __init__(self, master: Frame, *args, **kwargs) -> None:
self.file_type = self.add_button(
text="Plain Text",
callback=self.base.commands.change_language_mode,
description="Select Language Mode",
description="Change Language Mode",
side=tk.RIGHT,
)

# ---------------------------------------------------------------------

self.secondary_activitybar = ActivityBar(self)
self.secondary_activitybar.pack(side=tk.RIGHT)
self.secondary_activitybar.pack(side=tk.RIGHT, padx=(0, 10))

# ---------------------------------------------------------------------

Expand Down Expand Up @@ -221,8 +224,9 @@ def toggle_editmode(self, state: bool) -> None:

widgets = [
self.file_type,
self.eol,
self.encoding,
# TODO: EOL, Encoding should be optional
# self.eol,
# self.encoding,
self.indentation,
self.line_col_info,
]
Expand All @@ -246,8 +250,8 @@ def on_open_file(self, text: Text) -> None:
"""

self.file_type.change_text(text.language)
self.encoding.change_text(text.encoding.upper())
self.eol.change_text(get_eol_label(text.eol))
# self.encoding.change_text(text.encoding.upper())
# self.eol.change_text(get_eol_label(text.eol))

def set_line_col_info(self, line: int, col: int, selected: int = None) -> None:
"""Sets the line and column information on the status bar.
Expand Down Expand Up @@ -278,7 +282,7 @@ def set_spaces(self, spaces: int) -> None:
spaces (int): The number of spaces to set for indentation.
"""

self.indentation.change_text(text=f"Spaces: {spaces}")
self.indentation.change_text(text=f"{spaces}sp")

def pack(self):
"""Packs the status bar into the application."""
Expand Down Expand Up @@ -310,7 +314,8 @@ def change_custom_indentation(self, line: str = None) -> None:
print("failed change indentation", line)

def change_eol(self, val: str) -> typing.Callable:
"""Changes the end-of-line sequence.
"""Palette helper function
Changes the end-of-line sequence.
Args:
val (str): The end-of-line sequence to change to.
Expand All @@ -324,7 +329,8 @@ def change_eol(self, val: str) -> typing.Callable:
)

def change_language(self, language: str) -> typing.Callable:
"""Changes the language mode of the active editor.
"""Palette helper function
Changes the language mode of the active editor.
Args:
language (str): The language mode to change to.
Expand Down
2 changes: 1 addition & 1 deletion src/biscuit/settings/theme/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __init__(self, master, *args, **kwargs) -> None:
self.theme: Theme = master.theme

self.editors = EditorsPane(self)
self.panel = PanelPane(self)
self.panel = PanelPane(self, *self.theme.secondary)


class DrawerPane(FrameThemeObject):
Expand Down
2 changes: 1 addition & 1 deletion src/biscuit/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .ai import AI
from .control import Control
from .control import Inspect
from .debug import Debug
from .explorer import Explorer
from .extensions import Extensions
Expand Down
2 changes: 1 addition & 1 deletion src/biscuit/views/control/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .control import Control
from .control import Inspect
35 changes: 24 additions & 11 deletions src/biscuit/views/control/control.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import tkinter as tk

from hintedtext import HintedEntry

from biscuit.common.icons import Icons
from biscuit.common.ui import Entry, Frame, Scrollbar

from ..panelview import PanelView

HELP = """
Welcome to Biscuit Control Panel!
Welcome to Biscuit Inspect Console
----------------------------------
This is a Python console that allows you to interact with the application at runtime.
This is a Python console that allows you to interact with the Biscuit at runtime.
You can use this console to run commands, check the status of the application, and more.
`self` refers to the App instance, and you can access all the attributes and methods of the App class.
Expand All @@ -21,8 +24,8 @@
"""


class Control(PanelView):
"""The Control view."""
class Inspect(PanelView):
"""The Inspect view."""

def __init__(self, master, *args, **kwargs) -> None:
super().__init__(master, *args, **kwargs)
Expand All @@ -43,20 +46,30 @@ def __init__(self, master, *args, **kwargs) -> None:
padx=10,
pady=10,
font=("Consolas", 11),
**self.base.theme.views.panel.logs,
**self.base.theme.editors.text,
)
self.text.grid(row=0, column=0, sticky=tk.NSEW)

self.scrollbar = Scrollbar(container)
self.scrollbar = Scrollbar(container, style="EditorScrollbar")
self.scrollbar.grid(sticky=tk.NSEW, row=0, column=1)

self.entry = Entry(
frame = Frame(
self,
padx=5,
pady=5,
bg=self.base.theme.layout.background,
)
frame.grid(row=1, column=0, sticky=tk.NSEW, pady=(1, 0))

self.entry = HintedEntry(
frame,
relief=tk.FLAT,
font=("Consolas", 11),
hint="Type help to get started...",
hint="Use /help for help",
bg=self.base.theme.layout.background,
fg=self.base.theme.layout.foreground,
)
self.entry.grid(row=1, column=0, sticky=tk.NSEW)
self.entry.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.entry.bind("<Return>", self.enter)
self.entry.bind("<Up>", self.previous_command)
self.entry.bind("<Down>", self.next_command)
Expand Down Expand Up @@ -86,9 +99,9 @@ def enter(self, *_) -> None:
self.history_index = len(self.history)

match text:
case "help":
case "/help":
self.show_help()
case "clear":
case "/clear":
self.clear()

if result := self.base.control_execute(text):
Expand Down
4 changes: 2 additions & 2 deletions src/biscuit/views/logs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def __init__(self, master, *args, **kwargs) -> None:
padx=10,
pady=10,
font=("Consolas", 11),
**self.base.theme.views.panel.logs,
**self.base.theme.editors.text,
)
self.text.grid(row=0, column=0, sticky=tk.NSEW)

self.scrollbar = Scrollbar(self)
self.scrollbar = Scrollbar(self, style="EditorScrollbar")
self.scrollbar.grid(sticky=tk.NSEW, row=0, column=1)

self.text.config(yscrollcommand=self.scrollbar.set)
Expand Down
7 changes: 5 additions & 2 deletions src/biscuit/views/panelview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PanelView(View):

def __init__(self, master, *args, **kwargs) -> None:
super().__init__(master, *args, **kwargs)
self.config(**self.base.theme.views.panel)
self.config(bg=self.base.theme.border)

self.__actions__ = []

Expand All @@ -17,5 +17,8 @@ def add_action(self, icon, event=lambda *_: ...) -> None:

def generate_actions(self, panelbar) -> None:
self.__actions__ = [
IconButton(panelbar, *action) for action in self.__actions__
IconButton(
panelbar, *action, **self.base.theme.layout.content.editors.bar.tab
)
for action in self.__actions__
]
4 changes: 2 additions & 2 deletions src/biscuit/views/problems/problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def __init__(self, master, *args, **kwargs) -> None:
padx=10,
pady=10,
font=("Consolas", 11),
**self.base.theme.views.panel.logs
**self.base.theme.editors.text
)
self.text.grid(row=0, column=0, sticky=tk.NSEW)

self.scrollbar = Scrollbar(self)
self.scrollbar = Scrollbar(self, style="EditorScrollbar")
self.scrollbar.grid(sticky=tk.NSEW, row=0, column=1)

self.text.config(yscrollcommand=self.scrollbar.set)
Expand Down
Loading

0 comments on commit eca7ada

Please sign in to comment.