From 2b50afe14dc7a35a242ff29962a73ba55da9414a Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 12 Nov 2023 14:44:48 -0600 Subject: [PATCH 1/6] Mouse focus styling update --- src/core/controller_data.py | 11 ++++++++++- src/core/widgets/base/notebook/editor_notebook.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/controller_data.py b/src/core/controller_data.py index 7900d8b..519e767 100644 --- a/src/core/controller_data.py +++ b/src/core/controller_data.py @@ -28,7 +28,16 @@ class ControllerData: def set_active_src_view(self, source_view): if self.active_src_view: - self.active_src_view.get_parent().is_editor_focused = False + old_notebook = self.active_src_view.get_parent().get_parent() + old_notebook.is_editor_focused = False + + ctx = old_notebook.get_style_context() + ctx.remove_class("notebook-selected-focus") + + + notebook = source_view.get_parent().get_parent() + ctx = notebook.get_style_context() + ctx.add_class("notebook-selected-focus") self.active_src_view = source_view diff --git a/src/core/widgets/base/notebook/editor_notebook.py b/src/core/widgets/base/notebook/editor_notebook.py index c370403..afc3d95 100644 --- a/src/core/widgets/base/notebook/editor_notebook.py +++ b/src/core/widgets/base/notebook/editor_notebook.py @@ -80,7 +80,8 @@ class EditorNotebook(EditorControllerMixin, Gtk.Notebook): def _focused_target_changed(self, target): self.is_editor_focused = True if target == self.NAME else False - self.grab_focus() + if self.is_editor_focused: + self.grab_focus() def _add_action_widgets(self): start_box = Gtk.Box() From 6752cf47dfbb83635a1ba160e01fe710319eb02c Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 12 Nov 2023 16:02:04 -0600 Subject: [PATCH 2/6] Resolving info widget updating events --- plugins/lsp_client/plugin.py | 2 +- plugins/markdown_preview/plugin.py | 2 +- src/core/controller_data.py | 7 ++++++- src/core/widgets/base/general_info_widget.py | 14 ++++++++++++-- src/core/widgets/base/notebook/editor_events.py | 2 +- .../base/sourceview/source_view_controller.py | 4 ++-- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/plugins/lsp_client/plugin.py b/plugins/lsp_client/plugin.py index 29c87ff..11f2954 100644 --- a/plugins/lsp_client/plugin.py +++ b/plugins/lsp_client/plugin.py @@ -96,7 +96,7 @@ class Plugin(PluginBase): self.delay_completion(source_view, context, callback) def _do_completion(self, source_view, context, callback): - filepath = source_view.get_current_filepath() + filepath = source_view.get_current_file() if not filepath: return diff --git a/plugins/markdown_preview/plugin.py b/plugins/markdown_preview/plugin.py index 24df4a9..b363acb 100644 --- a/plugins/markdown_preview/plugin.py +++ b/plugins/markdown_preview/plugin.py @@ -103,7 +103,7 @@ class Plugin(MarkdownTemplateMixin, PluginBase): text = buffer.get_text(start_iter, end_iter, include_hidden_chars = False) html = markdown.markdown(text) - path = self._active_src_view.get_current_filepath().get_parent().get_path() + path = self._active_src_view.get_current_file().get_parent().get_path() data = self.wrap_html_to_body(html) self._markdown_view.load_html(content = data, base_uri = f"file://{path}/") diff --git a/src/core/controller_data.py b/src/core/controller_data.py index 519e767..def6d80 100644 --- a/src/core/controller_data.py +++ b/src/core/controller_data.py @@ -34,10 +34,15 @@ class ControllerData: ctx = old_notebook.get_style_context() ctx.remove_class("notebook-selected-focus") - notebook = source_view.get_parent().get_parent() ctx = notebook.get_style_context() ctx.add_class("notebook-selected-focus") + + file = source_view.get_current_file() + if file: + source_view.set_bottom_labels(file) + else: + event_system.emit("set_bottom_labels") self.active_src_view = source_view diff --git a/src/core/widgets/base/general_info_widget.py b/src/core/widgets/base/general_info_widget.py index 9e8dc51..f34ff9b 100644 --- a/src/core/widgets/base/general_info_widget.py +++ b/src/core/widgets/base/general_info_widget.py @@ -65,11 +65,13 @@ class GeneralInfoWidget: def set_bottom_labels(self, path = None, line_char = None, file_type = None, encoding_type = None): self._set_path_label(path) - self._set_line_char_label() + self._set_line_char_label(line_char) self._set_file_type_label(file_type) - self._set_encoding_label() + self._set_encoding_label(encoding_type) def _set_path_label(self, gfile = ""): + gfile = "" if not gfile else gfile + if isinstance(gfile, str): self.bottom_path_label.set_text( gfile ) self.bottom_path_label.set_tooltip_text( gfile ) @@ -78,10 +80,18 @@ class GeneralInfoWidget: self.bottom_path_label.set_tooltip_text( gfile.get_path() ) def _set_line_char_label(self, line_char = "1:1"): + line_char = "1:1" if not line_char else line_char + self.bottom_line_char_label.set_text(line_char) def _set_file_type_label(self, file_type = "buffer"): + file_type = "buffer" if not file_type else file_type + self.bottom_file_type_label.set_text(file_type) def _set_encoding_label(self, encoding_type = "utf-8"): + encoding_type = "utf-8" if not encoding_type else encoding_type + self.bottom_encoding_label.set_text(encoding_type) + + diff --git a/src/core/widgets/base/notebook/editor_events.py b/src/core/widgets/base/notebook/editor_events.py index bec494c..73993f5 100644 --- a/src/core/widgets/base/notebook/editor_events.py +++ b/src/core/widgets/base/notebook/editor_events.py @@ -42,7 +42,7 @@ class EditorEventsMixin: file_type = source_view.get_filetype() if not file_type == "buffer": - uri = source_view.get_current_filepath().get_uri() + uri = source_view.get_current_file().get_uri() event_system.emit("textDocument/didClose", (file_type, uri,)) page_num = notebook.page_num(container) diff --git a/src/core/widgets/base/sourceview/source_view_controller.py b/src/core/widgets/base/sourceview/source_view_controller.py index 447a9b9..a173524 100644 --- a/src/core/widgets/base/sourceview/source_view_controller.py +++ b/src/core/widgets/base/sourceview/source_view_controller.py @@ -13,7 +13,7 @@ from .source_view_events import SourceViewEvents class SourceViewControllerMixin(KeyInputController, SourceViewEvents): - def get_current_filepath(self): + def get_current_file(self): return self._current_file def get_filetype(self): @@ -30,7 +30,7 @@ class SourceViewControllerMixin(KeyInputController, SourceViewEvents): iter = buffer.get_iter_at_mark( buffer.get_insert() ) line = iter.get_line() offset = iter.get_line_offset() - uri = self.get_current_filepath().get_uri() + uri = self.get_current_file().get_uri() event_system.emit("textDocument/definition", (self.get_filetype(), uri, line, offset,)) From 9d2c62ef20a3bc1f61b9f6b0b4168edab0653e37 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 12 Nov 2023 16:50:53 -0600 Subject: [PATCH 3/6] File open sets default path to current path if any --- src/core/widgets/base/notebook/key_input_controller.py | 5 +++-- src/core/widgets/controls/open_file_button.py | 8 +++++++- src/core/widgets/save_file_dialog.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/widgets/base/notebook/key_input_controller.py b/src/core/widgets/base/notebook/key_input_controller.py index b9140cc..21f21be 100644 --- a/src/core/widgets/base/notebook/key_input_controller.py +++ b/src/core/widgets/base/notebook/key_input_controller.py @@ -50,7 +50,8 @@ class KeyInputController: if keyname == "t": self._create_view() if keyname == "o": - event_system.emit("open_files") + page_num, container, source_view = self.get_active_view() + event_system.emit("open_files", (source_view,)) return True @@ -65,4 +66,4 @@ class KeyInputController: if keyname == "Right": self.keyboard_move_tab_right(page_num) - return True + return True \ No newline at end of file diff --git a/src/core/widgets/controls/open_file_button.py b/src/core/widgets/controls/open_file_button.py index 411b857..3b98d65 100644 --- a/src/core/widgets/controls/open_file_button.py +++ b/src/core/widgets/controls/open_file_button.py @@ -46,6 +46,12 @@ class OpenFileButton(Gtk.Button): Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) + + try: + folder = widget.get_current_file().get_parent() + chooser.set_current_folder( folder.get_uri() ) + except Exception as e: + ... response = chooser.run() if response == Gtk.ResponseType.OK: @@ -55,4 +61,4 @@ class OpenFileButton(Gtk.Button): _gfile = Gio.File.new_for_path(path) event_system.emit("keyboard_open_file", (_gfile,)) - chooser.destroy() + chooser.destroy() \ No newline at end of file diff --git a/src/core/widgets/save_file_dialog.py b/src/core/widgets/save_file_dialog.py index 1a20096..75edede 100644 --- a/src/core/widgets/save_file_dialog.py +++ b/src/core/widgets/save_file_dialog.py @@ -57,7 +57,7 @@ class SaveFileDialog: dlg.set_current_name("new.txt") dlg.set_current_folder(os.path.expanduser('~')) else: - dlg.set_current_folder(current_file.get_parent().get_path()) + dlg.set_current_folder(current_file.get_parent().get_uri()) dlg.set_current_name(current_filename) response = dlg.run() From 257a368e0220f9fc7aada7788bf28ebee264241c Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 12 Nov 2023 17:34:13 -0600 Subject: [PATCH 4/6] Improved handle placement on ctrl+shift --> 2nd pane when hidden --- src/core/widgets/base/notebook/editor_events.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/widgets/base/notebook/editor_events.py b/src/core/widgets/base/notebook/editor_events.py index 73993f5..4e9a82c 100644 --- a/src/core/widgets/base/notebook/editor_events.py +++ b/src/core/widgets/base/notebook/editor_events.py @@ -114,7 +114,10 @@ class EditorEventsMixin: tab = page.get_tab_widget() self.detach_tab(page) - notebook.show() + if not notebook.is_visible(): + notebook.show() + event_system.emit("update_paned_handle") + notebook.insert_page(page, tab, -1) self.set_page_focus(page, notebook, self) From cec6f71727e16d02fea9ffae7dbbef9ec6b10d92 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 13 Nov 2023 22:09:25 -0600 Subject: [PATCH 5/6] More LSP effort; improved file load by freezing event system until loaded --- .../lsp_completion_provider.py | 31 ++++++++++--------- .../mixins/source_file_events_mixin.py | 4 ++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/core/widgets/base/sourceview/custom_completion_providers/lsp_completion_provider.py b/src/core/widgets/base/sourceview/custom_completion_providers/lsp_completion_provider.py index ed1bb8c..652cdae 100644 --- a/src/core/widgets/base/sourceview/custom_completion_providers/lsp_completion_provider.py +++ b/src/core/widgets/base/sourceview/custom_completion_providers/lsp_completion_provider.py @@ -25,6 +25,7 @@ class LSPCompletionProvider(GObject.Object, GtkSource.CompletionProvider): self._theme = Gtk.IconTheme.get_default() self._source_view = source_view + def do_get_name(self): return "LSP Code Completion" @@ -33,6 +34,11 @@ class LSPCompletionProvider(GObject.Object, GtkSource.CompletionProvider): return context.get_iter()[1] if isinstance(context.get_iter(), tuple) else context.get_iter() def do_match(self, context): + iter = self.get_iter_correctly(context) + buffer = iter.get_buffer() + if buffer.get_context_classes_at_iter(iter) != ['no-spell-check']: + return False + event_system.emit("textDocument/completion", (self._source_view, context, self.do_populate)) return True @@ -45,7 +51,7 @@ class LSPCompletionProvider(GObject.Object, GtkSource.CompletionProvider): def do_populate(self, context, result = None): proposals = [] if result: - if result.items: + if not result.items is None: for item in result.items: proposals.append( self.create_completion_item(item) ) else: @@ -69,20 +75,17 @@ class LSPCompletionProvider(GObject.Object, GtkSource.CompletionProvider): def create_completion_item(self, item): comp_item = GtkSource.CompletionItem.new() comp_item.set_label(item.label) - comp_item.set_text(item.textEdit) + + if item.textEdit: + if isinstance(item.textEdit, dict): + comp_item.set_text(item.textEdit["newText"]) + else: + comp_item.set_text(item.textEdit) + else: + comp_item.set_text(item.insertText) + comp_item.set_icon( self.get_icon_for_type(item.kind) ) comp_item.set_info(item.documentation) + return comp_item - - - - - - - - - - - - diff --git a/src/core/widgets/base/sourceview/mixins/source_file_events_mixin.py b/src/core/widgets/base/sourceview/mixins/source_file_events_mixin.py index debdc48..1affe10 100644 --- a/src/core/widgets/base/sourceview/mixins/source_file_events_mixin.py +++ b/src/core/widgets/base/sourceview/mixins/source_file_events_mixin.py @@ -70,7 +70,10 @@ class FileEventsMixin: file.set_location(gfile) self._file_loader = GtkSource.FileLoader.new(buffer, file) + event_system.emit("pause_event_processing") def finish_load_callback(obj, res, user_data = None): + event_system.emit("resume_event_processing") + self._file_loader.load_finish(res) self._document_loaded(line) self.update_labels(gfile) @@ -152,4 +155,3 @@ class FileEventsMixin: self.got_to_line(buffer, line) - From 0e8833f6f9c23ea6b0b8681fb104590a648f5e23 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Thu, 11 Jan 2024 19:48:10 -0600 Subject: [PATCH 6/6] moved utils --> libs --- src/__builtins__.py | 12 ++++++------ src/app.py | 4 ++-- src/{utils => libs}/__init__.py | 0 src/{utils => libs}/debugging.py | 0 src/{utils => libs}/endpoint_registry.py | 0 src/{utils => libs}/event_system.py | 0 src/{utils => libs}/ipc_server.py | 0 src/{utils => libs}/keybindings.py | 0 src/{utils => libs}/logger.py | 0 src/{utils => libs}/settings_manager/__init__.py | 0 src/{utils => libs}/settings_manager/manager.py | 0 .../settings_manager/options/__init__.py | 0 .../settings_manager/options/config.py | 0 .../settings_manager/options/debugging.py | 0 .../settings_manager/options/filters.py | 0 .../settings_manager/options/settings.py | 0 .../settings_manager/options/theming.py | 0 .../settings_manager/start_check_mixin.py | 0 src/{utils => libs}/singleton.py | 0 19 files changed, 8 insertions(+), 8 deletions(-) rename src/{utils => libs}/__init__.py (100%) rename src/{utils => libs}/debugging.py (100%) rename src/{utils => libs}/endpoint_registry.py (100%) rename src/{utils => libs}/event_system.py (100%) rename src/{utils => libs}/ipc_server.py (100%) rename src/{utils => libs}/keybindings.py (100%) rename src/{utils => libs}/logger.py (100%) rename src/{utils => libs}/settings_manager/__init__.py (100%) rename src/{utils => libs}/settings_manager/manager.py (100%) rename src/{utils => libs}/settings_manager/options/__init__.py (100%) rename src/{utils => libs}/settings_manager/options/config.py (100%) rename src/{utils => libs}/settings_manager/options/debugging.py (100%) rename src/{utils => libs}/settings_manager/options/filters.py (100%) rename src/{utils => libs}/settings_manager/options/settings.py (100%) rename src/{utils => libs}/settings_manager/options/theming.py (100%) rename src/{utils => libs}/settings_manager/start_check_mixin.py (100%) rename src/{utils => libs}/singleton.py (100%) diff --git a/src/__builtins__.py b/src/__builtins__.py index 2ccc2b4..38aa521 100644 --- a/src/__builtins__.py +++ b/src/__builtins__.py @@ -5,11 +5,11 @@ import threading # Lib imports # Application imports -from utils.event_system import EventSystem -from utils.endpoint_registry import EndpointRegistry -from utils.keybindings import Keybindings -from utils.logger import Logger -from utils.settings_manager.manager import SettingsManager +from libs.event_system import EventSystem +from libs.endpoint_registry import EndpointRegistry +from libs.keybindings import Keybindings +from libs.logger import Logger +from libs.settings_manager.manager import SettingsManager class BuiltinsException(Exception): @@ -47,4 +47,4 @@ builtins.logger = Logger(settings_manager.get_home_config_path(), \ _fh_log_lvl=settings.debugging.fh_log_lvl).get_logger() builtins.threaded = threaded_wrapper -builtins.daemon_threaded = daemon_threaded_wrapper +builtins.daemon_threaded = daemon_threaded_wrapper \ No newline at end of file diff --git a/src/app.py b/src/app.py index 8bb6255..e00fc89 100644 --- a/src/app.py +++ b/src/app.py @@ -5,8 +5,8 @@ import os # Lib imports # Application imports -from utils.debugging import debug_signal_handler -from utils.ipc_server import IPCServer +from libs.debugging import debug_signal_handler +from libs.ipc_server import IPCServer from core.window import Window diff --git a/src/utils/__init__.py b/src/libs/__init__.py similarity index 100% rename from src/utils/__init__.py rename to src/libs/__init__.py diff --git a/src/utils/debugging.py b/src/libs/debugging.py similarity index 100% rename from src/utils/debugging.py rename to src/libs/debugging.py diff --git a/src/utils/endpoint_registry.py b/src/libs/endpoint_registry.py similarity index 100% rename from src/utils/endpoint_registry.py rename to src/libs/endpoint_registry.py diff --git a/src/utils/event_system.py b/src/libs/event_system.py similarity index 100% rename from src/utils/event_system.py rename to src/libs/event_system.py diff --git a/src/utils/ipc_server.py b/src/libs/ipc_server.py similarity index 100% rename from src/utils/ipc_server.py rename to src/libs/ipc_server.py diff --git a/src/utils/keybindings.py b/src/libs/keybindings.py similarity index 100% rename from src/utils/keybindings.py rename to src/libs/keybindings.py diff --git a/src/utils/logger.py b/src/libs/logger.py similarity index 100% rename from src/utils/logger.py rename to src/libs/logger.py diff --git a/src/utils/settings_manager/__init__.py b/src/libs/settings_manager/__init__.py similarity index 100% rename from src/utils/settings_manager/__init__.py rename to src/libs/settings_manager/__init__.py diff --git a/src/utils/settings_manager/manager.py b/src/libs/settings_manager/manager.py similarity index 100% rename from src/utils/settings_manager/manager.py rename to src/libs/settings_manager/manager.py diff --git a/src/utils/settings_manager/options/__init__.py b/src/libs/settings_manager/options/__init__.py similarity index 100% rename from src/utils/settings_manager/options/__init__.py rename to src/libs/settings_manager/options/__init__.py diff --git a/src/utils/settings_manager/options/config.py b/src/libs/settings_manager/options/config.py similarity index 100% rename from src/utils/settings_manager/options/config.py rename to src/libs/settings_manager/options/config.py diff --git a/src/utils/settings_manager/options/debugging.py b/src/libs/settings_manager/options/debugging.py similarity index 100% rename from src/utils/settings_manager/options/debugging.py rename to src/libs/settings_manager/options/debugging.py diff --git a/src/utils/settings_manager/options/filters.py b/src/libs/settings_manager/options/filters.py similarity index 100% rename from src/utils/settings_manager/options/filters.py rename to src/libs/settings_manager/options/filters.py diff --git a/src/utils/settings_manager/options/settings.py b/src/libs/settings_manager/options/settings.py similarity index 100% rename from src/utils/settings_manager/options/settings.py rename to src/libs/settings_manager/options/settings.py diff --git a/src/utils/settings_manager/options/theming.py b/src/libs/settings_manager/options/theming.py similarity index 100% rename from src/utils/settings_manager/options/theming.py rename to src/libs/settings_manager/options/theming.py diff --git a/src/utils/settings_manager/start_check_mixin.py b/src/libs/settings_manager/start_check_mixin.py similarity index 100% rename from src/utils/settings_manager/start_check_mixin.py rename to src/libs/settings_manager/start_check_mixin.py diff --git a/src/utils/singleton.py b/src/libs/singleton.py similarity index 100% rename from src/utils/singleton.py rename to src/libs/singleton.py