/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/ace/mode-rdoc.js

  • Committer: galaxyAbstractor
  • Date: 2013-04-10 15:49:32 UTC
  • mto: (19.1.5 lenasys)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: galaxyabstractor@gmail.com-20130410154932-4vizlzk0ar5gykvi
* Added an simple admin panel to the codeviewer-cmssy stuff
* Redesigned a bit like the mockups - still stuff to come
* Implemented the codeviewer + admin panel again using the Framework CodeIgniter instead 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * rdoc.js
 
3
 *
 
4
 * Copyright (C) 2009-11 by RStudio, Inc.
 
5
 *
 
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.
 
11
 *
 
12
 */
 
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) {
 
14
 
 
15
 
 
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;
 
22
 
 
23
var Mode = function(suppressHighlighting) {
 
24
        this.$tokenizer = new Tokenizer(new RDocHighlightRules().getRules());
 
25
    this.$outdent = new MatchingBraceOutdent();
 
26
};
 
27
oop.inherits(Mode, TextMode);
 
28
 
 
29
(function() {
 
30
    this.getNextLineIndent = function(state, line, tab) {
 
31
        return this.$getIndent(line);
 
32
    };
 
33
}).call(Mode.prototype);
 
34
 
 
35
exports.Mode = Mode;
 
36
});
 
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) {
 
38
 
 
39
 
 
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");
 
44
 
 
45
var RDocHighlightRules = function() {
 
46
 
 
47
    this.$rules = {
 
48
        "start" : [
 
49
                {
 
50
                    token : "comment",
 
51
                    regex : "%.*$"
 
52
                }, {
 
53
                    token : "text", // non-command
 
54
                    regex : "\\\\[$&%#\\{\\}]"
 
55
                }, {
 
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",
 
58
               next : "nospell"
 
59
                }, {
 
60
                    token : "keyword", // command
 
61
                    regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])"
 
62
                }, {
 
63
               token : "paren.keyword.operator",
 
64
                    regex : "[[({]"
 
65
                }, {
 
66
               token : "paren.keyword.operator",
 
67
                    regex : "[\\])}]"
 
68
                }, {
 
69
                    token : "text",
 
70
                    regex : "\\s+"
 
71
                }
 
72
        ],
 
73
        "nospell" : [
 
74
           {
 
75
               token : "comment",
 
76
               regex : "%.*$",
 
77
               next : "start"
 
78
           }, {
 
79
               token : "nospell.text", // non-command
 
80
               regex : "\\\\[$&%#\\{\\}]"
 
81
           }, {
 
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"
 
84
           }, {
 
85
               token : "keyword", // command
 
86
               regex : "\\\\(?:[a-zA-z0-9]+|[^a-zA-z0-9])",
 
87
               next : "start"
 
88
           }, {
 
89
               token : "paren.keyword.operator",
 
90
               regex : "[[({]"
 
91
           }, {
 
92
               token : "paren.keyword.operator",
 
93
               regex : "[\\])]"
 
94
           }, {
 
95
               token : "paren.keyword.operator",
 
96
               regex : "}",
 
97
               next : "start"
 
98
           }, {
 
99
               token : "nospell.text",
 
100
               regex : "\\s+"
 
101
           }, {
 
102
               token : "nospell.text",
 
103
               regex : "\\w+"
 
104
           }
 
105
        ]
 
106
    };
 
107
};
 
108
 
 
109
oop.inherits(RDocHighlightRules, TextHighlightRules);
 
110
 
 
111
exports.RDocHighlightRules = RDocHighlightRules;
 
112
});
 
113
define('ace/mode/latex_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
114
 
 
115
 
 
116
var oop = require("../lib/oop");
 
117
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
118
 
 
119
var LatexHighlightRules = function() {   
 
120
    this.$rules = {
 
121
        "start" : [{
 
122
            token : "keyword",
 
123
            regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
 
124
        }, {
 
125
            token : "lparen",
 
126
            regex : "[[({]"
 
127
        }, {
 
128
            token : "rparen",
 
129
            regex : "[\\])}]"
 
130
        }, {
 
131
            token : "string",
 
132
            regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
 
133
        }, {
 
134
            token : "comment",
 
135
            regex : "%.*$"
 
136
        }]
 
137
    };
 
138
};
 
139
 
 
140
oop.inherits(LatexHighlightRules, TextHighlightRules);
 
141
 
 
142
exports.LatexHighlightRules = LatexHighlightRules;
 
143
 
 
144
});
 
145
 
 
146
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
 
147
 
 
148
 
 
149
var Range = require("../range").Range;
 
150
 
 
151
var MatchingBraceOutdent = function() {};
 
152
 
 
153
(function() {
 
154
 
 
155
    this.checkOutdent = function(line, input) {
 
156
        if (! /^\s+$/.test(line))
 
157
            return false;
 
158
 
 
159
        return /^\s*\}/.test(input);
 
160
    };
 
161
 
 
162
    this.autoOutdent = function(doc, row) {
 
163
        var line = doc.getLine(row);
 
164
        var match = line.match(/^(\s*\})/);
 
165
 
 
166
        if (!match) return 0;
 
167
 
 
168
        var column = match[1].length;
 
169
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
 
170
 
 
171
        if (!openBracePos || openBracePos.row == row) return 0;
 
172
 
 
173
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
 
174
        doc.replace(new Range(row, 0, row, column-1), indent);
 
175
    };
 
176
 
 
177
    this.$getIndent = function(line) {
 
178
        return line.match(/^\s*/)[0];
 
179
    };
 
180
 
 
181
}).call(MatchingBraceOutdent.prototype);
 
182
 
 
183
exports.MatchingBraceOutdent = MatchingBraceOutdent;
 
184
});