4
* Copyright (C) 2009-11 by RStudio, Inc.
6
* This program is licensed to you under the terms of version 3 of the
7
* GNU Affero General Public License. This program is distributed WITHOUT
8
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
9
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
10
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13
define('ace/mode/rdoc', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/rdoc_highlight_rules', 'ace/mode/matching_brace_outdent'], function(require, exports, module) {
16
var oop = require("../lib/oop");
17
var TextMode = require("./text").Mode;
18
var Tokenizer = require("../tokenizer").Tokenizer;
19
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
20
var RDocHighlightRules = require("./rdoc_highlight_rules").RDocHighlightRules;
21
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
23
var Mode = function(suppressHighlighting) {
24
this.$tokenizer = new Tokenizer(new RDocHighlightRules().getRules());
25
this.$outdent = new MatchingBraceOutdent();
27
oop.inherits(Mode, TextMode);
30
this.getNextLineIndent = function(state, line, tab) {
31
return this.$getIndent(line);
33
}).call(Mode.prototype);
37
define('ace/mode/rdoc_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules', 'ace/mode/latex_highlight_rules'], function(require, exports, module) {
40
var oop = require("../lib/oop");
41
var lang = require("../lib/lang");
42
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
43
var LaTeXHighlightRules = require("./latex_highlight_rules");
45
var RDocHighlightRules = function() {
53
token : "text", // non-command
54
regex : "\\\\[$&%#\\{\\}]"
56
token : "keyword", // command
57
regex : "\\\\(?:name|alias|method|S3method|S4method|item|code|preformatted|kbd|pkg|var|env|option|command|author|email|url|source|cite|acronym|href|code|preformatted|link|eqn|deqn|keyword|usage|examples|dontrun|dontshow|figure|if|ifelse|Sexpr|RdOpts|inputencoding|usepackage)\\b",
60
token : "keyword", // command
61
regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])"
63
token : "paren.keyword.operator",
66
token : "paren.keyword.operator",
79
token : "nospell.text", // non-command
80
regex : "\\\\[$&%#\\{\\}]"
82
token : "keyword", // command
83
regex : "\\\\(?:name|alias|method|S3method|S4method|item|code|preformatted|kbd|pkg|var|env|option|command|author|email|url|source|cite|acronym|href|code|preformatted|link|eqn|deqn|keyword|usage|examples|dontrun|dontshow|figure|if|ifelse|Sexpr|RdOpts|inputencoding|usepackage)\\b"
85
token : "keyword", // command
86
regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])",
89
token : "paren.keyword.operator",
92
token : "paren.keyword.operator",
95
token : "paren.keyword.operator",
99
token : "nospell.text",
102
token : "nospell.text",
109
oop.inherits(RDocHighlightRules, TextHighlightRules);
111
exports.RDocHighlightRules = RDocHighlightRules;
113
define('ace/mode/latex_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
116
var oop = require("../lib/oop");
117
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
119
var LatexHighlightRules = function() {
123
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
132
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
140
oop.inherits(LatexHighlightRules, TextHighlightRules);
142
exports.LatexHighlightRules = LatexHighlightRules;
146
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
149
var Range = require("../range").Range;
151
var MatchingBraceOutdent = function() {};
155
this.checkOutdent = function(line, input) {
156
if (! /^\s+$/.test(line))
159
return /^\s*\}/.test(input);
162
this.autoOutdent = function(doc, row) {
163
var line = doc.getLine(row);
164
var match = line.match(/^(\s*\})/);
166
if (!match) return 0;
168
var column = match[1].length;
169
var openBracePos = doc.findMatchingBracket({row: row, column: column});
171
if (!openBracePos || openBracePos.row == row) return 0;
173
var indent = this.$getIndent(doc.getLine(openBracePos.row));
174
doc.replace(new Range(row, 0, row, column-1), indent);
177
this.$getIndent = function(line) {
178
return line.match(/^\s*/)[0];
181
}).call(MatchingBraceOutdent.prototype);
183
exports.MatchingBraceOutdent = MatchingBraceOutdent;