Moved plugins and refactor command system
- Moved plugins to apropriate sub folders - Refactor command system with new add_command method and rename GetCommandSystemEvent to GetNewCommandSystemEvent - Add RegisterCommandEvent for dynamic command registration - Change footer container orientation to VERTICAL - Add search-highlight tag to source buffer - Add file change detection (deleted, externally modified) in source_file - Add JSON prettify option to source view popup menu - Enable hexpand on VTE widget - Update plugins_controller_mixin to use widget_registry
This commit is contained in:
65
plugins/code/search_replace/plugin.py
Normal file
65
plugins/code/search_replace/plugin.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from libs.event_factory import Event_Factory, Code_Event_Types
|
||||
|
||||
from plugins.plugin_types import PluginCode
|
||||
|
||||
from .search_replace import SearchReplace
|
||||
|
||||
|
||||
|
||||
search_replace = SearchReplace()
|
||||
|
||||
|
||||
|
||||
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):
|
||||
self._handle_view_change(event)
|
||||
|
||||
def _handle_view_change(self, event: Code_Event_Types.FocusedViewEvent):
|
||||
if search_replace.is_visible():
|
||||
buffer = search_replace.active_view.get_buffer()
|
||||
search_replace.clear_highlight(buffer)
|
||||
|
||||
search_replace.active_view = event.view
|
||||
|
||||
if search_replace.is_visible():
|
||||
search_replace._find_entry_search_change(
|
||||
search_replace.find_entry
|
||||
)
|
||||
|
||||
def load(self):
|
||||
footer = self.requests_ui_element("footer-container")
|
||||
footer.add( search_replace )
|
||||
|
||||
event = Event_Factory.create_event("register_command",
|
||||
command_name = "search_replace",
|
||||
command = Handler,
|
||||
binding_mode = "released",
|
||||
binding = "<Control>f"
|
||||
)
|
||||
|
||||
self.message_to("source_views", event)
|
||||
|
||||
def run(self):
|
||||
...
|
||||
|
||||
|
||||
class Handler:
|
||||
@staticmethod
|
||||
def execute(
|
||||
view: any
|
||||
):
|
||||
logger.debug("Command: Search/Replace")
|
||||
search_replace.hide() if search_replace.is_visible() else search_replace.show()
|
||||
Reference in New Issue
Block a user