/
mode-scad.min.js
1 lines (1 loc) 路 7.35 KB
/
mode-scad.min.js
1
define("ace/mode/scad",["require","exports","module","pilot/oop","ace/mode/text","ace/tokenizer","ace/mode/scad_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle"],function(e,t){var i=e("pilot/oop"),n=e("ace/mode/text").Mode,r=e("ace/tokenizer").Tokenizer,o=e("ace/mode/scad_highlight_rules").scadHighlightRules,s=e("ace/mode/matching_brace_outdent").MatchingBraceOutdent,a=e("ace/range").Range,c=e("ace/mode/behaviour/cstyle").CstyleBehaviour,l=function(){this.$tokenizer=new r((new o).getRules()),this.$outdent=new s,this.$behaviour=new c};i.inherits(l,n),function(){this.toggleCommentLines=function(e,t,i,n){for(var r=!0,o=/^(\s*)\/\//,s=i;n>=s;s++)if(!o.test(t.getLine(s))){r=!1;break}if(r)for(var c=new a(0,0,0,0),s=i;n>=s;s++){var l=t.getLine(s),d=l.match(o);c.start.row=s,c.end.row=s,c.end.column=d[0].length,t.replace(c,d[1])}else t.indentRows(i,n,"//")},this.getNextLineIndent=function(e,t,i){var n=this.$getIndent(t),r=this.$tokenizer.getLineTokens(t,e),o=r.tokens,s=r.state;if(o.length&&"comment"==o[o.length-1].type)return n;if("start"==e){var a=t.match(/^.*[\{\(\[]\s*$/);a&&(n+=i)}else if("doc-start"==e){if("start"==s)return"";var a=t.match(/^\s*(\/?)\*/);a&&(a[1]&&(n+=" "),n+="* ")}return n},this.checkOutdent=function(e,t,i){return this.$outdent.checkOutdent(t,i)},this.autoOutdent=function(e,t,i){this.$outdent.autoOutdent(t,i)}}.call(l.prototype),t.Mode=l}),define("ace/mode/scad_highlight_rules",["require","exports","module","pilot/oop","pilot/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t){var i=e("pilot/oop"),n=e("pilot/lang"),r=e("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules,o=e("ace/mode/text_highlight_rules").TextHighlightRules,s=function(){var e=n.arrayToMap("module|if|else|for".split("|")),t=n.arrayToMap("NULL".split("|"));this.$rules={start:[{token:"comment",regex:"\\/\\/.*$"},(new r).getStartRule("start"),{token:"comment",merge:!0,regex:"\\/\\*",next:"comment"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:'["].*\\\\$',next:"qqstring"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"string",regex:"['].*\\\\$",next:"qstring"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant",regex:"<[a-zA-Z0-9.]+>"},{token:"keyword",regex:"(?:use|include)"},{token:function(i){return"this"==i?"variable.language":e.hasOwnProperty(i)?"keyword":t.hasOwnProperty(i)?"constant.language":"identifier"},regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"},{token:"lparen",regex:"[[({]"},{token:"rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],comment:[{token:"comment",regex:".*?\\*\\/",next:"start"},{token:"comment",merge:!0,regex:".+"}],qqstring:[{token:"string",regex:'(?:(?:\\\\.)|(?:[^"\\\\]))*?"',next:"start"},{token:"string",merge:!0,regex:".+"}],qstring:[{token:"string",regex:"(?:(?:\\\\.)|(?:[^'\\\\]))*?'",next:"start"},{token:"string",merge:!0,regex:".+"}]},this.embedRules(r,"doc-",[(new r).getEndRule("start")])};i.inherits(s,o),t.scadHighlightRules=s}),define("ace/mode/doc_comment_highlight_rules",["require","exports","module","pilot/oop","ace/mode/text_highlight_rules"],function(e,t){var i=e("pilot/oop"),n=e("ace/mode/text_highlight_rules").TextHighlightRules,r=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},{token:"comment.doc",merge:!0,regex:"\\s+"},{token:"comment.doc",merge:!0,regex:"TODO"},{token:"comment.doc",merge:!0,regex:"[^@\\*]+"},{token:"comment.doc",merge:!0,regex:"."}]}};i.inherits(r,n),function(){this.getStartRule=function(e){return{token:"comment.doc",merge:!0,regex:"\\/\\*(?=\\*)",next:e}},this.getEndRule=function(e){return{token:"comment.doc",merge:!0,regex:"\\*\\/",next:e}}}.call(r.prototype),t.DocCommentHighlightRules=r}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t){var i=e("ace/range").Range,n=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),r=n.match(/^(\s*\})/);if(!r)return 0;var o=r[1].length,s=e.findMatchingBracket({row:t,column:o});if(!s||s.row==t)return 0;var a=this.$getIndent(e.getLine(s.row));e.replace(new i(t,0,t,o-1),a)},this.$getIndent=function(e){var t=e.match(/^(\s+)/);return t?t[1]:""}}).call(n.prototype),t.MatchingBraceOutdent=n}),define("ace/mode/behaviour/cstyle",["require","exports","module","pilot/oop","ace/mode/behaviour"],function(e,t){var i=e("pilot/oop"),n=e("ace/mode/behaviour").Behaviour,r=function(){this.add("braces","insertion",function(e,t,i,n,r){if("{"==r){var o=i.getSelectionRange(),s=n.doc.getTextRange(o);return""!==s?{text:"{"+s+"}",selection:!1}:{text:"{}",selection:[1,1]}}if("}"==r){var a=i.getCursorPosition(),c=n.doc.getLine(a.row),l=c.substring(a.column,a.column+1);if("}"==l){var d=n.$findOpeningBracket("}",{column:a.column+1,row:a.row});if(null!==d)return{text:"",selection:[1,1]}}}else if("\n"==r){var a=i.getCursorPosition(),c=n.doc.getLine(a.row),l=c.substring(a.column,a.column+1);if("}"==l){var u=n.findMatchingBracket({row:a.row,column:a.column+1});if(!u)return!1;var g=this.getNextLineIndent(e,c.substring(0,c.length-1),n.getTabString()),p=this.$getIndent(n.doc.getLine(u.row));return{text:"\n"+g+"\n"+p,selection:[1,g.length,1,g.length]}}}return!1}),this.add("braces","deletion",function(e,t,i,n,r){var o=n.doc.getTextRange(r);if(!r.isMultiLine()&&"{"==o){var s=n.doc.getLine(r.start.row),a=s.substring(r.end.column,r.end.column+1);if("}"==a)return r.end.column++,r}return!1}),this.add("parens","insertion",function(e,t,i,n,r){if("("==r){var o=i.getSelectionRange(),s=n.doc.getTextRange(o);return""!==s?{text:"("+s+")",selection:!1}:{text:"()",selection:[1,1]}}if(")"==r){var a=i.getCursorPosition(),c=n.doc.getLine(a.row),l=c.substring(a.column,a.column+1);if(")"==l){var d=n.$findOpeningBracket(")",{column:a.column+1,row:a.row});if(null!==d)return{text:"",selection:[1,1]}}}return!1}),this.add("parens","deletion",function(e,t,i,n,r){var o=n.doc.getTextRange(r);if(!r.isMultiLine()&&"("==o){var s=n.doc.getLine(r.start.row),a=s.substring(r.start.column+1,r.start.column+2);if(")"==a)return r.end.column++,r}return!1}),this.add("string_dquotes","insertion",function(e,t,i,n,r){if('"'==r){var o=i.getSelectionRange(),s=n.doc.getTextRange(o);if(""!==s)return{text:'"'+s+'"',selection:!1};var a=i.getCursorPosition(),c=n.doc.getLine(a.row),l=c.substring(a.column-1,a.column);if("\\"==l)return!1;for(var d,u=n.getTokens(o.start.row,o.start.row)[0].tokens,g=0,p=-1,h=0;u.length>h&&(d=u[h],"string"==d.type?p=-1:0>p&&(p=d.value.indexOf('"')),!(d.value.length+g>o.start.column));h++)g+=u[h].value.length;if(!d||0>p&&"comment"!==d.type&&("string"!==d.type||o.start.column!==d.value.length+g-1&&d.value.lastIndexOf('"')===d.value.length-1))return{text:'""',selection:[1,1]};if(d&&"string"===d.type){var _=c.substring(a.column,a.column+1);if('"'==_)return{text:"",selection:[1,1]}}}return!1}),this.add("string_dquotes","deletion",function(e,t,i,n,r){var o=n.doc.getTextRange(r);if(!r.isMultiLine()&&'"'==o){var s=n.doc.getLine(r.start.row),a=s.substring(r.start.column+1,r.start.column+2);if('"'==a)return r.end.column++,r}return!1})};i.inherits(r,n),t.CstyleBehaviour=r});