1 /*EditArea.prototype.comment_or_quotes= function(v0, v1, v2, v3, v4,v5,v6,v7,v8,v9, v10){
\r
3 if(v6 && v6 != undefined && v6!="")
\r
4 new_class="comments";
\r
5 return "µ__"+ new_class +"__µ"+v0+"µ_END_µ";
\r
9 /* EditArea.prototype.htmlTag= function(v0, v1, v2, v3, v4,v5,v6,v7,v8,v9, v10){
\r
10 res="<span class=htmlTag>"+v2;
\r
11 alert("v2: "+v2+" v3: "+v3);
\r
15 attributes="<span class=attribute>"+tab[0]+"</span>=";
\r
16 for(i=1; i<tab.length-1; i++){
\r
17 cut=tab[i].lastIndexOf(" ");
\r
18 attributes+="<span class=attributeVal>"+tab[i].substr(0,cut)+"</span>";
\r
19 attributes+="<span class=attribute>"+tab[i].substr(cut)+"</span>=";
\r
21 attributes+="<span class=attributeVal>"+tab[tab.length-1]+"</span>";
\r
23 res+=attributes+v5+"</span>";
\r
27 // determine if the selected text if a comment or a quoted text
\r
28 EditArea.prototype.comment_or_quote= function(){
\r
29 var new_class="", close_tag="", sy, arg, i;
\r
30 sy = parent.editAreaLoader.syntax[editArea.current_code_lang];
\r
31 arg = EditArea.prototype.comment_or_quote.arguments[0];
\r
33 for( i in sy["quotes"] ){
\r
34 if(arg.indexOf(i)==0){
\r
35 new_class="quotesmarks";
\r
36 close_tag=sy["quotes"][i];
\r
39 if(new_class.length==0)
\r
41 for(var i in sy["comments"]){
\r
42 if( arg.indexOf(i)==0 ){
\r
43 new_class="comments";
\r
44 close_tag=sy["comments"][i];
\r
48 // for single line comment the \n must not be included in the span tags
\r
49 if(close_tag=="\n"){
\r
50 return "µ__"+ new_class +"__µ"+ arg.replace(/(\r?\n)?$/m, "µ_END_µ$1");
\r
52 // the closing tag must be set only if the comment or quotes is closed
\r
53 reg= new RegExp(parent.editAreaLoader.get_escaped_regexp(close_tag)+"$", "m");
\r
54 if( arg.search(reg)!=-1 )
\r
55 return "µ__"+ new_class +"__µ"+ arg +"µ_END_µ";
\r
57 return "µ__"+ new_class +"__µ"+ arg;
\r
62 // apply special tags arround text to highlight
\r
63 EditArea.prototype.custom_highlight= function(){
\r
64 res= EditArea.prototype.custom_highlight.arguments[1]+"µ__"+ editArea.reg_exp_span_tag +"__µ" + EditArea.prototype.custom_highlight.arguments[2]+"µ_END_µ";
\r
65 if(EditArea.prototype.custom_highlight.arguments.length>5)
\r
66 res+= EditArea.prototype.custom_highlight.arguments[ EditArea.prototype.custom_highlight.arguments.length-3 ];
\r
71 // return identication that allow to know if revalidating only the text line won't make the syntax go mad
\r
72 EditArea.prototype.get_syntax_trace= function(text){
\r
73 if(this.settings["syntax"].length>0 && parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"])
\r
74 return text.replace(parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"], "$3");
\r
78 EditArea.prototype.colorize_text= function(text){
\r
79 //text="<div id='result' class='area' style='position: relative; z-index: 4; height: 500px; overflow: scroll;border: solid black 1px;'> ";
\r
82 // opera can't use pre element tabulation cause a tab=6 chars in the textarea and 8 chars in the pre
\r
83 text= this.replace_tab(text);
\r
86 text= " "+text; // for easier regExp
\r
88 /*if(this.do_html_tags)
\r
89 text= text.replace(/(<[a-z]+ [^>]*>)/gi, '[__htmlTag__]$1[_END_]');*/
\r
90 if(this.settings["syntax"].length>0)
\r
91 text= this.apply_syntax(text, this.settings["syntax"]);
\r
93 // remove the first space added
\r
94 return text.substr(1).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/µ_END_µ/g,"</span>").replace(/µ__([a-zA-Z0-9]+)__µ/g,"<span class='$1'>");
\r
97 EditArea.prototype.apply_syntax= function(text, lang){
\r
99 this.current_code_lang=lang;
\r
101 if(!parent.editAreaLoader.syntax[lang])
\r
104 sy = parent.editAreaLoader.syntax[lang];
\r
105 if(sy["custom_regexp"]['before']){
\r
106 for( var i in sy["custom_regexp"]['before']){
\r
107 var convert="$1µ__"+ sy["custom_regexp"]['before'][i]['class'] +"__µ$2µ_END_µ$3";
\r
108 text= text.replace(sy["custom_regexp"]['before'][i]['regexp'], convert);
\r
112 if(sy["comment_or_quote_reg_exp"]){
\r
113 //setTimeout("_$('debug_area').value=editArea.comment_or_quote_reg_exp;", 500);
\r
114 text= text.replace(sy["comment_or_quote_reg_exp"], this.comment_or_quote);
\r
117 if(sy["keywords_reg_exp"]){
\r
118 for(var i in sy["keywords_reg_exp"]){
\r
119 text= text.replace(sy["keywords_reg_exp"][i], 'µ__'+i+'__µ$2µ_END_µ');
\r
123 if(sy["delimiters_reg_exp"]){
\r
124 text= text.replace(sy["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');
\r
127 if(sy["operators_reg_exp"]){
\r
128 text= text.replace(sy["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');
\r
131 if(sy["custom_regexp"]['after']){
\r
132 for( var i in sy["custom_regexp"]['after']){
\r
133 var convert="$1µ__"+ sy["custom_regexp"]['after'][i]['class'] +"__µ$2µ_END_µ$3";
\r
134 text= text.replace(sy["custom_regexp"]['after'][i]['regexp'], convert);
\r