diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 7ce4cb51..2bfdcf2d 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3271,8 +3271,7 @@ class App(QtCore.QObject): self.ui.plot_tab_area.setTabText(0, "EDITOR Area") self.ui.plot_tab_area.protectTab(0) - self.inform.emit('[WARNING_NOTCL] %s' % - _("Editor is activated ...")) + self.inform.emit('[WARNING_NOTCL] %s' % _("Editor is activated ...")) self.should_we_save = True @@ -9918,9 +9917,34 @@ class App(QtCore.QObject): self.toggle_codeeditor = False def on_code_editor_close(self): - print("closed") self.toggle_codeeditor = False + def goto_text_line(self): + """ + Will scroll a text to the specified text line. + + :return: None + """ + dia_box = Dialog_box(title=_("Go to Line ..."), + label=_("Line:"), + icon=QtGui.QIcon(self.resource_location + '/jump_to16.png'), + initial_text='') + try: + line = int(dia_box.location) - 1 + except (ValueError, TypeError): + line = 0 + + if dia_box.ok: + # make sure to move first the cursor at the end so after finding the line the line will be positioned + # at the top of the window + self.ui.plot_tab_area.currentWidget().code_editor.moveCursor(QTextCursor.End) + # get the document() of the TextEditor + doc = self.ui.plot_tab_area.currentWidget().code_editor.document() + # create a Text Cursor based on the searched line + cursor = QTextCursor(doc.findBlockByLineNumber(line)) + # set cursor of the code editor with the cursor at the searcehd line + self.ui.plot_tab_area.currentWidget().code_editor.setTextCursor(cursor) + def on_filenewscript(self, silent=False, name=None, text=None): """ Will create a new script file and open it in the Code Editor @@ -9931,8 +9955,7 @@ class App(QtCore.QObject): :return: None """ if silent is False: - self.inform.emit('[success] %s' % - _("New TCL script file created in Code Editor.")) + self.inform.emit('[success] %s' % _("New TCL script file created in Code Editor.")) # delete the absolute and relative position and messages in the infobar self.ui.position_label.setText("") @@ -10035,8 +10058,7 @@ class App(QtCore.QObject): self.shell._sysShell.exec_command(cmd_line_shellfile_content, no_echo=True) if silent is False: - self.inform.emit('[success] %s' % - _("TCL script file opened in Code Editor and executed.")) + self.inform.emit('[success] %s' % _("TCL script file opened in Code Editor and executed.")) except Exception as e: log.debug("App.on_filerunscript() -> %s" % str(e)) sys.exit(2) diff --git a/README.md b/README.md index be8a7039..f7550818 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing. - the Apply button text in Preferences is now made red when changes were made and require to be applied - the Gerber UI is built only once now so the process is lighter on CPU - the Gerber apertures marking shapes storage is now built only once because the more are built the more sluggish is the interface +- added a new function called by shortcut key combo CTRL+G when the current widget in Plot Area is an Code Editor. It will jump to the specified line in the text. 28.12.2019 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index a0ccffb1..e555bdb5 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -2723,7 +2723,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow): # Open Gerber file if key == QtCore.Qt.Key_G: - self.app.on_fileopengerber() + widget_name = self.plot_tab_area.currentWidget().objectName() + if 'editor' in widget_name.lower(): + self.app.goto_text_line() + else: + self.app.on_fileopengerber() # Distance Tool if key == QtCore.Qt.Key_M: