* address TODO item for split_pane_manager plugin and bound keys * add split_pane_manager plugin with create/close split view commands * move sibling focus/move commands from core into plugin system * remove legacy toggle_source_view plugin * redesign EditorsContainer to use simpler Box-based layout * refactor source view API to return (scrolled_window, source_view) * add source view lifecycle events (create/remove/removed) * rename GetNewCommandSystemEvent → CreateCommandSystemEvent * update CommandsController to support command system creation and cleanup * ensure command systems are removed with their source views * improve focus border handling across sibling chains * update telescope integration for new source view structure * clean up container imports and initialization logic * remove old keybindings and align with new split pane workflow
105 lines
2.9 KiB
Python
105 lines
2.9 KiB
Python
# Python imports
|
|
|
|
# Lib imports
|
|
|
|
# Application imports
|
|
from libs.event_factory import Event_Factory, Code_Event_Types
|
|
from libs.dto.states import SourceViewStates
|
|
|
|
from plugins.plugin_types import PluginCode
|
|
|
|
from .telescope import Telescope
|
|
|
|
|
|
|
|
telescope = Telescope()
|
|
|
|
|
|
|
|
class Plugin(PluginCode):
|
|
def __init__(self):
|
|
super(Plugin, self).__init__()
|
|
|
|
|
|
def _controller_message(self, event: Code_Event_Types.CodeEvent):
|
|
if isinstance(event, Code_Event_Types.FocusedViewEvent):
|
|
...
|
|
elif isinstance(event, Code_Event_Types.AddedNewFileEvent):
|
|
telescope.list_box.add_row(event.file)
|
|
elif isinstance(event, Code_Event_Types.RemovedFileEvent):
|
|
telescope.list_box.remove_row(event)
|
|
elif isinstance(event, Code_Event_Types.FilePathSetEvent):
|
|
telescope.list_box.update_label(event)
|
|
|
|
def load(self):
|
|
window = self.request_ui_element("main-window")
|
|
|
|
telescope.map_parent_resize_event(window)
|
|
telescope.set_transient_for(window)
|
|
telescope.set_emit(self.emit)
|
|
|
|
event = Event_Factory.create_event("register_command",
|
|
command_name = "telescope",
|
|
command = Handler,
|
|
binding_mode = "released",
|
|
binding = "<Control>b"
|
|
)
|
|
self.emit_to("source_views", event)
|
|
|
|
event = Event_Factory.create_event(
|
|
"create_source_view",
|
|
state = SourceViewStates.INDEPENDENT
|
|
)
|
|
self.emit_to("source_views", event)
|
|
|
|
scrolled_win, source_view = event.response
|
|
telescope.set_source_view(scrolled_win, source_view)
|
|
|
|
event = Event_Factory.create_event(
|
|
"register_completer",
|
|
completer = source_view.get_completion()
|
|
)
|
|
self.emit_to("completion", event)
|
|
|
|
event = Event_Factory.create_event("get_files")
|
|
self.emit_to("files", event)
|
|
for file in event.response:
|
|
telescope.list_box.add_row(file)
|
|
|
|
def unload(self):
|
|
window = self.request_ui_element("main-window")
|
|
|
|
telescope.unmap_parent_resize_event(window)
|
|
|
|
event = Event_Factory.create_event("unregister_command",
|
|
command_name = "telescope",
|
|
command = Handler,
|
|
binding_mode = "released",
|
|
binding = "<Control>b"
|
|
)
|
|
self.emit_to("source_views", event)
|
|
|
|
event = Event_Factory.create_event(
|
|
"unregister_completer",
|
|
completer = telescope.source_view.get_completion()
|
|
)
|
|
self.emit_to("completion", event)
|
|
|
|
telescope.destroy()
|
|
|
|
|
|
def run(self):
|
|
...
|
|
|
|
|
|
class Handler:
|
|
@staticmethod
|
|
def execute(
|
|
view: any,
|
|
*args,
|
|
**kwargs
|
|
):
|
|
logger.debug("Command: Telescope")
|
|
telescope.set_active_row( view.get_buffer() )
|
|
telescope.hide() if telescope.is_visible() else telescope.show()
|