Merge pull request 'develop' (#1) from develop into master

Reviewed-on: #1
This commit is contained in:
itdominator 2024-01-12 01:55:22 +00:00
commit 30cf03b76f
31 changed files with 77 additions and 37 deletions

View File

@ -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

View File

@ -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}/")

View File

@ -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

View File

@ -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

View File

@ -28,7 +28,21 @@ 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")
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

View File

@ -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)

View File

@ -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)
@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,))

View File

@ -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()

View File

@ -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()