/
sweave.js
71 lines (60 loc) · 2.18 KB
/
sweave.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* sweave.js
*
* Copyright (C) 2009-11 by RStudio, Inc.
*
* 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.
*
* This program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
define("mode/sweave", function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var SweaveHighlightRules = require("mode/sweave_highlight_rules").SweaveHighlightRules;
var RCodeModel = require("mode/r_code_model").RCodeModel;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var Mode = function(suppressHighlighting, doc) {
if (suppressHighlighting)
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
else
this.$tokenizer = new Tokenizer(new SweaveHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$rCodeModel = new RCodeModel(doc, this.$tokenizer, /^r-/);
};
oop.inherits(Mode, TextMode);
(function() {
this.$complements = {
"(": ")",
"[": "]",
'"': '"',
"'": "'",
"{": "}"
};
this.$reOpen = /^[(["'{]$/;
this.$reClose = /^[)\]"'}]$/;
this.getNextLineIndent = function(state, line, tab, tabSize, row)
{
return this.$rCodeModel.getNextLineIndent(row, line, state, tab, tabSize);
};
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.allowAutoInsert = this.smartAllowAutoInsert;
}).call(Mode.prototype);
exports.Mode = Mode;
});