From 8e31bbbb9bd4f8fde41d22ad2760a96a10e0855a Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:53:30 -0400 Subject: [PATCH 01/17] - don't show tooltips if there's no content --- lib/ace/mouse/default_gutter_handler.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ace/mouse/default_gutter_handler.js b/lib/ace/mouse/default_gutter_handler.js index 1b5cb98607c..d8cdfd2ac18 100644 --- a/lib/ace/mouse/default_gutter_handler.js +++ b/lib/ace/mouse/default_gutter_handler.js @@ -87,7 +87,9 @@ function GutterHandler(mouseHandler) { tooltipAnnotation = annotation.text.join("
"); tooltip.setHtml(tooltipAnnotation); - tooltip.show(); + if (tooltipAnnotation.length){ + tooltip.show(); + } editor.on("mousewheel", hideTooltip); if (mouseHandler.$tooltipFollowsMouse) { From 97a162a1953fe3b701816642fddb8af62df94b3f Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:54:30 -0400 Subject: [PATCH 02/17] filter out redundant autocomplete items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - if a string matches a keyword it’s pretty likely to also show up as a local --- lib/ace/autocomplete.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index b243727fd9c..56a405be368 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -345,6 +345,21 @@ var FilteredList = function(array, filterText, mutateData) { item.score = (item.score || 0) - penalty; results.push(item); } + + + // don't clutter the list with local copies of keywords + var keywords = []; + for (var i=0, j=results.length; i=0;){ + if (!results[i]) continue + if (results[i].meta=='local' && keywords.indexOf(results[i].caption)!=-1){ + results.splice(i,1) + } + } + return results; }; }).call(FilteredList.prototype); From 2a203090e307ccc1b8d04582b0fbec1bd1d58c9a Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:56:01 -0400 Subject: [PATCH 03/17] ugly hack around the undo manager to allow resetting the text - not sure what a proper implementation of this would look like, but the default behavior of being able to undo to a blank screen feels like a bug --- lib/ace/document.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/ace/document.js b/lib/ace/document.js index a2ca72104ac..b35b6673208 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -69,6 +69,10 @@ var Document = function(text) { oop.implement(this, EventEmitter); + this.initialize = function(text) { + this.refresh(text); + }; + /** * Replaces all the lines in the current `Document` with the value of `text`. * @@ -78,6 +82,7 @@ var Document = function(text) { var len = this.getLength(); this.remove(new Range(0, 0, len, this.getLine(len-1).length)); this.insert({row: 0, column:0}, text); + // this.refresh(text); // patch in a version of _insertLines that emits a separate event }; /** @@ -265,6 +270,31 @@ var Document = function(text) { return position; }; + this.refresh = function(text, row){ + var row = row || 0 + var lines = this.$split(text); + + // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) + // to circumvent that we have to break huge inserts into smaller chunks here + if (lines.length > 0xFFFF) { + var end = this.refresh(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + context: 'refresh', + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return {row:0, column:0}; + } + /** * Fires whenever the document changes. * From 44e29f08b445e7da370a36893da180fac6dda3cc Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:56:54 -0400 Subject: [PATCH 04/17] plotdevice-specific build config --- Makefile | 29 ++ Makefile-plod.dryice.js | 728 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 757 insertions(+) create mode 100755 Makefile-plod.dryice.js diff --git a/Makefile b/Makefile index 95dcf964cb7..d0f6018cdc3 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,35 @@ build/src/ace.js : ${wildcard lib/*} \ ${wildcard lib/*/*/*/*/*/*} ./Makefile.dryice.js +build/src-min/ace.js : ${wildcard lib/*} \ + ${wildcard lib/*/*} \ + ${wildcard lib/*/*/*} \ + ${wildcard lib/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*/*} + /usr/local/bin/node ./Makefile-plod.dryice.js minimal --m + +embed: build/src-min/ace.js + @mkdir -p build/editor + @echo "// ACE Editor" > build/ace.js + @for f in ${wildcard build/src-min/[a-s]*.js} ${wildcard build/src-min/snippets/*.js} ; \ + do cat $$f >> build/ace.js; \ + echo >> build/ace.js; \ + done + + @echo >> build/ace.js + @echo "// Color Themes" >> build/ace.js + @for f in ${wildcard build/src-min/theme*.js} ; \ + do cat $$f >> build/ace.js; \ + echo >> build/ace.js; \ + done + +install: embed + @./env/bin/python themedump.py > /dev/null + @cp build/ace.js ../../Resources/ui/js/ace.js + @cp build/themes.json ../../Resources/ui/themes.json + @cp build/autocomplete.css ../../Resources/ui/autocomplete.css + doc: cd doc;\ (test -d node_modules && npm update) || npm install;\ diff --git a/Makefile-plod.dryice.js b/Makefile-plod.dryice.js new file mode 100755 index 00000000000..b567ccaf73c --- /dev/null +++ b/Makefile-plod.dryice.js @@ -0,0 +1,728 @@ +#!/usr/bin/env node +/* ***** 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 ***** */ + +var fs = require("fs"); +var path = require("path"); +if (!fs.existsSync) + fs.existsSync = path.existsSync; +else + path.existsSync = fs.existsSync; +var copy = require('dryice').copy; + +var ACE_HOME = __dirname; +var BUILD_DIR = ACE_HOME + "/build"; + +function main(args) { + if (args.indexOf("updateModes") !== -1) { + return updateModes(); + } + var type = "minimal"; + args = args.map(function(x) { + if (x[0] == "-" && x[1] != "-") + return "-" + x; + return x; + }); + + if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1)) + type = args[2]; + + var i = args.indexOf("--target"); + if (i != -1 && args[i+1]) + BUILD_DIR = args[i+1]; + + if (args.indexOf("--h") == -1) { + if (type == "minimal") { + buildAce({ + compress: args.indexOf("--m") != -1, + noconflict: args.indexOf("--nc") != -1, + shrinkwrap: args.indexOf("--s") != -1 + }); + } else if (type == "normal") { + ace(); + } else if (type == "demo") { + demo(); + } else if (type == "bm") { + bookmarklet(); + } else if (type == "full") { + demo(ace()); + bookmarklet(); + } else if (type == "highlighter") { + var project = buildAce({ + coreOnly: true, + exportModule: "ace/ext/static_highlight", + requires: ["ace/ext/static_highlight", "ace/theme/textmate"], + readFilters: [copy.filter.moduleDefines, function(a) { + console.log(a.substring(0, 2500)) + return a + }] + }) + copy({ + source: project.result, + filter: getWriteFilters(project.options, "main"), + dest: BUILD_DIR + "/static_highlight.js" + }); + } + } + + console.log("--- Ace Dryice Build Tool ---"); + console.log(""); + console.log("Options:"); + console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); + console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); + console.log(" demo Runs demo build of Ace"); + console.log(" bm Runs bookmarklet build of Ace"); + console.log(" full all of above"); + console.log(" highlighter "); + console.log("args:"); + console.log(" --target ./path path to build folder"); + console.log("flags:"); + console.log(" --h print this help"); + console.log(" --m minify"); + console.log(" --nc namespace require"); + console.log(" --s shrinkwrap (combines all output files into one)"); + console.log(""); + if (BUILD_DIR) + console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR) +} + +function bookmarklet() { + var targetDir = BUILD_DIR + "/textarea"; + copy({ + source: "build_support/editor_textarea.html", + dest: targetDir + '/editor.html' + }); + copy({ + source: "build_support/style.css", + dest: targetDir + '/style.css' + }); + + buildAce({ + targetDir: targetDir + "/src", + ns: "__ace_shadowed__", + exportModule: "ace/ext/textarea", + compress: false, + noconflict: true, + suffix: "", + name: "ace-bookmarklet", + workers: [], + keybindings: [] + }); +} + +function ace() { + console.log('# ace ---------'); + + // uncompressed + var project = buildAce({ + compress: false, + noconflict: false + }); + buildAce({ + compress: false, + noconflict: true + }); + + // compressed + buildAce({ + compress: true, + noconflict: false + }); + buildAce({ + compress: true, + noconflict: true + }); + + console.log('# ace License | Readme | Changelog ---------'); + + copy({ + source: ACE_HOME + "/build_support/editor.html", + dest: BUILD_DIR + "/editor.html" + }); + copy({ + source: ACE_HOME + "/LICENSE", + dest: BUILD_DIR + "/LICENSE" + }); + copy({ + source: ACE_HOME + "/ChangeLog.txt", + dest: BUILD_DIR + "/ChangeLog.txt" + }); + + return project; +} + +function demo(project) { + project = project || buildAce({ + compress: false, + noconflict: false, + coreOnly: true + }); + console.log('# kitchen sink ---------'); + + var version, ref; + try { + version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; + ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); + } catch(e) { + ref = ""; + version = ""; + } + + function changeComments(data) { + return (data + .replace(//g, "") + .replace(/PACKAGE\-\->| Date: Thu, 13 Mar 2014 20:57:16 -0400 Subject: [PATCH 05/17] plotdevice syntax --- plotdevice/mode/plotdevice.js | 117 +++++++++ plotdevice/mode/plotdevice_highlight_rules.js | 226 ++++++++++++++++++ 2 files changed, 343 insertions(+) create mode 100644 plotdevice/mode/plotdevice.js create mode 100644 plotdevice/mode/plotdevice_highlight_rules.js diff --git a/plotdevice/mode/plotdevice.js b/plotdevice/mode/plotdevice.js new file mode 100644 index 00000000000..d1520d968b2 --- /dev/null +++ b/plotdevice/mode/plotdevice.js @@ -0,0 +1,117 @@ +/* ***** 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 Tokenizer = require("../tokenizer").Tokenizer; +var PlotDeviceHighlightRules = require("./plotdevice_highlight_rules").PlotDeviceHighlightRules; +var PythonFoldMode = require("./folding/pythonic").FoldMode; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var Range = require("../range").Range; + +var Mode = function() { + this.HighlightRules = PlotDeviceHighlightRules; + this.foldingRules = new PythonFoldMode("\\:"); + this.$behaviour = new CstyleBehaviour(); + +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "#"; + + 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; + }; + + var outdents = { + "pass": 1, + "return": 1, + "raise": 1, + "break": 1, + "continue": 1 + }; + + this.checkOutdent = function(state, line, input) { + if (input !== "\r\n" && input !== "\r" && input !== "\n") + return false; + + var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens; + + if (!tokens) + return false; + + // ignore trailing comments + do { + var last = tokens.pop(); + } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/)))); + + if (!last) + return false; + + return (last.type == "keyword" && outdents[last.value]); + }; + + this.autoOutdent = function(state, doc, row) { + // outdenting in python is slightly different because it always applies + // to the next line and only of a new line is inserted + + row += 1; + var indent = this.$getIndent(doc.getLine(row)); + var tab = doc.getTabString(); + if (indent.slice(-tab.length) == tab) + doc.remove(new Range(row, indent.length-tab.length, row, indent.length)); + }; + + this.$id = "ace/mode/plotdevice"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/plotdevice/mode/plotdevice_highlight_rules.js b/plotdevice/mode/plotdevice_highlight_rules.js new file mode 100644 index 00000000000..9694776dc36 --- /dev/null +++ b/plotdevice/mode/plotdevice_highlight_rules.js @@ -0,0 +1,226 @@ +/* ***** 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 ***** */ +/* + * TODO: python delimiters + */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PlotDeviceHighlightRules = function() { + + var keywords = ( + "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + + "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + + "raise|return|try|while|with|yield" + + "|adict|odict|ddict|BezierPath|Bezier|ClippingPath|Color|Context|Family|Font|Stylesheet|Grob|Image|PlotDeviceError|Oval|PathElement|Curve|Point|Rect|Text|Transform|TransformContext|Variable" + ); + + var builtinConstants = ( + "True|False|None|NotImplemented|Ellipsis|__debug__" + ); + + var builtinNumConstants = "DEFAULT|FRAME|PAGE|BEVEL|BOOLEAN|BUTT|BUTTON|CENTER|CLOSE|CMYK|CORNER|CURVETO|DEFAULT_HEIGHT|DEFAULT_WIDTH|FORTYFIVE|HEIGHT|HSB|JUSTIFY|KEY_BACKSPACE|KEY_DOWN|KEY_ESC|KEY_LEFT|KEY_RIGHT|KEY_TAB|KEY_UP|LEFT|LINETO|MITER|MOVETO|NORMAL|NUMBER|RGB|GREY|RIGHT|ROUND|SQUARE|TEXT|WIDTH|DEGREES|RADIANS|PERCENT|cm|inch|mm|pi|tau" + + var builtinFunctions = ( + "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + + "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + + "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + + "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + + "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + + "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + + "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + + "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern" + + "|plot|measure|stylesheet|order|ordered|shuffled|addvar|align|arrow|autoclosepath|autotext|background|beginclip|beginpath|bezier|canvas|capstyle|choice|clip|closepath|color|colormode|colorrange|colors|curveto|drawpath|ellipse|endclip|endpath|export|files|fill|findpath|findvar|font|fonts|fontsize|grid|image|imagesize|joinstyle|line|lineheight|lineto|moveto|pen|plotstyle|nofill|nostroke|outputmode|oval|pop|push|random|rect|reset|rotate|save|scale|size|skew|speed|star|state_vars|stroke|strokewidth|text|textheight|textmetrics|textpath|textwidth|transform|translate|var|ximport" + ); + + var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); + var colorCodes = '(#?[a-f0-9]{3}([a-f0-9]{3}([a-f0-9]{2})?)?\\b)' + + //var futureReserved = ""; + var keywordMapper = this.createKeywordMapper({ + "invalid.deprecated": "debugger", + "support.function": builtinFunctions, + //"invalid.illegal": futureReserved, + "constant.language": builtinConstants, + "constant.numeric": builtinNumConstants, + "keyword": keywords + }, "identifier"); + + var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var octInteger = "(?:0[oO]?[0-7]+)"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var binInteger = "(?:0[bB][01]+)"; + var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; + + var exponent = "(?:[eE][+-]?\\d+)"; + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + var colorString = "'(" + colorCodes + "|" + colorEntities + ")'" + var qcolorString = '"(' + colorCodes + '|' + colorEntities + ')"' + + var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})"; + + this.$rules = { + "start" : [ { + token : "comment", + regex : "#.*$" + }, { + token : "keyword", + regex : '\\bdef\\b|\\bclass\\b', + next : "define" + }, { + token : "constant.numeric", // string containing a hex or named color + regex : colorString + }, { + token : "constant.numeric", // string containing a hex or named color + regex : qcolorString + }, { + token : "string", // multi line """ string start + regex : strPre + '"{3}', + next : "qqstring3" + }, { + token : "string", // " string + regex : strPre + '"(?=.)', + next : "qqstring" + }, { + token : "string", // multi line ''' string start + regex : strPre + "'{3}", + next : "qstring3" + }, { + token : "string", // ' string + regex : strPre + "'(?=.)", + next : "qstring" + }, { + token : "constant.numeric", // imaginary + regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // long integer + regex : integer + "[lL]\\b" + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + "define":[ + { + token : "constant.language", + regex : "def|class" + }, + { + token : "variable.language", + regex : "[A-Za-z_][A-Za-z0-9_]*", + next : "start" + }, + { + token : "text", + regex : "\\s+" + } + ], + "qqstring3" : [ { + token : "constant.language.escape", + regex : stringEscape + }, { + token : "string", // multi line """ string end + regex : '"{3}', + next : "start" + }, { + defaultToken : "string" + } ], + "qstring3" : [ { + token : "constant.language.escape", + regex : stringEscape + }, { + token : "string", // multi line ''' string end + regex : "'{3}", + next : "start" + }, { + defaultToken : "string" + } ], + "qqstring" : [{ + token : "constant.language.escape", + regex : stringEscape + }, { + token : "string", + regex : "\\\\$", + next : "qqstring" + }, { + token : "string", + regex : '"|$', + next : "start" + }, { + defaultToken: "string" + }], + "qstring" : [{ + token : "constant.language.escape", + regex : stringEscape + }, { + token : "string", + regex : "\\\\$", + next : "qstring" + }, { + token : "string", + regex : "'|$", + next : "start" + }, { + defaultToken: "string" + }] + }; +}; + +oop.inherits(PlotDeviceHighlightRules, TextHighlightRules); + +exports.PlotDeviceHighlightRules = PlotDeviceHighlightRules; +}); From 871cf0805664f149e754e5c15ad78e886d0b273f Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:57:39 -0400 Subject: [PATCH 06/17] plotdevice api snippets --- plotdevice/snippets/plotdevice.js | 7 + plotdevice/snippets/plotdevice.snippets | 228 ++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 plotdevice/snippets/plotdevice.js create mode 100644 plotdevice/snippets/plotdevice.snippets diff --git a/plotdevice/snippets/plotdevice.js b/plotdevice/snippets/plotdevice.js new file mode 100644 index 00000000000..39ec6a52ae8 --- /dev/null +++ b/plotdevice/snippets/plotdevice.js @@ -0,0 +1,7 @@ +define(function(require, exports, module) { +"use strict"; + +exports.snippetText = require("../requirejs/text!./plotdevice.snippets"); +exports.scope = "plotdevice"; + +}); diff --git a/plotdevice/snippets/plotdevice.snippets b/plotdevice/snippets/plotdevice.snippets new file mode 100644 index 00000000000..ea2b14924f0 --- /dev/null +++ b/plotdevice/snippets/plotdevice.snippets @@ -0,0 +1,228 @@ +### general purpose + +snippet { + {"${1:k}":${2:v}, kw$3} +snippet kw + "${1:k}":${2:v}, kw$3 +snippet dict + dict(${1:k}=${2:v}, dkw$3) +snippet dkw + ${1:k}=${2:v}, dkw$3 +snippet t + True +snippet f + False +snippet lorem + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." +snippet draw + def draw(state): + print FRAME$1 +snippet setup + def setup(state): + $1 +snippet stop + def stop(state): + $1 +snippet anim + speed(${1:30})$2 + def setup(state): + pass + def draw(state): + print FRAME + def stop(state): + pass + + +### Some handy abbreviations borrowed from python.snippets + +snippet imp + import ${1:module} +snippet xi + ${1:library} = ximport("$1") +snippet from + from ${1:package} import ${2:module} +snippet wh + while ${1:condition}: + $2 +snippet with + with ${1:expr} as ${2:var}: + $3 +# New Class +snippet cl + class ${1:ClassName}(${2:object}): + """${3:docstring for $1}""" + def __init__(self, ${4:arg}): + ${5:super($1, self).__init__()} + $6 +# New Function +snippet def + def ${1:fname}($2): + $3 +# New Method +snippet defs + def ${1:mname}(self, ${2:arg}): + $3 +# Ifs +snippet if + if ${1:condition}: + $2 +snippet el + else: + $1 +snippet ei + elif ${1:condition}: + $2 +# For +snippet for + for ${1:item} in ${2:items}: + $3 +snippet try + try: + ${1:# TODO: write code...} + except ${2:Exception}, ${3:e}: + ${4:raise $3} +# if __name__ == '__main__': +snippet ifmain + if __name__ == '__main__': + ${1:main()} +# __magic__ +snippet _ + __${1:init}__${2} + + + + + +### signatures for the plotdevice api + +snippet align + align(${1:LEFT/RIGHT/CENTER/JUSTIFY}) +snippet arrow + arrow(${1:x}, ${2:y}${3:, width=${4:100}, type=${5:NORMAL/FORTYFIVE}, draw=${6:True}}) +snippet autoclosepath + autoclosepath(${1:close=${2:True}}) +snippet autotext + autotext(${1:sourceFile}) +snippet background + background() +snippet beginclip + beginclip(${1:path}) +snippet beginpath + beginpath(${1:${2:x}, ${3:y}}) +snippet bezier + bezier(${1:${2:x}, ${3:y}}, close=${4:True}, draw=${5:True}) +snippet capstyle + capstyle(${1:style=${2:BUTT/ROUND/SQUARE}}) +snippet choice + choice(${1:seq}) +snippet clip + clip() +snippet closepath + closepath() +snippet color + color("${1:black}") +snippet colormode + colormode(${1:mode=${2:RGB/HSB/CMYK}, range=${3:None}}) +snippet colorrange + colorrange(${1:maxval}) +snippet curveto + curveto(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x}, ${6:y}) +snippet drawpath + drawpath(${1:path}) +snippet ellipse + ellipse(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, draw=${6:True}}) +snippet endclip + endclip() +snippet endpath + endpath(${1:draw=${2:True}}) +snippet export + export("${1:${2:document}.${3:mov}}"${4:, loop=${5:None}, fps=${6:None}, bitrate=${7:1.0}}) +snippet files + files("${1:${2:*}.${3:json}}") +snippet fill + fill(${1:"#${2:000}"}) +snippet findpath + findpath(${1:points}${2:, curvature=${3:1.0}}) +snippet findvar + findvar(${1:name}) +snippet font + font("${1:HelveticaNeue-Medium}", ${2:12}}) +snippet fonts + fonts(${1:like="${2:akzidenz}", western=${3:True}}) +snippet fontsize + fontsize(${1:12}) +snippet grid + grid(${1:cols}, ${2:rows}${3:, colSize=${4:1}, rowSize=${5:1}, shuffled=${6:False}}) +snippet image + image("${1:image.png}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, alpha=${7:1.0}, data=${8:None}, draw=${9:True}}) +snippet imagesize + imagesize("${1:image.png}"${2:, data=${3:None}}) +snippet joinstyle + joinstyle(${1:MITER/ROUND/BEVEL}) +snippet line + line(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}${5:, draw=${6:True}}) +snippet lineheight + lineheight(${1:None}) +snippet lineto + lineto(${1:x}, ${2:y}) +snippet moveto + moveto(${1:x}, ${2:y}) +snippet nofill + nofill() +snippet nostroke + nostroke() +snippet outputmode + outputmode(${1:RGB/HSB/CMYK}) +snippet oval + oval(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, draw=${6:True}}) +snippet pop + pop() +snippet push + push() +snippet random + random(${1:v1=${2:None}, v2=${3:None}}) +snippet rect + rect(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, roundness=${6:0.0}, draw=${7:True}}) +snippet reset + reset() +snippet rotate + rotate(${1:degrees}) +snippet save + canvas.save("${1:${2:doc}.${3:pdf}}") +snippet canvas.save + canvas.save("${1:${2:doc}.${3:pdf}}") +snippet scale + scale(${1:x=${2:1}, y=${3:None}}) +snippet size + size(${1:width}, ${2:height}) +snippet skew + skew(${1:x=${2:0}, y=${3:0}}) +snippet speed + speed(${1:fps}) +snippet star + star(${1:startx}, ${2:starty}${3:, points=${4:20}, outer=${5:100}, inner=${6:50}, draw=${7:True}}) +snippet stroke + stroke() +snippet strokewidth + strokewidth(${1:None}) +snippet text + text("${1:txt}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, outline=${7:False}, draw=${8:True}}) +snippet textheight + textheight("${1:txt}"${2:, width=${3:None}}) +snippet textmetrics + textmetrics("${1:txt}"${2:, width=${3:None}, height=${4:None}}) +snippet textpath + textpath("${1:txt}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}}) +snippet textwidth + textwidth("${1:txt}"${2:, width=${3:None}}) +snippet transform + transform() +snippet transform() + with transform(${1:${2:CENTER/CORNER, }${3:...}}): + $4 +snippet translate + translate(x=${1:0}, y=${2:0}) +snippet var + var(${1:name}, type=${2:NUMBER/TEXT/BOOLEAN/BUTTON}${3:, default=${4:None}, min=${5:0}, max=${6:100}, value=${7:None}}) +snippet ximport + ${1:libName} = ximport("$1") From 6f6faef3649c612d6a6124f197e2980018d2f5c2 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:57:57 -0400 Subject: [PATCH 07/17] ported the Blackboard theme from TextMate --- plotdevice/theme/blackboard.css | 98 +++++++++++++++++++++++++++++++++ plotdevice/theme/blackboard.js | 39 +++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 plotdevice/theme/blackboard.css create mode 100644 plotdevice/theme/blackboard.js diff --git a/plotdevice/theme/blackboard.css b/plotdevice/theme/blackboard.css new file mode 100644 index 00000000000..8f9c797af1b --- /dev/null +++ b/plotdevice/theme/blackboard.css @@ -0,0 +1,98 @@ +/* THIS THEME WAS AUTOGENERATED BY Theme.tmpl.css (UUID: A2C6BAA7-90D0-4147-BBF5-96B0CD92D109) */ + +.ace-blackboard .ace_gutter { + background: #0c1021; + color: #AEAEAE; +} + +.ace-blackboard .ace_print-margin { + width: 1px; + background: #e8e8e8; +} + +.ace-blackboard { + background-color: #0C1021; + color: #F8F8F8; +} + +.ace-blackboard .ace_cursor { + color: rgba(255, 255, 255, 0.65); +} + +.ace-blackboard .ace_marker-layer .ace_selection { + background: #325087; +} + +.ace-blackboard.ace_multiselect .ace_selection.ace_start { + box-shadow: 0 0 3px 0px #0C1021; + border-radius: 2px; +} + +.ace-blackboard .ace_marker-layer .ace_step { + background: rgb(198, 219, 174); +} + +.ace-blackboard .ace_marker-layer .ace_bracket { + margin: -1px 0 0 -1px; + border: 1px solid rgba(255, 255, 255, 0.25); +} + +.ace-blackboard .ace_marker-layer .ace_active-line { + background: rgba(255, 255, 255, 0.059); +} + +.ace-blackboard .ace_gutter-active-line { + background-color: rgba(255, 255, 255, 0.059); +} + +.ace-blackboard .ace_marker-layer .ace_selected-word { + border: 1px solid #253B76; +} + +.ace-blackboard .ace_fold { + background-color: #FBDE2D; + border-color: #F8F8F8; +} + +.ace-blackboard .ace_keyword, +.ace-blackboard .ace_storage { + color: #FBDE2D; +} + +.ace-blackboard .ace_constant { + color: #D8FA3C; +} + +.ace-blackboard .ace_support { + color: #8DA6CE; +} + +.ace-blackboard .ace_invalid.ace_illegal { + color: #F8F8F8; + background-color: #9D1E15; +} + +.ace-blackboard .ace_invalid.ace_deprecated { + font-style: italic; + color: #AB2A1D; +} + +.ace-blackboard .ace_string { + color: #61CE3C; +} + +.ace-blackboard .ace_invisible{ + color:rgba(174, 174, 174, 0.5); +} +.ace-blackboard .ace_comment { + color: #AEAEAE; +} + +.ace-blackboard .ace_meta.ace_tag { + color: #7F90AA; +} + +.ace-blackboard .ace_variable, +.ace-blackboard .ace_variable.ace_language { + color:rgba(255, 100, 0, 1.0); +} \ No newline at end of file diff --git a/plotdevice/theme/blackboard.js b/plotdevice/theme/blackboard.js new file mode 100644 index 00000000000..3252a02784e --- /dev/null +++ b/plotdevice/theme/blackboard.js @@ -0,0 +1,39 @@ +/* ***** 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) { + +exports.isDark = true; +exports.cssClass = "ace-blackboard"; +exports.cssText = require("../requirejs/text!./blackboard.css"); + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); From 451258beaf89634425e53b34d91f94245296d6fd Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 20:59:20 -0400 Subject: [PATCH 08/17] themedump extracts colors from theme files - the plotdevice app needs this information so its nstextview can match colors --- plotdevice/themedump/digest.py | 134 ++++++++++++++++++++++++++ plotdevice/themedump/requirements.txt | 2 + plotdevice/themedump/tmpl.css | 6 ++ plotdevice/themedump/tmpl.html | 24 +++++ 4 files changed, 166 insertions(+) create mode 100644 plotdevice/themedump/digest.py create mode 100644 plotdevice/themedump/requirements.txt create mode 100644 plotdevice/themedump/tmpl.css create mode 100644 plotdevice/themedump/tmpl.html diff --git a/plotdevice/themedump/digest.py b/plotdevice/themedump/digest.py new file mode 100644 index 00000000000..8b6cbdb9b27 --- /dev/null +++ b/plotdevice/themedump/digest.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# encoding: utf-8 +""" +digest.py + +Created by Christian Swinehart on 2014/02/04. +Copyright (c) 2014 Samizdat Drafting Co All rights reserved. +""" + +from __future__ import with_statement, division +import sys +import os +import re +from glob import glob +from os.path import basename +from collections import defaultdict +from pprint import pprint +import tinycss +from tinycss.color3 import parse_color +import json +py_root = os.path.dirname(os.path.abspath(__file__)) +_mkdir = lambda pth: os.path.exists(pth) or os.makedirs(pth) + +from jinja2 import Environment, FileSystemLoader +tmpls = Environment(loader=FileSystemLoader(py_root)) + +def redness(rgba): + return rgba.alpha * (rgba.red + (rgba.red-rgba.blue) + (rgba.red-rgba.green)) + +def hexcolor(rgba): + return '#%02x%02x%02x%02x'%(rgba.red*255,rgba.green*255,rgba.blue*255,rgba.alpha*255) + +def rgbacolor(hexclr, alpha=None): + hexclr = hexclr.lstrip('#') + r, g, b, a = [int(n, 16)/255.0 for n in (hexclr[0:2], hexclr[2:4], hexclr[4:6], hexclr[6:8])] + if alpha is not None: + # a = min(a, alpha) + a *= alpha + return 'rgba(%i, %i, %i, %0.1f)'%(r*255,g*255,b*255,a) + +def main(): + themes = defaultdict(lambda:defaultdict(defaultdict)) + + css_themes = {} + for theme_js in glob('../../lib/ace/theme/*.js'): + fname_stub = theme_js.replace('.js','') + theme_css = fname_stub + '.css' + theme_name = basename(fname_stub).replace('_',' ').replace('-',' ').title() + src = file(theme_js).read().decode('utf-8') + m = re.search(r'isDark.*(true|false)', src) + darkness = 'dark' if m.group(1)=='true' else 'light' + isdark = darkness=='dark' + + m = re.search(r'cssClass.*"(.*?)"', src) + theme_class = m.group(1) + # print theme_name, theme_class, darkness + css_themes[theme_name] = theme_class + + parser = tinycss.make_parser('page3') + stylesheet = parser.parse_stylesheet_file(theme_css) + textcolors = set() + for rule in stylesheet.rules: + selectors = rule.selector.as_css().split(',\n') + # print selectors + if selectors[0] == '.'+theme_class: + colors = {} + for d in rule.declarations: + fgbg = d.name.split('-')[0] + for v in d.value: + themes[theme_name]['colors'][fgbg] = hexcolor(parse_color(v)) + themes[theme_name].update(dict(dark=isdark, theme=theme_name, + module='ace/theme/'+basename(fname_stub))) + + # find all the text colors + for d in rule.declarations: + if d.name == 'color': + for v in d.value: + textcolors.add(parse_color(v)) + + + if any([s.endswith('.ace_selection') for s in selectors]): + for d in rule.declarations: + if d.name == 'background': + for v in d.value: + themes[theme_name]['colors']['selection'] = hexcolor(parse_color(v)) + + if any([s.endswith('.ace_comment') for s in selectors]): + for d in rule.declarations: + if d.name == 'color': + # themes[theme_name]['comment'] = d.value.as_css() + for v in d.value: + themes[theme_name]['colors']['comment'] = hexcolor(parse_color(v)) + + reddest = [hexcolor(c) for c in sorted(textcolors, key=redness, reverse=True)] + while reddest[0] in themes[theme_name]['colors'].values(): + reddest.pop(0) + themes[theme_name]['colors']['error'] = reddest[0] + + # pprint(json.loads(json.dumps(themes[theme_name]))) + # t = themes[theme_name] + # colors = dict(color=t['color'], background=t['background'], error=t['error'], comment=t['comment']) + # repack = dict(theme=t['theme'], dark=t['dark'], css=t['css'], colors=colors) + # themes[theme_name]['json'] = repack + # 1/0 + + + with file('../themes.json','w') as f: + # json.dump({t:themes[t]['json'] for t in themes}, f, indent=2) + json.dump(themes, f, indent=2) + + # rows = [dict(theme=n, module=t['theme'], background=t['background'], plain=t['color'], err=t['error'], comment=t['comment']) for n,t in themes.items()] + # # pprint(rows) + # html = tmpls.get_template('tmpl.html') + # info = {"rows":rows} + # with file('themes.html','w') as f: + # f.write(html.render(info).encode('utf-8')) + + + css = [] + tmpl = tmpls.get_template('tmpl.css') + for theme, clazz in css_themes.items(): + # colors = {c:rgbacolor(v) for c,v in themes[theme]['colors'].items()} + info = dict(clazz=clazz) + info.update({c:rgbacolor(v) for c,v in themes[theme]['colors'].items()}) + info['halfselection'] = rgbacolor(themes[theme]['colors']['selection'], .7) + print theme, clazz + css.append(tmpl.render(info)) + + with file('../autocomplete.css','w') as f: + f.write("\n".join(css)) + + +if __name__ == "__main__": + main() diff --git a/plotdevice/themedump/requirements.txt b/plotdevice/themedump/requirements.txt new file mode 100644 index 00000000000..b4aea016a40 --- /dev/null +++ b/plotdevice/themedump/requirements.txt @@ -0,0 +1,2 @@ +tinycss +jinja2 \ No newline at end of file diff --git a/plotdevice/themedump/tmpl.css b/plotdevice/themedump/tmpl.css new file mode 100644 index 00000000000..7eed363d006 --- /dev/null +++ b/plotdevice/themedump/tmpl.css @@ -0,0 +1,6 @@ +#editor.{{clazz}} ~ div.ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {border:1px solid {{selection}}; background-color:{{halfselection}};} +#editor.{{clazz}} ~ div.ace_autocomplete.ace-tm .ace_line{color:{{color}};} +#editor.{{clazz}} ~ div.ace_autocomplete.ace-tm .ace_line-hover {border-color:{{selection}}; background-color:{{halfselection}};} +#editor.{{clazz}} ~ div.ace_rightAlignedText {color:{{comment}};} +#editor.{{clazz}} ~ div.ace_autocomplete .ace_completion-highlight{color:{{error}};} +#editor.{{clazz}} ~ div.ace_autocomplete {background-color:{{background}}; color:{{color}}; border-color:{{color}};} diff --git a/plotdevice/themedump/tmpl.html b/plotdevice/themedump/tmpl.html new file mode 100644 index 00000000000..c03c1a5274c --- /dev/null +++ b/plotdevice/themedump/tmpl.html @@ -0,0 +1,24 @@ + + + + + + themedump + + + + + + + + +
+{% for row in rows %} +
+ {{row.theme}} Traceback (most recent call last): # Lorem ipsum dolor module +
+{% endfor %} +
+ + + From db93a90ef41a91bbc94129c89bdd208e3b3e3a27 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 21:09:52 -0400 Subject: [PATCH 09/17] ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c6a7ecc9975..1861c19fcfc 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ jam/ .git-ref npm-debug.log deps/ + +# themedump-generated files +plotdevice/autocomplete.css +plotdevice/themes.json \ No newline at end of file From 3052fb80fe92582beb49cc76e6c4be2032862a1e Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Thu, 13 Mar 2014 21:10:15 -0400 Subject: [PATCH 10/17] what it is --- Readme.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index d621b2a675c..0f3b1447c66 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,12 @@ +PlotDevice Editor +================= + +The PlotDevice application uses an embedded WebView for its text editor. This repository +contains the ace.js sources along with syntax-highlighting and tab-triggered snippets for the PlotDevice API. The main PlotDevice distribution includes a minified copy of the editor, so this repository is only useful if you wish to make additional customizations. + + Ace (Ajax.org Cloud9 Editor) -============================ +---------------------------- _Note_: The new site at http://ace.c9.io contains all the info below along with an embedding guide and all the other resources you need to get started with Ace. From abf942884b1052b7e86f507270486cef43dca869 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Sun, 20 Apr 2014 14:08:26 -0400 Subject: [PATCH 11/17] build script simplification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - plotdevice/unpack.sh adds the app-specific changes to the source tree - the `plod` dryice file builds our preferred subset of modules (if i could figure out how to cleanly pass the opts dict to the default dryice file that would be ideal, but i’m currently at a loss) - `make install` assumes a repo called `plotdevice` as a sibling to the `plotdevice-manual` directory --- Makefile | 54 +++++++------------ Makefile-plod.dryice.js | 24 +++++---- plotdevice/mode/plotdevice_highlight_rules.js | 10 ++-- plotdevice/unpack.sh | 8 +++ 4 files changed, 45 insertions(+), 51 deletions(-) create mode 100755 plotdevice/unpack.sh diff --git a/Makefile b/Makefile index d0f6018cdc3..890cd5bdb9f 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ pre_build: mkdir -p build/src mkdir -p build/demo/kitchen-sink mkdir -p build/textarea/src - + cp -r demo/kitchen-sink/styles.css build/demo/kitchen-sink/styles.css cp demo/kitchen-sink/logo.png build/demo/kitchen-sink/logo.png cp -r doc/site/images build/textarea @@ -18,42 +18,26 @@ build: pre_build # Minimal build: call Makefile.dryice.js only if our sources changed basic: build/src/ace.js -build/src/ace.js : ${wildcard lib/*} \ - ${wildcard lib/*/*} \ - ${wildcard lib/*/*/*} \ - ${wildcard lib/*/*/*/*} \ - ${wildcard lib/*/*/*/*/*} \ - ${wildcard lib/*/*/*/*/*/*} +build/src/ace.js: ${wildcard lib/*} \ + ${wildcard lib/*/*} \ + ${wildcard lib/*/*/*} \ + ${wildcard lib/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*/*} ./Makefile.dryice.js -build/src-min/ace.js : ${wildcard lib/*} \ - ${wildcard lib/*/*} \ - ${wildcard lib/*/*/*} \ - ${wildcard lib/*/*/*/*} \ - ${wildcard lib/*/*/*/*/*} \ - ${wildcard lib/*/*/*/*/*/*} - /usr/local/bin/node ./Makefile-plod.dryice.js minimal --m - -embed: build/src-min/ace.js - @mkdir -p build/editor - @echo "// ACE Editor" > build/ace.js - @for f in ${wildcard build/src-min/[a-s]*.js} ${wildcard build/src-min/snippets/*.js} ; \ - do cat $$f >> build/ace.js; \ - echo >> build/ace.js; \ - done - - @echo >> build/ace.js - @echo "// Color Themes" >> build/ace.js - @for f in ${wildcard build/src-min/theme*.js} ; \ - do cat $$f >> build/ace.js; \ - echo >> build/ace.js; \ - done - -install: embed - @./env/bin/python themedump.py > /dev/null - @cp build/ace.js ../../Resources/ui/js/ace.js - @cp build/themes.json ../../Resources/ui/themes.json - @cp build/autocomplete.css ../../Resources/ui/autocomplete.css +build/ace-min.js: ${wildcard lib/*} \ + ${wildcard lib/*/*} \ + ${wildcard lib/*/*/*} \ + ${wildcard lib/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*/*} + /usr/local/bin/node ./Makefile-plod.dryice.js minimal --s + +install: build/ace-min.js + @cp build/ace-min.js ../plotdevice/Resources/ui/js/ace.js + @cp plotdevice/themes.json ../plotdevice/Resources/ui/themes.json + @cp plotdevice/autocomplete.css ../plotdevice/Resources/ui/autocomplete.css doc: cd doc;\ diff --git a/Makefile-plod.dryice.js b/Makefile-plod.dryice.js index b567ccaf73c..139e205ed27 100755 --- a/Makefile-plod.dryice.js +++ b/Makefile-plod.dryice.js @@ -293,15 +293,15 @@ function getWriteFilters(options, projectType, main) { if (options.noconflict) filters.push(namespace(options.ns)); - + if (options.exportModule && projectType == "main" || projectType == "ext") { filters.push(exportAce(options.ns, options.exportModule, options.noconflict ? options.ns : "", projectType == "ext" && main)); } - + if (options.compress) filters.push(copy.filter.uglifyjs); - + // copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions filters.push(function(text) { var text = text.replace(/[\x00-\x08\x0b\x0c\x0e\x19\x80-\uffff]/g, function(c) { @@ -314,9 +314,9 @@ function getWriteFilters(options, projectType, main) { return "\\u0" + c; return "\\u" + c; }); - return text; + return text; }); - + return filters; } @@ -339,11 +339,13 @@ var buildAce = function(options) { modes: ["plotdevice","text"], themes: jsFileList("lib/ace/theme"), extensions: jsFileList("lib/ace/ext"), + // extensions: ['error_marker', 'keybinding_menu', 'language_tools'], // workers: workers("lib/ace/mode"), workers: [], keybindings: ["vim", "emacs"], readFilters: [copy.filter.moduleDefines] }; + console.log(options) for(var key in defaults) if (!options.hasOwnProperty(key)) @@ -419,7 +421,7 @@ var buildAce = function(options) { project.assumeAllFilesLoaded(); delete project.ignoredModules["ace/theme/textmate"]; delete project.ignoredModules["ace/requirejs/text!ace/theme/textmate.css"]; - + options.themes.forEach(function(theme) { console.log("theme " + theme); copy({ @@ -431,7 +433,7 @@ var buildAce = function(options) { dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".js" }); }); - + // generateThemesModule(options.themes); console.log('# ace key bindings ---------'); @@ -679,7 +681,7 @@ function exportAce(ns, module, requireBase, extModule) { }); })(); }; - + if (extModule) { module = extModule; template = function() { @@ -688,9 +690,9 @@ function exportAce(ns, module, requireBase, extModule) { })(); }; } - + text = text.replace(/function init\(packaged\) {/, "init(true);$&\n"); - + return (text + ";" + template .toString() .replace(/MODULE/g, module) @@ -707,7 +709,7 @@ function updateModes() { var source = fs.readFileSync(filepath, "utf8"); if (!/this.\$id\s*=\s*"/.test(source)) source = source.replace(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2'); - + source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"'); fs.writeFileSync(filepath, source, "utf8") }) diff --git a/plotdevice/mode/plotdevice_highlight_rules.js b/plotdevice/mode/plotdevice_highlight_rules.js index 9694776dc36..7cc50c9dad3 100644 --- a/plotdevice/mode/plotdevice_highlight_rules.js +++ b/plotdevice/mode/plotdevice_highlight_rules.js @@ -3,7 +3,7 @@ * * 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 @@ -14,7 +14,7 @@ * * 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 @@ -66,7 +66,7 @@ var PlotDeviceHighlightRules = function() { var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); var colorCodes = '(#?[a-f0-9]{3}([a-f0-9]{3}([a-f0-9]{2})?)?\\b)' - + //var futureReserved = ""; var keywordMapper = this.createKeywordMapper({ "invalid.deprecated": "debugger", @@ -105,10 +105,10 @@ var PlotDeviceHighlightRules = function() { regex : '\\bdef\\b|\\bclass\\b', next : "define" }, { - token : "constant.numeric", // string containing a hex or named color + token : "constant.numeric", // string containing a hex or named color regex : colorString }, { - token : "constant.numeric", // string containing a hex or named color + token : "constant.numeric", // string containing a hex or named color regex : qcolorString }, { token : "string", // multi line """ string start diff --git a/plotdevice/unpack.sh b/plotdevice/unpack.sh new file mode 100755 index 00000000000..4d76452bb1d --- /dev/null +++ b/plotdevice/unpack.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +ln -f mode/plotdevice.js ../lib/ace/mode/plotdevice.js +ln -f mode/plotdevice_highlight_rules.js ../lib/ace/mode/plotdevice_highlight_rules.js +ln -f snippets/plotdevice.js ../lib/ace/snippets/plotdevice.js +ln -f snippets/plotdevice.snippets ../lib/ace/snippets/plotdevice.snippets +ln -f theme/blackboard.css ../lib/ace/theme/blackboard.css +ln -f theme/blackboard.js ../lib/ace/theme/blackboard.js From a16dcb1a077e45d68c0ba46f51fdd5533c1b22d2 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Sun, 20 Apr 2014 14:42:58 -0400 Subject: [PATCH 12/17] moved build dir - `make install` now stages in plotdevice/editor rather than ./build --- .gitignore | 1 + Makefile | 8 ++++---- plotdevice/wipe.sh | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100755 plotdevice/wipe.sh diff --git a/.gitignore b/.gitignore index 1861c19fcfc..b9a996fa658 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,6 @@ npm-debug.log deps/ # themedump-generated files +plotdevice/editor plotdevice/autocomplete.css plotdevice/themes.json \ No newline at end of file diff --git a/Makefile b/Makefile index 890cd5bdb9f..d583aa2220b 100644 --- a/Makefile +++ b/Makefile @@ -26,16 +26,16 @@ build/src/ace.js: ${wildcard lib/*} \ ${wildcard lib/*/*/*/*/*/*} ./Makefile.dryice.js -build/ace-min.js: ${wildcard lib/*} \ +plotdevice/editor/ace-min.js: ${wildcard lib/*} \ ${wildcard lib/*/*} \ ${wildcard lib/*/*/*} \ ${wildcard lib/*/*/*/*} \ ${wildcard lib/*/*/*/*/*} \ ${wildcard lib/*/*/*/*/*/*} - /usr/local/bin/node ./Makefile-plod.dryice.js minimal --s + /usr/local/bin/node ./Makefile-plod.dryice.js minimal --s --target plotdevice/editor -install: build/ace-min.js - @cp build/ace-min.js ../plotdevice/Resources/ui/js/ace.js +install: plotdevice/editor/ace-min.js + @cp plotdevice/editor/ace-min.js ../plotdevice/Resources/ui/js/ace.js @cp plotdevice/themes.json ../plotdevice/Resources/ui/themes.json @cp plotdevice/autocomplete.css ../plotdevice/Resources/ui/autocomplete.css diff --git a/plotdevice/wipe.sh b/plotdevice/wipe.sh new file mode 100755 index 00000000000..01ca5fda876 --- /dev/null +++ b/plotdevice/wipe.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +rm ../lib/ace/mode/plotdevice.js +rm ../lib/ace/mode/plotdevice_highlight_rules.js +rm ../lib/ace/snippets/plotdevice.js +rm ../lib/ace/snippets/plotdevice.snippets +rm ../lib/ace/theme/blackboard.css +rm ../lib/ace/theme/blackboard.js From 2e700ed6d99cb1f5ccca0ad61d800895ae34be8c Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Sun, 20 Apr 2014 16:41:22 -0400 Subject: [PATCH 13/17] syntax updates - highlighting reflects changes to api - refined snippets --- .gitignore | 10 ++- plotdevice/mode/plotdevice_highlight_rules.js | 83 ++++++++++++------- plotdevice/snippets/plotdevice.snippets | 80 ++++++++++++------ 3 files changed, 115 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index b9a996fa658..604e1a96a19 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,12 @@ deps/ # themedump-generated files plotdevice/editor plotdevice/autocomplete.css -plotdevice/themes.json \ No newline at end of file +plotdevice/themes.json + +# plotdevice-specific syntax & themes +lib/ace/mode/plotdevice.js +lib/ace/mode/plotdevice_highlight_rules.js +lib/ace/snippets/plotdevice.js +lib/ace/snippets/plotdevice.snippets +lib/ace/theme/blackboard.css +lib/ace/theme/blackboard.js \ No newline at end of file diff --git a/plotdevice/mode/plotdevice_highlight_rules.js b/plotdevice/mode/plotdevice_highlight_rules.js index 7cc50c9dad3..adcce0548f8 100644 --- a/plotdevice/mode/plotdevice_highlight_rules.js +++ b/plotdevice/mode/plotdevice_highlight_rules.js @@ -39,42 +39,65 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var PlotDeviceHighlightRules = function() { - var keywords = ( - "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + - "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + - "raise|return|try|while|with|yield" + - "|adict|odict|ddict|BezierPath|Bezier|ClippingPath|Color|Context|Family|Font|Stylesheet|Grob|Image|PlotDeviceError|Oval|PathElement|Curve|Point|Rect|Text|Transform|TransformContext|Variable" - ); - - var builtinConstants = ( - "True|False|None|NotImplemented|Ellipsis|__debug__" - ); - - var builtinNumConstants = "DEFAULT|FRAME|PAGE|BEVEL|BOOLEAN|BUTT|BUTTON|CENTER|CLOSE|CMYK|CORNER|CURVETO|DEFAULT_HEIGHT|DEFAULT_WIDTH|FORTYFIVE|HEIGHT|HSB|JUSTIFY|KEY_BACKSPACE|KEY_DOWN|KEY_ESC|KEY_LEFT|KEY_RIGHT|KEY_TAB|KEY_UP|LEFT|LINETO|MITER|MOVETO|NORMAL|NUMBER|RGB|GREY|RIGHT|ROUND|SQUARE|TEXT|WIDTH|DEGREES|RADIANS|PERCENT|cm|inch|mm|pi|tau" - - var builtinFunctions = ( - "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + - "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + - "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + - "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + - "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + - "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + - "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + - "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern" + - "|plot|measure|stylesheet|order|ordered|shuffled|addvar|align|arrow|autoclosepath|autotext|background|beginclip|beginpath|bezier|canvas|capstyle|choice|clip|closepath|color|colormode|colorrange|colors|curveto|drawpath|ellipse|endclip|endpath|export|files|fill|findpath|findvar|font|fonts|fontsize|grid|image|imagesize|joinstyle|line|lineheight|lineto|moveto|pen|plotstyle|nofill|nostroke|outputmode|oval|pop|push|random|rect|reset|rotate|save|scale|size|skew|speed|star|state_vars|stroke|strokewidth|text|textheight|textmetrics|textpath|textwidth|transform|translate|var|ximport" - ); + var builtinKeywords = [ + "and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", + "exec", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "not", "or", + "pass", "print", "raise", "return", "try", "while", "with", "yield" + ] + + var plodClasses = [ + 'Bezier', 'BezierPath', 'Color', 'Curve', 'Effect', 'Family', 'Font', + 'Gradient', 'Grob', 'Image', 'Mask', 'PathElement', 'Pattern', 'Point', + 'Region', 'Shadow', 'Size', 'Stylesheet', 'Text', 'Transform', 'Variable', + 'adict', 'ddict', 'odict' + ] + + var builtinConstants = ["True", "False", "None", "NotImplemented", "Ellipsis", "__debug__"] + + var plodNumeric = [ + 'BEVEL', 'BOOLEAN', 'BUTT', 'BUTTON', 'CENTER', 'CLOSE', 'CMYK', 'CORNER', + 'CURVETO', 'DEFAULT', 'DEGREES', 'FORTYFIVE', 'FRAME', 'GREY', 'HEIGHT', 'HSB', + 'JUSTIFY', 'KEY_BACKSPACE', 'KEY_DOWN', 'KEY_ESC', 'KEY_LEFT', 'KEY_RIGHT', + 'KEY_TAB', 'KEY_UP', 'LEFT', 'LINETO', 'MITER', 'MOVETO', 'NORMAL', 'NUMBER', + 'PAGE', 'PERCENT', 'RADIANS', 'RGB', 'RIGHT', 'ROUND', 'SQUARE', 'TEXT', 'WIDTH', + 'cm', 'inch', 'mm', 'pi', 'pica', 'px', 'tau' + ] + + var builtinFunctions = [ + "abs", "divmod", "input", "open", "staticmethod", "all", "enumerate", "int", "ord", "str", "any", + "eval", "isinstance", "pow", "sum", "basestring", "execfile", "issubclass", "print", "super", + "binfile", "iter", "property", "tuple", "bool", "filter", "len", "range", "type", "bytearray", + "float", "list", "raw_input", "unichr", "callable", "format", "locals", "reduce", "unicode", + "chr", "frozenset", "long", "reload", "vars", "classmethod", "getattr", "map", "repr", "xrange", + "cmp", "globals", "max", "reversed", "zip", "compile", "hasattr", "memoryview", "round", + "__import__", "complex", "hash", "min", "set", "apply", "delattr", "help", "next", "setattr", + "buffer", "dict", "hex", "object", "slice", "coerce", "dir", "id", "oct", "sorted", "intern" + ] + + var plodFunctions = [ + 'align', 'alpha', 'arc', 'arcto', 'arrow', 'autoclosepath', 'autotext', + 'background', 'beginclip', 'beginpath', 'bezier', 'blend', 'canvas', + 'capstyle', 'choice', 'clear', 'clip', 'closepath', 'color', 'colormode', + 'colorrange', 'curveto', 'drawpath', 'ellipse', 'endclip', 'endpath', + 'export', 'files', 'fill', 'findpath', 'font', 'fonts', 'fontsize', + 'geometry', 'grid', 'image', 'imagesize', 'joinstyle', 'line', 'lineheight', + 'lineto', 'mask', 'measure', 'moveto', 'nofill', 'noshadow', 'nostroke', + 'order', 'ordered', 'outputmode', 'oval', 'pen', 'plot', 'poly', 'pop', + 'push', 'random', 'read', 'rect', 'reset', 'rotate', 'scale', 'shadow', + 'shuffled', 'size', 'skew', 'speed', 'star', 'stroke', 'strokewidth', + 'stylesheet', 'text', 'textheight', 'textmetrics', 'textpath', 'textwidth', + 'transform', 'translate', 'ximport' + ] var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); var colorCodes = '(#?[a-f0-9]{3}([a-f0-9]{3}([a-f0-9]{2})?)?\\b)' - //var futureReserved = ""; var keywordMapper = this.createKeywordMapper({ "invalid.deprecated": "debugger", - "support.function": builtinFunctions, - //"invalid.illegal": futureReserved, - "constant.language": builtinConstants, - "constant.numeric": builtinNumConstants, - "keyword": keywords + "support.function": builtinFunctions.concat(plodFunctions).join("|"), + "constant.language": builtinConstants.join("|"), + "constant.numeric": plodNumeric.join("|"), + "keyword": builtinKeywords.concat(plodClasses).join("|") }, "identifier"); var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; diff --git a/plotdevice/snippets/plotdevice.snippets b/plotdevice/snippets/plotdevice.snippets index ea2b14924f0..1fd5352f09a 100644 --- a/plotdevice/snippets/plotdevice.snippets +++ b/plotdevice/snippets/plotdevice.snippets @@ -97,8 +97,14 @@ snippet _ snippet align align(${1:LEFT/RIGHT/CENTER/JUSTIFY}) +snippet alpha + alpha(${1:1.0}) +snippet arc + arc(${1:x}, ${2:y}, ${3:radius}${4:, range=${5:None}, ccw=${6:False}, close=${7:False}}) +snippet arcto + arcto(${1:x}, ${2:y}${3:, cx=${4:None}, cy=${5:None}, radius=${6:None}, ccw=${7:False}, close=${8:False}}) snippet arrow - arrow(${1:x}, ${2:y}${3:, width=${4:100}, type=${5:NORMAL/FORTYFIVE}, draw=${6:True}}) + arrow(${1:x}, ${2:y}${3:, width=${4:100}, type=${5:NORMAL/FORTYFIVE}, plot=${6:True}}) snippet autoclosepath autoclosepath(${1:close=${2:True}}) snippet autotext @@ -106,17 +112,23 @@ snippet autotext snippet background background() snippet beginclip - beginclip(${1:path}) + beginclip(${1:stencil}${2:, mask=${3:False}, channel=${4:None}}) snippet beginpath beginpath(${1:${2:x}, ${3:y}}) snippet bezier - bezier(${1:${2:x}, ${3:y}}, close=${4:True}, draw=${5:True}) + bezier(${1:${2:x}, ${3:y}}, close=${4:True}, plot=${5:True}) +snippet blend + blend("${1:normal}") snippet capstyle capstyle(${1:style=${2:BUTT/ROUND/SQUARE}}) snippet choice choice(${1:seq}) +snippet clear + clear(${1:all}) snippet clip - clip() + clip(${1:stencil}${2:, channel="${3:black/white/alpha/red/green/blue}"}) +snippet mask + mask(${1:stencil}${2:, channel="${3:black/white/alpha/red/green/blue}"}) snippet closepath closepath() snippet color @@ -126,19 +138,19 @@ snippet colormode snippet colorrange colorrange(${1:maxval}) snippet curveto - curveto(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x}, ${6:y}) + curveto(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x}, ${6:y}${7:, close=${8:False}}) snippet drawpath drawpath(${1:path}) snippet ellipse - ellipse(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, draw=${6:True}}) + ellipse(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, range=${6:None}, ccw=${7:False}, close=${8:False}, plot=${9:True}}) snippet endclip endclip() snippet endpath - endpath(${1:draw=${2:True}}) + endpath(${1:plot=${2:True}}) snippet export - export("${1:${2:document}.${3:mov}}"${4:, loop=${5:None}, fps=${6:None}, bitrate=${7:1.0}}) + export("${1:${2:document}.${3:mov}}"${4:, fps=${5:None}, loop=${6:None}, bitrate=${7:1.0}}) snippet files - files("${1:${2:*}.${3:json}}") + files("${1:${2:*}.${3:json}}", case=${4:True}}) snippet fill fill(${1:"#${2:000}"}) snippet findpath @@ -151,62 +163,78 @@ snippet fonts fonts(${1:like="${2:akzidenz}", western=${3:True}}) snippet fontsize fontsize(${1:12}) +snippet geometry + geometry(${1:DEGREES/RADIANS/PERCENT}) snippet grid grid(${1:cols}, ${2:rows}${3:, colSize=${4:1}, rowSize=${5:1}, shuffled=${6:False}}) snippet image - image("${1:image.png}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, alpha=${7:1.0}, data=${8:None}, draw=${9:True}}) + image("${1:image.png}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, plot=${7:True}}) snippet imagesize imagesize("${1:image.png}"${2:, data=${3:None}}) snippet joinstyle joinstyle(${1:MITER/ROUND/BEVEL}) snippet line - line(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}${5:, draw=${6:True}}) + line(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}${5:, plot=${6:True}}) snippet lineheight lineheight(${1:None}) snippet lineto - lineto(${1:x}, ${2:y}) + lineto(${1:x}, ${2:y}${3:, close=${4:False}}) +snippet measure + measure(${1:obj}) snippet moveto moveto(${1:x}, ${2:y}) snippet nofill nofill() snippet nostroke nostroke() +snippet noshadow + noshadow() +snippet ordered + ordered(${1:seq}) snippet outputmode outputmode(${1:RGB/HSB/CMYK}) snippet oval - oval(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, draw=${6:True}}) + oval(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, range=${6:None}, ccw=${7:False}, close=${8:False}, plot=${9:True}}) +snippet pen + pen(${1:nib}) +snippet plot + plot(${1:obj}) +snippet poly + poly(${1:x}, ${2:y}, ${3:radius}, ${4:sides}${5:, plot=${6:True}}) snippet pop pop() snippet push push() snippet random random(${1:v1=${2:None}, v2=${3:None}}) +snippet read + read(${1:pth}${2:, format=${3:None}, encoding=${4:utf-8}, cols=${5:None}}) snippet rect - rect(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, roundness=${6:0.0}, draw=${7:True}}) + rect(${1:x}, ${2:y}, ${3:width}, ${4:height}${5:, roundness=${6:0.0}, plot=${7:True}}) snippet reset reset() snippet rotate - rotate(${1:degrees}) -snippet save - canvas.save("${1:${2:doc}.${3:pdf}}") -snippet canvas.save - canvas.save("${1:${2:doc}.${3:pdf}}") + rotate(${1:theta}) snippet scale scale(${1:x=${2:1}, y=${3:None}}) +snippet shadow + shadow(${1:"black"}, blur=${2:10}, offset=${3:10}))) +snippet shuffled + shuffled(${2:seq}) snippet size - size(${1:width}, ${2:height}) + size(${1:width}, ${2:height}, unit=${4:px}}) snippet skew - skew(${1:x=${2:0}, y=${3:0}}) + skew(${1:horizontal}, ${2:vertical}) snippet speed speed(${1:fps}) snippet star - star(${1:startx}, ${2:starty}${3:, points=${4:20}, outer=${5:100}, inner=${6:50}, draw=${7:True}}) + star(${1:x}, ${2:y}${3:, points=${4:20}, outer=${5:100}, inner=${6:None}, plot=${7:True}}}) snippet stroke stroke() snippet strokewidth - strokewidth(${1:None}) + strokewidth(${1:width}) snippet text - text("${1:txt}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, outline=${7:False}, draw=${8:True}}) + text("${1:txt}", ${2:x}, ${3:y}${4:, width=${5:None}, height=${6:None}, outline=${7:False}, plot=${8:True}}) snippet textheight textheight("${1:txt}"${2:, width=${3:None}}) snippet textmetrics @@ -221,8 +249,6 @@ snippet transform() with transform(${1:${2:CENTER/CORNER, }${3:...}}): $4 snippet translate - translate(x=${1:0}, y=${2:0}) -snippet var - var(${1:name}, type=${2:NUMBER/TEXT/BOOLEAN/BUTTON}${3:, default=${4:None}, min=${5:0}, max=${6:100}, value=${7:None}}) + translate(${1:x}, ${2:y}) snippet ximport ${1:libName} = ximport("$1") From 3ee65f2a131f0773a26ba6cb28a00a99953474cd Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Wed, 23 Apr 2014 09:54:22 -0400 Subject: [PATCH 14/17] added var() back to the api --- plotdevice/mode/plotdevice_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotdevice/mode/plotdevice_highlight_rules.js b/plotdevice/mode/plotdevice_highlight_rules.js index adcce0548f8..1187598263c 100644 --- a/plotdevice/mode/plotdevice_highlight_rules.js +++ b/plotdevice/mode/plotdevice_highlight_rules.js @@ -86,7 +86,7 @@ var PlotDeviceHighlightRules = function() { 'push', 'random', 'read', 'rect', 'reset', 'rotate', 'scale', 'shadow', 'shuffled', 'size', 'skew', 'speed', 'star', 'stroke', 'strokewidth', 'stylesheet', 'text', 'textheight', 'textmetrics', 'textpath', 'textwidth', - 'transform', 'translate', 'ximport' + 'transform', 'translate', "var", 'ximport' ] var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); From 2ece1287ce78687e5525900d457664d071a26aca Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Tue, 6 May 2014 20:28:21 -0400 Subject: [PATCH 15/17] remembered to minify --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d583aa2220b..bc7de8ddb1a 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ plotdevice/editor/ace-min.js: ${wildcard lib/*} \ /usr/local/bin/node ./Makefile-plod.dryice.js minimal --s --target plotdevice/editor install: plotdevice/editor/ace-min.js - @cp plotdevice/editor/ace-min.js ../plotdevice/Resources/ui/js/ace.js + @yui plotdevice/editor/ace-min.js > ../plotdevice/Resources/ui/js/ace.js @cp plotdevice/themes.json ../plotdevice/Resources/ui/themes.json @cp plotdevice/autocomplete.css ../plotdevice/Resources/ui/autocomplete.css From 7d1b8968226b25a8b9862f4e3de5c45b9b41e491 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Tue, 24 Jun 2014 15:56:38 -0400 Subject: [PATCH 16/17] updated some consts --- plotdevice/mode/plotdevice_highlight_rules.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plotdevice/mode/plotdevice_highlight_rules.js b/plotdevice/mode/plotdevice_highlight_rules.js index 1187598263c..b43764e86f5 100644 --- a/plotdevice/mode/plotdevice_highlight_rules.js +++ b/plotdevice/mode/plotdevice_highlight_rules.js @@ -53,10 +53,11 @@ var PlotDeviceHighlightRules = function() { ] var builtinConstants = ["True", "False", "None", "NotImplemented", "Ellipsis", "__debug__"] + var plodInteractive = ["MOUSEX", "MOUSEY", "KEY_UP", "KEY_DOWN", "KEY_LEFT", "KEY_RIGHT", "keydown", "mousedown", "keycode", "key"] var plodNumeric = [ 'BEVEL', 'BOOLEAN', 'BUTT', 'BUTTON', 'CENTER', 'CLOSE', 'CMYK', 'CORNER', - 'CURVETO', 'DEFAULT', 'DEGREES', 'FORTYFIVE', 'FRAME', 'GREY', 'HEIGHT', 'HSB', + 'CURVETO', 'DEFAULT', 'DEGREES', 'FORTYFIVE', 'FRAME', 'GREY', 'HEIGHT', 'HSV', 'JUSTIFY', 'KEY_BACKSPACE', 'KEY_DOWN', 'KEY_ESC', 'KEY_LEFT', 'KEY_RIGHT', 'KEY_TAB', 'KEY_UP', 'LEFT', 'LINETO', 'MITER', 'MOVETO', 'NORMAL', 'NUMBER', 'PAGE', 'PERCENT', 'RADIANS', 'RGB', 'RIGHT', 'ROUND', 'SQUARE', 'TEXT', 'WIDTH', @@ -89,13 +90,13 @@ var PlotDeviceHighlightRules = function() { 'transform', 'translate', "var", 'ximport' ] - var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); + var colorEntities = ('aliceblue|antiquewhite|aqua|aquamarine|azure|bark|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen'); var colorCodes = '(#?[a-f0-9]{3}([a-f0-9]{3}([a-f0-9]{2})?)?\\b)' var keywordMapper = this.createKeywordMapper({ "invalid.deprecated": "debugger", "support.function": builtinFunctions.concat(plodFunctions).join("|"), - "constant.language": builtinConstants.join("|"), + "constant.language": builtinConstants.concat(plodInteractive).join("|"), "constant.numeric": plodNumeric.join("|"), "keyword": builtinKeywords.concat(plodClasses).join("|") }, "identifier"); From bc053d91a2953d37765acdb9230def9a4cbca542 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Tue, 24 Jun 2014 15:57:36 -0400 Subject: [PATCH 17/17] updated install location - presumes `plotdevice` and `plotdevice-manual` are sibling folders --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bc7de8ddb1a..c2500425349 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,9 @@ plotdevice/editor/ace-min.js: ${wildcard lib/*} \ /usr/local/bin/node ./Makefile-plod.dryice.js minimal --s --target plotdevice/editor install: plotdevice/editor/ace-min.js - @yui plotdevice/editor/ace-min.js > ../plotdevice/Resources/ui/js/ace.js - @cp plotdevice/themes.json ../plotdevice/Resources/ui/themes.json - @cp plotdevice/autocomplete.css ../plotdevice/Resources/ui/autocomplete.css + @yui plotdevice/editor/ace-min.js > ../plotdevice/app/Resources/ui/js/ace.js + @cp plotdevice/themes.json ../plotdevice/app/Resources/ui/themes.json + @cp plotdevice/autocomplete.css ../plotdevice/app/Resources/ui/autocomplete.css doc: cd doc;\