Esempio n. 1
0
 def __init__(self):
     Mode.__init__(self)
     QtCore.QObject.__init__(self)
     self.__jobRunner = DelayJobRunner(self, nbThreadsMax=1, delay=700)
     self.tooltipDisplayRequested.connect(self.__displayTooltip)
     self.tooltipHideRequested.connect(QtGui.QToolTip.hideText)
     self.__requestCnt = 0
Esempio n. 2
0
 def __init__(self):
     Mode.__init__(self)
     QObject.__init__(self)
     self._pending = False
     self.aGotToDef = QAction("Go to assignments", self)
     self.aGotToDef.setShortcut("F2")
     self.aGotToDef.triggered.connect(self.requestGoTo)
Esempio n. 3
0
 def __init__(self):
     Mode.__init__(self)
     QtCore.QObject.__init__(self)
     self._pending = False
     self.actionGotoAssignments = QtGui.QAction("Go to assignments", self)
     self.actionGotoAssignments.setShortcut("F2")
     self.actionGotoAssignments.triggered.connect(self.requestGoTo)
Esempio n. 4
0
 def _onInstall(self, editor):
     Mode._onInstall(self, editor)
     for k, v in DEFAULT_LIGHT_STYLES.items():
         self.editor.style.addProperty(k, v, "Python")
     self.__foreground = self.editor.style.value(
         "whiteSpaceForeground")
     self.__bck = self.editor.style.value("background").name()
Esempio n. 5
0
    def __init__(self, document=None):
        SyntaxHighlighter.__init__(self, document,
                                   foldDetector=IndentBasedFoldDetector())
        self.__doc = document
        Mode.__init__(self)
        self.tri_single = (QtCore.QRegExp("'''"), 1, 'docstring')
        self.tri_double = (QtCore.QRegExp('"""'), 2, 'docstring')

        self.cnt = 0

        rules = []

        self.spacesPattern = QtCore.QRegExp(r'\s+')
        self.wordsPattern = QtCore.QRegExp(r'\s+')
        self.docstringPattern = QtCore.QRegExp(r"(:|@)\w+")

        # All other rules
        rules += [
            # 'def' followed by an identifier
            (r'\bdef\b\s*(\w+)', 'function'),
            # 'class' followed by an identifier
            (r'\bclass\b\s*(\w+)', 'class'),
            # words (keywords, builtin, ...
            (r'\b\w+\b', 'word'),
            # predefined items (__xxx__)
            (r'\b__.*__\b', 'predefined'),

            (r'@.*', 'decorator'),

            # Numeric literals
            (r'\b[+-]?[0-9]+[lL]?\b', 'numbers'),
            (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 'numbers'),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 'numbers'),
        ]
        # Double-quoted string, possibly containing escape sequences
        rules += [(r'%s' % o, 'operator')
                  for o in PyHighlighterMode.operators]

        rules += [(r'#[^\n]*', 'comment')]

        # Single-quoted string, possibly containing escape sequences
        rules += [(r'"[^"\\]*(\\.[^"\\]*)*"', 'string')]
        rules += [(r"'[^'\\]*(\\.[^'\\]*)*'", 'string')]

        # Build a QtCore.QRegExp for each pattern
        self.rules = [(QtCore.QRegExp(pat), fmt) for (pat, fmt) in rules]
Esempio n. 6
0
 def _onInstall(self, editor):
     Mode._onInstall(self, editor)
Esempio n. 7
0
 def __init__(self):
     QObject.__init__(self)
     Mode.__init__(self)
     self.__root_node = None
     self.__vars = []
     self.__paragraphs = []
Esempio n. 8
0
 def _onInstall(self, editor):
     Mode._onInstall(self, editor)
     if get_server():
         get_server().signals.workCompleted.connect(self._onWorkFinished)