Files
Newton-Editor/plugins/code/ui/terminals/plugin.py
itdominator 41f3501e1f feat(code): improve comment toggling, terminal navigation, and editor event wiring
- Refactor Commenter toggle logic for line and multi-line comments
  - Preserve indentation and cursor position
  - Improve handling of existing comment detection and removal
  - Simplify bounds vs line comment dispatch

- Enhance terminal project navigation
  - Add project marker detection via Gio file traversal
  - Implement go-to-project-or-home behavior (Home key shortcut)
  - Automatically `cd` into detected project root or home directory
  - Wire terminal widget navigation through VteWidget

- Improve terminal integration
  - Pass emit_to into terminals view for event dispatching
  - Add ability for VteWidget to trigger project navigation

- Update split pane shortcut
  - Change close split view binding to Alt+\

- Add editor event support
  - Emit `text_insert` event from SourceFile on insert
  - Add new TextInsertEvent DTO and register in event system

- Misc cleanup
  - Improve imports and structure in terminals module
  - Add project marker list and filesystem traversal helpers
2026-04-15 01:54:56 -05:00

62 lines
1.3 KiB
Python

# Python imports
# Lib imports
# Application imports
from libs.event_factory import Event_Factory, Code_Event_Types
from plugins.plugin_types import PluginCode
from .terminals_view import TerminalsView
terminals_view = TerminalsView()
class Plugin(PluginCode):
def __init__(self):
super(Plugin, self).__init__()
def _controller_message(self, event: Code_Event_Types.CodeEvent):
...
def load(self):
terminals_view.emit_to = self.emit_to
footer = self.request_ui_element("footer-container")
footer.add( terminals_view )
self._manage_signals("register_command")
def unload(self):
self._manage_signals("unregister_command")
terminals_view.destroy()
def _manage_signals(self, action: str):
event = Event_Factory.create_event(action,
command_name = "terminals",
command = Handler,
binding_mode = "released",
binding = "<Control>."
)
self.emit_to("source_views", event)
def run(self):
...
class Handler:
@staticmethod
def execute(
view: any,
*args,
**kwargs
):
logger.debug("Command: Terminal")
terminals_view.set_code_view(view)
terminals_view.hide() if terminals_view.is_visible() else terminals_view.show()