# -*- coding: utf-8 -*- # # File: portato/gui/qt/highlighter.py # This file is part of the Portato-Project, a graphical portage-frontend. # # Copyright (C) 2007 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. # # Written by René 'Necoro' Neumann # The syntax is inspired by the gtksourceview syntax by # Leonardo Ferreira Fontenelle from PyQt4 import Qt from portato.helper import debug import re # prefer Python-Module over Qt-one class EbuildHighlighter (Qt.QSyntaxHighlighter): """A QSyntaxHighlighter implementation for the use with ebuild-syntax.""" NORMAL_STATE = 0 STRING_STATE = 1 def __init__ (self, edit): """Constructor. @param edit: the EditWidget to use the highlighter with @type edit: Qt.QTextEdit""" Qt.QSyntaxHighlighter.__init__(self, edit) # # the regular expressions ... *muahahaha* # # comments self.comment = self.__create(r'#.*', color = "steelblue", italic = True) # bash variables self.bashVar = self.__create(r'(\$\{.+?\})|(\$\w+)', color = "green") # a string self.string = self.__create(r'(?