Hello, I'm trying to "paint" everything between /* and */, with this code:
self.
plainTextEdit.
moveCursor(self.
plainTextEdit.
find("/*"),QtGui.
QTextCursor.
MoveAnchor) self.
plainTextEdit.
moveCursor(self.
plainTextEdit.
find("*/") ,QtGui.
QTextCursor.
KeepAnchor)
cursor = self.plainTextEdit.textCursor()
currentWord
= QtWidgets.
QTextEdit.
ExtraSelection() yellowColor
= QtGui.
QColor("yellow") currentWord.format.setForeground(yellowColor)
currentWord.cursor = cursor
extraSelections.append(currentWord)
self.plainTextEdit.moveCursor(self.plainTextEdit.find("/*"),QtGui.QTextCursor.MoveAnchor)
self.plainTextEdit.moveCursor(self.plainTextEdit.find("*/") ,QtGui.QTextCursor.KeepAnchor)
cursor = self.plainTextEdit.textCursor()
currentWord = QtWidgets.QTextEdit.ExtraSelection()
yellowColor = QtGui.QColor("yellow")
currentWord.format.setForeground(yellowColor)
currentWord.cursor = cursor
extraSelections.append(currentWord)
To copy to clipboard, switch view to plain text mode
But I get this: http://i.imgur.com/ObSvmj5.png
it seems for some reason, MoveAnchor is not moving to /* location, but from start, can someone explain how can this be fixed?
Bookmarks