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 "jsp_colorizer.h"
00025
#include "paragdata.h"
00026
00027
#include <qfont.h>
00028
#include <qapplication.h>
00029
#include <qsettings.h>
00030
#include <private/qrichtext_p.h>
00031
00032 static const char *
jsp_keywords[] = {
00033
00034
"abstract",
00035
"break",
00036
"case",
00037
"catch",
00038
"class",
00039
"continue",
00040
"default",
00041
"do",
00042
"else",
00043
"extends",
00044
"false",
00045
"finally",
00046
"for",
00047
"goto",
00048
"if",
00049
"implements",
00050
"import",
00051
"instanceof",
00052
"interface",
00053
"native",
00054
"new",
00055
"null",
00056
"package",
00057
"private",
00058
"protected",
00059
"public",
00060
"return",
00061
"super",
00062
"strictfp",
00063
"switch",
00064
"synchronized",
00065
"this",
00066
"throws",
00067
"throw",
00068
"transient",
00069
"true",
00070
"try",
00071
"volatile",
00072
"while",
00073
"boolean",
00074
"byte",
00075
"char",
00076
"const",
00077
"double",
00078
"final",
00079
"float",
00080
"int",
00081
"long",
00082
"short",
00083
"static",
00084
"void",
00085 0
00086 };
00087
00088 JspColorizer::JspColorizer(
QEditor* editor )
00089 :
QSourceColorizer( editor )
00090 {
00091
00092
00093
00094
HLItemCollection* context0 =
new HLItemCollection( 0 );
00095 context0->
appendChild(
new StringHLItem(
"<!--", Comment, 1 ) );
00096 context0->
appendChild(
new StringHLItem(
"<%", Comment, 4 ) );
00097 context0->
appendChild(
new StringHLItem(
"<", Normal, 2 ) );
00098 context0->
appendChild(
new RegExpHLItem(
"&[\\w|_|!]+;", Constant, 0 ) );
00099
00100
00101 HLItemCollection* context1 =
new HLItemCollection( Comment );
00102 context1->
appendChild(
new StringHLItem(
"-->", Comment, 0 ) );
00103
00104 HLItemCollection* context2 =
new HLItemCollection( Normal );
00105 context2->
appendChild(
new StringHLItem(
"\"", String, 3 ) );
00106 context2->
appendChild(
new RegExpHLItem(
"[\\w|_]+", Keyword, 2 ) );
00107 context2->
appendChild(
new StringHLItem(
">", Normal, 0 ) );
00108
00109 HLItemCollection* context3 =
new HLItemCollection( String );
00110 context3->
appendChild(
new StringHLItem(
"\\\"", String, 3 ) );
00111 context3->
appendChild(
new StringHLItem(
"\"", String, 2 ) );
00112
00113
00114
00115
00116 HLItemCollection* context4 =
new HLItemCollection( Normal );
00117 context4->
appendChild(
new StringHLItem(
"%>", Comment, 0 ) );
00118 context4->
appendChild(
new StartsWithHLItem(
"//", Comment, 4 ) );
00119 context4->
appendChild(
new StringHLItem(
"/*", Comment, 5 ) );
00120 context4->
appendChild(
new StringHLItem(
"\"", String, 6 ) );
00121 context4->
appendChild(
new StringHLItem(
"'", String, 7 ) );
00122 context4->
appendChild(
new KeywordsHLItem(
jsp_keywords, Keyword, Normal, 4 ) );
00123 context4->
appendChild(
new NumberHLItem( Constant, 4 ) );
00124
00125
00126 HLItemCollection* context5 =
new HLItemCollection( Comment );
00127 context5->
appendChild(
new StringHLItem(
"*/", Comment, 4 ) );
00128
00129 HLItemCollection* context6 =
new HLItemCollection( String );
00130 context6->
appendChild(
new StringHLItem(
"\\\\", String, 6 ) );
00131 context6->
appendChild(
new StringHLItem(
"\\\"", String, 6 ) );
00132 context6->
appendChild(
new StringHLItem(
"\"", String, 4 ) );
00133
00134 HLItemCollection* context7 =
new HLItemCollection( String );
00135 context7->
appendChild(
new StringHLItem(
"\\\\", String, 7 ) );
00136 context7->
appendChild(
new StringHLItem(
"\\'", String, 7 ) );
00137 context7->
appendChild(
new StringHLItem(
"'", String, 4 ) );
00138
00139 m_items.append( context0 );
00140 m_items.append( context1 );
00141 m_items.append( context2 );
00142 m_items.append( context3 );
00143 m_items.append( context4 );
00144 m_items.append( context5 );
00145 m_items.append( context6 );
00146 m_items.append( context7 );
00147 }
00148
00149 JspColorizer::~JspColorizer()
00150 {
00151 }
00152