Enkodowanie nazw plików do UTF-8 przed przekazaniem ich do localrepo.commit. Powinno...
[redakcja.git] / project / static / js / regexp.js
1         /*EditArea.prototype.comment_or_quotes= function(v0, v1, v2, v3, v4,v5,v6,v7,v8,v9, v10){\r
2                 new_class="quotes";\r
3                 if(v6 && v6 != undefined && v6!="")\r
4                         new_class="comments";\r
5                 return "µ__"+ new_class +"__µ"+v0+"µ_END_µ";\r
6 \r
7         };*/\r
8         \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
12                 tab=v3.split("=");\r
13                 attributes="";\r
14                 if(tab.length>1){\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("&nbsp;");                               \r
18                                 attributes+="<span class=attributeVal>"+tab[i].substr(0,cut)+"</span>";\r
19                                 attributes+="<span class=attribute>"+tab[i].substr(cut)+"</span>=";\r
20                         }\r
21                         attributes+="<span class=attributeVal>"+tab[tab.length-1]+"</span>";\r
22                 }               \r
23                 res+=attributes+v5+"</span>";\r
24                 return res;             \r
25         };*/\r
26         \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
32                 \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
37                         }\r
38                 }\r
39                 if(new_class.length==0)\r
40                 {\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
45                                 }\r
46                         }\r
47                 }\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
51                 }else{\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
56                         else\r
57                                 return "µ__"+ new_class +"__µ"+ arg;\r
58                 }\r
59         };\r
60         \r
61 /*\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
67                 return res;\r
68         };\r
69         */\r
70         \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
75         };\r
76         \r
77                 \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
80           /*            \r
81                 if(this.isOpera){       \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
84                 }*/\r
85                 \r
86                 text= " "+text; // for easier regExp\r
87                 \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
92 \r
93                 // remove the first space added\r
94                 return text.substr(1).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/µ_END_µ/g,"</span>").replace(/µ__([a-zA-Z0-9]+)__µ/g,"<span class='$1'>");\r
95         };\r
96         \r
97         EditArea.prototype.apply_syntax= function(text, lang){\r
98                 var sy;\r
99                 this.current_code_lang=lang;\r
100         \r
101                 if(!parent.editAreaLoader.syntax[lang])\r
102                         return text;\r
103                         \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
109                         }\r
110                 }\r
111                 \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
115                 }\r
116                 \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
120                         }                       \r
121                 }\r
122                 \r
123                 if(sy["delimiters_reg_exp"]){\r
124                         text= text.replace(sy["delimiters_reg_exp"], 'µ__delimiters__µ$1µ_END_µ');\r
125                 }               \r
126                 \r
127                 if(sy["operators_reg_exp"]){\r
128                         text= text.replace(sy["operators_reg_exp"], 'µ__operators__µ$1µ_END_µ');\r
129                 }\r
130                 \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
135                         }\r
136                 }\r
137                         \r
138                 return text;\r
139         };\r