From 700fcb7e636cea7254a9b5d3e8ef46a6db10c536 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Fri, 28 Jan 2011 17:05:28 +0100 Subject: [PATCH 01/25] started adding ruby syntax highlighting --- lib/ace/mode/ruby.js | 170 ++++++++++++++++++++++++++ lib/ace/mode/ruby_highlight_rules.js | 172 +++++++++++++++++++++++++++ 2 files changed, 342 insertions(+) create mode 100644 lib/ace/mode/ruby.js create mode 100644 lib/ace/mode/ruby_highlight_rules.js diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js new file mode 100644 index 00000000..732eb541 --- /dev/null +++ b/lib/ace/mode/ruby.js @@ -0,0 +1,170 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * Shlomo Zalman Heigh + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var oop = require("pilot/oop"); +var TextMode = require("ace/mode/text").Mode; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules; +var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; +var Range = require("ace/range").Range; +var WorkerClient = require("ace/worker/worker_client").WorkerClient; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var outentedRows = []; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i).replace(re, "$1"); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = line.length + 2; + doc.replace(deleteRange, line); + } + return -2; + } + else { + return doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + return this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var doc = session.getDocument(); + var worker = new WorkerClient("../..", ["ace", "pilot"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.call("setValue", [doc.getValue()]); + + doc.on("change", function(e) { + e.range = { + start: e.data.range.start, + end: e.data.range.end + }; + worker.emit("change", e); + }); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i + * Shlomo Zalman Heigh + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var oop = require("pilot/oop"); +var lang = require("pilot/lang"); +var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; + +RubyHighlightRules = function() { + + var docComment = new DocCommentHighlightRules(); + + var keywords = lang.arrayToMap( + ("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|finally|for|" + + "if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield").split("|") + ); + + var buildinConstants = lang.arrayToMap( + ("true|false|nil").split("|") + ); + + var futureReserved = lang.arrayToMap([]); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "/#.*$/" + }, + docComment.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "/^\=begin$/", + next : "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 : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : function(value) { + if (value == "this") + return "variable.language"; + else if (keywords[value]) + return "keyword"; + else if (buildinConstants[value]) + return "constant.language"; + else if (futureReserved[value]) + return "invalid.illegal"; + else if (value == "debugger") + return "invalid.deprecated"; + else + return "identifier"; + }, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "/^\=end$/", + next : "start" + }, { + token : "comment", // comment spanning whole line + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + regex : '.+' + } + ] + }; + + this.addRules(docComment.getRules(), "doc-"); + this.$rules["doc-start"][0].next = "start"; +}; + +oop.inherits(RubyHighlightRules, TextHighlightRules); + +exports.RubyHighlightRules = RubyHighlightRules; +}); From a642d9891262dedb16d992124ecebab04486ae1c Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Fri, 28 Jan 2011 19:49:19 +0100 Subject: [PATCH 02/25] more ruby support --- lib/ace/mode/javascript_highlight_rules.js | 2 +- lib/ace/mode/ruby.js | 41 ---------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/lib/ace/mode/javascript_highlight_rules.js b/lib/ace/mode/javascript_highlight_rules.js index fd66db1a..b16f5969 100644 --- a/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/ace/mode/javascript_highlight_rules.js @@ -67,7 +67,7 @@ JavaScriptHighlightRules = function() { "start" : [ { token : "comment", - regex : "\\/\\/.*$" + regex : "/#.*$/" }, docComment.getStartRule("doc-start"), { diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js index 732eb541..840b4f73 100644 --- a/lib/ace/mode/ruby.js +++ b/lib/ace/mode/ruby.js @@ -122,47 +122,6 @@ oop.inherits(Mode, TextMode); this.autoOutdent = function(state, doc, row) { return this.$outdent.autoOutdent(doc, row); }; - - this.createWorker = function(session) { - var doc = session.getDocument(); - var worker = new WorkerClient("../..", ["ace", "pilot"], "ace/mode/javascript_worker", "JavaScriptWorker"); - worker.call("setValue", [doc.getValue()]); - - doc.on("change", function(e) { - e.range = { - start: e.data.range.start, - end: e.data.range.end - }; - worker.emit("change", e); - }); - - worker.on("jslint", function(results) { - var errors = []; - for (var i=0; i Date: Fri, 28 Jan 2011 20:49:43 +0100 Subject: [PATCH 03/25] fixed typo - JavaScript instead of Ruby --- lib/ace/mode/ruby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js index 840b4f73..34dd286d 100644 --- a/lib/ace/mode/ruby.js +++ b/lib/ace/mode/ruby.js @@ -41,7 +41,7 @@ define(function(require, exports, module) { var oop = require("pilot/oop"); var TextMode = require("ace/mode/text").Mode; var Tokenizer = require("ace/tokenizer").Tokenizer; -var JavaScriptHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules; +var RubyHighlightRules = require("ace/mode/ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; var Range = require("ace/range").Range; var WorkerClient = require("ace/worker/worker_client").WorkerClient; From 54507f44e7027c6b6adcf26df6cc2fbcb5664e80 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Sun, 30 Jan 2011 02:31:59 +0100 Subject: [PATCH 04/25] fixed changed JS instead of Ruby --- lib/ace/mode/javascript_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/javascript_highlight_rules.js b/lib/ace/mode/javascript_highlight_rules.js index b16f5969..fd66db1a 100644 --- a/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/ace/mode/javascript_highlight_rules.js @@ -67,7 +67,7 @@ JavaScriptHighlightRules = function() { "start" : [ { token : "comment", - regex : "/#.*$/" + regex : "\\/\\/.*$" }, docComment.getStartRule("doc-start"), { From d291e0aa68ad63235336f294e77b27bf62f980f0 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Sun, 30 Jan 2011 16:47:02 +0100 Subject: [PATCH 05/25] fixed ruby comment RegExps --- lib/ace/mode/ruby.js | 4 ++-- lib/ace/mode/ruby_highlight_rules.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js index 34dd286d..9214228d 100644 --- a/lib/ace/mode/ruby.js +++ b/lib/ace/mode/ruby.js @@ -57,7 +57,7 @@ oop.inherits(Mode, TextMode); this.toggleCommentLines = function(state, doc, startRow, endRow) { var outdent = true; var outentedRows = []; - var re = /^(\s*)\/\//; + var re = /^(\s*)#/; for (var i=startRow; i<= endRow; i++) { if (!re.test(doc.getLine(i))) { @@ -95,7 +95,7 @@ oop.inherits(Mode, TextMode); } if (state == "start") { - var match = line.match(/^.*[\{\(\[]\s*$/); + var match = line.match(/^.*[\{\(\[\:]\s*$/); if (match) { indent += tab; } diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index e16ed499..a331799e 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -65,12 +65,12 @@ RubyHighlightRules = function() { "start" : [ { token : "comment", - regex : "/#.*$/" + regex : "#.*$" }, docComment.getStartRule("doc-start"), { token : "comment", // multi line comment - regex : "/^\=begin$/", + regex : "^\=begin$", next : "comment" }, { token : "string.regexp", @@ -133,7 +133,7 @@ RubyHighlightRules = function() { "comment" : [ { token : "comment", // closing comment - regex : "/^\=end$/", + regex : "^\=end$", next : "start" }, { token : "comment", // comment spanning whole line From 3df5555bd16c29b597ac4273e13568553beb1ceb Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Mon, 31 Jan 2011 00:30:39 +0100 Subject: [PATCH 06/25] more ruby syntax highlighting rules --- lib/ace/mode/ruby_highlight_rules.js | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index a331799e..d6cb871e 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -47,15 +47,27 @@ RubyHighlightRules = function() { var docComment = new DocCommentHighlightRules(); + var builtinFunctions = lang.arrayToMap( + ("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!" + + "fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|" + + "printf|proc|putc|puts|raise|rand|readline|readlines|require|scan|select|set_trace_func|sleep|split|sprintf|srand|" + + "String|syscall|system|sub|sub!|test|throw|trace_var|trap|untrace_var|" + + "atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan").split("|") + ); + var keywords = lang.arrayToMap( - ("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|finally|for|" + - "if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield").split("|") + ("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|__FILE__|finally|for|" + + "if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|") ); var buildinConstants = lang.arrayToMap( - ("true|false|nil").split("|") + ("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|") ); - + + var builtinVariables = lang.arrayToMap( + ("$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE").split("|") + ); + var futureReserved = lang.arrayToMap([]); // regexp must not have capturing parentheses. Use (?:) instead. @@ -70,7 +82,7 @@ RubyHighlightRules = function() { docComment.getStartRule("doc-start"), { token : "comment", // multi line comment - regex : "^\=begin$", + regex : "^=begin", next : "comment" }, { token : "string.regexp", @@ -100,14 +112,18 @@ RubyHighlightRules = function() { regex : "(?:true|false)\\b" }, { token : function(value) { - if (value == "this") + if (value == "self") return "variable.language"; else if (keywords[value]) return "keyword"; else if (buildinConstants[value]) return "constant.language"; - else if (futureReserved[value]) - return "invalid.illegal"; + else if (builtinVariables[value]) + return "variable.language"; + else if (futureReserved[value]) + return "invalid.illegal"; + else if (builtinFunctions[value]) + return "support.function"; else if (value == "debugger") return "invalid.deprecated"; else @@ -133,7 +149,7 @@ RubyHighlightRules = function() { "comment" : [ { token : "comment", // closing comment - regex : "^\=end$", + regex : "^=end", next : "start" }, { token : "comment", // comment spanning whole line From d01e358790277ff1c8c48e408df49eb60f23e8d9 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 14:44:50 +0100 Subject: [PATCH 07/25] fixed some things, see https://groups.google.com/d/msg/ace-internals/Esa5o7DC0Go/8EXOdchDNPgJ --- lib/ace/mode/ruby_highlight_rules.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index d6cb871e..1d6b94ce 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -40,13 +40,10 @@ define(function(require, exports, module) { var oop = require("pilot/oop"); var lang = require("pilot/lang"); -var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules; var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; RubyHighlightRules = function() { - var docComment = new DocCommentHighlightRules(); - var builtinFunctions = lang.arrayToMap( ("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!" + "fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|" + @@ -65,11 +62,9 @@ RubyHighlightRules = function() { ); var builtinVariables = lang.arrayToMap( - ("$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE").split("|") + ("\\$DEBUG|\\$defout|\\$FILENAME|\\$LOAD_PATH|\\$SAFE|\\$stdin|\\$stdout|\\$stderr|\\$VERBOSE").split("|") ); - var futureReserved = lang.arrayToMap([]); - // regexp must not have capturing parentheses. Use (?:) instead. // regexps are ordered -> the first match is used @@ -81,10 +76,6 @@ RubyHighlightRules = function() { }, docComment.getStartRule("doc-start"), { - token : "comment", // multi line comment - regex : "^=begin", - next : "comment" - }, { token : "string.regexp", regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" }, { @@ -148,10 +139,6 @@ RubyHighlightRules = function() { ], "comment" : [ { - token : "comment", // closing comment - regex : "^=end", - next : "start" - }, { token : "comment", // comment spanning whole line regex : ".+" } From b73a8fa1fd988fa45dee91d75730bb74b4302595 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 14:47:03 +0100 Subject: [PATCH 08/25] fixed one more thing, forgotten from last commit --- lib/ace/mode/ruby_highlight_rules.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 1d6b94ce..37549820 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -110,8 +110,6 @@ RubyHighlightRules = function() { else if (buildinConstants[value]) return "constant.language"; else if (builtinVariables[value]) - return "variable.language"; - else if (futureReserved[value]) return "invalid.illegal"; else if (builtinFunctions[value]) return "support.function"; From 9de71274a0a81989f8bd0baabec46ad4b8a99447 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 14:50:59 +0100 Subject: [PATCH 09/25] fixed removed wrong line --- lib/ace/mode/ruby_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 37549820..5b9038e5 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -110,7 +110,7 @@ RubyHighlightRules = function() { else if (buildinConstants[value]) return "constant.language"; else if (builtinVariables[value]) - return "invalid.illegal"; + return "variable.language"; else if (builtinFunctions[value]) return "support.function"; else if (value == "debugger") From 0b34f168230787b72247b85f8e9965dd153ed489 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 17:17:35 +0100 Subject: [PATCH 10/25] https://groups.google.com/d/msg/ace-internals/Esa5o7DC0Go/X3LUZrMNL68J --- lib/ace/mode/ruby_highlight_rules.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 5b9038e5..dfe141d3 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -140,31 +140,8 @@ RubyHighlightRules = function() { token : "comment", // comment spanning whole line regex : ".+" } - ], - "qqstring" : [ - { - token : "string", - regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', - next : "start" - }, { - token : "string", - regex : '.+' - } - ], - "qstring" : [ - { - token : "string", - regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", - next : "start" - }, { - token : "string", - regex : '.+' - } ] }; - - this.addRules(docComment.getRules(), "doc-"); - this.$rules["doc-start"][0].next = "start"; }; oop.inherits(RubyHighlightRules, TextHighlightRules); From 0e7bd9aaa844740263b46768d14e5d361c706587 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 17:58:07 +0100 Subject: [PATCH 11/25] add ruby to demo/startup.js --- demo/startup.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/demo/startup.js b/demo/startup.js index c56a8dc6..85bd016c 100644 --- a/demo/startup.js +++ b/demo/startup.js @@ -52,6 +52,7 @@ exports.launch = function(env) { var XmlMode = require("ace/mode/xml").Mode; var PythonMode = require("ace/mode/python").Mode; var PhpMode = require("ace/mode/php").Mode; + var RubyMode = require("ace/mode/ruby").Mode; var TextMode = require("ace/mode/text").Mode; var UndoManager = require("ace/undomanager").UndoManager; @@ -102,6 +103,10 @@ exports.launch = function(env) { docs.php.setMode(new PhpMode()); docs.php.setUndoManager(new UndoManager()); + docs.ruby = new EditSession(document.getElementById("rubytext").innerHTML); + docs.ruby.setMode(new RubyMode()); + docs.ruby.setUndoManager(new UndoManager()); + var container = document.getElementById("editor"); env.editor = new Editor(new Renderer(container, theme)); @@ -113,7 +118,8 @@ exports.launch = function(env) { css: new CssMode(), javascript: new JavaScriptMode(), python: new PythonMode(), - php: new PhpMode() + php: new PhpMode(), + ruby: new RubyMode() }; function getMode() { @@ -146,6 +152,9 @@ exports.launch = function(env) { else if (mode instanceof PhpMode) { modeEl.value = "php"; } + else if (mode instanceof RubyMode) { + modeEl.value = "ruby"; + } else { modeEl.value = "text"; } @@ -272,6 +281,9 @@ exports.launch = function(env) { } else if (/^.*\.php$/i.test(file.name)) { mode = "php"; } + } else if (/^.*\.rb$/i.test(file.name)) { + mode = "ruby"; + } env.editor.onTextInput(reader.result); From 595f69bf703d56e9b8a6377b1f80c1731f7f937f Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 18:12:04 +0100 Subject: [PATCH 12/25] update ace demo --- editor.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/editor.html b/editor.html index be7968b2..bfd22663 100644 --- a/editor.html +++ b/editor.html @@ -19,6 +19,7 @@ + @@ -72,6 +73,7 @@ + From 5db453ebeb87a469c6311756605f0cbe7801d08b Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 20:24:54 +0100 Subject: [PATCH 13/25] added sample ruby code to editor.html --- editor.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/editor.html b/editor.html index bfd22663..576976f2 100644 --- a/editor.html +++ b/editor.html @@ -176,6 +176,10 @@ echo $output; ?> + + From d29723b9b96f6d720e6899c2196bfd705a245e1f Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 20:26:47 +0100 Subject: [PATCH 14/25] fixed php instead of ruby --- editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.html b/editor.html index 576976f2..7629b500 100644 --- a/editor.html +++ b/editor.html @@ -176,7 +176,7 @@ echo $output; ?> - From b23ff177cd119de46f9ae2226bc5845664d8fd93 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 20:30:20 +0100 Subject: [PATCH 15/25] fixed extra square-bracket --- demo/startup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/demo/startup.js b/demo/startup.js index 85bd016c..0436e29e 100644 --- a/demo/startup.js +++ b/demo/startup.js @@ -280,7 +280,6 @@ exports.launch = function(env) { mode = "python"; } else if (/^.*\.php$/i.test(file.name)) { mode = "php"; - } } else if (/^.*\.rb$/i.test(file.name)) { mode = "ruby"; } From 25288442f4a77ef2218ff1d301ea412a734d8513 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Tue, 1 Feb 2011 20:33:51 +0100 Subject: [PATCH 16/25] removed docComment --- lib/ace/mode/ruby_highlight_rules.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index dfe141d3..9cf7a12a 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -73,9 +73,7 @@ RubyHighlightRules = function() { { token : "comment", regex : "#.*$" - }, - docComment.getStartRule("doc-start"), - { + }, { token : "string.regexp", regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" }, { From 67836cc281df98d50716329d581d70d6e8354c22 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:05:15 +0100 Subject: [PATCH 17/25] ruby multi-line comments --- lib/ace/mode/ruby.js | 2 +- lib/ace/mode/ruby_highlight_rules.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js index 9214228d..ed68bb4c 100644 --- a/lib/ace/mode/ruby.js +++ b/lib/ace/mode/ruby.js @@ -79,7 +79,7 @@ oop.inherits(Mode, TextMode); return -2; } else { - return doc.indentRows(startRow, endRow, "//"); + return doc.indentRows(startRow, endRow, "#"); } }; diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 9cf7a12a..dc4de4a6 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -74,6 +74,10 @@ RubyHighlightRules = function() { token : "comment", regex : "#.*$" }, { + token : "comment", // multi line comment + regex : "^\=begin$", + next : "comment" + }, { token : "string.regexp", regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" }, { @@ -135,6 +139,10 @@ RubyHighlightRules = function() { ], "comment" : [ { + token : "comment", // closing comment + regex : "^\=end$", + next : "start" + }, { token : "comment", // comment spanning whole line regex : ".+" } From c2c7fc8f246b5d5d245cd20d6a465205e4b20f12 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:17:18 +0100 Subject: [PATCH 18/25] fixed up ruby.js --- lib/ace/mode/ruby.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/ace/mode/ruby.js b/lib/ace/mode/ruby.js index ed68bb4c..89b7a04d 100644 --- a/lib/ace/mode/ruby.js +++ b/lib/ace/mode/ruby.js @@ -95,21 +95,10 @@ oop.inherits(Mode, TextMode); } if (state == "start") { - var match = line.match(/^.*[\{\(\[\:]\s*$/); + var match = line.match(/^.*[\{\(\[]\s*$/); if (match) { indent += tab; } - } else if (state == "doc-start") { - if (endState == "start") { - return ""; - } - var match = line.match(/^\s*(\/?)\*/); - if (match) { - if (match[1]) { - indent += " "; - } - indent += "* "; - } } return indent; From 8b058e6d3621275fa468ed5f375598ba8e189421 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:23:25 +0100 Subject: [PATCH 19/25] removed qstring and qqstring --- lib/ace/mode/ruby_highlight_rules.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index dc4de4a6..b15f7d87 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -85,15 +85,13 @@ RubyHighlightRules = function() { regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }, { token : "string", // multi line string start - regex : '["].*\\\\$', - next : "qqstring" + regex : '["].*\\\\$' }, { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }, { token : "string", // multi line string start - regex : "['].*\\\\$", - next : "qstring" + regex : "['].*\\\\$" }, { token : "constant.numeric", // hex regex : "0[xX][0-9a-fA-F]+\\b" From 609e136ac54195667de90e8e144e1b0d5d1e8170 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:32:24 +0100 Subject: [PATCH 20/25] removed multi-line strings, ruby doesn't support that type --- lib/ace/mode/ruby_highlight_rules.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index b15f7d87..56f47288 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -83,15 +83,9 @@ RubyHighlightRules = function() { }, { token : "string", // single line regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' - }, { - token : "string", // multi line string start - regex : '["].*\\\\$' }, { token : "string", // single line regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" - }, { - token : "string", // multi line string start - regex : "['].*\\\\$" }, { token : "constant.numeric", // hex regex : "0[xX][0-9a-fA-F]+\\b" From 8abbd200a4a7491c5b531f651a5965932f2cae2b Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:36:16 +0100 Subject: [PATCH 21/25] removed // comments, not supported in ruby --- lib/ace/mode/ruby_highlight_rules.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 56f47288..69b6989d 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -80,12 +80,6 @@ RubyHighlightRules = function() { }, { token : "string.regexp", regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" - }, { - token : "string", // single line - regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' - }, { - token : "string", // single line - regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }, { token : "constant.numeric", // hex regex : "0[xX][0-9a-fA-F]+\\b" From 8bdb9126c4b63d020e48e5b3520c8791ff37cb8d Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:42:25 +0100 Subject: [PATCH 22/25] undo last commit, accidentally removed strings instead of // comments --- lib/ace/mode/ruby_highlight_rules.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 69b6989d..73e3302c 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -80,6 +80,12 @@ RubyHighlightRules = function() { }, { token : "string.regexp", regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }, { token : "constant.numeric", // hex regex : "0[xX][0-9a-fA-F]+\\b" From fb45af98c72830a94f30962d2074a003a51d5176 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:54:21 +0100 Subject: [PATCH 23/25] build in variables --- lib/ace/mode/ruby_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/ruby_highlight_rules.js b/lib/ace/mode/ruby_highlight_rules.js index 73e3302c..27187068 100644 --- a/lib/ace/mode/ruby_highlight_rules.js +++ b/lib/ace/mode/ruby_highlight_rules.js @@ -62,7 +62,7 @@ RubyHighlightRules = function() { ); var builtinVariables = lang.arrayToMap( - ("\\$DEBUG|\\$defout|\\$FILENAME|\\$LOAD_PATH|\\$SAFE|\\$stdin|\\$stdout|\\$stderr|\\$VERBOSE").split("|") + ("\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE").split("|") ); // regexp must not have capturing parentheses. Use (?:) instead. From 2125a919f4c37a2e4aa813d0a046f54a70906d52 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:57:21 +0100 Subject: [PATCH 24/25] updated ruby demo --- editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.html b/editor.html index 7629b500..0c99f88c 100644 --- a/editor.html +++ b/editor.html @@ -177,7 +177,7 @@ echo $output; ?> From 03a7efbbf8b4cbc1abdc114c2d213d7afacee180 Mon Sep 17 00:00:00 2001 From: Heigh Tech LLC Date: Wed, 2 Feb 2011 15:59:06 +0100 Subject: [PATCH 25/25] mend --- editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor.html b/editor.html index 0c99f88c..a1165e7b 100644 --- a/editor.html +++ b/editor.html @@ -176,7 +176,7 @@ echo $output; ?> -