plugin defined settings!!!!

This commit is contained in:
SpookyDervish
2025-10-30 17:45:30 +11:00
parent 13862bdad5
commit 94c2a72c41
5 changed files with 156 additions and 39 deletions

View File

@@ -1,7 +1,8 @@
from textual_window import Window
from textual.widgets import RichLog, Button
from textual import work, on
from textual import work
import textual.widgets
from typing import Any
from traceback import format_exception
from lupa import lua51
@@ -68,6 +69,9 @@ class PluginLoader(Window):
)
#self.app.mount(new_window)
return new_window
def create_setting(self, section_name: str, option_name: str, description: str, option_type: str, default_value: Any, on_changed_func = None):
self.app.config_handler.define_plugin_setting(section_name, option_name, description, option_type, default_value, on_changed_func)
# endregion
@@ -83,8 +87,6 @@ class PluginLoader(Window):
lua_runtime_stuff = {
"ui": {
"notify": self.fake_notify,
#"createSidebarButton": self.create_sidebar_button,
#"setTheme": self.set_theme,
"runAction": self.fake_run_action,
"addBind": self.add_bind,
"createAction": self.create_action,
@@ -93,7 +95,10 @@ class PluginLoader(Window):
"app": self.app,
"onMessage": self.run_on_message
},
"config": self.app.config_handler
"config": {
"get": self.app.config_handler.get,
"defineSetting": self.create_setting
}
}
log.write("[b]Finding plugins...[/]")
@@ -190,7 +195,7 @@ class PluginLoader(Window):
log.write("\n[b]Done loading plugins![/]")
if no_errors and int(self.app.config_handler.get("plugins", "log_timeout")) != -1:
log.write("[d]Window will automatically close in 10 seconds.[/]")
log.write(f'[d]Window will automatically close in {self.app.config_handler.get("plugins", "log_timeout")} seconds.[/]')
await asyncio.sleep(int(self.app.config_handler.get("plugins", "log_timeout")))
self.close_window()