From ec571ffa90b413c4afe7803a074143727118f2b1 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Wed, 25 Feb 2026 00:43:37 -0600 Subject: [PATCH] Added ability to toggle view visibility. --- plugins/code/toggle_source_view/__init__.py | 3 ++ plugins/code/toggle_source_view/__main__.py | 3 ++ plugins/code/toggle_source_view/manifest.json | 7 +++ plugins/code/toggle_source_view/plugin.py | 54 +++++++++++++++++++ .../commands/focus_left_sibling.py | 1 + .../commands/focus_right_sibling.py | 1 + .../commands/move_to_left_sibling.py | 1 + .../commands/move_to_right_sibling.py | 1 + .../views/source_views_controller.py | 2 + 9 files changed, 73 insertions(+) create mode 100644 plugins/code/toggle_source_view/__init__.py create mode 100644 plugins/code/toggle_source_view/__main__.py create mode 100644 plugins/code/toggle_source_view/manifest.json create mode 100644 plugins/code/toggle_source_view/plugin.py diff --git a/plugins/code/toggle_source_view/__init__.py b/plugins/code/toggle_source_view/__init__.py new file mode 100644 index 0000000..e6b1b36 --- /dev/null +++ b/plugins/code/toggle_source_view/__init__.py @@ -0,0 +1,3 @@ +""" + Plugin Module +""" diff --git a/plugins/code/toggle_source_view/__main__.py b/plugins/code/toggle_source_view/__main__.py new file mode 100644 index 0000000..c2e27a7 --- /dev/null +++ b/plugins/code/toggle_source_view/__main__.py @@ -0,0 +1,3 @@ +""" + Plugin Package +""" diff --git a/plugins/code/toggle_source_view/manifest.json b/plugins/code/toggle_source_view/manifest.json new file mode 100644 index 0000000..437fd81 --- /dev/null +++ b/plugins/code/toggle_source_view/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "Toggle Source View", + "author": "ITDominator", + "version": "0.0.1", + "support": "", + "requests": {} +} diff --git a/plugins/code/toggle_source_view/plugin.py b/plugins/code/toggle_source_view/plugin.py new file mode 100644 index 0000000..8db8b70 --- /dev/null +++ b/plugins/code/toggle_source_view/plugin.py @@ -0,0 +1,54 @@ +# Python imports + +# Lib imports + +# Application imports +from libs.event_factory import Event_Factory, Code_Event_Types + +from plugins.plugin_types import PluginCode + + + +class Plugin(PluginCode): + def __init__(self): + super(Plugin, self).__init__() + + def _controller_message(self, event: Code_Event_Types.CodeEvent): + ... + + def load(self): + event = Event_Factory.create_event("register_command", + command_name = "toggle_source_view", + command = Handler, + binding_mode = "released", + binding = "h" + ) + + self.message_to("source_views", event) + + def run(self): + ... + + +class Handler: + @staticmethod + def execute( + view: any, + char_str: str, + *args, + **kwargs + ): + logger.debug("Command: Toggle Source View") + target = view.get_parent() + target.hide() if target.is_visible() else target.show() + + if view.sibling_left: + target = view.sibling_left.get_parent() + target.show() + view.sibling_left.grab_focus() + + if view.sibling_right: + target = view.sibling_right.get_parent() + target.show() + view.sibling_right.grab_focus() + diff --git a/src/core/widgets/code/command_system/commands/focus_left_sibling.py b/src/core/widgets/code/command_system/commands/focus_left_sibling.py index 517df42..af3d76a 100644 --- a/src/core/widgets/code/command_system/commands/focus_left_sibling.py +++ b/src/core/widgets/code/command_system/commands/focus_left_sibling.py @@ -18,4 +18,5 @@ def execute( ): logger.debug("Command: Focus Left Sibling") if not view.sibling_left: return + view.sibling_left.get_parent().show() view.sibling_left.grab_focus() diff --git a/src/core/widgets/code/command_system/commands/focus_right_sibling.py b/src/core/widgets/code/command_system/commands/focus_right_sibling.py index 8d9baa0..8b900ba 100644 --- a/src/core/widgets/code/command_system/commands/focus_right_sibling.py +++ b/src/core/widgets/code/command_system/commands/focus_right_sibling.py @@ -18,4 +18,5 @@ def execute( ): logger.debug("Command: Focus Right Sibling") if not view.sibling_right: return + view.sibling_right.get_parent().show() view.sibling_right.grab_focus() diff --git a/src/core/widgets/code/command_system/commands/move_to_left_sibling.py b/src/core/widgets/code/command_system/commands/move_to_left_sibling.py index 7688366..e1e9096 100644 --- a/src/core/widgets/code/command_system/commands/move_to_left_sibling.py +++ b/src/core/widgets/code/command_system/commands/move_to_left_sibling.py @@ -23,6 +23,7 @@ def execute( popped_file, next_file = view.command.get_swap_file(view) view.sibling_left.set_buffer(buffer) + view.sibling_left.get_parent().show() view.sibling_left.grab_focus() if next_file: diff --git a/src/core/widgets/code/command_system/commands/move_to_right_sibling.py b/src/core/widgets/code/command_system/commands/move_to_right_sibling.py index b4a8166..5bce2b1 100644 --- a/src/core/widgets/code/command_system/commands/move_to_right_sibling.py +++ b/src/core/widgets/code/command_system/commands/move_to_right_sibling.py @@ -23,6 +23,7 @@ def execute( popped_file, next_file = view.command.get_swap_file(view) view.sibling_right.set_buffer(buffer) + view.sibling_right.get_parent().show() view.sibling_right.grab_focus() if next_file: diff --git a/src/core/widgets/code/controllers/views/source_views_controller.py b/src/core/widgets/code/controllers/views/source_views_controller.py index 01e07a4..87f2fcf 100644 --- a/src/core/widgets/code/controllers/views/source_views_controller.py +++ b/src/core/widgets/code/controllers/views/source_views_controller.py @@ -87,6 +87,8 @@ class SourceViewsController(ControllerBase, list): def first_map_load(self): for source_view in self: source_view.command.exec("new_file") + if not source_view.sibling_left: continue + source_view.get_parent().hide() source_view = self[0] source_view.grab_focus()