From ad74f5cfcda1e740e007f750f242bea33047920d Mon Sep 17 00:00:00 2001 From: necoro <> Date: Mon, 16 Apr 2007 22:34:28 +0000 Subject: added ebuild window for Qt-Frontend --- portato/gui/qt/highlighter.py | 110 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 portato/gui/qt/highlighter.py (limited to 'portato/gui/qt/highlighter.py') diff --git a/portato/gui/qt/highlighter.py b/portato/gui/qt/highlighter.py new file mode 100644 index 0000000..5572930 --- /dev/null +++ b/portato/gui/qt/highlighter.py @@ -0,0 +1,110 @@ +# -*- 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): + + NORMAL_STATE = 0 + STRING_STATE = 1 + + def __init__ (self, edit): + Qt.QSyntaxHighlighter.__init__(self, edit) + + self.comment = self.__create(r'#.*', color = "steelblue", italic = True) + self.bashVar = self.__create(r'(\$\{.+?\})|(\$\w+)', color = "green") + + self.syntax = {} + self.syntax["bashSyn"] = self.__create(r'\b(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\b', color = "navy", underline = True) + + self.syntax["bashCmd"] = self.__create(r'\b(make|awk|cat|cd|chmod|chown|cp|echo|env|export|grep|head|let|ln|mkdir|mv|rm|sed|set|tail|tar|touch|unset)\b', color = "navy", bold = True) + + self.syntax["portVar"] = self.__create(r'\b((ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)|(S|D|T|PV|PF|P|PN|A)|C(XX)?FLAGS|LDFLAGS|C(HOST|TARGET|BUILD))\b', color = "saddlebrown", bold = True) + + self.syntax["portCmd"] = self.__create(r'\b(e(begin|end|conf|install|make|warn|infon?|error|patch)|die|built_with_use|use(_(with|enable))?|inherit|hasq?|(has|best)_version|unpack|(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)|do(python|sed|dir|hard|sym|html|jar|mo)|keepdir|prepall(|docs|info|man|strip)|prep(info|lib|lib\.(so|a)|man|strip)|(|doc|ins|exe)into|f(owners|perms)|(exe|ins|dir)opts)\b', color = "saddlebrown", bold = True) + + self.syntax["portFunc"] = self.__create(r'^(src_(unpack|compile|install|test)|pkg_(config|nofetch|setup|(pre|post)(inst|rm)))', color = "green") + + self.string = self.__create(r'(?