Esempio n. 1
0
void Highlighter::updatePalette(bool invalidate)
{
	static const QList<PythonPaletteEntryType> kTypes = QList<PythonPaletteEntryType>()
		<< PPET_Keyword << PPET_Operator << PPET_Reserved << PPET_Brace << PPET_Defclass << PPET_String << PPET_String2
		<< PPET_Comment << PPET_Self << PPET_Number;
	if (invalidate)
		*m_Palette = PythonPaletteManager::instance().palette();

	foreach(PythonPaletteEntryType t, kTypes)
	{
		m_Formats[t] = getTextCharFormat(t, *m_Palette);
	}
Esempio n. 2
0
PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument* parent) :
		QSyntaxHighlighter(parent) {

	keywords = QStringList() << "and" << "assert" << "break" << "class" << "continue" << "def" <<
	                         "del" << "elif" << "else" << "except" << "exec" << "finally" <<
	                         "for" << "from" << "global" << "if" << "import" << "in" <<
	                         "is" << "lambda" << "not" << "or" << "pass" << "print" <<
	                         "raise" << "return" << "try" << "while" << "yield" <<
	                         "None" << "True" << "False";

	operators = QStringList() << "=" <<
	                          // Comparison
	                          "==" << "!=" << "<" << "<=" << ">" << ">=" <<
	                          // Arithmetic
	                          "\\+" << "-" << "\\*" << "/" << "//" << "%" << "\\*\\*" <<
	                          // In-place
	                          "\\+=" << "-=" << "\\*=" << "/=" << "%=" <<
	                          // Bitwise
	                          "\\^" << "\\|" << "&" << "~" << ">>" << "<<";

	braces = QStringList() << "{" << "}" << "\\(" << "\\)" << "\\[" << "]";

	basicStyles.insert("keyword", getTextCharFormat("blue"));
	basicStyles.insert("operator", getTextCharFormat("red"));
	basicStyles.insert("brace", getTextCharFormat("darkGray"));
	basicStyles.insert("defclass", getTextCharFormat("black", "bold"));
	basicStyles.insert("brace", getTextCharFormat("darkGray"));
	basicStyles.insert("string", getTextCharFormat("magenta"));
	basicStyles.insert("string2", getTextCharFormat("darkMagenta"));
	basicStyles.insert("comment", getTextCharFormat("darkGreen", "italic"));
	basicStyles.insert("self", getTextCharFormat("black", "italic"));
	basicStyles.insert("numbers", getTextCharFormat("brown"));

	triSingleQuote.setPattern("'''");
	triDoubleQuote.setPattern("\"\"\"");

	initializeRules();
}
PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument *parent)
    : QSyntaxHighlighter(parent) {
  keywords = QStringList() << "and"
                           << "assert"
                           << "break"
                           << "class"
                           << "continue"
                           << "def"
                           << "del"
                           << "elif"
                           << "else"
                           << "except"
                           << "exec"
                           << "finally"
                           << "for"
                           << "from"
                           << "global"
                           << "if"
                           << "import"
                           << "in"
                           << "is"
                           << "lambda"
                           << "not"
                           << "or"
                           << "pass"
                           << "raise"
                           << "return"
                           << "try"
                           << "while"
                           << "yield"
                           << "None"
                           << "True"
                           << "False";

  operators = QStringList() << "="
                            << "=="
                            << "!="
                            << "<"
                            << "<="
                            << ">"
                            << ">="
                            << "\\+"
                            << "-"
                            << "\\*"
                            << "/"
                            << "//"
                            << "%"
                            << "\\*\\*"
                            << "\\+="
                            << "-="
                            << "\\*="
                            << "/="
                            << "%="
                            << "\\^"
                            << "\\|"
                            << "&"
                            << "~"
                            << ">>"
                            << "<<";

  braces = QStringList() << ":"
                         << ";"
                         << ","
                         << "@"
                         << "{"
                         << "}"
                         << "\\("
                         << "\\)"
                         << "\\["
                         << "\\]";

  builtins = QStringList() << "abs"
                           << "divmod"
                           << "input"
                           << "open"
                           << "staticmethod"
                           << "all"
                           << "enumerate"
                           << "int"
                           << "ord"
                           << "str"
                           << "any"
                           << "eval"
                           << "isinstance"
                           << "pow"
                           << "sum"
                           << "basestring"
                           << "execfile"
                           << "issubclass"
                           << "print"
                           << "super"
                           << "bin"
                           << "file"
                           << "iter"
                           << "property"
                           << "tuple"
                           << "bool"
                           << "filter"
                           << "len"
                           << "range"
                           << "type"
                           << "bytearray"
                           << "float"
                           << "list"
                           << "raw_input"
                           << "unichr"
                           << "callable"
                           << "format"
                           << "locals"
                           << "reduce"
                           << "unicode"
                           << "chr"
                           << "frozenset"
                           << "long"
                           << "reload"
                           << "vars"
                           << "classmethod"
                           << "getattr"
                           << "map"
                           << "repr"
                           << "xrange"
                           << "cmp"
                           << "globals"
                           << "max"
                           << "reversed"
                           << "zip"
                           << "compile"
                           << "hasattr"
                           << "memoryview"
                           << "round"
                           << "__import__"
                           << "complex"
                           << "hash"
                           << "min"
                           << "set"
                           << "apply"
                           << "delattr"
                           << "help"
                           << "next"
                           << "setattr"
                           << "buffer"
                           << "dict"
                           << "hex"
                           << "object"
                           << "slice"
                           << "coerce"
                           << "dir"
                           << "id"
                           << "oct"
                           << "sorted"
                           << "intern";

  exceptions = QStringList() << "BaseException"
                             << "SystemExit"
                             << "KeyboardInterrupt"
                             << "GeneratorExit"
                             << "Exception"
                             << "StopIteration"
                             << "ArithmeticError"
                             << "FloatingPointError"
                             << "OverflowError"
                             << "ZeroDivisionError"
                             << "AssertionError"
                             << "AttributeError"
                             << "BufferError"
                             << "EOFError"
                             << "ImportError"
                             << "LookupError"
                             << "IndexError"
                             << "KeyError"
                             << "MemoryError"
                             << "NameError"
                             << "UnboundLocalError"
                             << "OSError"
                             << "BlockingIOError"
                             << "ChildProcessError"
                             << "ConnectionError"
                             << "BrokenPipeError"
                             << "ConnectionAbortedError"
                             << "ConnectionRefusedError"
                             << "ConnectionResetError"
                             << "FileExistsError"
                             << "FileNotFoundError"
                             << "InterruptedError"
                             << "IsADirectoryError"
                             << "NotADirectoryError"
                             << "PermissionError"
                             << "ProcessLookupError"
                             << "TimeoutError"
                             << "ReferenceError"
                             << "RuntimeError"
                             << "NotImplementedError"
                             << "SyntaxError"
                             << "IndentationError"
                             << "TabError"
                             << "SystemError"
                             << "TypeError"
                             << "ValueError"
                             << "UnicodeError"
                             << "UnicodeDecodeError"
                             << "UnicodeEncodeError"
                             << "UnicodeTranslateError"
                             << "Warning"
                             << "DeprecationWarning"
                             << "PendingDeprecationWarning"
                             << "RuntimeWarning"
                             << "SyntaxWarning"
                             << "UserWarning"
                             << "FutureWarning"
                             << "ImportWarning"
                             << "UnicodeWarning"
                             << "BytesWarning"
                             << "ResourceWarning";

  setStyles();
  mSearchRegex = tr("");
  mSearchHighlight = getTextCharFormat("black", "bold", "yellow");
  triSingleQuote.setPattern("'''");
  triDoubleQuote.setPattern("\"\"\"");

  initializeRules();
}
void PythonSyntaxHighlighter::setStyles() {
  basicStyles.insert("keyword", getTextCharFormat("orange", "bold"));
  basicStyles.insert("operator", getTextCharFormat("yellow", "bold"));
  basicStyles.insert("builtins", getTextCharFormat("lightblue", "underline"));
  basicStyles.insert("brace", getTextCharFormat("red", "bold"));
  basicStyles.insert("string", getTextCharFormat("magenta"));
  basicStyles.insert("stringlong", getTextCharFormat("magenta", "bold"));
  basicStyles.insert("comment", getTextCharFormat("darkgreen", "bold"));
  basicStyles.insert("special", getTextCharFormat("teal", "bold"));
  basicStyles.insert("numbers", getTextCharFormat("cyan"));
  basicStyles.insert("bugs", getTextCharFormat("yellow", "bold", "red"));
  basicStyles.insert("hackish", getTextCharFormat("royalblue", "bold"));
  basicStyles.insert("except", getTextCharFormat("royalblue", "underline"));
  basicStyles.insert("private", getTextCharFormat("white", "italic"));
  basicStyles.insert("bytes", getTextCharFormat("lightsteelblue"));
}
Esempio n. 5
0
BashHighlighter::BashHighlighter(QTextDocument* parent) :
		QSyntaxHighlighter(parent) {

	__keywords = QStringList() << "else" << "for" << "do" << "function" << "in"
	    << "select" << "until" << "while" << "elif" << "if" << "then" << "fi"
	    << "done" << "set";

	__builtins = QStringList() << ":" << "source" << "alias" << "bg"
	    << "bind" << "break" << "builtin" << "cd" << "caller" << "command"
	    << "compgen" << "complete" << "continue" << "dirs" << "disown"
	    << "echo" << "enable" << "eval" << "exec" << "exit" << "fc" << "fg"
	    << "getopts" << "hash" << "help" << "history" << "jobs" << "kill"
	    << "let" << "logout" << "popd" << "printf" << "pushd" << "pwd"
	    << "return" << "set" << "shift" << "shopt" << "suspend" << "test"
	    << "time" << "times" << "trap" << "type" << "ulimit" << "umask"
	    << "unalias" << "wait";

	__builtinsVar = QStringList() << "export" << "unset" << "declare"
	    << "typeset" << "local" << "read" << "readonly";

	__unixCommands = QStringList() << "arch" << "awk" << "bash" << "bunzip2"
	    << "bzcat" << "bscmp" << "bzdiff" << "bzegrep" << "bzfgrep" << "bzgrep"
	    << "bzip2" << "bzip2recover" << "bzless" << "bzmore" << "cat"
	    << "chattr" << "chgrp" << "chmod" << "chown" << "chvt" << "cp" << "date"
	    << "dd" << "deallocvt" << "df" << "dir" << "dircolors" << "dmesg"
	    << "dnsdomainname" << "domainname" << "du" << "dumpkeys" << "echo"
	    << "ed" << "egrep" << "false" << "fgconsole" << "fgrep" << "fuser"
	    << "gawk" << "getkeycodes" << "gocr" << "grep" << "groff" << "groups"
	    << "gunzip" << "gzexe" << "gzip" << "hostname" << "igawk" << "install"
	    << "kbd_mode" << "kbdrate" << "killall" << "last" << "lastb" << "link"
	    << "ln" << "loadkeys" << "loadunimap" << "login" << "ls" << "lsattr"
	    << "lsmod" << "lsmod.old" << "lzcat" << "lzcmp" << "lzdiff"
	    << "lzegrep" << "lzfgrep" << "lzgrep" << "lzless" << "lzcat" << "lzma"
	    << "lzmainfo" << "lzmore" << "mapscrn" << "mesg" << "mkdir" << "mkfifo"
	    << "mknod" << "mktemp" << "more" << "mount" << "mv" << "nano"
	    << "netstat" << "nisdomainname" << "nroff" << "openvt" << "pgawk"
	    << "pidof" << "ping" << "ps" << "pstree" << "pwd" << "rbash"
	    << "readlink" << "red" << "resizecons" << "rm" << "rmdir"
	    << "run-parts" << "sash" << "sed" << "setfont" << "setkeycodes"
	    << "setleds" << "setmetamode" << "setserial" << "sh" << "showkey"
	    << "shred" << "sleep" << "ssed" << "stat" << "stty" << "su"
	    << "sync" << "tar" << "tempfile" << "touch" << "troff" << "true"
	    << "umount" << "uname" << "unicode_start" << "unicode_stop"
	    << "unlink" << "unlzma" << "unxz" << "utmpdump" << "uuidgen"
	    << "vdir" << "wall" << "wc" << "xz" << "xzcat" << "ypdomainname"
	    << "zcat" << "zcmp" << "zdiff" << "zegrep" << "zfgrep" << "zforce"
	    << "zgrep" << "zless" << "zmore" << "znew" << "zsh";

	__operators = QStringList() << "=" <<
	    // Comparison
	    "==" << "!=" << "<" << "<=" << ">" << ">=" <<
	    // Arithmetic
	    "\\+" << "-" << "\\*" << "/" << "//" << "%" << "\\*\\*" <<
	    // In-place
	    "\\+=" << "-=" << "\\*=" << "/=" << "%=" <<
	    // Bitwise
	    "\\^" << "\\|" << "&" << "~" << ">>" << "<<";

	__braces = QStringList() << "{" << "}" << "\\(" << "\\)" << "\\[" << "]";

	__basicStyles.insert("keyword", getTextCharFormat(Qt::darkRed, "bold"));
	__basicStyles.insert("operator", getTextCharFormat(Qt::red));
	__basicStyles.insert("builtins", getTextCharFormat(Qt::darkBlue, "bold"));
	__basicStyles.insert("builtinsVar", getTextCharFormat(Qt::blue, "bold"));
	__basicStyles.insert("unixCommands", getTextCharFormat(Qt::darkRed, "bold"));
	__basicStyles.insert("brace", getTextCharFormat(Qt::darkRed, "bold"));
	__basicStyles.insert("string", getTextCharFormat(Qt::magenta));
	__basicStyles.insert("string2", getTextCharFormat(Qt::darkMagenta));
	__basicStyles.insert("comment", getTextCharFormat(Qt::blue));
	__basicStyles.insert("numbers", getTextCharFormat(Qt::blue));
	__basicStyles.insert("variable", getTextCharFormat(Qt::black, "bold"));

	triSingleQuote.setPattern("'''");
	triDoubleQuote.setPattern("\"\"\"");

	initializeRules();
}