From beb1bcec306326e9de8d850cbf101fa45832898e Mon Sep 17 00:00:00 2001 From: Lucas Brown <54835354+imlucasbrown@users.noreply.github.com> Date: Sun, 14 Jul 2024 16:51:02 -0500 Subject: [PATCH] Fixes to get the code editor open --- nxt_editor/dockwidgets/syntax.py | 9 +++++---- nxt_editor/pixmap_button.py | 2 +- nxt_editor/stage_view.py | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/nxt_editor/dockwidgets/syntax.py b/nxt_editor/dockwidgets/syntax.py index aae7750..5a64f01 100644 --- a/nxt_editor/dockwidgets/syntax.py +++ b/nxt_editor/dockwidgets/syntax.py @@ -117,7 +117,8 @@ def highlightBlock(self, text): # Do other syntax formatting for rule in self.rules: expression, nth, formatting = rule - index = expression.match(text).capturedStart() + match = expression.match(text) + index = match.capturedStart() # This is here because you can't do nested logic in regex nested = 0 if rule in self.special_rules: @@ -126,10 +127,10 @@ def highlightBlock(self, text): while index >= 0: # We actually want the index of the nth match - index = expression.pos(nth) - length = len(expression.cap(nth)) + index = match.capturedStart(nth) + length = len(match.captured(nth)) self.setFormat(index, length + nested, formatting) - index = expression.indexIn(text, index + length) + index = match.capturedStart(text) self.setCurrentBlockState(0) diff --git a/nxt_editor/pixmap_button.py b/nxt_editor/pixmap_button.py index 3239ad4..e4a07f6 100644 --- a/nxt_editor/pixmap_button.py +++ b/nxt_editor/pixmap_button.py @@ -71,7 +71,7 @@ def paintEvent(self, event): pix = self.pixmap_pressed painter = QtGui.QPainter(self) - painter.drawPixmap(event.rect(), pix) + painter.drawPixmap(event.rect(), QtGui.QPixmap(pix)) del painter def enterEvent(self, event): diff --git a/nxt_editor/stage_view.py b/nxt_editor/stage_view.py index dc243f1..b45af64 100644 --- a/nxt_editor/stage_view.py +++ b/nxt_editor/stage_view.py @@ -701,7 +701,7 @@ def mousePressEvent(self, event): self.zoom_start_pos = event.pos() self._previous_mouse_pos = event.pos() event.accept() - if event.buttons() == QtCore.Qt.LeftButton | QtCompat.QtCore.Qt.MidButton: + if event.buttons() == QtCore.Qt.LeftButton | QtCore.Qt.MiddleButton: self.zooming = True self.zoom_start_pos = event.pos() self._previous_mouse_pos = event.pos() @@ -748,7 +748,7 @@ def mousePressEvent(self, event): return # block immediate node movement # middle and right button events - elif event.button() == QtCompat.QtCore.Qt.MidButton: + elif event.button() == QtCore.Qt.MiddleButton: # start panning action self.panning = True self._previous_mouse_pos = None @@ -826,11 +826,11 @@ def mouseReleaseEvent(self, event): event.accept() if self.zooming: - if event.buttons() == QtCore.Qt.LeftButton | QtCompat.QtCore.Qt.MidButton: + if event.buttons() == QtCore.Qt.LeftButton | QtCore.Qt.MiddleButton: self.zooming = False elif event.buttons() == QtCore.Qt.LeftButton: self.zooming = False - elif event.buttons() == QtCompat.QtCore.Qt.MidButton: + elif event.buttons() == QtCore.Qt.MiddleButton: self.zooming = False if (self._rubber_band_origin is not None and event.button() is QtCore.Qt.LeftButton): @@ -968,7 +968,7 @@ def mouseReleaseEvent(self, event): self.block_context_menu = False self.contextMenuEvent(event) # complete panning action - if self.panning and event.button() == QtCompat.QtCore.Qt.MidButton: + if self.panning and event.button() == QtCore.Qt.MiddleButton: self._previous_mouse_pos = None self.panning = False self._current_pan_distance = 0.0