/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-c9search.js

  • Committer: Erik Wikström
  • Date: 2013-04-09 09:09:31 UTC
  • mfrom: (21 lenasys)
  • mto: (21.1.1 lenasys)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: wikxen@gmail.com-20130409090931-9jcs9kzg8et0912g
Remerged! Changed password hashes to VARCHAR(32)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Distributed under the BSD license:
3
 
 *
4
 
 * Copyright (c) 2010, Ajax.org B.V.
5
 
 * All rights reserved.
6
 
 * 
7
 
 * Redistribution and use in source and binary forms, with or without
8
 
 * modification, are permitted provided that the following conditions are met:
9
 
 *     * Redistributions of source code must retain the above copyright
10
 
 *       notice, this list of conditions and the following disclaimer.
11
 
 *     * Redistributions in binary form must reproduce the above copyright
12
 
 *       notice, this list of conditions and the following disclaimer in the
13
 
 *       documentation and/or other materials provided with the distribution.
14
 
 *     * Neither the name of Ajax.org B.V. nor the
15
 
 *       names of its contributors may be used to endorse or promote products
16
 
 *       derived from this software without specific prior written permission.
17
 
 * 
18
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
 
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 
 *
29
 
 * ***** END LICENSE BLOCK ***** */
30
 
 
31
 
define('ace/mode/c9search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c9search_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/c9search'], function(require, exports, module) {
32
 
 
33
 
 
34
 
var oop = require("../lib/oop");
35
 
var TextMode = require("./text").Mode;
36
 
var Tokenizer = require("../tokenizer").Tokenizer;
37
 
var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
38
 
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
39
 
var C9StyleFoldMode = require("./folding/c9search").FoldMode;
40
 
 
41
 
var Mode = function() {
42
 
    this.$tokenizer = new Tokenizer(new C9SearchHighlightRules().getRules());
43
 
    this.$outdent = new MatchingBraceOutdent();
44
 
    this.foldingRules = new C9StyleFoldMode();
45
 
};
46
 
oop.inherits(Mode, TextMode);
47
 
 
48
 
(function() {
49
 
    
50
 
    this.getNextLineIndent = function(state, line, tab) {
51
 
        var indent = this.$getIndent(line);
52
 
        return indent;
53
 
    };
54
 
 
55
 
    this.checkOutdent = function(state, line, input) {
56
 
        return this.$outdent.checkOutdent(line, input);
57
 
    };
58
 
 
59
 
    this.autoOutdent = function(state, doc, row) {
60
 
        this.$outdent.autoOutdent(doc, row);
61
 
    };
62
 
 
63
 
}).call(Mode.prototype);
64
 
 
65
 
exports.Mode = Mode;
66
 
 
67
 
});
68
 
 
69
 
define('ace/mode/c9search_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
70
 
 
71
 
 
72
 
var oop = require("../lib/oop");
73
 
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
74
 
 
75
 
var C9SearchHighlightRules = function() {
76
 
    this.$rules = {
77
 
        "start" : [
78
 
            {
79
 
                token : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text"],
80
 
                regex : "(^\\s+[0-9]+)(:\\s*)(.+)"
81
 
            },
82
 
            {
83
 
                token : ["string", "text"], // single line
84
 
                regex : "(.+)(:$)"
85
 
            }
86
 
        ]
87
 
    };
88
 
};
89
 
 
90
 
oop.inherits(C9SearchHighlightRules, TextHighlightRules);
91
 
 
92
 
exports.C9SearchHighlightRules = C9SearchHighlightRules;
93
 
 
94
 
});
95
 
 
96
 
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
97
 
 
98
 
 
99
 
var Range = require("../range").Range;
100
 
 
101
 
var MatchingBraceOutdent = function() {};
102
 
 
103
 
(function() {
104
 
 
105
 
    this.checkOutdent = function(line, input) {
106
 
        if (! /^\s+$/.test(line))
107
 
            return false;
108
 
 
109
 
        return /^\s*\}/.test(input);
110
 
    };
111
 
 
112
 
    this.autoOutdent = function(doc, row) {
113
 
        var line = doc.getLine(row);
114
 
        var match = line.match(/^(\s*\})/);
115
 
 
116
 
        if (!match) return 0;
117
 
 
118
 
        var column = match[1].length;
119
 
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
120
 
 
121
 
        if (!openBracePos || openBracePos.row == row) return 0;
122
 
 
123
 
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
124
 
        doc.replace(new Range(row, 0, row, column-1), indent);
125
 
    };
126
 
 
127
 
    this.$getIndent = function(line) {
128
 
        return line.match(/^\s*/)[0];
129
 
    };
130
 
 
131
 
}).call(MatchingBraceOutdent.prototype);
132
 
 
133
 
exports.MatchingBraceOutdent = MatchingBraceOutdent;
134
 
});
135
 
 
136
 
 
137
 
define('ace/mode/folding/c9search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
138
 
 
139
 
 
140
 
var oop = require("../../lib/oop");
141
 
var Range = require("../../range").Range;
142
 
var BaseFoldMode = require("./fold_mode").FoldMode;
143
 
 
144
 
var FoldMode = exports.FoldMode = function() {};
145
 
oop.inherits(FoldMode, BaseFoldMode);
146
 
 
147
 
(function() {
148
 
 
149
 
    this.foldingStartMarker = /^(\S.*\:|Searching for.*)$/;
150
 
    this.foldingStopMarker = /^(\s+|Found.*)$/;
151
 
    
152
 
    this.getFoldWidgetRange = function(session, foldStyle, row) {
153
 
        var lines = session.doc.getAllLines(row);
154
 
        var line = lines[row];
155
 
        var level1 = /^(Found.*|Searching for.*)$/;
156
 
        var level2 = /^(\S.*\:|\s*)$/;
157
 
        var re = level1.test(line) ? level1 : level2;
158
 
 
159
 
        if (this.foldingStartMarker.test(line)) {            
160
 
            for (var i = row + 1, l = session.getLength(); i < l; i++) {
161
 
                if (re.test(lines[i]))
162
 
                    break;
163
 
            }
164
 
 
165
 
            return new Range(row, line.length, i, 0);
166
 
        }
167
 
 
168
 
        if (this.foldingStopMarker.test(line)) {
169
 
            for (var i = row - 1; i >= 0; i--) {
170
 
                line = lines[i];
171
 
                if (re.test(line))
172
 
                    break;
173
 
            }
174
 
 
175
 
            return new Range(i, line.length, row, 0);
176
 
        }
177
 
    };
178
 
    
179
 
}).call(FoldMode.prototype);
180
 
 
181
 
});
182