From e4355adae7f8fc6c7279bd7a22ed5caec1fd1848 Mon Sep 17 00:00:00 2001 From: baboso Date: Sat, 31 May 2014 19:51:41 -0400 Subject: [PATCH 001/127] Initial commit for praat highlighting: based on Perl --- lib/ace/mode/praat.js | 90 ++++++++++++++ lib/ace/mode/praat_highlight_rules.js | 165 ++++++++++++++++++++++++++ 2 files changed, 255 insertions(+) create mode 100644 lib/ace/mode/praat.js create mode 100644 lib/ace/mode/praat_highlight_rules.js diff --git a/lib/ace/mode/praat.js b/lib/ace/mode/praat.js new file mode 100644 index 00000000..69c4d27e --- /dev/null +++ b/lib/ace/mode/praat.js @@ -0,0 +1,90 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = PerlHighlightRules; + + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"}); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "#"; + this.blockComment = [ + {start: "=begin", end: "=cut"}, + {start: "=item", end: "=cut"} + ]; + + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.$id = "ace/mode/perl"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js new file mode 100644 index 00000000..7c183fe3 --- /dev/null +++ b/lib/ace/mode/praat_highlight_rules.js @@ -0,0 +1,165 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PerlHighlightRules = function() { + + var keywords = ( + "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + + "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars" + ); + + var buildinConstants = ("ARGV|ENV|INC|SIG"); + + var builtinFunctions = ( + "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" + + "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" + + "getpeername|setpriority|getprotoent|setprotoent|getpriority|" + + "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" + + "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" + + "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" + + "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" + + "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" + + "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" + + "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" + + "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" + + "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" + + "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" + + "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" + + "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" + + "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" + + "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" + + "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" + + "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" + + "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" + + "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" + + "map|die|uc|lc|do" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": builtinFunctions + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment.doc", + regex : "^=(?:begin|item)\\b", + next : "block_comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0x[0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)" + }, { + token : "comment", + regex : "#.*$" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + regex : '.+' + } + ], + "block_comment": [ + { + token: "comment.doc", + regex: "^=cut\\b", + next: "start" + }, + { + defaultToken: "comment.doc" + } + ] + }; +}; + +oop.inherits(PerlHighlightRules, TextHighlightRules); + +exports.PerlHighlightRules = PerlHighlightRules; +}); From df92a99e93c57439c6870466c111ef985085e4a4 Mon Sep 17 00:00:00 2001 From: baboso Date: Sun, 1 Jun 2014 18:25:27 -0400 Subject: [PATCH 002/127] Praat syntax highlighter, first release --- demo/kitchen-sink/docs/praat.praat | 115 ++++++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/praat.js | 11 +- lib/ace/mode/praat_highlight_rules.js | 288 +++++++++++++++----------- 4 files changed, 290 insertions(+), 125 deletions(-) create mode 100644 demo/kitchen-sink/docs/praat.praat diff --git a/demo/kitchen-sink/docs/praat.praat b/demo/kitchen-sink/docs/praat.praat new file mode 100644 index 00000000..48a649a2 --- /dev/null +++ b/demo/kitchen-sink/docs/praat.praat @@ -0,0 +1,115 @@ +form Highlighter test + sentence My_sentence This should all be a string + text My_text This should also all be a string + word My_word Only the first word is a string, the rest is invalid + boolean Binary 1 + boolean Text no + boolean Quoted "yes" + comment This should be a string + real left_Range -123.6 + positive right_Range_max 3.3 + integer Int 4 + natural Nat 4 +endform + +# old-style procedure call +call oldStyle "quoted" 2 unquoted string +assert oldStyle.local = 1 + +# New-style procedure call with parens +@newStyle("quoted", 2, "quoted string") +if praatVersion >= 5364 + # New-style procedure call with colon + @newStyle: "quoted", 2, "quoted string" +endif +assert newStyle.local = 1 + +# if-block with built-in variables +if windows + # We are on Windows +elsif unix = 1 or !macintosh + # We are on Linux +else macintosh == 1 + # We are on Mac +endif + +# inline if with inline comment +var = if macintosh = 1 then 0 else 1 fi ; This is an inline comment + +# for-loop with explicit from using local variable +# and paren-style function calls and variable interpolation +n = numberOfSelected("Sound") +for i from newStyle.local to n + sound'i' = selected("Sound", i) + sound[i] = sound'i' +endfor + +for i from 1 to n + # Different styles of object selection + select sound'i' + sound = selected() + sound$ = selected$("Sound") + select Sound 'sound$' + selectObject(sound[i]) + selectObject: sound + + # New-style standalone command call + Rename: "SomeName" + + # Command call with assignment + duration = Get total duration + + # Multi-line command with modifier + pitch = noprogress To Pitch (ac): 0, 75, 15, "no", + ...0.03, 0.45, 0.01, 0.35, 0.14, 600 + + # Old-style command with assignment + minimum = Get minimum... 0 0 "Hertz" Parabolic + + # New-style multi-line command call with broken strings + table = Create Table with column names: "table", 0, + ..."file subject speaker + ...f0 f1 f2 f3 " + + ..."duration response" + + removeObject: pitch, table + + # Picture window commands + selectObject: sound + Select inner viewport: 1, 6, 0.5, 1.5 + Black + Draw... 0 0 0 0 "no" Curve + Draw inner box + Text bottom: "yes", sound$ + Erase all + + # Demo window commands + demo Erase all + demo Select inner viewport... 0 100 0 100 + demo Axes... 0 100 0 100 + demo Paint rectangle... white 0 100 0 100 + demo Purple + demo Times + demo 24 + # The "to" in "Click to finish" should not be a keyword + demo Text... 50 centre 50 half Click to finish + demoWaitForInput ( ) + demo Erase all + demo Select inner viewport... 0 100 0 100 + demo Axes... 0 100 0 100 + demo Paint rectangle... purple 0 100 0 100 + demo Yellow + demo Times + demo 24 + demo Text... 50 centre 50 half Finished +endfor + +# Old-style procedure declaration +procedure oldStyle .str1$ .num .str2$ + .local = 1 +endproc + +# New-style procedure declaration +procedure newStyle (.str1$, .num, .str2$) + .local = 1 +endproc diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 66fe3de8..b4fbd0da 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -113,6 +113,7 @@ var supportedModes = { pgSQL: ["pgsql"], PHP: ["php|phtml"], Powershell: ["ps1"], + Praat: ["praat"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], diff --git a/lib/ace/mode/praat.js b/lib/ace/mode/praat.js index 69c4d27e..01d18c9a 100644 --- a/lib/ace/mode/praat.js +++ b/lib/ace/mode/praat.js @@ -33,13 +33,13 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules; +var PraatHighlightRules = require("./praat_highlight_rules").PraatHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - this.HighlightRules = PerlHighlightRules; + this.HighlightRules = PraatHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"}); @@ -49,11 +49,6 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "#"; - this.blockComment = [ - {start: "=begin", end: "=cut"}, - {start: "=item", end: "=cut"} - ]; - this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); @@ -83,7 +78,7 @@ oop.inherits(Mode, TextMode); this.$outdent.autoOutdent(doc, row); }; - this.$id = "ace/mode/perl"; + this.$id = "ace/mode/praat"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 7c183fe3..693a6572 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -1,77 +1,106 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Distributed under the BSD license: - * - * Copyright (c) 2010, Ajax.org B.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Ajax.org B.V. nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * ***** END LICENSE BLOCK ***** */ - define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var PerlHighlightRules = function() { +var PraatHighlightRules = function() { var keywords = ( - "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + - "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars" + "if|then|else|elsif|elif|endif|fi|" + + "endfor|" + // other for-related keywords are specified below + "while|endwhile|" + + "repeat|until|" + + "select|plus|minus|" + + "assert" ); - var buildinConstants = ("ARGV|ENV|INC|SIG"); +// var buildinConstants = ("ARGV|ENV|INC|SIG"); - var builtinFunctions = ( - "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" + - "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" + - "getpeername|setpriority|getprotoent|setprotoent|getpriority|" + - "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" + - "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" + - "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" + - "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" + - "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" + - "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" + - "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" + - "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" + - "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" + - "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" + - "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" + - "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" + - "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" + - "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" + - "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" + - "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" + - "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" + - "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" + - "map|die|uc|lc|do" + var predefinedVariables = ( + "macintosh|windows|unix|" + + "praatVersion|praatVersion\\$" + + "pi|undefined|" + + "newline\\$|tab\\$|" + + "shellDirectory\\$|homeDirectory\\$|preferencesDirectory\\$|" + + "temporaryDirectory\\$|defaultDirectory\\$" + ); + + var functions = ( +// Math functions + "writeInfo|writeInfoLine|appendInfo|appendInfoLine|" + + "writeFile|writeFileLine|appendFile|appendFileLine|" + + "abs|round|floor|ceiling|min|max|imin|imax|" + + "sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" + + "exp|ln|log10|log2|" + + "sinh|cosh|tanh|arcsinh|arccosh|actanh|" + + "sigmoid|invSigmoid|erf|erfc|" + + "randomUniform|randomInteger|randomGauss|randomPoisson|" + + "lnGamma|gaussP|gaussQ|invGaussQ|" + + "chiSquareP|chiSquareQ|invChiSquareQ|studentP|studentQ|invStudentQ|" + + "fisherP|fisherQ|invFisherQ|" + + "binomialP|binomialQ|invBinomialP|invBinomialQ|" + + "hertzToBark|barkToHerz|" + + "hertzToMel|melToHertz|" + + "hertzToSemitones|semitonesToHerz|" + + "erb|hertzToErb|erbToHertz|" + + "phonToDifferenceLimens|differenceLimensToPhon|" + + "beta|besselI|besselK|" + +// String functions + "selected|selected$|numberOfSelected|variableExists|"+ + "index|rindex|startsWith|endsWith|"+ + "index_regex|rindex_regex|replace_regex$|"+ + "length|extractWord$|extractLine$|extractNumber|" + + "left$|right$|mid$|replace$|" + +// Pause functions + "beginPause|endPause|" + +// Demo functions + "demoShow|demoWindowTitle|demoInput|demoWaitForInput|" + + "demoClicked|demoClickedIn|demoX|demoY|" + + "demoKeyPressed|demoKey$|" + + "demoExtraControlKeyPressed|demoShiftKeyPressed|"+ + "demoCommandKeyPressed|demoOptionKeyPressed|" + +// File functions + "environment$|" + + "chooseDirectory$|createDirectory|fileReadable|deleteFile|" + + "selectObject|removeObject|plusObject|minusObject|" + + "runScript|exitScript" ); + var objectTypes = ( + "Collection|Strings|ManPages|SortedSetOfString|Sound|Matrix|Polygon|" + + "PointProcess|ParamCurve|Spectrum|Ltas|Spectrogram|Formant|" + + "Excitation|Cochleagram|VocalTract|FormantPoint|FormantTier|" + + "FormantGrid|Label|Tier|Autosegment|Intensity|Pitch|Harmonicity|" + + "Transition|RealPoint|RealTier|PitchTier|IntensityTier|DurationTier|" + + "AmplitudeTier|SpectrumTier|Manipulation|TextPoint|TextInterval|" + + "TextTier|IntervalTier|TextGrid|LongSound|WordList|SpellingChecker|" + + "Movie|Corpus|TableOfReal|Distributions|PairDistribution|Table|" + + "LinearRegression|LogisticRegression|Art|Artword|Speaker|Activation|" + + "BarkFilter|Categories|Cepstrum|CCA|ChebyshevSeries|" + + "ClassificationTable|Confusion|Correlation|Covariance|Discriminant|" + + "DTW|Eigen|Excitations|FormantFilter|Index|KlattTable|Permutation|" + + "ISpline|LegendreSeries|MelFilter|MSpline|Pattern|PCA|Polynomial|" + + "Roots|SimpleString|StringsIndex|SpeechSynthesizer|SPINET|SSCP|SVD|" + + "AffineTransform|Procrustes|ContingencyTable|Dissimilarity|" + + "Similarity|Configuration|Distance|Salience|ScalarProduct|Weight|" + + "KlattGrid|HMM|HMM_State|HMM_Observation|HMM_ObservationSequence|" + + "HMM_StateSequence|GaussianMixture|Diagonalizer|MixingMatrix|" + + "CrossCorrelationTable|CrossCorrelationTables|Network|OTGrammar|" + + "OTHistory|OTMulti|FFNet|Cepstrumc|LPC|LFCC|MFCC|ExperimentMFC|" + + "ResultsMFC|EEG|ERPTier|ERP|KNN|FeatureWeights" + ); + var keywordMapper = this.createKeywordMapper({ "keyword": keywords, - "constant.language": buildinConstants, - "support.function": builtinFunctions +// "constant.language": buildinConstants, + "support.function": functions + }, "identifier"); + + var inlineIf = this.createKeywordMapper({ + "keyword": "(if|then|else|fi)", +// "constant.language": buildinConstants, + "support.function": functions }, "identifier"); // regexp must not have capturing parentheses. Use (?:) instead. @@ -80,86 +109,111 @@ var PerlHighlightRules = function() { this.$rules = { "start" : [ { - token : "comment.doc", - regex : "^=(?:begin|item)\\b", - next : "block_comment" + token : "entity.name.type", + regex : "(" + objectTypes + ")" }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + token : "variable.language", + regex : "(" + predefinedVariables + ")" }, { - token : "string", // single line - regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + token : ["support.function", "text"], + regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())" }, { - token : "string", // multi line string start - regex : '["].*\\\\$', - next : "qqstring" +// token : ["keyword", "text", "keyword", "text", "keyword", "text"], +// regex : /\b(for)(\s+\S+\s*)(?:(from)(\s+[a-z][a-zA-Z0-9_.]*\$?\s*))?(?:(to)(\s+\S+\s*))?/, +// }, { + token : "keyword", + regex : /(\bfor\b)/, + next : "for" }, { - token : "string", // single line - regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + token : "keyword", + regex : "(\\b(?:" + keywords + ")\\b)" }, { - token : "string", // multi line string start - regex : "['].*\\\\$", - next : "qstring" + token : "string.interpolated", + regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/ }, { - token : "constant.numeric", // hex - regex : "0x[0-9a-fA-F]+\\b" + token : "string", + regex : /"[^"]*"/ }, { - token : "constant.numeric", // float - regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + token : ["text", "keyword", "text", "entity.name.section"], // multi line string start + regex : /(^\s*)(\bform\b)(\s+)(.*)/, + next : "form" }, { - token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + token : "constant.numeric", + regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + token : ["entity.name.function", "text"], + regex : /(@\S+)(:|\s*\()/ + }, { + token : ["text", "keyword", "text", "entity.name.function"], + regex : /(^\s*)(call)(\s+)(\S+)/ + }, { + token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"], + regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ + }, { + token : ["text", "keyword", "text", "keyword"], + regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ + }, { + token : ["text", "keyword"], + regex : /(^\s*)(demo\b)/ }, { token : "keyword.operator", - regex : "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)" + regex : /(?:\b((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)\b)/ }, { token : "comment", regex : "#.*$" }, { - token : "lparen", - regex : "[[({]" + token : "text", + regex : /\s+/ + } + ], + "form" : [ + { + token : ["keyword", "text", "constant.numeric"], + regex : /((?:optionmenu|choice)\s+)(\S+:\s+)([0-9]+)/ }, { - token : "rparen", - regex : "[\\])}]" + token : ["keyword", "constant.numeric"], + regex : /((?:option|button)\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/ + }, { + token : ["keyword", "string"], + regex : /((?:option|button)\s+)(.*)/ + }, { + token : ["keyword", "text", "string"], + regex : /((?:sentence|text)\s+)(\S+\s*)(.*)/ + }, { + token : ["keyword", "text", "string", "invalid.illegal"], + regex : /(word\s+)(\S+\s*)(\S+)?(\s.*)?/ + }, { + token : ["keyword", "text", "constant.language"], + regex : /(boolean\s+)(\S+\s*)(0|1|"?(?:yes|no)"?)/ + }, { + token : ["keyword", "text", "constant.numeric"], + regex : /((?:real|natural|positive|integer)\s+)(\S+\s*)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/ + }, { + token : ["keyword", "string"], + regex : /(comment\s+)(.*)/ + }, { + token : "keyword", + regex : 'endform', + next : "start" + } + ], + "for" : [ + { + token : ["keyword", "text", "constant.numeric", "text"], + regex : /(from|to)(\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?)(\s*)/ + }, { + token : ["keyword", "text"], + regex : /(from|to)(\s+\S+\s*)/ }, { token : "text", - regex : "\\s+" - } - ], - "qqstring" : [ - { - token : "string", - regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + regex : /$/, next : "start" - }, { - token : "string", - regex : '.+' } ], - "qstring" : [ - { - token : "string", - regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", - next : "start" - }, { - token : "string", - regex : '.+' - } - ], - "block_comment": [ - { - token: "comment.doc", - regex: "^=cut\\b", - next: "start" - }, - { - defaultToken: "comment.doc" - } - ] }; }; -oop.inherits(PerlHighlightRules, TextHighlightRules); +oop.inherits(PraatHighlightRules, TextHighlightRules); -exports.PerlHighlightRules = PerlHighlightRules; +exports.PraatHighlightRules = PraatHighlightRules; }); From 08afa03cb9c140ffe7ca86e3b5edb038b9433a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?= Date: Tue, 3 Jun 2014 14:32:55 -0400 Subject: [PATCH 003/127] Fixed operators and introduced broken lines --- lib/ace/mode/praat_highlight_rules.js | 47 ++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 693a6572..0ce8a802 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -8,7 +8,7 @@ var PraatHighlightRules = function() { var keywords = ( "if|then|else|elsif|elif|endif|fi|" + - "endfor|" + // other for-related keywords are specified below + "endfor|endproc|" + // other for-related keywords are specified below "while|endwhile|" + "repeat|until|" + "select|plus|minus|" + @@ -109,6 +109,18 @@ var PraatHighlightRules = function() { this.$rules = { "start" : [ { + token : ["text", "keyword.operator", "text"], + regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/ + }, { + token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"], + regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ + }, { + token : ["text", "keyword", "text", "keyword"], + regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ + }, { + token : ["text", "keyword"], + regex : /(^\s*)(demo\b)/ + }, { token : "entity.name.type", regex : "(" + objectTypes + ")" }, { @@ -118,9 +130,6 @@ var PraatHighlightRules = function() { token : ["support.function", "text"], regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())" }, { -// token : ["keyword", "text", "keyword", "text", "keyword", "text"], -// regex : /\b(for)(\s+\S+\s*)(?:(from)(\s+[a-z][a-zA-Z0-9_.]*\$?\s*))?(?:(to)(\s+\S+\s*))?/, -// }, { token : "keyword", regex : /(\bfor\b)/, next : "for" @@ -133,6 +142,10 @@ var PraatHighlightRules = function() { }, { token : "string", regex : /"[^"]*"/ + }, { + token : "string", + regex : /"[^"]*$/, + next : "brokenstring" }, { token : ["text", "keyword", "text", "entity.name.section"], // multi line string start regex : /(^\s*)(\bform\b)(\s+)(.*)/, @@ -140,6 +153,9 @@ var PraatHighlightRules = function() { }, { token : "constant.numeric", regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + token : ["keyword", "text", "entity.name.function"], + regex : /(procedure)(\s+)(\S+)/ }, { token : ["entity.name.function", "text"], regex : /(@\S+)(:|\s*\()/ @@ -147,17 +163,8 @@ var PraatHighlightRules = function() { token : ["text", "keyword", "text", "entity.name.function"], regex : /(^\s*)(call)(\s+)(\S+)/ }, { - token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"], - regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ - }, { - token : ["text", "keyword", "text", "keyword"], - regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ - }, { - token : ["text", "keyword"], - regex : /(^\s*)(demo\b)/ - }, { - token : "keyword.operator", - regex : /(?:\b((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)\b)/ + token : "comment", + regex : ";.*$" }, { token : "comment", regex : "#.*$" @@ -210,6 +217,16 @@ var PraatHighlightRules = function() { next : "start" } ], + "brokenstring" : [ + { + token : ["text", "string"], + regex : /(\s*\.{3})([^"]*)/ + }, { + token : "string", + regex : /"/, + next : "start" + } + ], }; }; From d57e010ca3c3bbb77a2b7104bd1837fdf3a4af9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?= Date: Tue, 3 Jun 2014 15:10:31 -0400 Subject: [PATCH 004/127] Added single number font size changing commands (praat) --- lib/ace/mode/praat_highlight_rules.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 0ce8a802..9ba554ec 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -118,9 +118,13 @@ var PraatHighlightRules = function() { token : ["text", "keyword", "text", "keyword"], regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ }, { - token : ["text", "keyword"], - regex : /(^\s*)(demo\b)/ + token : ["text", "keyword", "text", "keyword"], + regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/ }, { + // Is this rule necessary? + // token : ["text", "keyword"], + // regex : /(^\s*)(demo\b)/ + // }, { token : "entity.name.type", regex : "(" + objectTypes + ")" }, { From a519520ae7cf18abd7a97c88665b40f4c7d962e2 Mon Sep 17 00:00:00 2001 From: baboso Date: Wed, 4 Jun 2014 18:03:55 -0400 Subject: [PATCH 005/127] Removed useless rules, added support for do() syntax --- demo/kitchen-sink/docs/praat.praat | 7 ++++--- lib/ace/mode/praat_highlight_rules.js | 19 ++++--------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/demo/kitchen-sink/docs/praat.praat b/demo/kitchen-sink/docs/praat.praat index 48a649a2..f15e4058 100644 --- a/demo/kitchen-sink/docs/praat.praat +++ b/demo/kitchen-sink/docs/praat.praat @@ -63,8 +63,8 @@ for i from 1 to n pitch = noprogress To Pitch (ac): 0, 75, 15, "no", ...0.03, 0.45, 0.01, 0.35, 0.14, 600 - # Old-style command with assignment - minimum = Get minimum... 0 0 "Hertz" Parabolic + # do-style command with assignment + minimum = do("Get minimum...", 0, 0, "Hertz", "Parabolic") # New-style multi-line command call with broken strings table = Create Table with column names: "table", 0, @@ -76,7 +76,8 @@ for i from 1 to n # Picture window commands selectObject: sound - Select inner viewport: 1, 6, 0.5, 1.5 + # do-style command + do("Select inner viewport...", 1, 6, 0.5, 1.5) Black Draw... 0 0 0 0 "no" Curve Draw inner box diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 9ba554ec..1e53b94c 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -15,8 +15,6 @@ var PraatHighlightRules = function() { "assert" ); -// var buildinConstants = ("ARGV|ENV|INC|SIG"); - var predefinedVariables = ( "macintosh|windows|unix|" + "praatVersion|praatVersion\\$" + @@ -91,18 +89,6 @@ var PraatHighlightRules = function() { "ResultsMFC|EEG|ERPTier|ERP|KNN|FeatureWeights" ); - var keywordMapper = this.createKeywordMapper({ - "keyword": keywords, -// "constant.language": buildinConstants, - "support.function": functions - }, "identifier"); - - var inlineIf = this.createKeywordMapper({ - "keyword": "(if|then|else|fi)", -// "constant.language": buildinConstants, - "support.function": functions - }, "identifier"); - // regexp must not have capturing parentheses. Use (?:) instead. // regexps are ordered -> the first match is used @@ -120,6 +106,9 @@ var PraatHighlightRules = function() { }, { token : ["text", "keyword", "text", "keyword"], regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/ + }, { + token : ["text", "support.function", "text"], + regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/ }, { // Is this rule necessary? // token : ["text", "keyword"], @@ -151,7 +140,7 @@ var PraatHighlightRules = function() { regex : /"[^"]*$/, next : "brokenstring" }, { - token : ["text", "keyword", "text", "entity.name.section"], // multi line string start + token : ["text", "keyword", "text", "entity.name.section"], regex : /(^\s*)(\bform\b)(\s+)(.*)/, next : "form" }, { From 17c75da27b040310cf1aa06a92c14fbb0d893ec1 Mon Sep 17 00:00:00 2001 From: baboso Date: Thu, 5 Jun 2014 00:45:20 -0400 Subject: [PATCH 006/127] Added sendpraat and unquoted string directives, simplified demo example, added some other missing functions/directives --- demo/kitchen-sink/docs/praat.praat | 44 ++++++++++++------ lib/ace/ext/modelist.js | 2 +- lib/ace/mode/praat.js | 1 - lib/ace/mode/praat_highlight_rules.js | 64 +++++++++++++++++++++------ 4 files changed, 81 insertions(+), 30 deletions(-) diff --git a/demo/kitchen-sink/docs/praat.praat b/demo/kitchen-sink/docs/praat.praat index f15e4058..c5dde785 100644 --- a/demo/kitchen-sink/docs/praat.praat +++ b/demo/kitchen-sink/docs/praat.praat @@ -12,6 +12,13 @@ form Highlighter test natural Nat 4 endform +# External scripts +include /path/to/file +runScript: "/path/to/file" +execute /path/to/file + +stopwatch + # old-style procedure call call oldStyle "quoted" 2 unquoted string assert oldStyle.local = 1 @@ -22,15 +29,14 @@ if praatVersion >= 5364 # New-style procedure call with colon @newStyle: "quoted", 2, "quoted string" endif -assert newStyle.local = 1 # if-block with built-in variables if windows # We are on Windows elsif unix = 1 or !macintosh - # We are on Linux + exitScript: "We are on Linux" else macintosh == 1 - # We are on Mac + exit We are on Mac endif # inline if with inline comment @@ -89,22 +95,32 @@ for i from 1 to n demo Select inner viewport... 0 100 0 100 demo Axes... 0 100 0 100 demo Paint rectangle... white 0 100 0 100 - demo Purple - demo Times - demo 24 - # The "to" in "Click to finish" should not be a keyword demo Text... 50 centre 50 half Click to finish demoWaitForInput ( ) demo Erase all - demo Select inner viewport... 0 100 0 100 - demo Axes... 0 100 0 100 - demo Paint rectangle... purple 0 100 0 100 - demo Yellow - demo Times - demo 24 - demo Text... 50 centre 50 half Finished + demo Text: 50, "centre", 50, "half", "Finished" endfor +# An old-style sendpraat block +sendpraat Praat + ...'newline$' Create Sound as pure tone... "tone" 1 0 0.4 44100 440 0.2 0.01 0.01 + ...'newline$' Play + ...'newline$' Remove + +# A new-style sendpraat block +beginSendPraat: "Praat" + Create Sound as pure tone: "tone", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01 + duration = Get total duration + Remove +endSendPraat: "duration" +appendInfoLine: "The generated sound lasted for ", duration, "seconds" + +time = stopwatch +clearinfo +echo This script took +print 'time' seconds to +printline execute. + # Old-style procedure declaration procedure oldStyle .str1$ .num .str2$ .local = 1 diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index b4fbd0da..5c5552b4 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -113,7 +113,7 @@ var supportedModes = { pgSQL: ["pgsql"], PHP: ["php|phtml"], Powershell: ["ps1"], - Praat: ["praat"], + Praat: ["praat|praatscript|psc|proc"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], diff --git a/lib/ace/mode/praat.js b/lib/ace/mode/praat.js index 01d18c9a..7b100ef0 100644 --- a/lib/ace/mode/praat.js +++ b/lib/ace/mode/praat.js @@ -42,7 +42,6 @@ var Mode = function() { this.HighlightRules = PraatHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.foldingRules = new CStyleFoldMode({start: "^=(begin|item)\\b", end: "^=(cut)\\b"}); }; oop.inherits(Mode, TextMode); diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 1e53b94c..39220a52 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -8,7 +8,7 @@ var PraatHighlightRules = function() { var keywords = ( "if|then|else|elsif|elif|endif|fi|" + - "endfor|endproc|" + // other for-related keywords are specified below + "endfor|endproc|" + // related keywords specified below "while|endwhile|" + "repeat|until|" + "select|plus|minus|" + @@ -24,10 +24,16 @@ var PraatHighlightRules = function() { "temporaryDirectory\\$|defaultDirectory\\$" ); + // What is "endSendPraat"? Function? Directive? + var directives = ( + "clearinfo|endSendPraat" + ); + var functions = ( -// Math functions +// Info functions "writeInfo|writeInfoLine|appendInfo|appendInfoLine|" + "writeFile|writeFileLine|appendFile|appendFileLine|" + +// Math functions "abs|round|floor|ceiling|min|max|imin|imax|" + "sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" + "exp|ln|log10|log2|" + @@ -45,24 +51,26 @@ var PraatHighlightRules = function() { "phonToDifferenceLimens|differenceLimensToPhon|" + "beta|besselI|besselK|" + // String functions - "selected|selected$|numberOfSelected|variableExists|"+ + "selected|selected\\$|numberOfSelected|variableExists|"+ "index|rindex|startsWith|endsWith|"+ - "index_regex|rindex_regex|replace_regex$|"+ - "length|extractWord$|extractLine$|extractNumber|" + - "left$|right$|mid$|replace$|" + + "index_regex|rindex_regex|replace_regex\\$|"+ + "length|extractWord\\$|extractLine\\$|extractNumber|" + + "left\\$|right\\$|mid\\$|replace\\$|" + // Pause functions "beginPause|endPause|" + // Demo functions "demoShow|demoWindowTitle|demoInput|demoWaitForInput|" + "demoClicked|demoClickedIn|demoX|demoY|" + - "demoKeyPressed|demoKey$|" + + "demoKeyPressed|demoKey\\$|" + "demoExtraControlKeyPressed|demoShiftKeyPressed|"+ "demoCommandKeyPressed|demoOptionKeyPressed|" + // File functions - "environment$|" + - "chooseDirectory$|createDirectory|fileReadable|deleteFile|" + + "environment\\$|chooseReadFile\\$|" + + "chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" + "selectObject|removeObject|plusObject|minusObject|" + - "runScript|exitScript" + "runScript|exitScript|" + +// sendpraat functions + "beginSendPraat|endSendPraat" ); var objectTypes = ( @@ -95,18 +103,35 @@ var PraatHighlightRules = function() { this.$rules = { "start" : [ { + // stopwatch + token : ["text", "text", "keyword.operator", "text", "keyword"], + regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(stopwatch)/ + }, { + // Directives which introduce unquoted strings + token : ["text", "keyword", "text", "string"], + regex : /(^\s*)(print(?:line)?|echo|exit|pause|sendpraat|include|execute)(\s+)(.*)/ + }, { + // Directives with no arguments + token : ["text", "keyword"], + regex : "(^\\s*)(" + directives + ")$" + }, { + // Operators token : ["text", "keyword.operator", "text"], regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/ }, { + // Commands token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"], regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ }, { + // Demo commands token : ["text", "keyword", "text", "keyword"], regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/ }, { + // Font-sizing commands token : ["text", "keyword", "text", "keyword"], regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/ }, { + // do-style command calls token : ["text", "support.function", "text"], regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/ }, { @@ -114,53 +139,64 @@ var PraatHighlightRules = function() { // token : ["text", "keyword"], // regex : /(^\s*)(demo\b)/ // }, { + // Object types token : "entity.name.type", regex : "(" + objectTypes + ")" }, { + // Predefined variables token : "variable.language", regex : "(" + predefinedVariables + ")" }, { + // Functions token : ["support.function", "text"], regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())" }, { + // For-loop declarations token : "keyword", regex : /(\bfor\b)/, next : "for" }, { + // Generic keywords token : "keyword", regex : "(\\b(?:" + keywords + ")\\b)" }, { + // Interpolated strings token : "string.interpolated", regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/ }, { + // Generic strings token : "string", regex : /"[^"]*"/ }, { + // Multiline quoted strings token : "string", regex : /"[^"]*$/, next : "brokenstring" }, { + // Form declarations token : ["text", "keyword", "text", "entity.name.section"], regex : /(^\s*)(\bform\b)(\s+)(.*)/, next : "form" }, { + // Numeric constants token : "constant.numeric", regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ }, { + // Procedure declarations token : ["keyword", "text", "entity.name.function"], regex : /(procedure)(\s+)(\S+)/ }, { + // New-style procedure calls token : ["entity.name.function", "text"], regex : /(@\S+)(:|\s*\()/ }, { + // Old-style procedure calls token : ["text", "keyword", "text", "entity.name.function"], regex : /(^\s*)(call)(\s+)(\S+)/ }, { + // Comments token : "comment", - regex : ";.*$" - }, { - token : "comment", - regex : "#.*$" + regex : /(^\s*#|;).*$/ }, { token : "text", regex : /\s+/ From 84a8201dfd71b191a75140fa2b1f07a12be5d47d Mon Sep 17 00:00:00 2001 From: baboso Date: Thu, 5 Jun 2014 18:44:20 -0400 Subject: [PATCH 007/127] Removed useless rule --- lib/ace/mode/praat_highlight_rules.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 39220a52..9cf98bcb 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -135,10 +135,6 @@ var PraatHighlightRules = function() { token : ["text", "support.function", "text"], regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/ }, { - // Is this rule necessary? - // token : ["text", "keyword"], - // regex : /(^\s*)(demo\b)/ - // }, { // Object types token : "entity.name.type", regex : "(" + objectTypes + ")" From 299d174dc77c98566dacd547f0c3bfb72c91cbc3 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 22 May 2014 20:26:11 +0400 Subject: [PATCH 008/127] do not use setInnerHTML since it isn't faster on new browsers --- demo/kitchen-sink/demo.js | 2 +- lib/ace/layer/marker.js | 2 +- lib/ace/layer/text.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 0b35ca74..552b1e65 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -592,7 +592,7 @@ env.editSnippets = function() { require("ace/ext/language_tools"); env.editor.setOptions({ enableBasicAutocompletion: true, - enableLiveAutocompletion: true, + enableLiveAutocompletion: false, enableSnippets: true }); diff --git a/lib/ace/layer/marker.js b/lib/ace/layer/marker.js index cd1b992d..37e038b5 100644 --- a/lib/ace/layer/marker.js +++ b/lib/ace/layer/marker.js @@ -93,7 +93,7 @@ var Marker = function(parentEl) { this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config); } } - this.element = dom.setInnerHtml(this.element, html.join("")); + this.element.innerHTML = html.join(""); }; this.$getTop = function(row, layerConfig) { diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 140700aa..748d2231 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -203,7 +203,7 @@ var Text = function(parentEl) { html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false ); lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - dom.setInnerHtml(lineElement, html.join("")); + lineElement.innerHTML = html.join(""); } row++; } @@ -310,7 +310,7 @@ var Text = function(parentEl) { row++; } - this.element = dom.setInnerHtml(this.element, html.join("")); + this.element.innerHTML = html.join(""); }; this.$textToken = { From 109923873ad91ad590a59662c9c4f513db974aec Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 11 Oct 2013 16:30:02 +0400 Subject: [PATCH 009/127] do not hang the browser when edit is called for textarea --- lib/ace/ace.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/ace/ace.js b/lib/ace/ace.js index d7da2fb7..500b458f 100644 --- a/lib/ace/ace.js +++ b/lib/ace/ace.js @@ -79,11 +79,21 @@ exports.edit = function(el) { throw new Error("ace.edit can't find div #" + _id); } - if (el.env && el.env.editor instanceof Editor) + if (el && el.env && el.env.editor instanceof Editor) return el.env.editor; - var doc = exports.createEditSession(dom.getInnerText(el)); - el.innerHTML = ''; + var value = ""; + if (el && /input|textarea/i.test(el.tagName)) { + var oldNode = el; + value = oldNode.value; + el = dom.createElement("pre"); + oldNode.parentNode.replaceChild(el, oldNode); + } else { + value = dom.getInnerText(el); + el.innerHTML = ''; + } + + var doc = exports.createEditSession(value); var editor = new Editor(new Renderer(el)); editor.setSession(doc); @@ -93,11 +103,12 @@ exports.edit = function(el) { editor: editor, onResize: editor.resize.bind(editor, null) }; + if (oldNode) env.textarea = oldNode; event.addListener(window, "resize", env.onResize); editor.on("destroy", function() { event.removeListener(window, "resize", env.onResize); }); - el.env = editor.env = env; + editor.container.env = editor.env = env; return editor; }; From f9b3655c943dee63b7aba01610bd1ee1d88e6878 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 2 Jul 2014 22:24:20 +0400 Subject: [PATCH 010/127] fix autocomplete popup click regression --- lib/ace/autocomplete/popup.js | 1 + lib/ace/keyboard/textinput.js | 14 +++++++++----- lib/ace/mouse/mouse_handler.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index a0ab7604..c8d168a6 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -67,6 +67,7 @@ var AcePopup = function(parentNode) { popup.renderer.setStyle("ace_autocomplete"); popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); var noop = function(){}; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index fbf37786..ed213d70 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -428,13 +428,17 @@ var TextInput = function(parentNode, host) { this.onContextMenu = function(e) { afterContextMenu = true; - if (!tempStyle) - tempStyle = text.style.cssText; - - text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : ""); - resetSelection(host.selection.isEmpty()); host._emit("nativecontextmenu", {target: host, domEvent: e}); + this.moveToMouse(e, true); + }; + + this.moveToMouse = function(e, bringToFront) { + if (!tempStyle) + tempStyle = text.style.cssText; + text.style.cssText = (bringToFront ? "z-index:100000;" : "") + + (useragent.isIE ? "opacity:0.1;" : ""); + var rect = host.container.getBoundingClientRect(); var style = dom.computedStyle(host.container); var top = rect.top + (parseInt(style.borderTopWidth) || 0); diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index ce88eb81..9cf26721 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -49,7 +49,7 @@ var MouseHandler = function(editor) { var focusEditor = function(e) { if (!editor.isFocused() && editor.textInput) - editor.textInput.onContextMenu(e); + editor.textInput.moveToMouse(e); editor.focus() }; From f8be5072ac0d3ea6befade28a53c4e4c8fbbab96 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 2 Jul 2014 23:56:24 +0400 Subject: [PATCH 011/127] allow using name instead of caption --- lib/ace/autocomplete/popup.js | 2 +- lib/ace/autocomplete/text_completer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js index c8d168a6..a34ebf09 100644 --- a/lib/ace/autocomplete/popup.js +++ b/lib/ace/autocomplete/popup.js @@ -179,7 +179,7 @@ var AcePopup = function(parentNode) { if (typeof data == "string") data = {value: data}; if (!data.caption) - data.caption = data.value; + data.caption = data.value || data.name; var last = -1; var flag, c; diff --git a/lib/ace/autocomplete/text_completer.js b/lib/ace/autocomplete/text_completer.js index 6eebfc61..17a4bdad 100644 --- a/lib/ace/autocomplete/text_completer.js +++ b/lib/ace/autocomplete/text_completer.js @@ -68,7 +68,7 @@ define(function(require, exports, module) { var wordList = Object.keys(wordScore); callback(null, wordList.map(function(word) { return { - name: word, + caption: word, value: word, score: wordScore[word], meta: "local" From 8ed27996207ed25e1e0a4b9ce7394b805ee7ce40 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 3 Jul 2014 00:12:27 +0400 Subject: [PATCH 012/127] do not close the popup if there are matching completions --- lib/ace/autocomplete.js | 13 ++++++------- lib/ace/ext/language_tools.js | 4 ---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index adf9bd73..13d140d9 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -101,12 +101,12 @@ var Autocomplete = function() { this.changeTimer.cancel(); if (this.popup && this.popup.isOpen) { - this.gatherCompletionsId = this.gatherCompletionsId + 1; - } - - if (this.popup) + this.gatherCompletionsId += 1; this.popup.hide(); - + } + + if (this.base) + this.base.detach(); this.activated = false; this.completions = this.base = null; }; @@ -205,8 +205,7 @@ var Autocomplete = function() { var line = session.getLine(pos.row); var prefix = util.retrievePrecedingIdentifier(line, pos.column); - this.base = editor.getCursorPosition(); - this.base.column -= prefix.length; + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); var matches = []; var total = editor.completers.length; diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index dc56e6e0..d8b2a1dd 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -161,10 +161,6 @@ var doLiveAutocomplete = function(e) { editor.completer.autoSelect = false; editor.completer.autoInsert = false; editor.completer.showPopup(editor); - } else if (!prefix && hasCompleter) { - // When the prefix is empty - // close the autocomplete dialog - editor.completer.detach(); } } }; From bf72097811c2285a4999b527c79b24ef5d3ea070 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 4 Jul 2014 11:25:53 -0700 Subject: [PATCH 013/127] add a gitignore mode --- demo/kitchen-sink/docs/gitignore.gitignore | 8 +++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/gitignore.js | 19 +++++++++++++++ lib/ace/mode/gitignore_highlight_rules.js | 28 ++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 demo/kitchen-sink/docs/gitignore.gitignore create mode 100644 lib/ace/mode/gitignore.js create mode 100644 lib/ace/mode/gitignore_highlight_rules.js diff --git a/demo/kitchen-sink/docs/gitignore.gitignore b/demo/kitchen-sink/docs/gitignore.gitignore new file mode 100644 index 00000000..80f4f386 --- /dev/null +++ b/demo/kitchen-sink/docs/gitignore.gitignore @@ -0,0 +1,8 @@ +# A sample .gitiignore file. + +.buildlog +.DS_Store +.svn + +# Also ignore user settings... +/.settings diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 57470ed0..15a31610 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -70,6 +70,7 @@ var supportedModes = { Forth: ["frt|fs|ldr"], FTL: ["ftl"], Gherkin: ["feature"], + Gitignore: ["^.gitignore"], Glsl: ["glsl|frag|vert"], golang: ["go"], Groovy: ["groovy"], diff --git a/lib/ace/mode/gitignore.js b/lib/ace/mode/gitignore.js new file mode 100644 index 00000000..fd9b04f4 --- /dev/null +++ b/lib/ace/mode/gitignore.js @@ -0,0 +1,19 @@ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var GitignoreHighlightRules = require("./gitignore_highlight_rules").GitignoreHighlightRules; + +var Mode = function() { + this.HighlightRules = GitignoreHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.$id = "ace/mode/gitignore"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/gitignore_highlight_rules.js b/lib/ace/mode/gitignore_highlight_rules.js new file mode 100644 index 00000000..8889511d --- /dev/null +++ b/lib/ace/mode/gitignore_highlight_rules.js @@ -0,0 +1,28 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var GitignoreHighlightRules = function() { + this.$rules = { + "start" : [ + { + token : "comment", + regex : /[#].*$/ + } + ] + }; + + this.normalizeRules(); +}; + +GitignoreHighlightRules.metaData = { + fileTypes: ['gitignore'], + name: 'Gitignore' +}; + +oop.inherits(GitignoreHighlightRules, TextHighlightRules); + +exports.GitignoreHighlightRules = GitignoreHighlightRules; +}); From e6f01878d7a6f800bbf62ffc5f3a459bd9d75bbf Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 4 Jul 2014 11:35:07 -0700 Subject: [PATCH 014/127] add snippets; fix the kitchensink demo --- demo/kitchen-sink/docs/{gitignore.gitignore => .gitignore} | 2 +- lib/ace/snippets/gitignore.js | 7 +++++++ lib/ace/snippets/gitignore.snippets | 0 3 files changed, 8 insertions(+), 1 deletion(-) rename demo/kitchen-sink/docs/{gitignore.gitignore => .gitignore} (70%) create mode 100644 lib/ace/snippets/gitignore.js create mode 100644 lib/ace/snippets/gitignore.snippets diff --git a/demo/kitchen-sink/docs/gitignore.gitignore b/demo/kitchen-sink/docs/.gitignore similarity index 70% rename from demo/kitchen-sink/docs/gitignore.gitignore rename to demo/kitchen-sink/docs/.gitignore index 80f4f386..17e256b1 100644 --- a/demo/kitchen-sink/docs/gitignore.gitignore +++ b/demo/kitchen-sink/docs/.gitignore @@ -1,4 +1,4 @@ -# A sample .gitiignore file. +# A sample .gitignore file. .buildlog .DS_Store diff --git a/lib/ace/snippets/gitignore.js b/lib/ace/snippets/gitignore.js new file mode 100644 index 00000000..0a632c99 --- /dev/null +++ b/lib/ace/snippets/gitignore.js @@ -0,0 +1,7 @@ +define(function(require, exports, module) { +"use strict"; + +exports.snippetText = require("../requirejs/text!./gitignore.snippets"); +exports.scope = "gitignore"; + +}); diff --git a/lib/ace/snippets/gitignore.snippets b/lib/ace/snippets/gitignore.snippets new file mode 100644 index 00000000..e69de29b From cc03e77327fc7c83ed4983974b49105628d65039 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 7 Jul 2014 08:17:25 -0700 Subject: [PATCH 015/127] review comments --- demo/kitchen-sink/docs/.gitignore | 3 +++ lib/ace/mode/gitignore_highlight_rules.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/demo/kitchen-sink/docs/.gitignore b/demo/kitchen-sink/docs/.gitignore index 17e256b1..56ec8fd9 100644 --- a/demo/kitchen-sink/docs/.gitignore +++ b/demo/kitchen-sink/docs/.gitignore @@ -4,5 +4,8 @@ .DS_Store .svn +# Negated patterns: +!foo.bar + # Also ignore user settings... /.settings diff --git a/lib/ace/mode/gitignore_highlight_rules.js b/lib/ace/mode/gitignore_highlight_rules.js index 8889511d..cfa42afa 100644 --- a/lib/ace/mode/gitignore_highlight_rules.js +++ b/lib/ace/mode/gitignore_highlight_rules.js @@ -9,7 +9,10 @@ var GitignoreHighlightRules = function() { "start" : [ { token : "comment", - regex : /[#].*$/ + regex : /^\s*#.*$/ + }, { + token : "keyword", // negated patterns + regex : /^\s*!.*$/ } ] }; From 4904f74dbdcc21a0a58852f55194a81864ebf8cf Mon Sep 17 00:00:00 2001 From: baboso Date: Tue, 8 Jul 2014 15:18:57 -0400 Subject: [PATCH 016/127] Minor changes to Praat syntax files --- demo/kitchen-sink/docs/praat.praat | 16 +++++++++ lib/ace/mode/praat_highlight_rules.js | 51 ++++++++++++++------------- lib/ace/snippets/praat.js | 7 ++++ lib/ace/snippets/praat.snippets | 0 4 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 lib/ace/snippets/praat.js create mode 100644 lib/ace/snippets/praat.snippets diff --git a/demo/kitchen-sink/docs/praat.praat b/demo/kitchen-sink/docs/praat.praat index c5dde785..3700ae6f 100644 --- a/demo/kitchen-sink/docs/praat.praat +++ b/demo/kitchen-sink/docs/praat.praat @@ -59,6 +59,22 @@ for i from 1 to n selectObject(sound[i]) selectObject: sound + # Pause commands + beginPause("Viewing " + sound$) + if i > 1 + button = endPause("Stop", "Previous", + ...if i = total_sounds then "Finish" else "Next" fi, + ...3, 1) + else + button = endPause("Stop", + ...if i = total_sounds then "Finish" else "Next" fi, + ...2, 1) + endif + editor_name$ = if total_textgrids then "TextGrid " else "Sound " fi + name$ + nocheck editor 'editor_name$' + nocheck Close + nocheck endeditor + # New-style standalone command call Rename: "SomeName" diff --git a/lib/ace/mode/praat_highlight_rules.js b/lib/ace/mode/praat_highlight_rules.js index 9cf98bcb..8b826487 100644 --- a/lib/ace/mode/praat_highlight_rules.js +++ b/lib/ace/mode/praat_highlight_rules.js @@ -74,27 +74,28 @@ var PraatHighlightRules = function() { ); var objectTypes = ( - "Collection|Strings|ManPages|SortedSetOfString|Sound|Matrix|Polygon|" + - "PointProcess|ParamCurve|Spectrum|Ltas|Spectrogram|Formant|" + - "Excitation|Cochleagram|VocalTract|FormantPoint|FormantTier|" + - "FormantGrid|Label|Tier|Autosegment|Intensity|Pitch|Harmonicity|" + - "Transition|RealPoint|RealTier|PitchTier|IntensityTier|DurationTier|" + - "AmplitudeTier|SpectrumTier|Manipulation|TextPoint|TextInterval|" + - "TextTier|IntervalTier|TextGrid|LongSound|WordList|SpellingChecker|" + - "Movie|Corpus|TableOfReal|Distributions|PairDistribution|Table|" + - "LinearRegression|LogisticRegression|Art|Artword|Speaker|Activation|" + - "BarkFilter|Categories|Cepstrum|CCA|ChebyshevSeries|" + - "ClassificationTable|Confusion|Correlation|Covariance|Discriminant|" + - "DTW|Eigen|Excitations|FormantFilter|Index|KlattTable|Permutation|" + - "ISpline|LegendreSeries|MelFilter|MSpline|Pattern|PCA|Polynomial|" + - "Roots|SimpleString|StringsIndex|SpeechSynthesizer|SPINET|SSCP|SVD|" + - "AffineTransform|Procrustes|ContingencyTable|Dissimilarity|" + - "Similarity|Configuration|Distance|Salience|ScalarProduct|Weight|" + - "KlattGrid|HMM|HMM_State|HMM_Observation|HMM_ObservationSequence|" + - "HMM_StateSequence|GaussianMixture|Diagonalizer|MixingMatrix|" + - "CrossCorrelationTable|CrossCorrelationTables|Network|OTGrammar|" + - "OTHistory|OTMulti|FFNet|Cepstrumc|LPC|LFCC|MFCC|ExperimentMFC|" + - "ResultsMFC|EEG|ERPTier|ERP|KNN|FeatureWeights" + "Activation|AffineTransform|AmplitudeTier|Art|Artword|Autosegment|" + + "BarkFilter|CCA|Categories|Cepstrum|Cepstrumc|ChebyshevSeries|" + + "ClassificationTable|Cochleagram|Collection|Configuration|" + + "Confusion|ContingencyTable|Corpus|Correlation|Covariance|" + + "CrossCorrelationTable|CrossCorrelationTables|DTW|Diagonalizer|" + + "Discriminant|Dissimilarity|Distance|Distributions|DurationTier|" + + "EEG|ERP|ERPTier|Eigen|Excitation|Excitations|ExperimentMFC|FFNet|" + + "FeatureWeights|Formant|FormantFilter|FormantGrid|FormantPoint|" + + "FormantTier|GaussianMixture|HMM|HMM_Observation|" + + "HMM_ObservationSequence|HMM_State|HMM_StateSequence|Harmonicity|" + + "ISpline|Index|Intensity|IntensityTier|IntervalTier|KNN|KlattGrid|" + + "KlattTable|LFCC|LPC|Label|LegendreSeries|LinearRegression|" + + "LogisticRegression|LongSound|Ltas|MFCC|MSpline|ManPages|" + + "Manipulation|Matrix|MelFilter|MixingMatrix|Movie|Network|" + + "OTGrammar|OTHistory|OTMulti|PCA|PairDistribution|ParamCurve|" + + "Pattern|Permutation|Pitch|PitchTier|PointProcess|Polygon|" + + "Polynomial|Procrustes|RealPoint|RealTier|ResultsMFC|Roots|SPINET|" + + "SSCP|SVD|Salience|ScalarProduct|Similarity|SimpleString|" + + "SortedSetOfString|Sound|Speaker|Spectrogram|Spectrum|SpectrumTier|" + + "SpeechSynthesizer|SpellingChecker|Strings|StringsIndex|Table|" + + "TableOfReal|TextGrid|TextInterval|TextPoint|TextTier|Tier|" + + "Transition|VocalTract|Weight|WordList" ); // regexp must not have capturing parentheses. Use (?:) instead. @@ -103,6 +104,10 @@ var PraatHighlightRules = function() { this.$rules = { "start" : [ { + // Interpolated strings + token : "string.interpolated", + regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/ + }, { // stopwatch token : ["text", "text", "keyword.operator", "text", "keyword"], regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(stopwatch)/ @@ -156,10 +161,6 @@ var PraatHighlightRules = function() { token : "keyword", regex : "(\\b(?:" + keywords + ")\\b)" }, { - // Interpolated strings - token : "string.interpolated", - regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/ - }, { // Generic strings token : "string", regex : /"[^"]*"/ diff --git a/lib/ace/snippets/praat.js b/lib/ace/snippets/praat.js new file mode 100644 index 00000000..18afa87f --- /dev/null +++ b/lib/ace/snippets/praat.js @@ -0,0 +1,7 @@ +define(function(require, exports, module) { +"use strict"; + +exports.snippetText = require("../requirejs/text!./praat.snippets"); +exports.scope = "praat"; + +}); diff --git a/lib/ace/snippets/praat.snippets b/lib/ace/snippets/praat.snippets new file mode 100644 index 00000000..e69de29b From a3bb907f46b7c8c1d939ad2cf4f0d4ed543f18d3 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 9 Jul 2014 18:32:00 +0400 Subject: [PATCH 017/127] v1.1.5 --- ChangeLog.txt | 8 ++++++++ build | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 224f9326..589d9a46 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +2014.07.09 Version 1.1.5 + +* Bugfixes + - fix regression in autocomplete popup + +* new language modes + - gitignore (Devon Carew) + 2014.07.01 Version 1.1.4 * New Features diff --git a/build b/build index b85b38c1..cbc08e4e 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit b85b38c1e33e161826f4dd7774ef73aac55e0d14 +Subproject commit cbc08e4ebc4843eebec8dcd213751cb0d64c955b From a885aea2f0300fc74cc672cf63dbbb3544ae3793 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 9 Jul 2014 16:22:24 -0700 Subject: [PATCH 018/127] add the show and hide keywords to the dart mode --- lib/ace/mode/dart_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/dart_highlight_rules.js b/lib/ace/mode/dart_highlight_rules.js index 750392f7..0cd5811b 100644 --- a/lib/ace/mode/dart_highlight_rules.js +++ b/lib/ace/mode/dart_highlight_rules.js @@ -54,7 +54,7 @@ var DartHighlightRules = function() { }, { token: "keyword.other.import.dart", - regex: "(?:\\b)(?:library|import|export|part|of)(?:\\b)" + regex: "(?:\\b)(?:library|import|export|part|of|show|hide)(?:\\b)" }, { token : ["keyword.other.import.dart", "text"], From fd182ea76f370b31482e508c97ab8b8a45adb73a Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 10 Jul 2014 12:56:11 +0100 Subject: [PATCH 019/127] Redraw lines and active line highlight when offscreen updates are made When setUseWrapMode is true, if some text is inserted into a line which is above the cursor and offscreen, then the renderer did not previously redraw the lines or active line highlight. However, if this insert causes the line to wrap onto another line then everything is shifted down by one visual line, leaving the onscreen lines in an out of date state. With this commit, the onscreen lines and active line highlight are now redrawn when this happens. --- lib/ace/editor.js | 1 + lib/ace/virtual_renderer.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 6a68e5de..e198ecaa 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -708,6 +708,7 @@ var Editor = function(renderer, session) { // update cursor because tab characters can influence the cursor position this.$cursorChange(); + this.$updateHighlightActiveLine(); }; this.onTokenizerUpdate = function(e) { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 33f3a906..dfb435be 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -276,8 +276,13 @@ var VirtualRenderer = function(container, theme) { this.$changedLines.lastRow = lastRow; } - if (this.$changedLines.firstRow > this.layerConfig.lastRow || - this.$changedLines.lastRow < this.layerConfig.firstRow) + // If the change happened offscreen above us then it's possible + // that a new line wrap will affect the position of the lines on our + // screen so they need redrawn. + if (this.$changedLines.lastRow < this.layerConfig.firstRow) + this.$changedLines.lastRow = this.layerConfig.lastRow + + if (this.$changedLines.firstRow > this.layerConfig.lastRow) return; this.$loop.schedule(this.CHANGE_LINES); }; From 0afb5f6da6921be6ff41407deb3b14bec6ac6df1 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Tue, 15 Jul 2014 01:38:50 +0200 Subject: [PATCH 020/127] Update latex.js Most of LaTeX is text. Word wrapping etc. should behave accordingly. --- lib/ace/mode/latex.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ace/mode/latex.js b/lib/ace/mode/latex.js index 1f8c07cb..24048d5e 100644 --- a/lib/ace/mode/latex.js +++ b/lib/ace/mode/latex.js @@ -14,6 +14,8 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { + this.type = "text"; + this.lineCommentStart = "%"; this.$id = "ace/mode/latex"; From d3d2e0823ba25a53a244338cf2466c2b786b572c Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 11 Jul 2014 16:07:12 +0400 Subject: [PATCH 021/127] fix Double tapping to select words doesn't work reliably --- demo/kitchen-sink/demo.js | 21 ++---------------- lib/ace/lib/event.js | 2 ++ lib/ace/mouse/default_handlers.js | 34 +++++++++++------------------ lib/ace/mouse/mouse_handler_test.js | 8 +++---- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 552b1e65..c7beb3d0 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -415,28 +415,11 @@ bindDropdown("folding", function(value) { }); bindDropdown("soft_wrap", function(value) { - var session = env.editor.session; - var renderer = env.editor.renderer; - switch (value) { - case "off": - session.setUseWrapMode(false); - renderer.setPrintMarginColumn(80); - break; - case "free": - session.setUseWrapMode(true); - session.setWrapLimitRange(null, null); - renderer.setPrintMarginColumn(80); - break; - default: - session.setUseWrapMode(true); - var col = parseInt(value, 10); - session.setWrapLimitRange(col, col); - renderer.setPrintMarginColumn(col); - } + env.editor.setOption("wrap", value); }); bindCheckbox("select_style", function(checked) { - env.editor.setSelectionStyle(checked ? "line" : "text"); + env.editor.setOption("selectionStyle", checked ? "line" : "text"); }); bindCheckbox("highlight_active", function(checked) { diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js index 612b6a34..b8e2199d 100644 --- a/lib/ace/lib/event.js +++ b/lib/ace/lib/event.js @@ -191,6 +191,8 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac startY = e.clientY; } } + + e._clicks = clicks; eventHandler[callbackName]("mousedown", e); diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index e7a31540..48d09ee4 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -71,21 +71,20 @@ function DefaultHandlers(mouseHandler) { var selectionRange = editor.getSelectionRange(); var selectionEmpty = selectionRange.isEmpty(); - if (selectionEmpty) { + if (selectionEmpty) editor.selection.moveToPosition(pos); - } // 2: contextmenu, 1: linux paste editor.textInput.onContextMenu(ev.domEvent); return; // stopping event here breaks contextmenu on ff mac } + this.mousedownEvent.time = Date.now(); // if this click caused the editor to be focused should not clear the // selection if (inSelection && !editor.isFocused()) { editor.focus(); if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) { - this.mousedownEvent.time = Date.now(); this.setState("focusWait"); this.captureMouse(ev); return; @@ -93,31 +92,21 @@ function DefaultHandlers(mouseHandler) { } this.captureMouse(ev); - if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) { - // Directly pick STATE_SELECT, since the user is not clicking inside - // a selection. - this.startSelect(pos); - } else if (inSelection) { - this.mousedownEvent.time = Date.now(); - this.startSelect(pos); - } + this.startSelect(pos, ev.domEvent._clicks > 1); return ev.preventDefault(); }; - this.startSelect = function(pos) { + this.startSelect = function(pos, waitForClickSelection) { pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y); var editor = this.editor; // allow double/triple click handlers to change selection - var shiftPressed = this.mousedownEvent.getShiftKey(); - setTimeout(function(){ - if (shiftPressed) { - editor.selection.selectToPosition(pos); - } - else if (!this.$clickSelection) { - editor.selection.moveToPosition(pos); - } + + if (this.mousedownEvent.getShiftKey()) + editor.selection.selectToPosition(pos); + else if (!waitForClickSelection) + editor.selection.moveToPosition(pos); + if (!waitForClickSelection) this.select(); - }.bind(this), 0); if (editor.renderer.scroller.setCapture) { editor.renderer.scroller.setCapture(); } @@ -216,6 +205,7 @@ function DefaultHandlers(mouseHandler) { this.setState("selectByWords"); } this.$clickSelection = range; + this.select(); }; this.onTripleClick = function(ev) { @@ -230,6 +220,7 @@ function DefaultHandlers(mouseHandler) { } else { this.$clickSelection = editor.selection.getLineRange(pos.row); } + this.select(); }; this.onQuadClick = function(ev) { @@ -238,6 +229,7 @@ function DefaultHandlers(mouseHandler) { editor.selectAll(); this.$clickSelection = editor.getSelectionRange(); this.setState("selectAll"); + this.select(); }; this.onMouseWheel = function(ev) { diff --git a/lib/ace/mouse/mouse_handler_test.js b/lib/ace/mouse/mouse_handler_test.js index 571acdac..96374d71 100644 --- a/lib/ace/mouse/mouse_handler_test.js +++ b/lib/ace/mouse/mouse_handler_test.js @@ -58,17 +58,15 @@ module.exports = { next(); }, - "test: double tap. issue #956" : function(done) { + "test: double tap. issue #956" : function() { // mouse up fired immediately after mouse down var target = this.editor.renderer.getMouseEventTarget(); target.dispatchEvent(MouseEvent("down", {x: 1, y: 1})); target.dispatchEvent(MouseEvent("up", {x: 1, y: 1})); target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2})); target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2})); - setTimeout(function() { - assert.equal(this.editor.getSelectedText(), "Juhu"); - done(); - }.bind(this)); + + assert.equal(this.editor.getSelectedText(), "Juhu"); } }; From c1c08945b23682eff67752ac0bc58d8b2efe813f Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 16 Jul 2014 22:46:35 +0400 Subject: [PATCH 022/127] do not scroll cursor into view after quad click --- lib/ace/mouse/default_handlers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 48d09ee4..bbd85484 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -229,7 +229,6 @@ function DefaultHandlers(mouseHandler) { editor.selectAll(); this.$clickSelection = editor.getSelectionRange(); this.setState("selectAll"); - this.select(); }; this.onMouseWheel = function(ev) { From a52b30317ba665d81df1c7e1a1b48399504917d5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 11 Jul 2014 17:03:34 +0400 Subject: [PATCH 023/127] add heredoc support for sh mode --- lib/ace/mode/sh_highlight_rules.js | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/ace/mode/sh_highlight_rules.js b/lib/ace/mode/sh_highlight_rules.js index 73ece2f8..43f536f4 100644 --- a/lib/ace/mode/sh_highlight_rules.js +++ b/lib/ace/mode/sh_highlight_rules.js @@ -99,6 +99,62 @@ var ShHighlightRules = function() { }, { defaultToken: "string" }] + }, { + stateName: "heredoc", + onMatch : function(value, currentState, stack) { + var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; + var tokens = value.split(this.splitRegex); + stack.push(next, tokens[4]); + return [ + {type:"constant", value: tokens[1]}, + {type:"text", value: tokens[2]}, + {type:"string", value: tokens[3]}, + {type:"support.class", value: tokens[4]}, + {type:"string", value: tokens[5]} + ]; + }, + regex : "(<<-?)(\\s*)(['\"`]?)([\\w\-]+)(['\"`]?)", + rules: { + heredoc: [{ + onMatch: function(value, currentState, stack) { + if (value === stack[1]) { + stack.shift(); + stack.shift(); + this.next = stack[0] || "start"; + return "support.class"; + } + this.next = ""; + return "string"; + }, + regex: ".*$", + next: "start" + }], + indentedHeredoc: [{ + token: "string", + regex: "^ +" + }, { + onMatch: function(value, currentState, stack) { + if (value === stack[1]) { + stack.shift(); + stack.shift(); + this.next = stack[0] || "start"; + return "support.class"; + } + this.next = ""; + return "string"; + }, + regex: ".*$", + next: "start" + }] + } + }, { + regex : "$", + token : "empty", + next : function(currentState, stack) { + if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc") + return stack[0]; + return currentState; + } }, { token : "variable.language", regex : builtinVariable From 1ad5e66be0f022c14f2fcc1153d301421299fa4c Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 16 Jul 2014 23:27:20 +0400 Subject: [PATCH 024/127] fix #2051 highlighting php string in script tag --- lib/ace/tokenizer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index 64bf59e8..85fa6c7b 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -268,11 +268,14 @@ var Tokenizer = function(rules) { type = rule.token; if (rule.next) { - if (typeof rule.next == "string") + if (typeof rule.next == "string") { + if (stack.length && stack[0] == currentState && stack[1] == rule.next) + stack.shift(); currentState = rule.next; - else + } else { currentState = rule.next(currentState, stack); - + } + state = this.states[currentState]; if (!state) { window.console && console.error && console.error(currentState, "doesn't exist"); From d53c91e41a05b2b32886a58e2d627a8f3a8a2fd7 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 16 Jul 2014 23:29:37 +0400 Subject: [PATCH 025/127] update mode tests --- lib/ace/mode/_test/text_php.txt | 24 ++++ lib/ace/mode/_test/tokens_gitignore.json | 33 +++++ lib/ace/mode/_test/tokens_lsl.json | 2 +- lib/ace/mode/_test/tokens_lua.json | 2 +- lib/ace/mode/_test/tokens_php.json | 39 +++++- lib/ace/mode/_test/tokens_vala.json | 158 +++++++++++++++++++++++ lib/ace/mode/_test/tokens_xquery.json | 44 ------- 7 files changed, 255 insertions(+), 47 deletions(-) create mode 100644 lib/ace/mode/_test/text_php.txt create mode 100644 lib/ace/mode/_test/tokens_gitignore.json create mode 100644 lib/ace/mode/_test/tokens_vala.json delete mode 100644 lib/ace/mode/_test/tokens_xquery.json diff --git a/lib/ace/mode/_test/text_php.txt b/lib/ace/mode/_test/text_php.txt new file mode 100644 index 00000000..b76aa8a5 --- /dev/null +++ b/lib/ace/mode/_test/text_php.txt @@ -0,0 +1,24 @@ + not &js; diff --git a/lib/ace/mode/_test/tokens_gitignore.json b/lib/ace/mode/_test/tokens_gitignore.json new file mode 100644 index 00000000..8689a724 --- /dev/null +++ b/lib/ace/mode/_test/tokens_gitignore.json @@ -0,0 +1,33 @@ +[[ + "start", + ["comment","# A sample .gitignore file."] +],[ + "start" +],[ + "start", + ["text",".buildlog"] +],[ + "start", + ["text",".DS_Store"] +],[ + "start", + ["text",".svn"] +],[ + "start" +],[ + "start", + ["comment","# Negated patterns:"] +],[ + "start", + ["keyword","!foo.bar"] +],[ + "start" +],[ + "start", + ["comment","# Also ignore user settings..."] +],[ + "start", + ["text","/.settings"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_lsl.json b/lib/ace/mode/_test/tokens_lsl.json index 93575a2c..2248a607 100644 --- a/lib/ace/mode/_test/tokens_lsl.json +++ b/lib/ace/mode/_test/tokens_lsl.json @@ -500,4 +500,4 @@ ["paren.rparen.lsl","}"] ],[ "start" -]] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_lua.json b/lib/ace/mode/_test/tokens_lua.json index 3fde966d..b60c7cb1 100644 --- a/lib/ace/mode/_test/tokens_lua.json +++ b/lib/ace/mode/_test/tokens_lua.json @@ -345,4 +345,4 @@ ["text"," "], ["comment","--[[ blah ]]"], ["paren.rparen",")"] -]] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_php.json b/lib/ace/mode/_test/tokens_php.json index d8a41eec..d1458a65 100644 --- a/lib/ace/mode/_test/tokens_php.json +++ b/lib/ace/mode/_test/tokens_php.json @@ -129,6 +129,43 @@ ],[ "php-start" ],[ - "start", + ["php-start","js-start"], + ["support.php_tag","?>"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text"," "], + ["support.php_tag",""] +],[ + "js-comment_regex_allowed", + ["comment","/*this is js "], + ["support.php_tag",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," not "], + ["constant.language.escape.reference.xml","&js;"] +],[ + "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_vala.json b/lib/ace/mode/_test/tokens_vala.json new file mode 100644 index 00000000..efe6e7c8 --- /dev/null +++ b/lib/ace/mode/_test/tokens_vala.json @@ -0,0 +1,158 @@ +[[ + "start", + ["meta.using.vala",""], + ["keyword.other.using.vala","using"], + ["meta.using.vala"," "], + ["storage.modifier.using.vala","Gtk"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text"," "] +],[ + "text0", + ["storage.type.primitive.array.vala","int"], + ["text"," main ("], + ["storage.type.primitive.array.vala","string"], + ["text","[] args) {"] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","init ("], + ["storage.modifier.vala","ref"], + ["text"," args)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," foo "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.generic.vala","MyFoo>"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0" +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," window "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Window"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","title "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","border_width "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["constant.numeric.vala","10"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","window_position "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["storage.type.vala","WindowPosition"], + ["keyword.operator.dereference.vala","."], + ["constant.other.vala","CENTER"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","set_default_size("], + ["constant.numeric.vala","350"], + ["text",", "], + ["constant.numeric.vala","70"], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","destroy"], + ["keyword.operator.dereference.vala","."], + ["text","connect("], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main_quit)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," label "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Label"], + ["text","("], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","add(label)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","show_all()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["keyword.control.vala","return"], + ["text"," "], + ["constant.numeric.vala","0"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_xquery.json b/lib/ace/mode/_test/tokens_xquery.json deleted file mode 100644 index aaf9ab9b..00000000 --- a/lib/ace/mode/_test/tokens_xquery.json +++ /dev/null @@ -1,44 +0,0 @@ -[[ - "[\"start\"]", - ["keyword","xquery"], - ["text"," "], - ["keyword","version"], - ["text"," "], - ["string","\""], - ["string","1.0"], - ["string","\""], - ["text",";"] -],[ - "[\"start\"]" -],[ - "[\"start\"]", - ["keyword","let"], - ["text"," "], - ["variable","$message"], - ["text"," "], - ["keyword.operator",":="], - ["text"," "], - ["string","\""], - ["string","Hello World!"], - ["string","\""] -],[ - "[\"start\",\"StartTag\",\"TagContent\"]", - ["keyword","return"], - ["text"," "], - ["meta.tag",""] -],[ - "[\"start\",\"StartTag\",\"TagContent\"]", - ["text"," "], - ["meta.tag",""], - ["text","{"], - ["variable","$message"], - ["text","}"], - ["meta.tag",""] -],[ - "[\"start\"]", - ["meta.tag",""] -],[ - "[\"start\"]" -]] \ No newline at end of file From fcd1dbb98d5ee96b8615577334e585645114f01a Mon Sep 17 00:00:00 2001 From: Conaclos Date: Sun, 20 Jul 2014 17:22:21 +0200 Subject: [PATCH 026/127] Adding Eiffel language mode. - Adding Eiffel highlight rules and Eiffel mode - Use Sudoku grid example of Eiffel Rosetta Code project as Eiffel example --- demo/kitchen-sink/docs/eiffel.e | 246 +++++++++++++++++++++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/eiffel.js | 51 +++++ lib/ace/mode/eiffel_highlight_rules.js | 143 ++++++++++++++ 4 files changed, 441 insertions(+) create mode 100644 demo/kitchen-sink/docs/eiffel.e create mode 100644 lib/ace/mode/eiffel.js create mode 100644 lib/ace/mode/eiffel_highlight_rules.js diff --git a/demo/kitchen-sink/docs/eiffel.e b/demo/kitchen-sink/docs/eiffel.e new file mode 100644 index 00000000..4b349566 --- /dev/null +++ b/demo/kitchen-sink/docs/eiffel.e @@ -0,0 +1,246 @@ +note + description: "[ + Sudoku grid and simple resolution facilities. + ]" + author: "Victorien ELVINGER" + date: "22 August 2013" + revision: "3" + libraries: "Relies on ARRAY2 from EiffelBase" + +class + SUDOKU_GRID + +inherit + + ANY + redefine + default_create, + out + end + +create + default_create + +feature {NONE} -- Creation + + default_create + -- Create an empty grid. + do + create grid.make_filled (Default_value, 9, 9) + ensure then + unsolved: not solved + end + +feature -- Access + + item alias "[]" (a_row, a_column: INTEGER): INTEGER assign put + -- Value at coordinates (`a_row', `a_column'). + require + valid_row (a_row) + valid_column (a_column) + do + Result := grid [a_row, a_column] + end + + out: STRING + -- Printable representation. + do + Result := "" + across column_range as column_ic loop + across row_range as row_ic loop + Result := Result + grid [row_ic.item, column_ic.item].out + " " + end + Result := Result + "%N" + end + end + + column_range: INTEGER_INTERVAL + -- Column interval. + do + Result := 1 |..| grid.width + end + + row_range: INTEGER_INTERVAL + -- Row interval. + do + Result := 1 |..| grid.height + end + + subgrid_column_range (a_column: INTEGER): INTEGER_INTERVAL + -- Colum interval of the subgrids including `a_column'. + require + valid_column (a_column) + local + l_column: like a_column + do + l_column := ((a_column - 1) // 3)*3 + 1 + Result := l_column |..| (l_column + 2) + ensure + lower_bound: (<<1, 4, 7>>).has (Result.lower) + upper_bound: (<<3, 6, 9>>).has (Result.upper) + end + + subgrid_row_range (a_row: INTEGER): INTEGER_INTERVAL + -- Row interval of the subgrids including `a_row'. + require + valid_row (a_row) + local + l_row: like a_row + do + l_row := ((a_row - 1) // 3) * 3 + 1 + Result := l_row |..| (l_row + 2) + ensure + lower_bound: (<<1, 4, 7>>).has (Result.lower) + upper_bound: (<<3, 6, 9>>).has (Result.upper) + end + +feature -- Status report + + solved: BOOLEAN + -- Is completed? + + valid_column (a_column: INTEGER): BOOLEAN + -- Is `a_column' a valid coordinate? + do + Result := 1 <= a_column and a_column <= grid.width + end + + valid_row (a_row: INTEGER): BOOLEAN + -- Is `a_row' a valid coordinate? + do + Result := 1 <= a_row and a_row <= grid.height + end + + valid_value (a_value: INTEGER): BOOLEAN + -- Is `a_value' a valid item? + do + Result := 1 <= a_value and a_value <= 9 + end + + valid (a_value: INTEGER; a_row, a_column: INTEGER): BOOLEAN + -- Can `a_value' be inserted at coordinates (`a_row', `a_column')? + require + valid_value (a_value) + valid_row (a_row) + valid_column (a_column) + do + Result := not (subgrid_has (a_value, a_row, a_column) or row_has (a_value, a_row) or column_has (a_value, a_column)) + end + + subgrid_has (a_value: INTEGER; a_row, a_column: INTEGER): BOOLEAN + -- Is there `a_value' in the subgrid containing coordinates (`a_row', `a_column')? + require + valid_row (a_row) + valid_column (a_column) + do + across + subgrid_row_range (a_row) as row_ic + until + Result + loop + across + subgrid_column_range (a_column) as column_ic + until + Result + loop + Result := grid [row_ic.item, column_ic.item] = a_value + end + end + end + + row_has (a_value: INTEGER; a_row: INTEGER): BOOLEAN + -- Exist there an item `a_value' at coordinates (`a_row', ?)? + require + valid_row (a_row) + do + Result := across column_range as ic some grid [a_row, ic.item] = a_value end + end + + column_has (a_value: INTEGER; a_column: INTEGER): BOOLEAN + -- Exist there an item `a_value' at coordinates (?, `a_column')? + require + valid_column (a_column) + do + Result := across row_range as ic some grid [ic.item, a_column] = a_value end + end + +feature -- Extension + + put (a_value: INTEGER; a_row, a_column: INTEGER) + -- Assign item `a_value' at coordinates (`a_row', `a_column'). + require + valid_value (a_value) + valid_row (a_row) + valid_column (a_column) + valid (a_value, a_row, a_column) + do + grid [a_row, a_column] := a_value + ensure + item_inserted: grid [a_row, a_column] = a_value + end + +feature -- Change + + solve + -- Try to solve grid. + do + sub_solve (1, 1) + end + +feature {NONE} -- Implementation + + grid: ARRAY2 [INTEGER] + -- Board. + + Default_value: INTEGER = 0 + -- Empty cell content. + + sub_solve (a_row, a_column: INTEGER) + -- Solve grid from row `a_row' and column `a_column'. + require + valid_row (a_row) + valid_column (a_column) + do + if valid_value (grid [a_row, a_column]) then + solve_after (a_row, a_column) + else + across + 1 |..| 9 as ic + until + solved + loop + if valid (ic.item, a_row, a_column) then + put (ic.item, a_row, a_column) + solve_after (a_row, a_column) + + if not solved then + grid [a_row, a_column] := Default_value + end + end + end + end + end + + solve_after (a_row, a_column: INTEGER) + -- Solve the next cell. + require + valid_row (a_row) + valid_column (a_column) + do + if a_column = grid.width then + if a_row = grid.height then + solved := True + else + sub_solve (a_row + 1, 1) + end + else + sub_solve (a_row, a_column + 1) + end + end + +invariant + valid_numbers: solved implies across grid as ic all valid_value (ic.item) end + nine_columns: grid.width = 9 + nine_rows: grid.height = 9 + +end diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 2028386e..53b78f00 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -65,6 +65,7 @@ var supportedModes = { Diff: ["diff|patch"], Dockerfile: ["^Dockerfile"], Dot: ["dot"], + Eiffel: ["e"], Erlang: ["erl|hrl"], EJS: ["ejs"], Forth: ["frt|fs|ldr"], diff --git a/lib/ace/mode/eiffel.js b/lib/ace/mode/eiffel.js new file mode 100644 index 00000000..2ef84ff8 --- /dev/null +++ b/lib/ace/mode/eiffel.js @@ -0,0 +1,51 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var EiffelHighlightRules = require("./eiffel_highlight_rules").EiffelHighlightRules; +var Range = require("../range").Range; + +var Mode = function() { + this.HighlightRules = EiffelHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.$id = "ace/mode/eiffel"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + diff --git a/lib/ace/mode/eiffel_highlight_rules.js b/lib/ace/mode/eiffel_highlight_rules.js new file mode 100644 index 00000000..f2cc8bd6 --- /dev/null +++ b/lib/ace/mode/eiffel_highlight_rules.js @@ -0,0 +1,143 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var EiffelHighlightRules = function() { + var keywords = "across|agent|alias|all|attached|as|assign|attribute|check|" + + "class|convert|create|debug|deferred|detachable|do|else|elseif|end|" + + "ensure|expanded|export|external|feature|from|frozen|if|inherit|" + + "inspect|invariant|like|local|loop|not|note|obsolete|old|once|" + + "Precursor|redefine|rename|require|rescue|retry|select|separate|" + + "some|then|undefine|until|variant|when"; + + var operatorKeywords = "and|implies|or|xor"; + + var languageConstants = "Void"; + + var booleanConstants = "True|False"; + + var languageVariables = "Current|Result"; + + var keywordMapper = this.createKeywordMapper({ + "constant.language": languageConstants, + "constant.language.boolean": booleanConstants, + "variable.language": languageVariables, + "keyword.operator": operatorKeywords, + "keyword": keywords + }, "identifier", true); + + this.$rules = { + "start": [{ + token : "comment.line.double-dash", + regex : /--.*$/ + }, { + token : "string.quoted.double", + regex : /"(?:%"|[^%])*?"/ + }, { + token : "string.quoted.other", // "[ ]" aligned verbatim string + regex : /"\[/, + next: "aligned_verbatim_string" + }, { + token : "string.quoted.other", // "{ }" non-aligned verbatim string + regex : /"\{/, + next: "non-aligned_verbatim_string" + }, { + token : "constant.character", + regex : /'(?:%%|%T|%R|%N|%F|%'|[^%])'/ + }, { + token : "constant.numeric", // real + regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/ + }, { + token : "constant.numeric", // integer + regex : /\d(?:_?\d)*\b/ + }, { + token : "constant.numeric", // hex + regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/ + }, { + token : "constant.numeric", // octal + regex : /0[cC][0-7](?:_?[0-7])*\b/ + },{ + token : "constant.numeric", // bin + regex : /0[bB][01](?:_?[01])*\b/ + }, { + token : "keyword.operator", + regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./ + }, { + token : "keyword.operator", // punctuation + regex : /\.|:|,|;\b/ + }, { + token : function (v) { + var result = keywordMapper (v); + if (result === "identifier" && v === v.toUpperCase ()) { + result = "entity.name.type"; + } + return result; + }, + regex : /[a-zA-Z][a-zA-Z\d_]*\b/ + }, { + token : "paren.lparen", + regex : /[\[({]/ + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "text", + regex : /\s+/ + } + ], + "aligned_verbatim_string" : [{ + token : "string", // closing multi-line comment + regex : /]"/, + next : "start" + }, { + token : "string", // comment spanning whole line + regex : /[^(?:\]")]+/ + } + ], + "non-aligned_verbatim_string" : [{ + token : "string.quoted.other", // closing multi-line comment + regex : /}"/, + next : "start" + }, { + token : "string.quoted.other", // comment spanning whole line + regex : /[^(?:\}")]+/ + } + ]}; +}; + +oop.inherits(EiffelHighlightRules, TextHighlightRules); + +exports.EiffelHighlightRules = EiffelHighlightRules; +}); From 7e55724c522598378c9d16f8893cf222ad5bf202 Mon Sep 17 00:00:00 2001 From: Conaclos Date: Sun, 20 Jul 2014 19:10:50 +0200 Subject: [PATCH 027/127] Add comment mark in Eiffel mode. --- lib/ace/mode/eiffel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ace/mode/eiffel.js b/lib/ace/mode/eiffel.js index 2ef84ff8..f8ba173b 100644 --- a/lib/ace/mode/eiffel.js +++ b/lib/ace/mode/eiffel.js @@ -42,6 +42,7 @@ var Mode = function() { oop.inherits(Mode, TextMode); (function() { + this.lineCommentStart = "--"; this.$id = "ace/mode/eiffel"; }).call(Mode.prototype); From 9284732a28f727b3185cec56e4f0d236b221d1bc Mon Sep 17 00:00:00 2001 From: Conaclos Date: Sun, 20 Jul 2014 19:12:03 +0200 Subject: [PATCH 028/127] Remove eiffel example. Current example is too large. --- demo/kitchen-sink/docs/eiffel.e | 246 -------------------------------- 1 file changed, 246 deletions(-) delete mode 100644 demo/kitchen-sink/docs/eiffel.e diff --git a/demo/kitchen-sink/docs/eiffel.e b/demo/kitchen-sink/docs/eiffel.e deleted file mode 100644 index 4b349566..00000000 --- a/demo/kitchen-sink/docs/eiffel.e +++ /dev/null @@ -1,246 +0,0 @@ -note - description: "[ - Sudoku grid and simple resolution facilities. - ]" - author: "Victorien ELVINGER" - date: "22 August 2013" - revision: "3" - libraries: "Relies on ARRAY2 from EiffelBase" - -class - SUDOKU_GRID - -inherit - - ANY - redefine - default_create, - out - end - -create - default_create - -feature {NONE} -- Creation - - default_create - -- Create an empty grid. - do - create grid.make_filled (Default_value, 9, 9) - ensure then - unsolved: not solved - end - -feature -- Access - - item alias "[]" (a_row, a_column: INTEGER): INTEGER assign put - -- Value at coordinates (`a_row', `a_column'). - require - valid_row (a_row) - valid_column (a_column) - do - Result := grid [a_row, a_column] - end - - out: STRING - -- Printable representation. - do - Result := "" - across column_range as column_ic loop - across row_range as row_ic loop - Result := Result + grid [row_ic.item, column_ic.item].out + " " - end - Result := Result + "%N" - end - end - - column_range: INTEGER_INTERVAL - -- Column interval. - do - Result := 1 |..| grid.width - end - - row_range: INTEGER_INTERVAL - -- Row interval. - do - Result := 1 |..| grid.height - end - - subgrid_column_range (a_column: INTEGER): INTEGER_INTERVAL - -- Colum interval of the subgrids including `a_column'. - require - valid_column (a_column) - local - l_column: like a_column - do - l_column := ((a_column - 1) // 3)*3 + 1 - Result := l_column |..| (l_column + 2) - ensure - lower_bound: (<<1, 4, 7>>).has (Result.lower) - upper_bound: (<<3, 6, 9>>).has (Result.upper) - end - - subgrid_row_range (a_row: INTEGER): INTEGER_INTERVAL - -- Row interval of the subgrids including `a_row'. - require - valid_row (a_row) - local - l_row: like a_row - do - l_row := ((a_row - 1) // 3) * 3 + 1 - Result := l_row |..| (l_row + 2) - ensure - lower_bound: (<<1, 4, 7>>).has (Result.lower) - upper_bound: (<<3, 6, 9>>).has (Result.upper) - end - -feature -- Status report - - solved: BOOLEAN - -- Is completed? - - valid_column (a_column: INTEGER): BOOLEAN - -- Is `a_column' a valid coordinate? - do - Result := 1 <= a_column and a_column <= grid.width - end - - valid_row (a_row: INTEGER): BOOLEAN - -- Is `a_row' a valid coordinate? - do - Result := 1 <= a_row and a_row <= grid.height - end - - valid_value (a_value: INTEGER): BOOLEAN - -- Is `a_value' a valid item? - do - Result := 1 <= a_value and a_value <= 9 - end - - valid (a_value: INTEGER; a_row, a_column: INTEGER): BOOLEAN - -- Can `a_value' be inserted at coordinates (`a_row', `a_column')? - require - valid_value (a_value) - valid_row (a_row) - valid_column (a_column) - do - Result := not (subgrid_has (a_value, a_row, a_column) or row_has (a_value, a_row) or column_has (a_value, a_column)) - end - - subgrid_has (a_value: INTEGER; a_row, a_column: INTEGER): BOOLEAN - -- Is there `a_value' in the subgrid containing coordinates (`a_row', `a_column')? - require - valid_row (a_row) - valid_column (a_column) - do - across - subgrid_row_range (a_row) as row_ic - until - Result - loop - across - subgrid_column_range (a_column) as column_ic - until - Result - loop - Result := grid [row_ic.item, column_ic.item] = a_value - end - end - end - - row_has (a_value: INTEGER; a_row: INTEGER): BOOLEAN - -- Exist there an item `a_value' at coordinates (`a_row', ?)? - require - valid_row (a_row) - do - Result := across column_range as ic some grid [a_row, ic.item] = a_value end - end - - column_has (a_value: INTEGER; a_column: INTEGER): BOOLEAN - -- Exist there an item `a_value' at coordinates (?, `a_column')? - require - valid_column (a_column) - do - Result := across row_range as ic some grid [ic.item, a_column] = a_value end - end - -feature -- Extension - - put (a_value: INTEGER; a_row, a_column: INTEGER) - -- Assign item `a_value' at coordinates (`a_row', `a_column'). - require - valid_value (a_value) - valid_row (a_row) - valid_column (a_column) - valid (a_value, a_row, a_column) - do - grid [a_row, a_column] := a_value - ensure - item_inserted: grid [a_row, a_column] = a_value - end - -feature -- Change - - solve - -- Try to solve grid. - do - sub_solve (1, 1) - end - -feature {NONE} -- Implementation - - grid: ARRAY2 [INTEGER] - -- Board. - - Default_value: INTEGER = 0 - -- Empty cell content. - - sub_solve (a_row, a_column: INTEGER) - -- Solve grid from row `a_row' and column `a_column'. - require - valid_row (a_row) - valid_column (a_column) - do - if valid_value (grid [a_row, a_column]) then - solve_after (a_row, a_column) - else - across - 1 |..| 9 as ic - until - solved - loop - if valid (ic.item, a_row, a_column) then - put (ic.item, a_row, a_column) - solve_after (a_row, a_column) - - if not solved then - grid [a_row, a_column] := Default_value - end - end - end - end - end - - solve_after (a_row, a_column: INTEGER) - -- Solve the next cell. - require - valid_row (a_row) - valid_column (a_column) - do - if a_column = grid.width then - if a_row = grid.height then - solved := True - else - sub_solve (a_row + 1, 1) - end - else - sub_solve (a_row, a_column + 1) - end - end - -invariant - valid_numbers: solved implies across grid as ic all valid_value (ic.item) end - nine_columns: grid.width = 9 - nine_rows: grid.height = 9 - -end From b651a424f101f1f448c085ac2828757d7b6bb9ab Mon Sep 17 00:00:00 2001 From: Conaclos Date: Sun, 20 Jul 2014 19:12:34 +0200 Subject: [PATCH 029/127] Adding the new Eiffel example. --- demo/kitchen-sink/docs/eiffel.e | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 demo/kitchen-sink/docs/eiffel.e diff --git a/demo/kitchen-sink/docs/eiffel.e b/demo/kitchen-sink/docs/eiffel.e new file mode 100644 index 00000000..943cdb35 --- /dev/null +++ b/demo/kitchen-sink/docs/eiffel.e @@ -0,0 +1,30 @@ +note + description: "Represents a person." + +class + PERSON + +create + make, make_unknown + +feature {NONE} -- Creation + + make (a_name: like name) + -- Create a person with `a_name' as `name'. + do + name := a_name + ensure + name = a_name + end + + make_unknown + do ensure + name = Void + end + +feature -- Access + + name: detachable STRING + -- Full name or Void if unknown. + +end \ No newline at end of file From 0eaae8712e4e52e03ffc3165f86cff0b8dc92c39 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 22 Jul 2014 16:32:40 +0400 Subject: [PATCH 030/127] do not rename kr_theme to kr during the build --- Makefile.dryice.js | 2 +- lib/ace/config.js | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 2bc36f8b..bac090f7 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -359,7 +359,7 @@ function buildAce(options) { buildSubmodule(options, { projectType: "theme", require: ["ace/theme/" + name] - }, "theme-" + name.replace("_theme", "")); + }, "theme-" + name); }); // keybindings ["vim", "emacs"].forEach(function(name) { diff --git a/lib/ace/config.js b/lib/ace/config.js index f4e4c89a..94e9465f 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -80,11 +80,7 @@ exports.moduleUrl = function(name, component) { // todo make this configurable or get rid of '-' var sep = component == "snippets" ? "/" : "-"; - var base = parts[parts.length - 1]; - if (sep == "-") { - var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); - base = base.replace(re, ""); - } + var base = parts[parts.length - 1]; if ((!base || base == component) && parts.length > 1) base = parts[parts.length - 2]; From 23f678229aaad720b8f82d98743bece56114a2de Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 22 Jul 2014 16:57:14 +0400 Subject: [PATCH 031/127] update config_test.js --- lib/ace/config_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/config_test.js b/lib/ace/config_test.js index d09a2801..ac664fae 100644 --- a/lib/ace/config_test.js +++ b/lib/ace/config_test.js @@ -43,7 +43,7 @@ module.exports = { "test: path resolution" : function() { config.set("packaged", "true"); var url = config.moduleUrl("kr_theme", "theme"); - assert.equal(url, "theme-kr.js"); + assert.equal(url, "theme-kr_theme.js"); config.set("basePath", "a/b"); url = config.moduleUrl("m/theme", "theme"); From d40bec839dc58e2e7c6f5484a350666b8a29731b Mon Sep 17 00:00:00 2001 From: Diego Ferreyra Date: Thu, 24 Jul 2014 17:14:40 -0300 Subject: [PATCH 032/127] ie11 fix getBoundingClientRect() error --- lib/ace/layer/font_metrics.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ace/layer/font_metrics.js b/lib/ace/layer/font_metrics.js index a1423732..a89ed9db 100644 --- a/lib/ace/layer/font_metrics.js +++ b/lib/ace/layer/font_metrics.js @@ -128,7 +128,12 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) { this.$measureSizes = function() { if (CHAR_COUNT === 1) { - var rect = this.$measureNode.getBoundingClientRect(); + var rect = null; + try { + rect = this.$measureNode.getBoundingClientRect(); + } catch(e) { + rect = { top : this.$measureNode.offsetTop, left : this.$measureNode.offsetLeft } + }; var size = { height: rect.height, width: rect.width From 80f42e13ffe424ea5ac1f4f68b7e2173a9c39778 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 28 Jul 2014 19:10:41 +0400 Subject: [PATCH 033/127] accept mode options object in static highlight extension --- lib/ace/ext/static_highlight.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js index 1d69a9bb..9116467b 100644 --- a/lib/ace/ext/static_highlight.js +++ b/lib/ace/ext/static_highlight.js @@ -98,7 +98,6 @@ var highlight = function(el, opts, callback) { * and `css`. * @returns {object} An object containing the properties `html` and `css`. */ - highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { var waiting = 1; var modeCache = EditSession.prototype.$modes; @@ -112,11 +111,17 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba --waiting || done(); }); } - + // allow setting mode options e.h {path: "ace/mode/php", inline:true} + var modeOptions; + if (mode && typeof mode === "object" && !mode.getTokenizer) { + modeOptions = mode; + mode = modeOptions.path; + } if (typeof mode == "string") { waiting++; config.loadModule(['mode', mode], function(m) { - if (!modeCache[mode]) modeCache[mode] = new m.Mode(); + if (!modeCache[mode] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); mode = modeCache[mode]; --waiting || done(); }); @@ -130,14 +135,13 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba return --waiting || done(); }; -/* +/** * Transforms a given input code snippet into HTML using the given mode * @param {string} input Code snippet * @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode') * @param {string} r Code snippet * @returns {object} An object containing: html, css */ - highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { lineStart = parseInt(lineStart || 1, 10); From 7ab9ce686f41fecbe9c95ee993b84b4bcb0a2110 Mon Sep 17 00:00:00 2001 From: Diego Ferreyra Date: Mon, 28 Jul 2014 14:34:39 -0300 Subject: [PATCH 034/127] ie11 fix getBoundingClientRect() error --- lib/ace/layer/font_metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/layer/font_metrics.js b/lib/ace/layer/font_metrics.js index a89ed9db..9100a0f6 100644 --- a/lib/ace/layer/font_metrics.js +++ b/lib/ace/layer/font_metrics.js @@ -132,7 +132,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) { try { rect = this.$measureNode.getBoundingClientRect(); } catch(e) { - rect = { top : this.$measureNode.offsetTop, left : this.$measureNode.offsetLeft } + rect = {width: 0, height:0 } }; var size = { height: rect.height, From b0babd3f255788fdefe5c928a64fe08d8badcb38 Mon Sep 17 00:00:00 2001 From: Diego Ferreyra Date: Mon, 28 Jul 2014 14:37:15 -0300 Subject: [PATCH 035/127] ie11 fix getBoundingClientRect() error missing ";" --- lib/ace/layer/font_metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/layer/font_metrics.js b/lib/ace/layer/font_metrics.js index 9100a0f6..06bd4b0d 100644 --- a/lib/ace/layer/font_metrics.js +++ b/lib/ace/layer/font_metrics.js @@ -132,7 +132,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) { try { rect = this.$measureNode.getBoundingClientRect(); } catch(e) { - rect = {width: 0, height:0 } + rect = {width: 0, height:0 }; }; var size = { height: rect.height, From f4990b3a56d04b8245ad4b57199e56907b40c98d Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 1 Aug 2014 21:45:43 +0400 Subject: [PATCH 036/127] make sure text redraw isn't missed when bgTokenizer state changes --- lib/ace/background_tokenizer.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/ace/background_tokenizer.js b/lib/ace/background_tokenizer.js index b2ba3733..da8008bd 100644 --- a/lib/ace/background_tokenizer.js +++ b/lib/ace/background_tokenizer.js @@ -36,8 +36,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; /** - * - * * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. * * If a certain row is changed, everything below that row is re-tokenized. @@ -50,8 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; * @param {Tokenizer} tokenizer The tokenizer to use * @param {Editor} editor The editor to associate with * - * - * * @constructor **/ @@ -89,10 +85,9 @@ var BackgroundTokenizer = function(tokenizer, editor) { // only check every 5 lines processedLines ++; - if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { + if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { self.running = setTimeout(self.$worker, 20); - self.currentLine = currentLine; - return; + break; } } self.currentLine = currentLine; From 72dcd289050f0d129139906960dbe822e06eaedc Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 1 Aug 2014 22:06:43 +0400 Subject: [PATCH 037/127] trigger redraw less often --- lib/ace/editor.js | 2 +- lib/ace/virtual_renderer.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index e198ecaa..83782f06 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -702,7 +702,7 @@ var Editor = function(renderer, session) { lastRow = range.end.row; else lastRow = Infinity; - this.renderer.updateLines(range.start.row, lastRow); + this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode); this._signal("change", e); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index dfb435be..d3e26758 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -258,7 +258,7 @@ var VirtualRenderer = function(container, theme) { * * **/ - this.updateLines = function(firstRow, lastRow) { + this.updateLines = function(firstRow, lastRow, force) { if (lastRow === undefined) lastRow = Infinity; @@ -279,9 +279,13 @@ var VirtualRenderer = function(container, theme) { // If the change happened offscreen above us then it's possible // that a new line wrap will affect the position of the lines on our // screen so they need redrawn. - if (this.$changedLines.lastRow < this.layerConfig.firstRow) - this.$changedLines.lastRow = this.layerConfig.lastRow - + // TODO: better solution is to not change scroll position when text is changed outside of visible area + if (this.$changedLines.lastRow < this.layerConfig.firstRow) { + if (force) + this.$changedLines.lastRow = this.layerConfig.lastRow; + else + return; + } if (this.$changedLines.firstRow > this.layerConfig.lastRow) return; this.$loop.schedule(this.CHANGE_LINES); From 5744a3c6e3fc0c15b4fb22803db339e690f38f7f Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 1 Aug 2014 20:53:08 +0400 Subject: [PATCH 038/127] fix bracket matching in vala mode --- lib/ace/mode/vala_highlight_rules.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ace/mode/vala_highlight_rules.js b/lib/ace/mode/vala_highlight_rules.js index f199426d..b4a96a3d 100644 --- a/lib/ace/mode/vala_highlight_rules.js +++ b/lib/ace/mode/vala_highlight_rules.js @@ -136,7 +136,7 @@ var ValaHighlightRules = function() { [ { token: 'meta.class.vala', regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)', push: - [ { token: 'punctuation.section.class.end.vala', + [ { token: 'paren.vala', regex: '}', next: 'pop' }, { include: '#storage-modifiers' }, @@ -166,10 +166,10 @@ var ValaHighlightRules = function() { { include: '#object-types-inherited' }, { include: '#comments' }, { defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] }, - { token: 'meta.class.body.vala', + { token: 'paren.vala', regex: '{', push: - [ { token: 'meta.class.body.vala', regex: '(?=})', next: 'pop' }, + [ { token: 'paren.vala', regex: '(?=})', next: 'pop' }, { include: '#class-body' }, { defaultToken: 'meta.class.body.vala' } ] }, { defaultToken: 'meta.class.vala' } ], @@ -266,7 +266,7 @@ var ValaHighlightRules = function() { [ { token: 'meta.method.vala', regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()', push: - [ { token: 'meta.method.vala', regex: '}|(?=;)', next: 'pop' }, + [ { token: 'paren.vala', regex: '}|(?=;)', next: 'pop' }, { include: '#storage-modifiers' }, { token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ], regex: '([\\~\\w\\.]+)(\\s*\\()', @@ -285,10 +285,10 @@ var ValaHighlightRules = function() { { include: '#all-types' }, { defaultToken: 'meta.method.return-type.vala' } ] }, { include: '#throws' }, - { token: 'meta.method.body.vala', + { token: 'paren.vala', regex: '{', push: - [ { token: 'meta.method.body.vala', regex: '(?=})', next: 'pop' }, + [ { token: 'paren.vala', regex: '(?=})', next: 'pop' }, { include: '#code' }, { defaultToken: 'meta.method.body.vala' } ] }, { defaultToken: 'meta.method.vala' } ] } ], From b990ad3f90f14f99cfbe8bcb2a807027cfee7228 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 2 Aug 2014 00:56:34 +0400 Subject: [PATCH 039/127] update csslint --- lib/ace/mode/css/csslint.js | 968 ++++++++++++++++++++++++------------ lib/ace/mode/css_worker.js | 7 +- 2 files changed, 647 insertions(+), 328 deletions(-) diff --git a/lib/ace/mode/css/csslint.js b/lib/ace/mode/css/csslint.js index a3a7a9bd..c3c79a80 100644 --- a/lib/ace/mode/css/csslint.js +++ b/lib/ace/mode/css/csslint.js @@ -4,7 +4,7 @@ CSSLint Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal +of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is @@ -13,7 +13,7 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Build: v0.10.0 31-March-2014 08:16:48 */ +/* Build: v0.10.0 22-July-2014 01:17:52 */ /*! Parser-Lib Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. @@ -46,11 +46,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.4, Build time: 7-January-2014 07:32:49 */ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ var parserlib = {}; (function(){ - /** * A generic base to inherit from for any object * that needs event handling. @@ -506,7 +505,7 @@ SyntaxUnit.prototype = { * @method valueOf */ valueOf: function(){ - return this.toString(); + return this.text; }, /** @@ -921,8 +920,6 @@ TokenStreamBase.prototype = { }; - - parserlib.util = { StringReader: StringReader, SyntaxError : SyntaxError, @@ -931,8 +928,6 @@ EventTarget : EventTarget, TokenStreamBase : TokenStreamBase }; })(); - - /* Parser-Lib Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. @@ -956,7 +951,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.4, Build time: 7-January-2014 07:32:49 */ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ (function(){ var EventTarget = parserlib.util.EventTarget, TokenStreamBase = parserlib.util.TokenStreamBase, @@ -964,7 +959,6 @@ StringReader = parserlib.util.StringReader, SyntaxError = parserlib.util.SyntaxError, SyntaxUnit = parserlib.util.SyntaxUnit; - var Colors = { aliceblue :"#f0f8ff", antiquewhite :"#faebd7", @@ -1182,7 +1176,6 @@ function Combinator(text, line, col){ Combinator.prototype = new SyntaxUnit(); Combinator.prototype.constructor = Combinator; - /*global SyntaxUnit, Parser*/ /** * Represents a media feature, such as max-width:500. @@ -1215,7 +1208,6 @@ function MediaFeature(name, value){ MediaFeature.prototype = new SyntaxUnit(); MediaFeature.prototype.constructor = MediaFeature; - /*global SyntaxUnit, Parser*/ /** * Represents an individual media query. @@ -1259,7 +1251,6 @@ function MediaQuery(modifier, mediaType, features, line, col){ MediaQuery.prototype = new SyntaxUnit(); MediaQuery.prototype.constructor = MediaQuery; - /*global Tokens, TokenStream, SyntaxError, Properties, Validation, ValidationError, SyntaxUnit, PropertyValue, PropertyValuePart, SelectorPart, SelectorSubPart, Selector, PropertyName, Combinator, MediaFeature, MediaQuery, EventTarget */ @@ -1521,7 +1512,7 @@ Parser.prototype = function(){ tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); //grab the URI value - uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1"); this._readWhitespace(); @@ -1626,8 +1617,10 @@ Parser.prototype = function(){ while(true) { if (tokenStream.peek() == Tokens.PAGE_SYM){ this._page(); - } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ + } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ this._font_face(); + } else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){ + this._viewport(); } else if (!this._ruleset()){ break; } @@ -2823,7 +2816,7 @@ Parser.prototype = function(){ value = null, operator = null; - value = this._term(); + value = this._term(inFunction); if (value !== null){ values.push(value); @@ -2840,7 +2833,7 @@ Parser.prototype = function(){ valueParts = []; }*/ - value = this._term(); + value = this._term(inFunction); if (value === null){ break; @@ -2858,7 +2851,7 @@ Parser.prototype = function(){ return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; }, - _term: function(){ + _term: function(inFunction){ /* * term @@ -2872,6 +2865,7 @@ Parser.prototype = function(){ var tokenStream = this._tokenStream, unary = null, value = null, + endChar = null, token, line, col; @@ -2892,6 +2886,20 @@ Parser.prototype = function(){ col = tokenStream.token().startCol; } + //see if it's a simple block + } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){ + + token = tokenStream.token(); + endChar = token.endChar; + value = token.value + this._expr(inFunction).text; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + tokenStream.mustMatch(Tokens.type(endChar)); + value += endChar; + this._readWhitespace(); + //see if there's a simple match } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, Tokens.ANGLE, Tokens.TIME, @@ -3536,7 +3544,6 @@ nth ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S* ; */ - /*global Validation, ValidationTypes, ValidationError*/ var Properties = { @@ -3553,6 +3560,7 @@ var Properties = { "animation-delay" : { multi: "