From f6cfc7c6306e3857211c51474c5436c6fac192bd Mon Sep 17 00:00:00 2001 From: SpookyDervish <78246495+SpookyDervish@users.noreply.github.com> Date: Thu, 30 Oct 2025 07:53:19 +1100 Subject: [PATCH] more ui stuff --- main.py | 3 ++- plugin_loader.py | 1 + settings.py | 24 +++++++++++++++++++++--- settings_store.py | 5 +++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index ce52228..270dabb 100644 --- a/main.py +++ b/main.py @@ -76,7 +76,8 @@ class Berry(App): # yield Terminal(command="bash", id="terminal") yield Footer() - yield PluginLoader() + if bool(int(self.config_handler.get("plugins", "enabled"))) == True: + yield PluginLoader() def action_settings(self): self.push_screen(SettingsScreen()) diff --git a/plugin_loader.py b/plugin_loader.py index 9b4eba3..cc36b1c 100644 --- a/plugin_loader.py +++ b/plugin_loader.py @@ -93,6 +93,7 @@ class PluginLoader(Window): "app": self.app, "onMessage": self.run_on_message }, + "config": self.app.config_handler } log.write("[b]Finding plugins...[/]") diff --git a/settings.py b/settings.py index 37de181..b1a4b3a 100644 --- a/settings.py +++ b/settings.py @@ -1,5 +1,5 @@ from textual.screen import ModalScreen -from textual.widgets import Label, Select, TabbedContent, TabPane, Switch +from textual.widgets import Label, Select, TabbedContent, TabPane, Switch, Input from textual.containers import Vertical, HorizontalGroup, VerticalGroup from textual.binding import Binding @@ -25,6 +25,7 @@ class SettingsScreen(ModalScreen): .setting { padding: 0 2; content-align: center middle; + margin-bottom: 1; .setting-name { text-style: bold; @@ -39,9 +40,10 @@ class SettingsScreen(ModalScreen): VerticalGroup { width: 50%; min-width: 20; + margin-right: 1; } - Select { + Select, Input { max-width: 30; } } @@ -62,6 +64,9 @@ class SettingsScreen(ModalScreen): if event.switch.id == "word-wrap": self.app.query_one("#code-editor").soft_wrap = event.value self.app.config_handler.set("editor", "word_wrap", str(int(event.value))) + elif event.switch.id == "plugins-enabled": + self.app.config_handler.set("plugins", "enabled", str(int(event.value))) + self.notify("Restart for changes to apply.", title="Restart Required", severity="warning") def on_select_changed(self, event: Select.Changed): if event.select.id == "colour-theme": @@ -93,8 +98,21 @@ class SettingsScreen(ModalScreen): yield Label("Enable word wrap in the code editor.", classes="setting-desc") yield Switch(value=bool(int(self.app.config_handler.get("editor", "word_wrap"))), id="word-wrap") with TabPane("Plugins"): + with HorizontalGroup(classes="setting"): with VerticalGroup(): yield Label("Plugins Enabled", classes="setting-name") yield Label("Enable or disable Lua plugins. This requires a restart.", classes="setting-desc") - yield Switch(value=True) + yield Switch(value=bool(int(self.app.config_handler.get("plugins", "enabled"))), id="plugins-enabled") + + with HorizontalGroup(classes="setting"): + with VerticalGroup(): + yield Label("Plugins Log", classes="setting-name") + yield Label("Show the plugin loader log on startup.", classes="setting-desc") + yield Switch(value=bool(int(self.app.config_handler.get("plugins", "log"))), id="plugins-log") + + with HorizontalGroup(classes="setting"): + with VerticalGroup(): + yield Label("Log Timeout", classes="setting-name") + yield Label("How many seconds before the log automatically closes. This gets overriden by the [b]Plugins Log[/] option. The window doesn't automatically close if there was an error.", classes="setting-desc") + yield Input(value=self.app.config_handler.get("plugins", "log_timeout"), id="log-timeout", type="integer") \ No newline at end of file diff --git a/settings_store.py b/settings_store.py index fdfdb03..488ebc9 100644 --- a/settings_store.py +++ b/settings_store.py @@ -28,7 +28,6 @@ class ConfigHandler: def apply_settings(self): self.app.query_one("#code-editor").soft_wrap = bool(int(self.get("editor", "word_wrap"))) self.app.theme = self.get("appearance", "colour_theme") - self.app.notify(self.get("appearance", "colour_theme")) def write_settings(self): with open(self.config_dir / "config.ini", "w") as configfile: @@ -46,7 +45,9 @@ class ConfigHandler: "word_wrap": "0" } self.config["plugins"] = { - "enabled": "1" + "enabled": "1", + "log": "1", + "log_timeout": "10" } self.config["appearance"] = { "colour_theme": "textual-dark"