refactor: remove split_pane_manager plugin and harden view handling
- Delete deprecated split_pane_manager command plugin and all related commands - Introduce new split_pane command structure (untracked replacement) - Add guard in code_minimap to handle missing active view - Prevent language detection for non-file buffers in command_helpers This cleans up legacy split pane logic and improves stability for edge cases.
This commit is contained in:
@@ -16,6 +16,19 @@ from libs.event_factory import Event_Factory, Code_Event_Types
|
|||||||
|
|
||||||
emit_to: callable = None
|
emit_to: callable = None
|
||||||
|
|
||||||
|
def get_source_view(widget):
|
||||||
|
if isinstance(widget, GtkSource.View):
|
||||||
|
return widget
|
||||||
|
|
||||||
|
if isinstance(widget, Gtk.ScrolledWindow):
|
||||||
|
return widget.get_child()
|
||||||
|
|
||||||
|
if isinstance(widget, Gtk.Paned):
|
||||||
|
return get_source_view(widget.get_child1())
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def execute(
|
def execute(
|
||||||
source_view,
|
source_view,
|
||||||
char_str,
|
char_str,
|
||||||
@@ -39,7 +52,7 @@ def execute(
|
|||||||
remaining = source_view1
|
remaining = source_view1
|
||||||
closing_view = source_view
|
closing_view = source_view
|
||||||
|
|
||||||
remaining_view = remaining.get_child()
|
remaining_view = get_source_view(remaining)
|
||||||
left = closing_view.sibling_left
|
left = closing_view.sibling_left
|
||||||
right = closing_view.sibling_right
|
right = closing_view.sibling_right
|
||||||
|
|
||||||
@@ -54,13 +54,24 @@ def execute(
|
|||||||
pane.pack2( scrolled_win2, True, True )
|
pane.pack2( scrolled_win2, True, True )
|
||||||
container.add(pane)
|
container.add(pane)
|
||||||
|
|
||||||
pane.show_all()
|
def _show(pane, alloc, is_vertical: bool):
|
||||||
|
if is_vertical:
|
||||||
|
pane.set_position(alloc.width / 2)
|
||||||
|
else:
|
||||||
|
pane.set_position(alloc.height / 2)
|
||||||
|
|
||||||
|
pane.disconnect(pane.show_id)
|
||||||
|
|
||||||
is_control, is_shift, is_alt = modkeys_states
|
is_control, is_shift, is_alt = modkeys_states
|
||||||
if is_control and is_shift:
|
alloc = container.get_allocation()
|
||||||
|
if char_str == "|":
|
||||||
|
pane.show_id = pane.connect("show", _show, alloc, True)
|
||||||
pane.set_orientation(Gtk.Orientation.VERTICAL)
|
pane.set_orientation(Gtk.Orientation.VERTICAL)
|
||||||
elif is_control:
|
elif char_str == "\\":
|
||||||
|
pane.show_id = pane.connect("show", _show, alloc, False)
|
||||||
pane.set_orientation(Gtk.Orientation.HORIZONTAL)
|
pane.set_orientation(Gtk.Orientation.HORIZONTAL)
|
||||||
|
|
||||||
source_view2.grab_focus()
|
pane.show_all()
|
||||||
|
|
||||||
source_view2.command.exec("new_file")
|
source_view2.command.exec("new_file")
|
||||||
|
source_view2.grab_focus()
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "Split Pane Manager",
|
"name": "Split Pane",
|
||||||
"author": "ITDominator",
|
"author": "ITDominator",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"support": "",
|
"support": "",
|
||||||
@@ -30,6 +30,7 @@ class Plugin(PluginCode):
|
|||||||
|
|
||||||
event = Event_Factory.create_event("get_active_view")
|
event = Event_Factory.create_event("get_active_view")
|
||||||
self.emit_to("source_views", event)
|
self.emit_to("source_views", event)
|
||||||
|
if not event.response: return
|
||||||
code_minimap.set_smini_view(event.response)
|
code_minimap.set_smini_view(event.response)
|
||||||
|
|
||||||
def unload(self):
|
def unload(self):
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ from gi.repository import GtkSource
|
|||||||
|
|
||||||
|
|
||||||
def set_language_and_style(view, file):
|
def set_language_and_style(view, file):
|
||||||
|
language = None
|
||||||
|
if not file.fname == "buffer":
|
||||||
language = view.language_manager.guess_language(file.fname, None)
|
language = view.language_manager.guess_language(file.fname, None)
|
||||||
|
|
||||||
file.buffer.set_language(language)
|
file.buffer.set_language(language)
|
||||||
file.buffer.set_style_scheme(view.syntax_theme)
|
file.buffer.set_style_scheme(view.syntax_theme)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user