From 3ad7c3b65d8cc7a411a577a0b8376ac9aa2b9604 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 14 Oct 2023 15:44:45 -0500 Subject: [PATCH] Added mouse zoom; fixed colorize bug; set default line to 0 --- plugins/colorize/plugin.py | 2 +- .../sourceview/source_file_events_mixin.py | 2 +- .../widgets/base/sourceview/source_view.py | 24 +++++++++++++++++++ .../base/sourceview/source_view_events.py | 2 +- user_config/usr/share/newton/stylesheet.css | 7 +++++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/plugins/colorize/plugin.py b/plugins/colorize/plugin.py index 453d787..d1f77a6 100644 --- a/plugins/colorize/plugin.py +++ b/plugins/colorize/plugin.py @@ -72,7 +72,7 @@ class Plugin(PluginBase): start = iter.copy() for tag in tags: - if self.tag_stub_name in tag.props.name: + if tag.props.name and self.tag_stub_name in tag.props.name: buffer.remove_tag(tag, start, end) tag_table.remove(tag) diff --git a/src/core/widgets/base/sourceview/source_file_events_mixin.py b/src/core/widgets/base/sourceview/source_file_events_mixin.py index 36a1acf..74e72b9 100644 --- a/src/core/widgets/base/sourceview/source_file_events_mixin.py +++ b/src/core/widgets/base/sourceview/source_file_events_mixin.py @@ -75,7 +75,7 @@ class FileEventsMixin: self.update_labels(gfile) self._loading_file = False - self._file_loader.load_async(io_priority = 70, + self._file_loader.load_async(io_priority = 80, cancellable = None, progress_callback = None, progress_callback_data = None, diff --git a/src/core/widgets/base/sourceview/source_view.py b/src/core/widgets/base/sourceview/source_view.py index 7d2288f..9dd6345 100644 --- a/src/core/widgets/base/sourceview/source_view.py +++ b/src/core/widgets/base/sourceview/source_view.py @@ -82,6 +82,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View): self.connect("drag-data-received", self._on_drag_data_received) self.connect("key-press-event", self._key_press_event) self.connect("button-press-event", self._button_press_event) + self.connect("scroll-event", self._scroll_event) self._buffer.connect('changed', self._is_modified) self._buffer.connect("mark-set", self._on_cursor_move) @@ -180,6 +181,29 @@ class SourceView(SourceViewEventsMixin, GtkSource.View): elif eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 3: # r-click ... + def _scroll_event(self, widget, eve): + accel_mask = Gtk.accelerator_get_default_mod_mask() + x, y, z = eve.get_scroll_deltas() + if eve.state & accel_mask == Gdk.ModifierType.CONTROL_MASK: + if z > 0: + self.scale_down_text() + else: + self.scale_up_text() + + return True + + if eve.state & accel_mask == Gdk.ModifierType.SHIFT_MASK: + adjustment = self.get_hadjustment() + current_val = adjustment.get_value() + step_val = adjustment.get_step_increment() + + if z > 0: # NOTE: scroll left + adjustment.set_value(current_val - step_val * 2) + else: # NOTE: scroll right + adjustment.set_value(current_val + step_val * 2) + + return True + def _focus_in_event(self, widget, eve = None): event_system.emit("set_active_src_view", (self,)) self.get_parent().get_parent().is_editor_focused = True diff --git a/src/core/widgets/base/sourceview/source_view_events.py b/src/core/widgets/base/sourceview/source_view_events.py index 3599a44..e6d92d2 100644 --- a/src/core/widgets/base/sourceview/source_view_events.py +++ b/src/core/widgets/base/sourceview/source_view_events.py @@ -64,7 +64,7 @@ class SourceViewEventsMixin(MarkEventsMixin, FileEventsMixin): event_system.emit("set_line_char_label", (f"{row}:{col}",)) def got_to_line(self, line: int = 0): - index = line - 1 + index = line buffer = self.get_buffer() line_itr = buffer.get_iter_at_line(index) char_iter = buffer.get_iter_at_line_offset(index, line_itr.get_bytes_in_line()) diff --git a/user_config/usr/share/newton/stylesheet.css b/user_config/usr/share/newton/stylesheet.css index ee6d236..6b94ea9 100644 --- a/user_config/usr/share/newton/stylesheet.css +++ b/user_config/usr/share/newton/stylesheet.css @@ -39,7 +39,7 @@ notebook > header > tabs > tab { } notebook > header > tabs > tab:active { - background: rgba(39, 43, 52, 0.0); + background: rgba(0, 0, 0, 0.0); } @@ -223,3 +223,8 @@ popover { .px97 { font-size: 97px; } .px98 { font-size: 98px; } .px99 { font-size: 99px; } + + +.mini-view > text { + background: rgba(39, 43, 52, 0.64); +} \ No newline at end of file