diff --git a/main.py b/main.py index b8e38c6..047ffe9 100644 --- a/main.py +++ b/main.py @@ -89,7 +89,7 @@ class Berry(App): console.clear() else: try: - result = subprocess.check_output(command, shell=True, text=True) + result = subprocess.check_output(command, shell=True, text=True, stderr=subprocess.STDOUT) console.write(result) except subprocess.CalledProcessError as e: console.write(e.stdout) diff --git a/plugin_loader.py b/plugin_loader.py index f93faf9..a2a018e 100644 --- a/plugin_loader.py +++ b/plugin_loader.py @@ -19,6 +19,8 @@ class PluginLoader(Window): allow_maximize=True ) + # region Lua functions + def fake_notify(self, message: str, title: str = None, severity: str = "information"): self.app.notify(message=message, title=title, severity=severity) @@ -31,7 +33,8 @@ class PluginLoader(Window): def add_bind(self, action_name: str, key: str, description: str, show: bool = True): # a bit of a sneaky way of doing things - self.app.bind(key, action_name, description=description, show=show) + #self.app.bind(key, action_name, description=description, show=show) + self.app._bindings.bind(key, action_name, description, show, priority=True) self.app.refresh_bindings() def fake_run_action(self, action_name: str): @@ -43,6 +46,23 @@ class PluginLoader(Window): setattr(self.app, f"action_{action_name}", wrapper) + def create_window(self, title: str, icon: str = "", show_title: bool = True, can_close: bool = True, can_maximize: bool = True, can_resize: bool = True, start_horizontal: str = "center", start_vertical: str = "middle"): + new_window = Window( + id=title, + mode="temporary" if can_close else 'permanent', + allow_maximize=can_maximize, + allow_resize=can_resize, + start_open=True, + icon=icon, + show_title=show_title, + starting_horizontal=start_horizontal, + starting_vertical=start_vertical + ) + self.app.mount(new_window) + return new_window + + # endregion + @work async def find_plugins(self): log = self.query_one(RichLog) @@ -59,7 +79,8 @@ class PluginLoader(Window): "setTheme": self.set_theme, "runAction": self.fake_run_action, "addBind": self.add_bind, - "createAction": self.create_action + "createAction": self.create_action, + "createWindow": self.create_window } } @@ -153,8 +174,8 @@ class PluginLoader(Window): log.write("\n[b]Done loading plugins![/]") if no_errors: - log.write("[d]Window will automatically close in 5 seconds.[/]") - await asyncio.sleep(5.0) + log.write("[d]Window will automatically close in 10 seconds.[/]") + await asyncio.sleep(10) self.close_window() async def on_mount(self): diff --git a/plugins/test-plugin/lua/main.lua b/plugins/test-plugin/lua/main.lua index d45467f..e9f07c5 100644 --- a/plugins/test-plugin/lua/main.lua +++ b/plugins/test-plugin/lua/main.lua @@ -1,7 +1,7 @@ local plugin = {} function testAction() - berry.ui.notify("I just ran the test action!") + local window = berry.ui.createWindow("test window") end function plugin.init()