- added Find function in Tcl Shell (will search for either the selected text in the command line or for the one stored on the clipboard)

This commit is contained in:
Marius Stanciu
2020-11-25 18:32:18 +02:00
committed by Marius
parent 51e3dc3308
commit 9b08c51bba
3 changed files with 28 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ CHANGELOG for FlatCAM beta
- some changes in the Tools visibility in the Tools ToolBar
- added confirmation status messages for clearing the recent files/projects lists
- moved around portions of code in the App.__init__ for optimization; added a control in Preferences for usage of Log in Tcl Shell
- added a text placeholder in the Tcl Shell
- added Find function in Tcl Shell (will search for either the selected text in the command line or for the one stored on the clipboard)
24.11.2020

View File

@@ -3865,6 +3865,7 @@ class _BrowserTextEdit(QTextEdit):
self.menu = None
self.version = version
self.app = app
self.find_text = lambda: None
def contextMenuEvent(self, event):
# self.menu = self.createStandardContextMenu(event.pos())
@@ -3884,6 +3885,12 @@ class _BrowserTextEdit(QTextEdit):
self.menu.addAction(sel_all_action)
sel_all_action.triggered.connect(self.selectAll)
find_action = QAction('%s\t%s' % (_("Find"), _('Ctrl+F')), self)
self.menu.addAction(find_action)
find_action.triggered.connect(self.find_text)
self.menu.addSeparator()
if self.app:
save_action = QAction('%s\t%s' % (_("Save Log"), _('Ctrl+S')), self)
# save_action.setShortcut(QKeySequence(Qt.Key_S))
@@ -3913,6 +3920,9 @@ class _BrowserTextEdit(QTextEdit):
# Copy Text
elif key == QtCore.Qt.Key_C:
self.copy_text()
# Copy Text
elif key == QtCore.Qt.Key_F:
self.find_text()
# Save Log
elif key == QtCore.Qt.Key_S:
if self.app:

View File

@@ -7,7 +7,7 @@
# ##########################################################
from PyQt5 import QtCore, QtGui
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QTextCursor, QPixmap
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QHBoxLayout, QLabel
from appGUI.GUIElements import _BrowserTextEdit, _ExpandableTextEdit, FCLabel
@@ -48,6 +48,7 @@ class TermWidget(QWidget):
"span {white-space:pre;}")
self._edit = _ExpandableTextEdit(self, self)
self._edit.setPlaceholderText(_("Type a command to be executed ..."))
self._edit.historyNext.connect(self._on_history_next)
self._edit.historyPrev.connect(self._on_history_prev)
self._edit.setFocus()
@@ -320,6 +321,20 @@ class FCShell(TermWidget):
self.app.inform_shell[str].connect(self.app.info_shell)
self.app.inform_shell[str, bool].connect(self.app.info_shell)
self._browser.find_text = self.find_text
def find_text(self):
edit_cursor = self._edit.textCursor()
txt = edit_cursor.selectedText()
clipboard = QtWidgets.QApplication.clipboard()
searched_txt = txt if txt != '' else clipboard.text()
r = self._browser.find(str(searched_txt))
if r is False:
self._browser.moveCursor(QtGui.QTextCursor.Start)
self._browser.find(str(searched_txt))
def init_tcl(self):
if hasattr(self, 'tcl') and self.tcl is not None:
# self.tcl = None