Skip to content

Commit

Permalink
Fixes to get the code editor open
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLucasBrown committed Jul 14, 2024
1 parent 7488717 commit beb1bce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions nxt_editor/dockwidgets/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nxt_editor/pixmap_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions nxt_editor/stage_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit beb1bce

Please sign in to comment.