- added autocomplete finish with ENTER key for the TCL Shell
- made sure that the autocomplete function works only for FlatCAM Scripts
This commit is contained in:
@@ -3915,7 +3915,8 @@ class App(QtCore.QObject):
|
||||
obj_name = self.collection.get_active().options['name']
|
||||
except AttributeError:
|
||||
obj_name = 'file'
|
||||
_filter_ = "FlatConfig Files (*.FlatConfig);;All Files (*.*)"
|
||||
if filt is None:
|
||||
_filter_ = "FlatConfig Files (*.FlatConfig);;All Files (*.*)"
|
||||
|
||||
try:
|
||||
filename = str(QtWidgets.QFileDialog.getSaveFileName(
|
||||
@@ -5766,6 +5767,7 @@ class App(QtCore.QObject):
|
||||
# first clear previous text in text editor (if any)
|
||||
self.ui.code_editor.clear()
|
||||
self.toggle_codeeditor = True
|
||||
self.ui.code_editor.completer_enable = False
|
||||
|
||||
# Switch plot_area to CNCJob tab
|
||||
self.ui.plot_tab_area.setCurrentWidget(self.ui.cncjob_tab)
|
||||
@@ -5824,6 +5826,7 @@ class App(QtCore.QObject):
|
||||
def on_filenewscript(self):
|
||||
flt = "FlatCAM Scripts (*.FlatScript);;All Files (*.*)"
|
||||
self.init_code_editor(name=_("Script Editor"))
|
||||
self.ui.code_editor.completer_enable = True
|
||||
self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt))
|
||||
self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt))
|
||||
|
||||
|
||||
@@ -9,9 +9,14 @@ CAD program, and create G-Code for Isolation routing.
|
||||
|
||||
=================================================
|
||||
|
||||
20.03.2019
|
||||
|
||||
- added autocomplete finish with ENTER key for the TCL Shell
|
||||
- made sure that the autocomplete function works only for FlatCAM Scripts
|
||||
|
||||
19.03.2019
|
||||
|
||||
- added autocomplete for Code editor; TODO: needs to be enabled only when doing Scripts, right now is available for everyone.
|
||||
- added autocomplete for Code editor;
|
||||
- autocomplete in Code Editor is finished by hitting either TAB key or ENTER key
|
||||
- fixed the Gerber.merge() to work for the case when one of the merged Gerber objects solid_geometry type is Polygon and not a list
|
||||
|
||||
|
||||
@@ -501,6 +501,8 @@ class FCTextAreaExtended(QtWidgets.QTextEdit):
|
||||
self.set_model_data(keyword_list=[])
|
||||
self.completer.insertText.connect(self.insertCompletion)
|
||||
|
||||
self.completer_enable = False
|
||||
|
||||
def set_model_data(self, keyword_list):
|
||||
self.model.setStringList(keyword_list)
|
||||
|
||||
@@ -563,19 +565,20 @@ class FCTextAreaExtended(QtWidgets.QTextEdit):
|
||||
else:
|
||||
super(FCTextAreaExtended, self).keyPressEvent(event)
|
||||
|
||||
tc.select(QTextCursor.WordUnderCursor)
|
||||
cr = self.cursorRect()
|
||||
if self.completer_enable:
|
||||
tc.select(QTextCursor.WordUnderCursor)
|
||||
cr = self.cursorRect()
|
||||
|
||||
if len(tc.selectedText()) > 0:
|
||||
self.completer.setCompletionPrefix(tc.selectedText())
|
||||
popup = self.completer.popup()
|
||||
popup.setCurrentIndex(self.completer.completionModel().index(0, 0))
|
||||
if len(tc.selectedText()) > 0:
|
||||
self.completer.setCompletionPrefix(tc.selectedText())
|
||||
popup = self.completer.popup()
|
||||
popup.setCurrentIndex(self.completer.completionModel().index(0, 0))
|
||||
|
||||
cr.setWidth(self.completer.popup().sizeHintForColumn(0)
|
||||
+ self.completer.popup().verticalScrollBar().sizeHint().width())
|
||||
self.completer.complete(cr)
|
||||
else:
|
||||
self.completer.popup().hide()
|
||||
cr.setWidth(self.completer.popup().sizeHintForColumn(0)
|
||||
+ self.completer.popup().verticalScrollBar().sizeHint().width())
|
||||
self.completer.complete(cr)
|
||||
else:
|
||||
self.completer.popup().hide()
|
||||
|
||||
|
||||
class FCComboBox(QtWidgets.QComboBox):
|
||||
@@ -1466,6 +1469,13 @@ class _ExpandableTextEdit(QTextEdit):
|
||||
"""
|
||||
Catch keyboard events. Process Enter, Up, Down
|
||||
"""
|
||||
|
||||
key = event.key()
|
||||
if (key == Qt.Key_Tab or key == Qt.Key_Return or key == Qt.Key_Enter) and self.completer.popup().isVisible():
|
||||
self.completer.insertText.emit(self.completer.getSelected())
|
||||
self.completer.setCompletionMode(QCompleter.PopupCompletion)
|
||||
return
|
||||
|
||||
if event.matches(QKeySequence.InsertParagraphSeparator):
|
||||
text = self.toPlainText()
|
||||
if self._termWidget.is_command_complete(text):
|
||||
@@ -1496,10 +1506,6 @@ class _ExpandableTextEdit(QTextEdit):
|
||||
return self._termWidget.browser().keyPressEvent(event)
|
||||
|
||||
tc = self.textCursor()
|
||||
if event.key() == Qt.Key_Tab and self.completer.popup().isVisible():
|
||||
self.completer.insertText.emit(self.completer.getSelected())
|
||||
self.completer.setCompletionMode(QCompleter.PopupCompletion)
|
||||
return
|
||||
|
||||
QTextEdit.keyPressEvent(self, event)
|
||||
tc.select(QTextCursor.WordUnderCursor)
|
||||
|
||||
Reference in New Issue
Block a user