Clean up codebase and improve file loading
- Moved plugins to proper sub groups (autopairs, code_minimap, colorize, commentzar, info_bar, markdown_preview, prettify_json, search_replace, tabs_bar, telescope, toggle_source_view, lsp_client) - Add filter_out_loaded_files to prevent opening already-loaded files - Add INDEPENDENT source view state - Fix cursor scroll position on buffer switch - Fix signal blocking during file load - Fix word boundary in completion provider - Refactor code events into single events module
This commit is contained in:
66
plugins/code/ui/search_replace/plugin.py
Normal file
66
plugins/code/ui/search_replace/plugin.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
|
||||
# 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.request_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", "<Control>r"]
|
||||
)
|
||||
|
||||
self.emit_to("source_views", event)
|
||||
|
||||
def run(self):
|
||||
...
|
||||
|
||||
|
||||
class Handler:
|
||||
@staticmethod
|
||||
def execute(
|
||||
view: any,
|
||||
*args,
|
||||
**kwargs
|
||||
):
|
||||
logger.debug("Command: Search/Replace")
|
||||
|
||||
search_replace.last_key = args[0]
|
||||
search_replace.hide() if search_replace.is_visible() else search_replace.show()
|
||||
Reference in New Issue
Block a user