- fixing an issue with not building the UI for the generated objects when running a script and then trying to enable/disable the plots
- attempting to add a feature in the text editors to autoselect all words in a document that are the same as the one that was clicked - all the colors set in Preferences now have to be in the 8digits format RGBA (including the alpha channel as a suffix) - it is required to delete the current preferences files
This commit is contained in:
@@ -2019,6 +2019,7 @@ class FCPlainTextAreaExtended(QtWidgets.QPlainTextEdit):
|
||||
super().__init__(parent)
|
||||
|
||||
self.completer = MyCompleter()
|
||||
self.previous_selected_word = ''
|
||||
|
||||
self.model = QtCore.QStringListModel()
|
||||
self.completer.setModel(self.model)
|
||||
@@ -2295,6 +2296,50 @@ class FCPlainTextAreaExtended(QtWidgets.QPlainTextEdit):
|
||||
else:
|
||||
self.completer.popup().hide()
|
||||
|
||||
def mouseReleaseEvent(self, e: QtGui.QMouseEvent) -> None:
|
||||
super().mouseReleaseEvent(e)
|
||||
# self.select_word_instances(e.pos())
|
||||
|
||||
def select_word_instances(self, pos):
|
||||
cursor = self.textCursor()
|
||||
cursor.select(QtGui.QTextCursor.SelectionType.WordUnderCursor)
|
||||
sel_word = cursor.selectedText()
|
||||
|
||||
if sel_word != self.previous_selected_word or sel_word == '':
|
||||
cs = self.cursorForPosition(pos)
|
||||
position = cs.position()
|
||||
# first clear a possible previous highlight
|
||||
cursor.select(QtGui.QTextCursor.SelectionType.Document)
|
||||
cursor.setCharFormat(QtGui.QTextCharFormat())
|
||||
cursor.clearSelection()
|
||||
self.setTextCursor(cursor)
|
||||
cursor.setPosition(position, QtGui.QTextCursor.MoveMode.MoveAnchor)
|
||||
# cursor.movePosition(QtGui.QTextCursor.MoveOperation.StartOfWord, QtGui.QTextCursor.MoveMode.KeepAnchor, 1)
|
||||
self.setTextCursor(cursor)
|
||||
|
||||
self.previous_selected_word = sel_word
|
||||
if sel_word == '':
|
||||
return
|
||||
|
||||
# Setup the desired format for matches
|
||||
fmt = QtGui.QTextCharFormat()
|
||||
fmt.setBackground(Qt.GlobalColor.lightGray)
|
||||
text = self.toPlainText()
|
||||
|
||||
pattern = re.compile(r'%s' % sel_word)
|
||||
start = pattern.search(text, 0)
|
||||
idx = 0
|
||||
|
||||
while start and idx < len(text):
|
||||
idx = start.start()
|
||||
# Select the matched text and apply the desired format
|
||||
cursor.setPosition(idx, QtGui.QTextCursor.MoveMode.MoveAnchor)
|
||||
cursor.movePosition(QtGui.QTextCursor.MoveOperation.EndOfWord, QtGui.QTextCursor.MoveMode.KeepAnchor ,1)
|
||||
cursor.mergeCharFormat(fmt)
|
||||
start = pattern.search(text, idx+1)
|
||||
|
||||
cursor.select(QtGui.QTextCursor.SelectionType.WordUnderCursor)
|
||||
|
||||
def comment(self):
|
||||
"""
|
||||
Got it from here:
|
||||
|
||||
Reference in New Issue
Block a user