more ui stuff
This commit is contained in:
3
main.py
3
main.py
@@ -76,7 +76,8 @@ class Berry(App):
|
|||||||
# yield Terminal(command="bash", id="terminal")
|
# yield Terminal(command="bash", id="terminal")
|
||||||
|
|
||||||
yield Footer()
|
yield Footer()
|
||||||
yield PluginLoader()
|
if bool(int(self.config_handler.get("plugins", "enabled"))) == True:
|
||||||
|
yield PluginLoader()
|
||||||
|
|
||||||
def action_settings(self):
|
def action_settings(self):
|
||||||
self.push_screen(SettingsScreen())
|
self.push_screen(SettingsScreen())
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class PluginLoader(Window):
|
|||||||
"app": self.app,
|
"app": self.app,
|
||||||
"onMessage": self.run_on_message
|
"onMessage": self.run_on_message
|
||||||
},
|
},
|
||||||
|
"config": self.app.config_handler
|
||||||
}
|
}
|
||||||
|
|
||||||
log.write("[b]Finding plugins...[/]")
|
log.write("[b]Finding plugins...[/]")
|
||||||
|
|||||||
24
settings.py
24
settings.py
@@ -1,5 +1,5 @@
|
|||||||
from textual.screen import ModalScreen
|
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.containers import Vertical, HorizontalGroup, VerticalGroup
|
||||||
from textual.binding import Binding
|
from textual.binding import Binding
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ class SettingsScreen(ModalScreen):
|
|||||||
.setting {
|
.setting {
|
||||||
padding: 0 2;
|
padding: 0 2;
|
||||||
content-align: center middle;
|
content-align: center middle;
|
||||||
|
margin-bottom: 1;
|
||||||
|
|
||||||
.setting-name {
|
.setting-name {
|
||||||
text-style: bold;
|
text-style: bold;
|
||||||
@@ -39,9 +40,10 @@ class SettingsScreen(ModalScreen):
|
|||||||
VerticalGroup {
|
VerticalGroup {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
min-width: 20;
|
min-width: 20;
|
||||||
|
margin-right: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Select {
|
Select, Input {
|
||||||
max-width: 30;
|
max-width: 30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,6 +64,9 @@ class SettingsScreen(ModalScreen):
|
|||||||
if event.switch.id == "word-wrap":
|
if event.switch.id == "word-wrap":
|
||||||
self.app.query_one("#code-editor").soft_wrap = event.value
|
self.app.query_one("#code-editor").soft_wrap = event.value
|
||||||
self.app.config_handler.set("editor", "word_wrap", str(int(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):
|
def on_select_changed(self, event: Select.Changed):
|
||||||
if event.select.id == "colour-theme":
|
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 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")
|
yield Switch(value=bool(int(self.app.config_handler.get("editor", "word_wrap"))), id="word-wrap")
|
||||||
with TabPane("Plugins"):
|
with TabPane("Plugins"):
|
||||||
|
|
||||||
with HorizontalGroup(classes="setting"):
|
with HorizontalGroup(classes="setting"):
|
||||||
with VerticalGroup():
|
with VerticalGroup():
|
||||||
yield Label("Plugins Enabled", classes="setting-name")
|
yield Label("Plugins Enabled", classes="setting-name")
|
||||||
yield Label("Enable or disable Lua plugins. This requires a restart.", classes="setting-desc")
|
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")
|
||||||
@@ -28,7 +28,6 @@ class ConfigHandler:
|
|||||||
def apply_settings(self):
|
def apply_settings(self):
|
||||||
self.app.query_one("#code-editor").soft_wrap = bool(int(self.get("editor", "word_wrap")))
|
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.theme = self.get("appearance", "colour_theme")
|
||||||
self.app.notify(self.get("appearance", "colour_theme"))
|
|
||||||
|
|
||||||
def write_settings(self):
|
def write_settings(self):
|
||||||
with open(self.config_dir / "config.ini", "w") as configfile:
|
with open(self.config_dir / "config.ini", "w") as configfile:
|
||||||
@@ -46,7 +45,9 @@ class ConfigHandler:
|
|||||||
"word_wrap": "0"
|
"word_wrap": "0"
|
||||||
}
|
}
|
||||||
self.config["plugins"] = {
|
self.config["plugins"] = {
|
||||||
"enabled": "1"
|
"enabled": "1",
|
||||||
|
"log": "1",
|
||||||
|
"log_timeout": "10"
|
||||||
}
|
}
|
||||||
self.config["appearance"] = {
|
self.config["appearance"] = {
|
||||||
"colour_theme": "textual-dark"
|
"colour_theme": "textual-dark"
|
||||||
|
|||||||
Reference in New Issue
Block a user