1
/*EditArea.prototype.comment_or_quotes= function(v0, v1, v2, v3, v4,v5,v6,v7,v8,v9, v10){
3
if(v6 && v6 != undefined && v6!="")
5
return "µ__"+ new_class +"__µ"+v0+"µ_END_µ";
9
/* EditArea.prototype.htmlTag= function(v0, v1, v2, v3, v4,v5,v6,v7,v8,v9, v10){
10
res="<span class=htmlTag>"+v2;
11
alert("v2: "+v2+" v3: "+v3);
15
attributes="<span class=attribute>"+tab[0]+"</span>=";
16
for(i=1; i<tab.length-1; i++){
17
cut=tab[i].lastIndexOf(" ");
18
attributes+="<span class=attributeVal>"+tab[i].substr(0,cut)+"</span>";
19
attributes+="<span class=attribute>"+tab[i].substr(cut)+"</span>=";
21
attributes+="<span class=attributeVal>"+tab[tab.length-1]+"</span>";
23
res+=attributes+v5+"</span>";
27
// determine if the selected text if a comment or a quoted text
28
EditArea.prototype.comment_or_quote= function(){
31
for(var i in parent.editAreaLoader.syntax[editArea.current_code_lang]["quotes"]){
32
if(EditArea.prototype.comment_or_quote.arguments[0].indexOf(i)==0){
33
new_class="quotesmarks";
34
close_tag=parent.editAreaLoader.syntax[editArea.current_code_lang]["quotes"][i];
37
if(new_class.length==0)
39
for(var i in parent.editAreaLoader.syntax[editArea.current_code_lang]["comments"]){
40
if(EditArea.prototype.comment_or_quote.arguments[0].indexOf(i)==0){
42
close_tag=parent.editAreaLoader.syntax[editArea.current_code_lang]["comments"][i];
46
// for single line comment the \n must not be included in the span tags
48
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0].replace(/(\r?\n)?$/m, "µ_END_µ$1");
50
// the closing tag must be set only if the comment or quotes is closed
51
reg= new RegExp(parent.editAreaLoader.get_escaped_regexp(close_tag)+"$", "m");
52
if(EditArea.prototype.comment_or_quote.arguments[0].search(reg)!=-1)
53
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0]+"µ_END_µ";
55
return "µ__"+ new_class +"__µ"+EditArea.prototype.comment_or_quote.arguments[0];
60
// apply special tags arround text to highlight
61
EditArea.prototype.custom_highlight= function(){
62
res= EditArea.prototype.custom_highlight.arguments[1]+"µ__"+ editArea.reg_exp_span_tag +"__µ" + EditArea.prototype.custom_highlight.arguments[2]+"µ_END_µ";
63
if(EditArea.prototype.custom_highlight.arguments.length>5)
64
res+= EditArea.prototype.custom_highlight.arguments[ EditArea.prototype.custom_highlight.arguments.length-3 ];
69
// return identication that allow to know if revalidating only the text line won't make the syntax go mad
70
EditArea.prototype.get_syntax_trace= function(text){
71
if(this.settings["syntax"].length>0 && parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"])
72
return text.replace(parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"], "$3");
76
EditArea.prototype.colorize_text= function(text){
77
//text="<div id='result' class='area' style='position: relative; z-index: 4; height: 500px; overflow: scroll;border: solid black 1px;'> ";
79
if(this.nav['isOpera']){
80
// opera can't use pre element tabulation cause a tab=6 chars in the textarea and 8 chars in the pre
81
text= this.replace_tab(text);
84
text= " "+text; // for easier regExp
86
/*if(this.do_html_tags)
87
text= text.replace(/(<[a-z]+ [^>]*>)/gi, '[__htmlTag__]$1[_END_]');*/
88
if(this.settings["syntax"].length>0)
89
text= this.apply_syntax(text, this.settings["syntax"]);
90
/*for(var lang in this.settin){
91
text=this.apply_syntax(text, lang);
94
text= text.substr(1); // remove the first space added
95
text= text.replace(/&/g,"&");
96
text= text.replace(/</g,"<");
97
text= text.replace(/>/g,">"); // no need if there is no <
98
//text= text.replace(/ /g," ");
99
text= text.replace(/µ_END_µ/g,"</span>");
100
text= text.replace(/µ__([a-zA-Z0-9]+)__µ/g,"<span class='$1'>");
103
//text= text.replace(//gi, "<span class='quote'>$1</span>");
104
//alert("text: \n"+text);
109
EditArea.prototype.apply_syntax= function(text, lang){
110
this.current_code_lang=lang;
112
if(!parent.editAreaLoader.syntax[lang])
115
/*alert(typeof(text)+"\n"+text.length);
118
for(var script_start in this.code[lang]["script_delimiters"]){
119
var pos_start= text.indexOf(script_start);
120
var pos_end= text.length; // MUST BE SET TO CORRECT VAL!!!
122
var start_text=text.substr(0, pos_start);
123
var middle_text= text.substring(pos_start, pos_end);
124
var end_text= text.substring(pos_end);
125
if(this.code[lang]["comment_or_quote_reg_exp"]){
126
//setTimeout("document.getElementById('debug_area').value=editArea.comment_or_quote_reg_exp;", 500);
127
middle_text= middle_text.replace(this.code[lang]["comment_or_quote_reg_exp"], this.comment_or_quote);
130
if(this.code[lang]["keywords_reg_exp"]){
131
for(var i in this.code[lang]["keywords_reg_exp"]){
132
this.reg_exp_span_tag=i;
133
middle_text= middle_text.replace(this.code[lang]["keywords_reg_exp"][i], this.custom_highlight);
137
if(this.code[lang]["delimiters_reg_exp"]){
138
middle_text= middle_text.replace(this.code[lang]["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');
141
if(this.code[lang]["operators_reg_exp"]){
142
middle_text= middle_text.replace(this.code[lang]["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');
145
text= start_text+ middle_text + end_text;
147
if(parent.editAreaLoader.syntax[lang]["custom_regexp"]['before']){
148
for( var i in parent.editAreaLoader.syntax[lang]["custom_regexp"]['before']){
149
var convert="$1µ__"+ parent.editAreaLoader.syntax[lang]["custom_regexp"]['before'][i]['class'] +"__µ$2µ_END_µ$3";
150
text= text.replace(parent.editAreaLoader.syntax[lang]["custom_regexp"]['before'][i]['regexp'], convert);
154
if(parent.editAreaLoader.syntax[lang]["comment_or_quote_reg_exp"]){
155
//setTimeout("document.getElementById('debug_area').value=editArea.comment_or_quote_reg_exp;", 500);
156
text= text.replace(parent.editAreaLoader.syntax[lang]["comment_or_quote_reg_exp"], this.comment_or_quote);
159
if(parent.editAreaLoader.syntax[lang]["keywords_reg_exp"]){
160
for(var i in parent.editAreaLoader.syntax[lang]["keywords_reg_exp"]){
161
/*this.reg_exp_span_tag=i;
162
text= text.replace(parent.editAreaLoader.syntax[lang]["keywords_reg_exp"][i], this.custom_highlight);
164
text= text.replace(parent.editAreaLoader.syntax[lang]["keywords_reg_exp"][i], 'µ__'+i+'__µ$2µ_END_µ');
168
if(parent.editAreaLoader.syntax[lang]["delimiters_reg_exp"]){
169
text= text.replace(parent.editAreaLoader.syntax[lang]["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');
172
if(parent.editAreaLoader.syntax[lang]["operators_reg_exp"]){
173
text= text.replace(parent.editAreaLoader.syntax[lang]["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');
176
if(parent.editAreaLoader.syntax[lang]["custom_regexp"]['after']){
177
for( var i in parent.editAreaLoader.syntax[lang]["custom_regexp"]['after']){
178
var convert="$1µ__"+ parent.editAreaLoader.syntax[lang]["custom_regexp"]['after'][i]['class'] +"__µ$2µ_END_µ$3";
179
text= text.replace(parent.editAreaLoader.syntax[lang]["custom_regexp"]['after'][i]['regexp'], convert);