editors/qeditor/python_colorizer.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include "python_colorizer.h"
00025
#include "qeditor.h"
00026
#include "paragdata.h"
00027
00028
#include <qfont.h>
00029
#include <qapplication.h>
00030
#include <qsettings.h>
00031
#include <private/qrichtext_p.h>
00032
00033 static const char *
python_keywords[] = {
00034
00035
"and",
00036
"assert",
00037
"break",
00038
"class",
00039
"continue",
00040
"def",
00041
"del",
00042
"elif",
00043
"else",
00044
"except",
00045
"exec",
00046
"finally",
00047
"for",
00048
"from",
00049
"global",
00050
"if",
00051
"import",
00052
"in",
00053
"is",
00054
"lambda",
00055
"not",
00056
"or",
00057
"pass",
00058
"print",
00059
"raise",
00060
"return",
00061
"try",
00062
"while",
00063 0
00064 };
00065
00066 PythonColorizer::PythonColorizer(
QEditor* editor )
00067 :
QSourceColorizer( editor )
00068 {
00069
HLItemCollection* context0 =
new HLItemCollection( 0 );
00070 context0->
appendChild(
new StartsWithHLItem(
"#", Comment, 0 ) );
00071 context0->
appendChild(
new WhiteSpacesHLItem( Normal, 0 ) );
00072 context0->
appendChild(
new StringHLItem(
"'''", String, 3 ) );
00073 context0->
appendChild(
new StringHLItem(
"\"\"\"", String, 4 ) );
00074 context0->
appendChild(
new StringHLItem(
"\"", String, 1 ) );
00075 context0->
appendChild(
new StringHLItem(
"'", String, 2 ) );
00076 context0->
appendChild(
new KeywordsHLItem(
python_keywords, Keyword, Normal, 0 ) );
00077 context0->
appendChild(
new NumberHLItem( Constant, 0 ) );
00078
00079 HLItemCollection* context1 =
new HLItemCollection( String );
00080 context1->
appendChild(
new StringHLItem(
"\\\\", String, 1 ) );
00081 context1->
appendChild(
new StringHLItem(
"\\\"", String, 1 ) );
00082 context1->
appendChild(
new StringHLItem(
"\"", String, 0 ) );
00083
00084 HLItemCollection* context2 =
new HLItemCollection( String );
00085 context2->
appendChild(
new StringHLItem(
"\\'", String, 2 ) );
00086 context2->
appendChild(
new StringHLItem(
"\\\\", String, 2 ) );
00087 context2->
appendChild(
new StringHLItem(
"'", String, 0 ) );
00088
00089 HLItemCollection* context3 =
new HLItemCollection( String );
00090 context3->
appendChild(
new StringHLItem(
"'''", String, 0 ) );
00091
00092 HLItemCollection* context4 =
new HLItemCollection( String );
00093 context4->
appendChild(
new StringHLItem(
"\"\"\"", String, 0 ) );
00094
00095
00096 m_items.append( context0 );
00097 m_items.append( context1 );
00098 m_items.append( context2 );
00099 m_items.append( context3 );
00100 m_items.append( context4 );
00101 }
00102
00103 PythonColorizer::~PythonColorizer()
00104 {
00105 }
00106
This file is part of the documentation for KDevelop Version 3.0.4.