diff --git a/README.md b/README.md index 6415acc3..c9f012b6 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - another fix for bug in clear geometry processing for Gerber apertures - added a protection for the case that the aperture table is part of a deleted object +- in Script Editor added support for auto-add closing parenthesis, brace and bracket 4.05.2019 diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py index 0231cf3e..b1ac19f3 100644 --- a/flatcamGUI/GUIElements.py +++ b/flatcamGUI/GUIElements.py @@ -576,6 +576,40 @@ class FCTextAreaExtended(QtWidgets.QTextEdit): self.completer.insertText.emit(self.completer.getSelected()) self.completer.setCompletionMode(QCompleter.PopupCompletion) return + elif key == Qt.Key_BraceLeft: + tc.insertText('{}') + self.moveCursor(QtGui.QTextCursor.Left) + elif key == Qt.Key_BracketLeft: + tc.insertText('[]') + self.moveCursor(QtGui.QTextCursor.Left) + elif key == Qt.Key_ParenLeft: + tc.insertText('()') + self.moveCursor(QtGui.QTextCursor.Left) + + elif key == Qt.Key_BraceRight: + tc.select(QtGui.QTextCursor.WordUnderCursor) + if tc.selectedText() == '}': + tc.movePosition(QTextCursor.Right) + self.setTextCursor(tc) + else: + tc.clearSelection() + self.textCursor().insertText('}') + elif key == Qt.Key_BracketRight: + tc.select(QtGui.QTextCursor.WordUnderCursor) + if tc.selectedText() == ']': + tc.movePosition(QTextCursor.Right) + self.setTextCursor(tc) + else: + tc.clearSelection() + self.textCursor().insertText(']') + elif key == Qt.Key_ParenRight: + tc.select(QtGui.QTextCursor.WordUnderCursor) + if tc.selectedText() == ')': + tc.movePosition(QTextCursor.Right) + self.setTextCursor(tc) + else: + tc.clearSelection() + self.textCursor().insertText(')') else: super(FCTextAreaExtended, self).keyPressEvent(event)