diff --git a/src/core/widgets/code/command_system/command_helpers.py b/src/core/widgets/code/command_system/command_helpers.py index 92a1786..33669c9 100644 --- a/src/core/widgets/code/command_system/command_helpers.py +++ b/src/core/widgets/code/command_system/command_helpers.py @@ -9,7 +9,6 @@ from gi.repository import GtkSource def set_language_and_style(view, file): language = view.language_manager.guess_language(file.fname, None) - file.ftype = "buffer" if not language else language file.buffer.set_language(language) file.buffer.set_style_scheme(view.syntax_theme) diff --git a/src/core/widgets/code/command_system/command_system.py b/src/core/widgets/code/command_system/command_system.py index 0cbfbd0..0dd0e65 100644 --- a/src/core/widgets/code/command_system/command_system.py +++ b/src/core/widgets/code/command_system/command_system.py @@ -26,16 +26,13 @@ class CommandSystem: method = getattr(commands, command) args, kwargs = self.data - if kwargs: - return method.execute(*args, kwargs) - else: - return method.execute(*args) + return method.execute(*args, **kwargs) - def exec_with_args(self, command: str, args: list) -> any: + def exec_with_args(self, command: str, *args, **kwargs) -> any: if not hasattr(commands, command): return method = getattr(commands, command) - return method.execute(*args) + return method.execute(*args, **kwargs) def add_command(self, command_name: str, command: callable): setattr(commands, command_name, command) diff --git a/src/core/widgets/code/command_system/commands/buffer_redo.py b/src/core/widgets/code/command_system/commands/buffer_redo.py index 9d4e3e5..cce0bc1 100644 --- a/src/core/widgets/code/command_system/commands/buffer_redo.py +++ b/src/core/widgets/code/command_system/commands/buffer_redo.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Buffer Redo") diff --git a/src/core/widgets/code/command_system/commands/buffer_undo.py b/src/core/widgets/code/command_system/commands/buffer_undo.py index 36d53b6..8f08e3d 100644 --- a/src/core/widgets/code/command_system/commands/buffer_undo.py +++ b/src/core/widgets/code/command_system/commands/buffer_undo.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Buffer Undo") diff --git a/src/core/widgets/code/command_system/commands/close_file.py b/src/core/widgets/code/command_system/commands/close_file.py index 3c2e31e..67f5cb5 100644 --- a/src/core/widgets/code/command_system/commands/close_file.py +++ b/src/core/widgets/code/command_system/commands/close_file.py @@ -13,7 +13,9 @@ from ..command_helpers import update_info_bar_if_focused def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Close File") view.command.remove_file(view) diff --git a/src/core/widgets/code/command_system/commands/cut_to_temp_buffer.py b/src/core/widgets/code/command_system/commands/cut_to_temp_buffer.py index 7215e20..cae4e63 100644 --- a/src/core/widgets/code/command_system/commands/cut_to_temp_buffer.py +++ b/src/core/widgets/code/command_system/commands/cut_to_temp_buffer.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Cut to Temp Buffer") diff --git a/src/core/widgets/code/command_system/commands/dnd_load_file_to_buffer.py b/src/core/widgets/code/command_system/commands/dnd_load_file_to_buffer.py index d596632..ff74819 100644 --- a/src/core/widgets/code/command_system/commands/dnd_load_file_to_buffer.py +++ b/src/core/widgets/code/command_system/commands/dnd_load_file_to_buffer.py @@ -15,7 +15,9 @@ from ..command_helpers import update_info_bar_if_focused def execute( view: GtkSource.View, - uri: str + uri: str, + *args, + **kwargs ): logger.debug("Command: DnD Load File To Buffer") file = view.command.new_file(view) @@ -23,7 +25,7 @@ def execute( gfile = Gio.File.new_for_uri(uri) view.command.exec_with_args( "load_file", - (view, gfile, file) + view, gfile, file ) view.set_buffer(file.buffer) diff --git a/src/core/widgets/code/command_system/commands/dnd_load_files.py b/src/core/widgets/code/command_system/commands/dnd_load_files.py index 6e29a2a..0356fac 100644 --- a/src/core/widgets/code/command_system/commands/dnd_load_files.py +++ b/src/core/widgets/code/command_system/commands/dnd_load_files.py @@ -14,7 +14,9 @@ from gi.repository import Gio def execute( view: GtkSource.View, - uris: list = [] + uris: list = [], + *args, + **kwargs ): logger.debug("Command: DnD Load Files") for uri in uris: @@ -23,4 +25,4 @@ def execute( except Exception as e: gfile = Gio.File.new_for_path(uri) - view.command.exec_with_args("load_file", (view, gfile)) \ No newline at end of file + view.command.exec_with_args("load_file", view, gfile) diff --git a/src/core/widgets/code/command_system/commands/duplicate_line.py b/src/core/widgets/code/command_system/commands/duplicate_line.py index bc4f65d..59fc3a6 100644 --- a/src/core/widgets/code/command_system/commands/duplicate_line.py +++ b/src/core/widgets/code/command_system/commands/duplicate_line.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Duplicate Line") diff --git a/src/core/widgets/code/command_system/commands/focus_left_sibling.py b/src/core/widgets/code/command_system/commands/focus_left_sibling.py index d3eaed4..517df42 100644 --- a/src/core/widgets/code/command_system/commands/focus_left_sibling.py +++ b/src/core/widgets/code/command_system/commands/focus_left_sibling.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Focus Left Sibling") if not view.sibling_left: return diff --git a/src/core/widgets/code/command_system/commands/focus_right_sibling.py b/src/core/widgets/code/command_system/commands/focus_right_sibling.py index 8ed5e08..8d9baa0 100644 --- a/src/core/widgets/code/command_system/commands/focus_right_sibling.py +++ b/src/core/widgets/code/command_system/commands/focus_right_sibling.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Focus Right Sibling") if not view.sibling_right: return diff --git a/src/core/widgets/code/command_system/commands/get_current_file.py b/src/core/widgets/code/command_system/commands/get_current_file.py index 51f5a44..68f04eb 100644 --- a/src/core/widgets/code/command_system/commands/get_current_file.py +++ b/src/core/widgets/code/command_system/commands/get_current_file.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Get Current File") diff --git a/src/core/widgets/code/command_system/commands/get_filetype.py b/src/core/widgets/code/command_system/commands/get_filetype.py index ae98fcd..498474b 100644 --- a/src/core/widgets/code/command_system/commands/get_filetype.py +++ b/src/core/widgets/code/command_system/commands/get_filetype.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Get File Type") file = view.command.get_file(view) diff --git a/src/core/widgets/code/command_system/commands/get_text.py b/src/core/widgets/code/command_system/commands/get_text.py index 20876ab..e3c667e 100644 --- a/src/core/widgets/code/command_system/commands/get_text.py +++ b/src/core/widgets/code/command_system/commands/get_text.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Get Text") diff --git a/src/core/widgets/code/command_system/commands/go_to.py b/src/core/widgets/code/command_system/commands/go_to.py index 55d6efe..e654588 100644 --- a/src/core/widgets/code/command_system/commands/go_to.py +++ b/src/core/widgets/code/command_system/commands/go_to.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Go-To") diff --git a/src/core/widgets/code/command_system/commands/has_focus.py b/src/core/widgets/code/command_system/commands/has_focus.py index 3f87456..8722f61 100644 --- a/src/core/widgets/code/command_system/commands/has_focus.py +++ b/src/core/widgets/code/command_system/commands/has_focus.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Has Focus") ctx = view.get_parent().get_style_context() diff --git a/src/core/widgets/code/command_system/commands/line_down.py b/src/core/widgets/code/command_system/commands/line_down.py index 5aa730c..e976f1a 100644 --- a/src/core/widgets/code/command_system/commands/line_down.py +++ b/src/core/widgets/code/command_system/commands/line_down.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Line Down") view.emit("move-lines", True) diff --git a/src/core/widgets/code/command_system/commands/line_up.py b/src/core/widgets/code/command_system/commands/line_up.py index e10c15d..bc62c78 100644 --- a/src/core/widgets/code/command_system/commands/line_up.py +++ b/src/core/widgets/code/command_system/commands/line_up.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Line Up") view.emit("move-lines", False) diff --git a/src/core/widgets/code/command_system/commands/load_file.py b/src/core/widgets/code/command_system/commands/load_file.py index 637eff6..da0afd0 100644 --- a/src/core/widgets/code/command_system/commands/load_file.py +++ b/src/core/widgets/code/command_system/commands/load_file.py @@ -18,6 +18,8 @@ def execute( view: GtkSource.View, gfile: Gio.File, file: SourceFile = None, + *args, + **kwargs ): logger.debug("Command: Load File") if not file: diff --git a/src/core/widgets/code/command_system/commands/load_start_files.py b/src/core/widgets/code/command_system/commands/load_start_files.py index f7d60dc..32b6cb4 100644 --- a/src/core/widgets/code/command_system/commands/load_start_files.py +++ b/src/core/widgets/code/command_system/commands/load_start_files.py @@ -14,6 +14,8 @@ from gi.repository import Gio def execute( view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Load Start File(s)") @@ -28,7 +30,7 @@ def execute( view.command.exec_with_args( "load_file", - (view, gfile, file) + view, gfile, file ) if not starting_files: return @@ -37,4 +39,4 @@ def execute( file = file.replace("FILE|", "") gfile = Gio.File.new_for_path(file) - view.command.exec_with_args("load_file", (view, gfile)) + view.command.exec_with_args("load_file", view, gfile) diff --git a/src/core/widgets/code/command_system/commands/move_to_left_sibling.py b/src/core/widgets/code/command_system/commands/move_to_left_sibling.py index ea6b83b..7688366 100644 --- a/src/core/widgets/code/command_system/commands/move_to_left_sibling.py +++ b/src/core/widgets/code/command_system/commands/move_to_left_sibling.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Move To Left Sibling") if not view.sibling_left: return diff --git a/src/core/widgets/code/command_system/commands/move_to_right_sibling.py b/src/core/widgets/code/command_system/commands/move_to_right_sibling.py index 71f150e..b4a8166 100644 --- a/src/core/widgets/code/command_system/commands/move_to_right_sibling.py +++ b/src/core/widgets/code/command_system/commands/move_to_right_sibling.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Move To Right Sibling") if not view.sibling_right: return diff --git a/src/core/widgets/code/command_system/commands/new_file.py b/src/core/widgets/code/command_system/commands/new_file.py index 13b838d..414bdf8 100644 --- a/src/core/widgets/code/command_system/commands/new_file.py +++ b/src/core/widgets/code/command_system/commands/new_file.py @@ -14,7 +14,9 @@ from ..command_helpers import set_language_and_style, update_info_bar_if_focused def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: New File") diff --git a/src/core/widgets/code/command_system/commands/open_files.py b/src/core/widgets/code/command_system/commands/open_files.py index 3ce87e8..d318589 100644 --- a/src/core/widgets/code/command_system/commands/open_files.py +++ b/src/core/widgets/code/command_system/commands/open_files.py @@ -13,7 +13,9 @@ from ..command_helpers import update_info_bar_if_focused def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Open File(s)") gfiles = event_system.emit_and_await("open-files") @@ -22,9 +24,9 @@ def execute( file = view.command.get_file(view) if file.ftype == "buffer": gfile = gfiles.pop() - view.command.exec_with_args("load_file", (view, gfile, file)) + view.command.exec_with_args("load_file", view, gfile, file) view.set_buffer(file.buffer) update_info_bar_if_focused(view.command, view) for i, gfile in enumerate(gfiles): - view.command.exec_with_args("load_file", (view, gfile)) + view.command.exec_with_args("load_file", view, gfile) diff --git a/src/core/widgets/code/command_system/commands/paste_temp_buffer.py b/src/core/widgets/code/command_system/commands/paste_temp_buffer.py index 12640c6..8c7cd7a 100644 --- a/src/core/widgets/code/command_system/commands/paste_temp_buffer.py +++ b/src/core/widgets/code/command_system/commands/paste_temp_buffer.py @@ -13,7 +13,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Paste Temp Buffer") diff --git a/src/core/widgets/code/command_system/commands/save_file.py b/src/core/widgets/code/command_system/commands/save_file.py index 2dedbaf..02e379e 100644 --- a/src/core/widgets/code/command_system/commands/save_file.py +++ b/src/core/widgets/code/command_system/commands/save_file.py @@ -13,7 +13,9 @@ from ..command_helpers import set_language_and_style def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Save File") file = view.command.get_file(view) diff --git a/src/core/widgets/code/command_system/commands/save_file_as.py b/src/core/widgets/code/command_system/commands/save_file_as.py index b493841..3795308 100644 --- a/src/core/widgets/code/command_system/commands/save_file_as.py +++ b/src/core/widgets/code/command_system/commands/save_file_as.py @@ -13,7 +13,9 @@ from ..command_helpers import set_language_and_style, update_info_bar_if_focused def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.info("Command: Save File As") file = view.command.get_file(view) diff --git a/src/core/widgets/code/command_system/commands/set_buffer.py b/src/core/widgets/code/command_system/commands/set_buffer.py index 119e5a2..b24ab71 100644 --- a/src/core/widgets/code/command_system/commands/set_buffer.py +++ b/src/core/widgets/code/command_system/commands/set_buffer.py @@ -16,7 +16,9 @@ from ..command_helpers import update_info_bar_if_focused def execute( view: GtkSource.View, - file: SourceFile + file: SourceFile, + *args, + **kwargs ): logger.debug("Command: Set Buffer") diff --git a/src/core/widgets/code/command_system/commands/set_buffer_language.py b/src/core/widgets/code/command_system/commands/set_buffer_language.py index 6268110..702f8fa 100644 --- a/src/core/widgets/code/command_system/commands/set_buffer_language.py +++ b/src/core/widgets/code/command_system/commands/set_buffer_language.py @@ -13,7 +13,9 @@ from gi.repository import GtkSource def execute( view: GtkSource.View, - language: str + language: str, + *args, + **kwargs ): logger.debug("Command: Set Buffer Language") diff --git a/src/core/widgets/code/command_system/commands/set_buffer_style.py b/src/core/widgets/code/command_system/commands/set_buffer_style.py index 76a1d7a..6fd0e2b 100644 --- a/src/core/widgets/code/command_system/commands/set_buffer_style.py +++ b/src/core/widgets/code/command_system/commands/set_buffer_style.py @@ -13,7 +13,9 @@ from gi.repository import GtkSource def execute( view: GtkSource.View, - style: str + style: str, + *args, + **kwargs ): logger.debug("Command: Set Buffer Style") diff --git a/src/core/widgets/code/command_system/commands/set_focus_border.py b/src/core/widgets/code/command_system/commands/set_focus_border.py index 2f2cdaf..20510f7 100644 --- a/src/core/widgets/code/command_system/commands/set_focus_border.py +++ b/src/core/widgets/code/command_system/commands/set_focus_border.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Set Focus Border") ctx = view.get_parent().get_style_context() diff --git a/src/core/widgets/code/command_system/commands/set_miniview.py b/src/core/widgets/code/command_system/commands/set_miniview.py index dd3f374..67396a5 100644 --- a/src/core/widgets/code/command_system/commands/set_miniview.py +++ b/src/core/widgets/code/command_system/commands/set_miniview.py @@ -13,6 +13,8 @@ from gi.repository import GtkSource def execute( view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Set MiniView") event_system.emit("set-mini-view", (view,)) diff --git a/src/core/widgets/code/command_system/commands/show_completion.py b/src/core/widgets/code/command_system/commands/show_completion.py index baec540..73b561f 100644 --- a/src/core/widgets/code/command_system/commands/show_completion.py +++ b/src/core/widgets/code/command_system/commands/show_completion.py @@ -12,7 +12,9 @@ from gi.repository import GtkSource def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Show Completion") completer = view.get_completion() diff --git a/src/core/widgets/code/command_system/commands/update_info_bar.py b/src/core/widgets/code/command_system/commands/update_info_bar.py index 1a641d3..6776247 100644 --- a/src/core/widgets/code/command_system/commands/update_info_bar.py +++ b/src/core/widgets/code/command_system/commands/update_info_bar.py @@ -13,6 +13,8 @@ from gi.repository import GtkSource def execute( view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Update Info Bar") file = view.command.get_file(view) diff --git a/src/core/widgets/code/command_system/commands/zoom_in.py b/src/core/widgets/code/command_system/commands/zoom_in.py index a4038ea..792d9af 100644 --- a/src/core/widgets/code/command_system/commands/zoom_in.py +++ b/src/core/widgets/code/command_system/commands/zoom_in.py @@ -13,7 +13,9 @@ from gi.repository import Pango def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Zoom In") diff --git a/src/core/widgets/code/command_system/commands/zoom_out.py b/src/core/widgets/code/command_system/commands/zoom_out.py index e17c37e..18cc390 100644 --- a/src/core/widgets/code/command_system/commands/zoom_out.py +++ b/src/core/widgets/code/command_system/commands/zoom_out.py @@ -13,7 +13,9 @@ from gi.repository import Pango def execute( - view: GtkSource.View = None + view: GtkSource.View, + *args, + **kwargs ): logger.debug("Command: Zoom Out") diff --git a/src/core/widgets/code/controllers/views/source_views_controller.py b/src/core/widgets/code/controllers/views/source_views_controller.py index f090805..01e07a4 100644 --- a/src/core/widgets/code/controllers/views/source_views_controller.py +++ b/src/core/widgets/code/controllers/views/source_views_controller.py @@ -40,12 +40,16 @@ class SourceViewsController(ControllerBase, list): self.signal_mapper.insert_text(event.file, event.text) def _register_command(self, event: Code_Event_Types.RegisterCommandEvent): - self.state_manager.key_mapper.map_command( - event.command_name, - { - f"{event.binding_mode}": event.binding - } - ) + if not isinstance(event.binding, list): + event.binding = [ event.binding ] + + for binding in event.binding: + self.state_manager.key_mapper.map_command( + event.command_name, + { + f"{event.binding_mode}": binding + } + ) for view in self: view.command.add_command( diff --git a/src/core/widgets/code/controllers/views/states/source_view_insert_state.py b/src/core/widgets/code/controllers/views/states/source_view_insert_state.py index 7a2bd66..d75b577 100644 --- a/src/core/widgets/code/controllers/views/states/source_view_insert_state.py +++ b/src/core/widgets/code/controllers/views/states/source_view_insert_state.py @@ -22,7 +22,8 @@ class SourceViewsInsertState: event = Event_Factory.create_event("focused_view", view = source_view) emit(event) - def insert_text(self, file, text): + def insert_text(self, file, text: str): + return True def move_cursor(self, source_view, step, count, extend_selection, emit): @@ -51,21 +52,23 @@ class SourceViewsInsertState: def key_press_event(self, source_view, eve, key_mapper): command = key_mapper._key_press_event(eve) is_future = key_mapper._key_release_event(eve) + char_str = key_mapper.get_char(eve) - if is_future: return True + if is_future: return True if not command: return False - source_view.command.exec(command) + source_view.command.exec_with_args(command, source_view, char_str) return True def key_release_event(self, source_view, eve, key_mapper): - command = key_mapper._key_release_event(eve) - is_past = key_mapper._key_press_event(eve) + command = key_mapper._key_release_event(eve) + is_past = key_mapper._key_press_event(eve) + char_str = key_mapper.get_char(eve) if is_past: return True if not command: return False - source_view.command.exec(command) + source_view.command.exec_with_args(command, source_view, char_str) return True diff --git a/src/core/widgets/code/key_mapper.py b/src/core/widgets/code/key_mapper.py index 5d8be68..0fae401 100644 --- a/src/core/widgets/code/key_mapper.py +++ b/src/core/widgets/code/key_mapper.py @@ -96,19 +96,28 @@ class KeyMapper: getattr(self.states[state], press_state)[keyname] = command def _key_press_event(self, eve): - keyname = Gdk.keyval_name(eve.keyval).lower() + keyname = self.get_keyname(eve) + char_str = self.get_char(eve) self._set_key_state(eve) if keyname in self.states[self.state].held: return self.states[self.state].held[keyname] + if char_str in self.states[self.state].held: + return self.states[self.state].held[char_str] + + def _key_release_event(self, eve): - keyname = Gdk.keyval_name(eve.keyval).lower() + keyname = self.get_keyname(eve) + char_str = self.get_char(eve) self._set_key_state(eve) if keyname in self.states[self.state].released: return self.states[self.state].released[keyname] + if char_str in self.states[self.state].released: + return self.states[self.state].released[char_str] + def _set_key_state(self, eve): modifiers = Gdk.ModifierType(eve.get_state() & ~Gdk.ModifierType.LOCK_MASK) is_control = modifiers & Gdk.ModifierType.CONTROL_MASK @@ -137,3 +146,9 @@ class KeyMapper: def get_raw_keyname(self, eve): return Gdk.keyval_name(eve.keyval) + + def get_keyname(self, eve): + return Gdk.keyval_name(eve.keyval).lower() + + def get_char(self, eve): + return chr( Gdk.keyval_to_unicode(eve.keyval) ) diff --git a/src/core/widgets/code/mixins/source_view_dnd_mixin.py b/src/core/widgets/code/mixins/source_view_dnd_mixin.py index 46299b3..bbfed59 100644 --- a/src/core/widgets/code/mixins/source_view_dnd_mixin.py +++ b/src/core/widgets/code/mixins/source_view_dnd_mixin.py @@ -33,7 +33,7 @@ class SourceViewDnDMixin: def _on_uri_data_received(self, uris: []): uri = uris.pop(0) - self.command.exec_with_args("dnd_load_file_to_buffer", (self, uri)) + self.command.exec_with_args("dnd_load_file_to_buffer", self, uri) if not uris: return diff --git a/src/core/widgets/code/source_file.py b/src/core/widgets/code/source_file.py index be1054f..430163c 100644 --- a/src/core/widgets/code/source_file.py +++ b/src/core/widgets/code/source_file.py @@ -99,8 +99,8 @@ class SourceFile(GtkSource.File): ) # Note: 'idle_add' needed b/c markers don't get thir positions - # updated relative to the initial insert. - # If not used, seg faults galor during multi insert. + # updated relative to the initial insert. + # If not used, seg faults galor during multi insert. GLib.idle_add(self.emit, event) def _mark_set( @@ -136,7 +136,6 @@ class SourceFile(GtkSource.File): if self.was_deleted: self.was_deleted = False -# self.set_path(gfile) self.set_location( None ) self.set_location( gfile ) @@ -148,6 +147,11 @@ class SourceFile(GtkSource.File): self.set_path(gfile) text = gfile.load_bytes()[0].get_data().decode("UTF-8") + info = gfile.query_info('standard::content-type', Gio.FileQueryInfoFlags.NONE, None) + content_type = info.get_content_type() + self.ftype = Gio.content_type_get_mime_type(content_type) + logger.debug(f"File content type: {self.ftype}") + undo_manager = self.buffer.get_undo_manager() def move_insert_to_start(): diff --git a/src/core/widgets/code/tab_widget.py b/src/core/widgets/code/tab_widget.py index 2f56c70..729cc29 100644 --- a/src/core/widgets/code/tab_widget.py +++ b/src/core/widgets/code/tab_widget.py @@ -31,6 +31,8 @@ class TabWidget(Gtk.Box): self.set_orientation(0) self.set_hexpand(False) + self.set_vexpand(False) + self.set_size_request(-1, 12) def _setup_signals(self): ... diff --git a/src/libs/controllers/controller_manager.py b/src/libs/controllers/controller_manager.py index 1288b2b..09311d2 100644 --- a/src/libs/controllers/controller_manager.py +++ b/src/libs/controllers/controller_manager.py @@ -33,7 +33,9 @@ class ControllerManager(Singleton, dict): raise ControllerManagerException("Must pass in a 'name' and 'controller'...") if name in self.keys(): - raise ControllerManagerException(f"Can't bind controller to registered name of '{name}'...") + raise ControllerManagerException( + f"Can't bind controller to existing registered name of '{name}'..." + ) controller.set_controller_context( self._crete_controller_context() ) diff --git a/src/libs/dto/code/register_command_event.py b/src/libs/dto/code/register_command_event.py index d4441fe..09a477c 100644 --- a/src/libs/dto/code/register_command_event.py +++ b/src/libs/dto/code/register_command_event.py @@ -14,7 +14,7 @@ from ..base_event import BaseEvent @dataclass class RegisterCommandEvent(BaseEvent): - command_name: str = "" - command: callable = None - binding_mode: str = "" - binding: str = "" + command_name: str = "" + command: callable = None + binding_mode: str = "" + binding: str or list = "" diff --git a/src/plugins/controller.py b/src/plugins/controller.py index ead0ebf..429a60f 100644 --- a/src/plugins/controller.py +++ b/src/plugins/controller.py @@ -3,6 +3,7 @@ import os import sys import importlib import traceback +import asyncio from os.path import join from os.path import isdir @@ -75,9 +76,14 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi module = self._load_plugin_module(path, folder, target) if is_pre_launch: - self.execute_plugin(module, manifest_meta) + asyncio.run( + self.execute_plugin(module, manifest_meta) + ) else: - GLib.idle_add(self.execute_plugin, module, manifest_meta) + GLib.idle_add( + asyncio.run, + self.execute_plugin(module, manifest_meta) + ) except Exception as e: logger.info(f"Malformed Plugin: Not loading -->: '{folder}' !") logger.debug(f"Trace: {traceback.print_exc()}") @@ -119,7 +125,7 @@ class PluginsController(ControllerBase, PluginsControllerMixin, PluginReloadMixi manifest_metas: list = self._manifest_manager.get_post_launch_plugins() self._load_plugins(manifest_metas) - def execute_plugin(self, module: type, manifest_meta: ManifestMeta): + async def execute_plugin(self, module: type, manifest_meta: ManifestMeta): plugin = module.Plugin() plugin.plugin_context: PluginContext = self.create_plugin_context()