Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

) according to it.|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#!/usr/bin/env python
import sys
from PyQt4 import QtCore, QtGui, uic
class HighLighter (QtGui.QSyntaxHighlighter):
class HighlightingRule:
pattern = QtCore.QRegExp()
format = QtGui.QTextCharFormat()
highlightingRules = []
keywordFormat = QtGui.QTextCharFormat()
def __init__(self, parent=None):
QtGui.QSyntaxHighlighter.__init__(parent)
rule = self.HighlightingRule()
self.keywordFormat.foreground = QtCore.Qt.darkBlue
self.keywordFormat.fontWeight = QtGui.QFont.Bold
keywordPatterns = QtCore.QStringList()
keywordPatterns += "\\bmov\\b"
keywordPatterns += "\\badd\\b"
keywordPatterns += "\\bjmp\\b"
keywordPatterns += "\\bjnz\\b"
for i in keywordPatterns:
rule.pattern = QtCore.QRegExp(i)
rule.format = self.keywordFormat
self.highlightingRules += [rule]
print "num eh que eu cheguei aki mesmo"
def highlightBlock(self, text):
print "entrei"
for i in self.highlightingRules:
expression = QRegExp(i.pattern)
index = text.indexOf(expression)
while(index >= 0):
length = expression.matchedLength()
self.setFormat(index, length, i.format)
index = text.indexOf(expression, index+length)
class FasmIde(QtGui.QMainWindow):
def __init__(self, *args):
QtGui.QWidget.__init__(self, *args)
uic.loadUi("fasmIde.ui", self)
a = HighLighter(self.txtEdit.document())
self.txtEdit.document()
# @QtCore.pyqtSignature("")
app = QtGui.QApplication(sys.argv)
widget = FasmIde()
widget.show()
app.exec_()
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
<ui version="4.0" >
<class>frmFasmIde</class>
<widget class="QMainWindow" name="frmFasmIde" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>853</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTextEdit" name="txtEdit" />
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuHelp" >
<property name="title" >
<string>Help</string>
</property>
</widget>
<widget class="QMenu" name="menuEditar" >
<property name="title" >
<string>Editar</string>
</property>
</widget>
<widget class="QMenu" name="menuArquivo" >
<property name="title" >
<string>Arquivo</string>
</property>
<addaction name="actionAbrir" />
<addaction name="separator" />
<addaction name="actionSalvar" />
</widget>
<addaction name="menuArquivo" />
<addaction name="menuEditar" />
<addaction name="menuHelp" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<action name="actionAbrir" >
<property name="text" >
<string>Abrir</string>
</property>
</action>
<action name="actionSalvar" >
<property name="text" >
<string>Salvar</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
|