datagram 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.env.sample +7 -0
- data/.gitignore +20 -0
- data/.rbenv-version +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/Procfile +1 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/config.ru +5 -0
- data/datagram.gemspec +23 -0
- data/db/migrate/1_create_queries.rb +9 -0
- data/db/migrate/2_add_name_to_queries.rb +5 -0
- data/lib/datagram/version.rb +3 -0
- data/lib/datagram.rb +135 -0
- data/lib/views/application.coffee +222 -0
- data/lib/views/index.haml +47 -0
- data/lib/views/layout.haml +17 -0
- data/lib/views/style.sass +179 -0
- data/public/ace/ace.js +15209 -0
- data/public/ace/ext-elastic_tabstops_lite.js +301 -0
- data/public/ace/ext-emmet.js +253 -0
- data/public/ace/ext-searchbox.js +441 -0
- data/public/ace/ext-spellcheck.js +67 -0
- data/public/ace/ext-static_highlight.js +96 -0
- data/public/ace/ext-textarea.js +492 -0
- data/public/ace/ext-whitespace.js +204 -0
- data/public/ace/keybinding-emacs.js +962 -0
- data/public/ace/keybinding-vim.js +1704 -0
- data/public/ace/mode-abap.js +260 -0
- data/public/ace/mode-asciidoc.js +372 -0
- data/public/ace/mode-c9search.js +182 -0
- data/public/ace/mode-c_cpp.js +737 -0
- data/public/ace/mode-clojure.js +299 -0
- data/public/ace/mode-coffee.js +426 -0
- data/public/ace/mode-coldfusion.js +1753 -0
- data/public/ace/mode-csharp.js +612 -0
- data/public/ace/mode-css.js +773 -0
- data/public/ace/mode-curly.js +1950 -0
- data/public/ace/mode-dart.js +945 -0
- data/public/ace/mode-diff.js +166 -0
- data/public/ace/mode-django.js +1969 -0
- data/public/ace/mode-dot.js +320 -0
- data/public/ace/mode-ftl.js +907 -0
- data/public/ace/mode-glsl.js +810 -0
- data/public/ace/mode-golang.js +632 -0
- data/public/ace/mode-groovy.js +1037 -0
- data/public/ace/mode-haml.js +487 -0
- data/public/ace/mode-haxe.js +609 -0
- data/public/ace/mode-html.js +1881 -0
- data/public/ace/mode-jade.js +1951 -0
- data/public/ace/mode-java.js +996 -0
- data/public/ace/mode-javascript.js +876 -0
- data/public/ace/mode-json.js +578 -0
- data/public/ace/mode-jsp.js +1351 -0
- data/public/ace/mode-jsx.js +635 -0
- data/public/ace/mode-latex.js +189 -0
- data/public/ace/mode-less.js +807 -0
- data/public/ace/mode-liquid.js +862 -0
- data/public/ace/mode-lisp.js +138 -0
- data/public/ace/mode-livescript.js +288 -0
- data/public/ace/mode-logiql.js +664 -0
- data/public/ace/mode-lsl.js +828 -0
- data/public/ace/mode-lua.js +455 -0
- data/public/ace/mode-luapage.js +2340 -0
- data/public/ace/mode-lucene.js +64 -0
- data/public/ace/mode-makefile.js +313 -0
- data/public/ace/mode-markdown.js +2280 -0
- data/public/ace/mode-mushcode.js +704 -0
- data/public/ace/mode-mushcode_high_rules.js +569 -0
- data/public/ace/mode-objectivec.js +659 -0
- data/public/ace/mode-ocaml.js +443 -0
- data/public/ace/mode-pascal.js +233 -0
- data/public/ace/mode-perl.js +316 -0
- data/public/ace/mode-pgsql.js +908 -0
- data/public/ace/mode-php.js +2291 -0
- data/public/ace/mode-powershell.js +618 -0
- data/public/ace/mode-python.js +264 -0
- data/public/ace/mode-r.js +404 -0
- data/public/ace/mode-rdoc.js +184 -0
- data/public/ace/mode-rhtml.js +2168 -0
- data/public/ace/mode-ruby.js +431 -0
- data/public/ace/mode-sass.js +442 -0
- data/public/ace/mode-scad.js +670 -0
- data/public/ace/mode-scala.js +1025 -0
- data/public/ace/mode-scheme.js +144 -0
- data/public/ace/mode-scss.js +832 -0
- data/public/ace/mode-sh.js +204 -0
- data/public/ace/mode-sql.js +118 -0
- data/public/ace/mode-stylus.js +483 -0
- data/public/ace/mode-svg.js +1442 -0
- data/public/ace/mode-tcl.js +319 -0
- data/public/ace/mode-tex.js +166 -0
- data/public/ace/mode-text.js +0 -0
- data/public/ace/mode-textile.js +170 -0
- data/public/ace/mode-tmsnippet.js +200 -0
- data/public/ace/mode-toml.js +180 -0
- data/public/ace/mode-typescript.js +961 -0
- data/public/ace/mode-vbscript.js +281 -0
- data/public/ace/mode-velocity.js +962 -0
- data/public/ace/mode-xml.js +789 -0
- data/public/ace/mode-xquery.js +2750 -0
- data/public/ace/mode-yaml.js +289 -0
- data/public/ace/theme-ambiance.js +202 -0
- data/public/ace/theme-chaos.js +182 -0
- data/public/ace/theme-chrome.js +161 -0
- data/public/ace/theme-clouds.js +135 -0
- data/public/ace/theme-clouds_midnight.js +136 -0
- data/public/ace/theme-cobalt.js +150 -0
- data/public/ace/theme-crimson_editor.js +154 -0
- data/public/ace/theme-dawn.js +146 -0
- data/public/ace/theme-dreamweaver.js +173 -0
- data/public/ace/theme-eclipse.js +122 -0
- data/public/ace/theme-github.js +136 -0
- data/public/ace/theme-idle_fingers.js +136 -0
- data/public/ace/theme-kr.js +143 -0
- data/public/ace/theme-merbivore.js +135 -0
- data/public/ace/theme-merbivore_soft.js +136 -0
- data/public/ace/theme-mono_industrial.js +148 -0
- data/public/ace/theme-monokai.js +140 -0
- data/public/ace/theme-pastel_on_dark.js +148 -0
- data/public/ace/theme-solarized_dark.js +128 -0
- data/public/ace/theme-solarized_light.js +131 -0
- data/public/ace/theme-terminal.js +154 -0
- data/public/ace/theme-textmate.js +0 -0
- data/public/ace/theme-tomorrow.js +147 -0
- data/public/ace/theme-tomorrow_night.js +147 -0
- data/public/ace/theme-tomorrow_night_blue.js +145 -0
- data/public/ace/theme-tomorrow_night_bright.js +147 -0
- data/public/ace/theme-tomorrow_night_eighties.js +144 -0
- data/public/ace/theme-twilight.js +147 -0
- data/public/ace/theme-vibrant_ink.js +131 -0
- data/public/ace/theme-xcode.js +125 -0
- data/public/ace/worker-coffee.js +7091 -0
- data/public/ace/worker-css.js +8289 -0
- data/public/ace/worker-javascript.js +6496 -0
- data/public/ace/worker-json.js +2305 -0
- data/public/ace/worker-lua.js +3313 -0
- data/public/ace/worker-php.js +6743 -0
- data/public/ace/worker-xquery.js +21897 -0
- data/public/font/FontAwesome.otf +0 -0
- data/public/font/fontawesome-webfont.eot +0 -0
- data/public/font/fontawesome-webfont.svg +284 -0
- data/public/font/fontawesome-webfont.ttf +0 -0
- data/public/font/fontawesome-webfont.woff +0 -0
- data/public/font-awesome.css +540 -0
- data/public/jquery.js +9597 -0
- data/script/migrate.sh +2 -0
- metadata +242 -0
|
@@ -0,0 +1,962 @@
|
|
|
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/keyboard/emacs', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/incremental_search', 'ace/commands/incremental_search_commands', 'ace/keyboard/hash_handler', 'ace/lib/keys'], function(require, exports, module) {
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var dom = require("../lib/dom");
|
|
35
|
+
require("../incremental_search");
|
|
36
|
+
var iSearchCommandModule = require("../commands/incremental_search_commands");
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var screenToTextBlockCoordinates = function(x, y) {
|
|
40
|
+
var canvasPos = this.scroller.getBoundingClientRect();
|
|
41
|
+
|
|
42
|
+
var col = Math.floor(
|
|
43
|
+
(x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
|
|
44
|
+
);
|
|
45
|
+
var row = Math.floor(
|
|
46
|
+
(y + this.scrollTop - canvasPos.top) / this.lineHeight
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return this.session.screenToDocumentPosition(row, col);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var HashHandler = require("./hash_handler").HashHandler;
|
|
53
|
+
exports.handler = new HashHandler();
|
|
54
|
+
|
|
55
|
+
exports.handler.isEmacs = true
|
|
56
|
+
|
|
57
|
+
var initialized = false;
|
|
58
|
+
var $formerLongWords;
|
|
59
|
+
var $formerLineStart;
|
|
60
|
+
|
|
61
|
+
exports.handler.attach = function(editor) {
|
|
62
|
+
if (!initialized) {
|
|
63
|
+
initialized = true;
|
|
64
|
+
dom.importCssString('\
|
|
65
|
+
.emacs-mode .ace_cursor{\
|
|
66
|
+
border: 2px rgba(50,250,50,0.8) solid!important;\
|
|
67
|
+
-moz-box-sizing: border-box!important;\
|
|
68
|
+
-webkit-box-sizing: border-box!important;\
|
|
69
|
+
box-sizing: border-box!important;\
|
|
70
|
+
background-color: rgba(0,250,0,0.9);\
|
|
71
|
+
opacity: 0.5;\
|
|
72
|
+
}\
|
|
73
|
+
.emacs-mode .ace_cursor.ace_hidden{\
|
|
74
|
+
opacity: 1;\
|
|
75
|
+
background-color: transparent;\
|
|
76
|
+
}\
|
|
77
|
+
.emacs-mode .ace_overwrite-cursors .ace_cursor {\
|
|
78
|
+
opacity: 1;\
|
|
79
|
+
background-color: transparent;\
|
|
80
|
+
border-width: 0 0 2px 2px !important;\
|
|
81
|
+
}\
|
|
82
|
+
.emacs-mode .ace_text-layer {\
|
|
83
|
+
z-index: 4\
|
|
84
|
+
}\
|
|
85
|
+
.emacs-mode .ace_cursor-layer {\
|
|
86
|
+
z-index: 2\
|
|
87
|
+
}', 'emacsMode'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
$formerLongWords = editor.session.$selectLongWords;
|
|
91
|
+
editor.session.$selectLongWords = true;
|
|
92
|
+
$formerLineStart = editor.session.$useEmacsStyleLineStart;
|
|
93
|
+
editor.session.$useEmacsStyleLineStart = true;
|
|
94
|
+
|
|
95
|
+
editor.session.$emacsMark = null;
|
|
96
|
+
|
|
97
|
+
editor.emacsMarkMode = function() {
|
|
98
|
+
return this.session.$emacsMark;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
editor.setEmacsMarkMode = function(p) {
|
|
102
|
+
this.session.$emacsMark = p;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
editor.on("click", $resetMarkMode);
|
|
106
|
+
editor.on("changeSession", $kbSessionChange);
|
|
107
|
+
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
|
108
|
+
editor.setStyle("emacs-mode");
|
|
109
|
+
editor.commands.addCommands(commands);
|
|
110
|
+
exports.handler.platform = editor.commands.platform;
|
|
111
|
+
editor.$emacsModeHandler = this;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
exports.handler.detach = function(editor) {
|
|
115
|
+
delete editor.renderer.screenToTextCoordinates;
|
|
116
|
+
editor.session.$selectLongWords = $formerLongWords;
|
|
117
|
+
editor.session.$useEmacsStyleLineStart = $formerLineStart;
|
|
118
|
+
editor.removeEventListener("click", $resetMarkMode);
|
|
119
|
+
editor.removeEventListener("changeSession", $kbSessionChange);
|
|
120
|
+
editor.unsetStyle("emacs-mode");
|
|
121
|
+
editor.commands.removeCommands(commands);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var $kbSessionChange = function(e) {
|
|
125
|
+
if (e.oldSession) {
|
|
126
|
+
e.oldSession.$selectLongWords = $formerLongWords;
|
|
127
|
+
e.oldSession.$useEmacsStyleLineStart = $formerLineStart;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
$formerLongWords = e.session.$selectLongWords;
|
|
131
|
+
e.session.$selectLongWords = true;
|
|
132
|
+
$formerLineStart = e.session.$useEmacsStyleLineStart;
|
|
133
|
+
e.session.$useEmacsStyleLineStart = true;
|
|
134
|
+
|
|
135
|
+
if (!e.session.hasOwnProperty('$emacsMark'))
|
|
136
|
+
e.session.$emacsMark = null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var $resetMarkMode = function(e) {
|
|
140
|
+
e.editor.session.$emacsMark = null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var keys = require("../lib/keys").KEY_MODS,
|
|
144
|
+
eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"},
|
|
145
|
+
combinations = ["C-S-M-CMD",
|
|
146
|
+
"S-M-CMD", "C-M-CMD", "C-S-CMD", "C-S-M",
|
|
147
|
+
"M-CMD", "S-CMD", "S-M", "C-CMD", "C-M", "C-S",
|
|
148
|
+
"CMD", "M", "S", "C"];
|
|
149
|
+
combinations.forEach(function(c) {
|
|
150
|
+
var hashId = 0;
|
|
151
|
+
c.split("-").forEach(function(c) {
|
|
152
|
+
hashId = hashId | keys[eMods[c]];
|
|
153
|
+
});
|
|
154
|
+
eMods[hashId] = c.toLowerCase() + "-";
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
exports.handler.bindKey = function(key, command) {
|
|
158
|
+
if (!key)
|
|
159
|
+
return;
|
|
160
|
+
|
|
161
|
+
var ckb = this.commmandKeyBinding;
|
|
162
|
+
key.split("|").forEach(function(keyPart) {
|
|
163
|
+
keyPart = keyPart.toLowerCase();
|
|
164
|
+
ckb[keyPart] = command;
|
|
165
|
+
keyPart = keyPart.split(" ")[0];
|
|
166
|
+
if (!ckb[keyPart])
|
|
167
|
+
ckb[keyPart] = "null";
|
|
168
|
+
}, this);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
|
|
173
|
+
var editor = data.editor;
|
|
174
|
+
if (hashId == -1) {
|
|
175
|
+
editor.setEmacsMarkMode(null);
|
|
176
|
+
if (data.count) {
|
|
177
|
+
var str = Array(data.count + 1).join(key);
|
|
178
|
+
data.count = null;
|
|
179
|
+
return {command: "insertstring", args: str};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (key == "\x00") return undefined;
|
|
184
|
+
|
|
185
|
+
var modifier = eMods[hashId];
|
|
186
|
+
if (modifier == "c-" || data.universalArgument) {
|
|
187
|
+
var count = parseInt(key[key.length - 1]);
|
|
188
|
+
if (count) {
|
|
189
|
+
data.count = count;
|
|
190
|
+
return {command: "null"};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
data.universalArgument = false;
|
|
194
|
+
if (modifier) key = modifier + key;
|
|
195
|
+
if (data.keyChain) key = data.keyChain += " " + key;
|
|
196
|
+
var command = this.commmandKeyBinding[key];
|
|
197
|
+
data.keyChain = command == "null" ? key : "";
|
|
198
|
+
if (!command) return undefined;
|
|
199
|
+
if (command === "null") return {command: "null"};
|
|
200
|
+
|
|
201
|
+
if (command === "universalArgument") {
|
|
202
|
+
data.universalArgument = true;
|
|
203
|
+
return {command: "null"};
|
|
204
|
+
}
|
|
205
|
+
var args;
|
|
206
|
+
if (typeof command !== "string") {
|
|
207
|
+
args = command.args;
|
|
208
|
+
if (command.command) command = command.command;
|
|
209
|
+
if (command === "goorselect") {
|
|
210
|
+
command = editor.emacsMarkMode() ? args[1] : args[0];
|
|
211
|
+
args = null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (typeof command === "string") {
|
|
216
|
+
if (command === "insertstring" ||
|
|
217
|
+
command === "splitline" ||
|
|
218
|
+
command === "togglecomment") {
|
|
219
|
+
editor.setEmacsMarkMode(null);
|
|
220
|
+
}
|
|
221
|
+
command = this.commands[command] || editor.commands.commands[command];
|
|
222
|
+
if (!command) return undefined;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!command.readonly && !command.isYank)
|
|
226
|
+
data.lastCommand = null;
|
|
227
|
+
|
|
228
|
+
if (data.count) {
|
|
229
|
+
var count = data.count;
|
|
230
|
+
data.count = 0;
|
|
231
|
+
return {
|
|
232
|
+
args: args,
|
|
233
|
+
command: {
|
|
234
|
+
exec: function(editor, args) {
|
|
235
|
+
for (var i = 0; i < count; i++)
|
|
236
|
+
command.exec(editor, args);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {command: command, args: args};
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
exports.emacsKeys = {
|
|
246
|
+
"Up|C-p" : {command: "goorselect", args: ["golineup","selectup"]},
|
|
247
|
+
"Down|C-n" : {command: "goorselect", args: ["golinedown","selectdown"]},
|
|
248
|
+
"Left|C-b" : {command: "goorselect", args: ["gotoleft","selectleft"]},
|
|
249
|
+
"Right|C-f" : {command: "goorselect", args: ["gotoright","selectright"]},
|
|
250
|
+
"C-Left|M-b" : {command: "goorselect", args: ["gotowordleft","selectwordleft"]},
|
|
251
|
+
"C-Right|M-f" : {command: "goorselect", args: ["gotowordright","selectwordright"]},
|
|
252
|
+
"Home|C-a" : {command: "goorselect", args: ["gotolinestart","selecttolinestart"]},
|
|
253
|
+
"End|C-e" : {command: "goorselect", args: ["gotolineend","selecttolineend"]},
|
|
254
|
+
"C-Home|S-M-,": {command: "goorselect", args: ["gotostart","selecttostart"]},
|
|
255
|
+
"C-End|S-M-." : {command: "goorselect", args: ["gotoend","selecttoend"]},
|
|
256
|
+
"S-Up|S-C-p" : "selectup",
|
|
257
|
+
"S-Down|S-C-n" : "selectdown",
|
|
258
|
+
"S-Left|S-C-b" : "selectleft",
|
|
259
|
+
"S-Right|S-C-f" : "selectright",
|
|
260
|
+
"S-C-Left|S-M-b" : "selectwordleft",
|
|
261
|
+
"S-C-Right|S-M-f" : "selectwordright",
|
|
262
|
+
"S-Home|S-C-a" : "selecttolinestart",
|
|
263
|
+
"S-End|S-C-e" : "selecttolineend",
|
|
264
|
+
"S-C-Home" : "selecttostart",
|
|
265
|
+
"S-C-End" : "selecttoend",
|
|
266
|
+
|
|
267
|
+
"C-l" : "recenterTopBottom",
|
|
268
|
+
"M-s" : "centerselection",
|
|
269
|
+
"M-g": "gotoline",
|
|
270
|
+
"C-x C-p": "selectall",
|
|
271
|
+
"C-Down": {command: "goorselect", args: ["gotopagedown","selectpagedown"]},
|
|
272
|
+
"C-Up": {command: "goorselect", args: ["gotopageup","selectpageup"]},
|
|
273
|
+
"PageDown|C-v": {command: "goorselect", args: ["gotopagedown","selectpagedown"]},
|
|
274
|
+
"PageUp|M-v": {command: "goorselect", args: ["gotopageup","selectpageup"]},
|
|
275
|
+
"S-C-Down": "selectpagedown",
|
|
276
|
+
"S-C-Up": "selectpageup",
|
|
277
|
+
|
|
278
|
+
"C-s": "iSearch",
|
|
279
|
+
"C-r": "iSearchBackwards",
|
|
280
|
+
|
|
281
|
+
"M-C-s": "findnext",
|
|
282
|
+
"M-C-r": "findprevious",
|
|
283
|
+
"S-M-5": "replace",
|
|
284
|
+
"Backspace": "backspace",
|
|
285
|
+
"Delete|C-d": "del",
|
|
286
|
+
"Return|C-m": {command: "insertstring", args: "\n"}, // "newline"
|
|
287
|
+
"C-o": "splitline",
|
|
288
|
+
|
|
289
|
+
"M-d|C-Delete": {command: "killWord", args: "right"},
|
|
290
|
+
"C-Backspace|M-Backspace|M-Delete": {command: "killWord", args: "left"},
|
|
291
|
+
"C-k": "killLine",
|
|
292
|
+
|
|
293
|
+
"C-y|S-Delete": "yank",
|
|
294
|
+
"M-y": "yankRotate",
|
|
295
|
+
"C-g": "keyboardQuit",
|
|
296
|
+
|
|
297
|
+
"C-w": "killRegion",
|
|
298
|
+
"M-w": "killRingSave",
|
|
299
|
+
"C-Space": "setMark",
|
|
300
|
+
"C-x C-x": "exchangePointAndMark",
|
|
301
|
+
|
|
302
|
+
"C-t": "transposeletters",
|
|
303
|
+
"M-u": "touppercase", // Doesn't work
|
|
304
|
+
"M-l": "tolowercase",
|
|
305
|
+
"M-/": "autocomplete", // Doesn't work
|
|
306
|
+
"C-u": "universalArgument",
|
|
307
|
+
|
|
308
|
+
"M-;": "togglecomment",
|
|
309
|
+
|
|
310
|
+
"C-/|C-x u|S-C--|C-z": "undo",
|
|
311
|
+
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo?
|
|
312
|
+
"C-x r": "selectRectangularRegion",
|
|
313
|
+
"M-x": {command: "focusCommandLine", args: "M-x "}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
exports.handler.bindKeys(exports.emacsKeys);
|
|
318
|
+
|
|
319
|
+
exports.handler.addCommands({
|
|
320
|
+
recenterTopBottom: function(editor) {
|
|
321
|
+
var renderer = editor.renderer;
|
|
322
|
+
var pos = renderer.$cursorLayer.getPixelPosition();
|
|
323
|
+
var h = renderer.$size.scrollerHeight - renderer.lineHeight;
|
|
324
|
+
var scrollTop = renderer.scrollTop;
|
|
325
|
+
if (Math.abs(pos.top - scrollTop) < 2) {
|
|
326
|
+
scrollTop = pos.top - h;
|
|
327
|
+
} else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) {
|
|
328
|
+
scrollTop = pos.top;
|
|
329
|
+
} else {
|
|
330
|
+
scrollTop = pos.top - h * 0.5;
|
|
331
|
+
}
|
|
332
|
+
editor.session.setScrollTop(scrollTop);
|
|
333
|
+
},
|
|
334
|
+
selectRectangularRegion: function(editor) {
|
|
335
|
+
editor.multiSelect.toggleBlockSelection();
|
|
336
|
+
},
|
|
337
|
+
setMark: function(editor) {
|
|
338
|
+
var markMode = editor.emacsMarkMode();
|
|
339
|
+
if (markMode) {
|
|
340
|
+
var cp = editor.getCursorPosition();
|
|
341
|
+
if (editor.selection.isEmpty() &&
|
|
342
|
+
markMode.row == cp.row && markMode.column == cp.column) {
|
|
343
|
+
editor.setEmacsMarkMode(null);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
markMode = editor.getCursorPosition();
|
|
348
|
+
editor.setEmacsMarkMode(markMode);
|
|
349
|
+
editor.selection.setSelectionAnchor(markMode.row, markMode.column);
|
|
350
|
+
},
|
|
351
|
+
exchangePointAndMark: {
|
|
352
|
+
exec: function(editor) {
|
|
353
|
+
var range = editor.selection.getRange();
|
|
354
|
+
editor.selection.setSelectionRange(range, !editor.selection.isBackwards());
|
|
355
|
+
},
|
|
356
|
+
readonly: true,
|
|
357
|
+
multiselectAction: "forEach"
|
|
358
|
+
},
|
|
359
|
+
killWord: {
|
|
360
|
+
exec: function(editor, dir) {
|
|
361
|
+
editor.clearSelection();
|
|
362
|
+
if (dir == "left")
|
|
363
|
+
editor.selection.selectWordLeft();
|
|
364
|
+
else
|
|
365
|
+
editor.selection.selectWordRight();
|
|
366
|
+
|
|
367
|
+
var range = editor.getSelectionRange();
|
|
368
|
+
var text = editor.session.getTextRange(range);
|
|
369
|
+
exports.killRing.add(text);
|
|
370
|
+
|
|
371
|
+
editor.session.remove(range);
|
|
372
|
+
editor.clearSelection();
|
|
373
|
+
},
|
|
374
|
+
multiselectAction: "forEach"
|
|
375
|
+
},
|
|
376
|
+
killLine: function(editor) {
|
|
377
|
+
editor.setEmacsMarkMode(null);
|
|
378
|
+
var pos = editor.getCursorPosition();
|
|
379
|
+
if (pos.column == 0 &&
|
|
380
|
+
editor.session.doc.getLine(pos.row).length == 0) {
|
|
381
|
+
editor.selection.selectLine();
|
|
382
|
+
} else {
|
|
383
|
+
editor.clearSelection();
|
|
384
|
+
editor.selection.selectLineEnd();
|
|
385
|
+
}
|
|
386
|
+
var range = editor.getSelectionRange();
|
|
387
|
+
var text = editor.session.getTextRange(range);
|
|
388
|
+
exports.killRing.add(text);
|
|
389
|
+
|
|
390
|
+
editor.session.remove(range);
|
|
391
|
+
editor.clearSelection();
|
|
392
|
+
},
|
|
393
|
+
yank: function(editor) {
|
|
394
|
+
editor.onPaste(exports.killRing.get());
|
|
395
|
+
editor.keyBinding.$data.lastCommand = "yank";
|
|
396
|
+
},
|
|
397
|
+
yankRotate: function(editor) {
|
|
398
|
+
if (editor.keyBinding.$data.lastCommand != "yank")
|
|
399
|
+
return;
|
|
400
|
+
editor.undo();
|
|
401
|
+
editor.onPaste(exports.killRing.rotate());
|
|
402
|
+
editor.keyBinding.$data.lastCommand = "yank";
|
|
403
|
+
},
|
|
404
|
+
killRegion: function(editor) {
|
|
405
|
+
exports.killRing.add(editor.getCopyText());
|
|
406
|
+
editor.commands.byName.cut.exec(editor);
|
|
407
|
+
},
|
|
408
|
+
killRingSave: function(editor) {
|
|
409
|
+
exports.killRing.add(editor.getCopyText());
|
|
410
|
+
},
|
|
411
|
+
keyboardQuit: function(editor) {
|
|
412
|
+
editor.selection.clearSelection();
|
|
413
|
+
editor.setEmacsMarkMode(null);
|
|
414
|
+
},
|
|
415
|
+
focusCommandLine: function(editor, arg) {
|
|
416
|
+
if (editor.showCommandLine)
|
|
417
|
+
editor.showCommandLine(arg);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
exports.handler.addCommands(iSearchCommandModule.iSearchStartCommands);
|
|
422
|
+
|
|
423
|
+
var commands = exports.handler.commands;
|
|
424
|
+
commands.yank.isYank = true;
|
|
425
|
+
commands.yankRotate.isYank = true;
|
|
426
|
+
|
|
427
|
+
exports.killRing = {
|
|
428
|
+
$data: [],
|
|
429
|
+
add: function(str) {
|
|
430
|
+
str && this.$data.push(str);
|
|
431
|
+
if (this.$data.length > 30)
|
|
432
|
+
this.$data.shift();
|
|
433
|
+
},
|
|
434
|
+
get: function() {
|
|
435
|
+
return this.$data[this.$data.length - 1] || "";
|
|
436
|
+
},
|
|
437
|
+
pop: function() {
|
|
438
|
+
if (this.$data.length > 1)
|
|
439
|
+
this.$data.pop();
|
|
440
|
+
return this.get();
|
|
441
|
+
},
|
|
442
|
+
rotate: function() {
|
|
443
|
+
this.$data.unshift(this.$data.pop());
|
|
444
|
+
return this.get();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
define('ace/incremental_search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/search', 'ace/search_highlight', 'ace/commands/incremental_search_commands', 'ace/lib/dom', 'ace/commands/command_manager', 'ace/editor', 'ace/config'], function(require, exports, module) {
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
var oop = require("./lib/oop");
|
|
454
|
+
var Range = require("./range").Range;
|
|
455
|
+
var Search = require("./search").Search;
|
|
456
|
+
var SearchHighlight = require("./search_highlight").SearchHighlight;
|
|
457
|
+
var iSearchCommandModule = require("./commands/incremental_search_commands");
|
|
458
|
+
var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler;
|
|
459
|
+
function IncrementalSearch() {
|
|
460
|
+
this.$options = {wrap: false, skipCurrent: false};
|
|
461
|
+
this.$keyboardHandler = new ISearchKbd(this);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
oop.inherits(IncrementalSearch, Search);
|
|
465
|
+
|
|
466
|
+
;(function() {
|
|
467
|
+
|
|
468
|
+
this.activate = function(ed, backwards) {
|
|
469
|
+
this.$editor = ed;
|
|
470
|
+
this.$startPos = this.$currentPos = ed.getCursorPosition();
|
|
471
|
+
this.$options.needle = '';
|
|
472
|
+
this.$options.backwards = backwards;
|
|
473
|
+
ed.keyBinding.addKeyboardHandler(this.$keyboardHandler);
|
|
474
|
+
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
|
|
475
|
+
this.selectionFix(ed);
|
|
476
|
+
this.statusMessage(true);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
this.deactivate = function(reset) {
|
|
480
|
+
this.cancelSearch(reset);
|
|
481
|
+
this.$editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler);
|
|
482
|
+
if (this.$mousedownHandler) {
|
|
483
|
+
this.$editor.removeEventListener('mousedown', this.$mousedownHandler);
|
|
484
|
+
delete this.$mousedownHandler;
|
|
485
|
+
}
|
|
486
|
+
this.message('');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
this.selectionFix = function(editor) {
|
|
490
|
+
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
|
|
491
|
+
editor.clearSelection();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
this.highlight = function(regexp) {
|
|
496
|
+
var sess = this.$editor.session,
|
|
497
|
+
hl = sess.$isearchHighlight = sess.$isearchHighlight || sess.addDynamicMarker(
|
|
498
|
+
new SearchHighlight(null, "ace_isearch-result", "text"));
|
|
499
|
+
hl.setRegexp(regexp);
|
|
500
|
+
sess._emit("changeBackMarker"); // force highlight layer redraw
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this.cancelSearch = function(reset) {
|
|
504
|
+
var e = this.$editor;
|
|
505
|
+
this.$prevNeedle = this.$options.needle;
|
|
506
|
+
this.$options.needle = '';
|
|
507
|
+
if (reset) {
|
|
508
|
+
e.moveCursorToPosition(this.$startPos);
|
|
509
|
+
this.$currentPos = this.$startPos;
|
|
510
|
+
}
|
|
511
|
+
this.highlight(null);
|
|
512
|
+
return Range.fromPoints(this.$currentPos, this.$currentPos);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
|
|
516
|
+
if (!this.$editor) return null;
|
|
517
|
+
var options = this.$options;
|
|
518
|
+
if (needleUpdateFunc) {
|
|
519
|
+
options.needle = needleUpdateFunc.call(this, options.needle || '') || '';
|
|
520
|
+
}
|
|
521
|
+
if (options.needle.length === 0) {
|
|
522
|
+
this.statusMessage(true);
|
|
523
|
+
return this.cancelSearch(true);
|
|
524
|
+
};
|
|
525
|
+
options.start = this.$currentPos;
|
|
526
|
+
var session = this.$editor.session,
|
|
527
|
+
found = this.find(session);
|
|
528
|
+
if (found) {
|
|
529
|
+
if (options.backwards) found = Range.fromPoints(found.end, found.start);
|
|
530
|
+
this.$editor.moveCursorToPosition(found.end);
|
|
531
|
+
if (moveToNext) this.$currentPos = found.end;
|
|
532
|
+
this.highlight(options.re)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
this.statusMessage(found);
|
|
536
|
+
|
|
537
|
+
return found;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
this.addChar = function(c) {
|
|
541
|
+
return this.highlightAndFindWithNeedle(false, function(needle) {
|
|
542
|
+
return needle + c;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
this.removeChar = function(c) {
|
|
547
|
+
return this.highlightAndFindWithNeedle(false, function(needle) {
|
|
548
|
+
return needle.length > 0 ? needle.substring(0, needle.length-1) : needle;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
this.next = function(options) {
|
|
553
|
+
options = options || {};
|
|
554
|
+
this.$options.backwards = !!options.backwards;
|
|
555
|
+
this.$currentPos = this.$editor.getCursorPosition();
|
|
556
|
+
return this.highlightAndFindWithNeedle(true, function(needle) {
|
|
557
|
+
return options.useCurrentOrPrevSearch && needle.length === 0 ?
|
|
558
|
+
this.$prevNeedle || '' : needle;
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
this.onMouseDown = function(evt) {
|
|
563
|
+
this.deactivate();
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
this.statusMessage = function(found) {
|
|
568
|
+
var options = this.$options, msg = '';
|
|
569
|
+
msg += options.backwards ? 'reverse-' : '';
|
|
570
|
+
msg += 'isearch: ' + options.needle;
|
|
571
|
+
msg += found ? '' : ' (not found)';
|
|
572
|
+
this.message(msg);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
this.message = function(msg) {
|
|
576
|
+
if (this.$editor.showCommandLine) {
|
|
577
|
+
this.$editor.showCommandLine(msg);
|
|
578
|
+
this.$editor.focus();
|
|
579
|
+
} else {
|
|
580
|
+
console.log(msg);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
}).call(IncrementalSearch.prototype);
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
exports.IncrementalSearch = IncrementalSearch;
|
|
588
|
+
|
|
589
|
+
var dom = require('./lib/dom');
|
|
590
|
+
dom.importCssString && dom.importCssString("\
|
|
591
|
+
.ace_marker-layer .ace_isearch-result {\
|
|
592
|
+
position: absolute;\
|
|
593
|
+
z-index: 6;\
|
|
594
|
+
-moz-box-sizing: border-box;\
|
|
595
|
+
-webkit-box-sizing: border-box;\
|
|
596
|
+
box-sizing: border-box;\
|
|
597
|
+
}\
|
|
598
|
+
div.ace_isearch-result {\
|
|
599
|
+
border-radius: 4px;\
|
|
600
|
+
background-color: rgba(255, 200, 0, 0.5);\
|
|
601
|
+
box-shadow: 0 0 4px rgb(255, 200, 0);\
|
|
602
|
+
}\
|
|
603
|
+
.ace_dark div.ace_isearch-result {\
|
|
604
|
+
background-color: rgb(100, 110, 160);\
|
|
605
|
+
box-shadow: 0 0 4px rgb(80, 90, 140);\
|
|
606
|
+
}", "incremental-search-highlighting");
|
|
607
|
+
var commands = require("./commands/command_manager");
|
|
608
|
+
(function() {
|
|
609
|
+
this.setupIncrementalSearch = function(editor, val) {
|
|
610
|
+
if (this.usesIncrementalSearch == val) return;
|
|
611
|
+
this.usesIncrementalSearch = val;
|
|
612
|
+
var iSearchCommands = iSearchCommandModule.iSearchStartCommands;
|
|
613
|
+
var method = val ? 'addCommands' : 'removeCommands';
|
|
614
|
+
this[method](iSearchCommands);
|
|
615
|
+
};
|
|
616
|
+
}).call(commands.CommandManager.prototype);
|
|
617
|
+
var Editor = require("./editor").Editor;
|
|
618
|
+
require("./config").defineOptions(Editor.prototype, "editor", {
|
|
619
|
+
useIncrementalSearch: {
|
|
620
|
+
set: function(val) {
|
|
621
|
+
this.keyBinding.$handlers.forEach(function(handler) {
|
|
622
|
+
if (handler.setupIncrementalSearch) {
|
|
623
|
+
handler.setupIncrementalSearch(this, val);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
this._emit('incrementalSearchSettingChanged', {isEnabled: val});
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
define('ace/commands/incremental_search_commands', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/commands/occur_commands'], function(require, exports, module) {
|
|
634
|
+
|
|
635
|
+
var config = require("../config");
|
|
636
|
+
var oop = require("../lib/oop");
|
|
637
|
+
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
|
638
|
+
var occurStartCommand = require("./occur_commands").occurStartCommand;
|
|
639
|
+
exports.iSearchStartCommands = [{
|
|
640
|
+
name: "iSearch",
|
|
641
|
+
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
|
642
|
+
exec: function(editor, options) {
|
|
643
|
+
config.loadModule(["core", "ace/incremental_search"], function(e) {
|
|
644
|
+
var iSearch = e.iSearch = e.iSearch || new e.IncrementalSearch();
|
|
645
|
+
iSearch.activate(editor, options.backwards);
|
|
646
|
+
if (options.jumpToFirstMatch) iSearch.next(options);
|
|
647
|
+
});
|
|
648
|
+
},
|
|
649
|
+
readOnly: true
|
|
650
|
+
}, {
|
|
651
|
+
name: "iSearchBackwards",
|
|
652
|
+
exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {backwards: true}); },
|
|
653
|
+
readOnly: true
|
|
654
|
+
}, {
|
|
655
|
+
name: "iSearchAndGo",
|
|
656
|
+
bindKey: {win: "Ctrl-K", mac: "Command-G"},
|
|
657
|
+
exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {jumpToFirstMatch: true, useCurrentOrPrevSearch: true}); },
|
|
658
|
+
readOnly: true
|
|
659
|
+
}, {
|
|
660
|
+
name: "iSearchBackwardsAndGo",
|
|
661
|
+
bindKey: {win: "Ctrl-Shift-K", mac: "Command-Shift-G"},
|
|
662
|
+
exec: function(editor) { editor.execCommand('iSearch', {jumpToFirstMatch: true, backwards: true, useCurrentOrPrevSearch: true}); },
|
|
663
|
+
readOnly: true
|
|
664
|
+
}];
|
|
665
|
+
exports.iSearchCommands = [{
|
|
666
|
+
name: "restartSearch",
|
|
667
|
+
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
|
668
|
+
exec: function(iSearch) {
|
|
669
|
+
iSearch.cancelSearch(true);
|
|
670
|
+
},
|
|
671
|
+
readOnly: true,
|
|
672
|
+
isIncrementalSearchCommand: true
|
|
673
|
+
}, {
|
|
674
|
+
name: "searchForward",
|
|
675
|
+
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
|
|
676
|
+
exec: function(iSearch, options) {
|
|
677
|
+
options.useCurrentOrPrevSearch = true;
|
|
678
|
+
iSearch.next(options);
|
|
679
|
+
},
|
|
680
|
+
readOnly: true,
|
|
681
|
+
isIncrementalSearchCommand: true
|
|
682
|
+
}, {
|
|
683
|
+
name: "searchBackward",
|
|
684
|
+
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
|
|
685
|
+
exec: function(iSearch, options) {
|
|
686
|
+
options.useCurrentOrPrevSearch = true;
|
|
687
|
+
options.backwards = true;
|
|
688
|
+
iSearch.next(options);
|
|
689
|
+
},
|
|
690
|
+
readOnly: true,
|
|
691
|
+
isIncrementalSearchCommand: true
|
|
692
|
+
}, {
|
|
693
|
+
name: "extendSearchTerm",
|
|
694
|
+
exec: function(iSearch, string) {
|
|
695
|
+
iSearch.addChar(string);
|
|
696
|
+
},
|
|
697
|
+
readOnly: true,
|
|
698
|
+
isIncrementalSearchCommand: true
|
|
699
|
+
}, {
|
|
700
|
+
name: "extendSearchTermSpace",
|
|
701
|
+
bindKey: "space",
|
|
702
|
+
exec: function(iSearch) { iSearch.addChar(' '); },
|
|
703
|
+
readOnly: true,
|
|
704
|
+
isIncrementalSearchCommand: true
|
|
705
|
+
}, {
|
|
706
|
+
name: "shrinkSearchTerm",
|
|
707
|
+
bindKey: "backspace",
|
|
708
|
+
exec: function(iSearch) {
|
|
709
|
+
iSearch.removeChar();
|
|
710
|
+
},
|
|
711
|
+
readOnly: true,
|
|
712
|
+
isIncrementalSearchCommand: true
|
|
713
|
+
}, {
|
|
714
|
+
name: 'confirmSearch',
|
|
715
|
+
bindKey: 'return',
|
|
716
|
+
exec: function(iSearch) { iSearch.deactivate(); },
|
|
717
|
+
readOnly: true,
|
|
718
|
+
isIncrementalSearchCommand: true
|
|
719
|
+
}, {
|
|
720
|
+
name: 'cancelSearch',
|
|
721
|
+
bindKey: 'esc|Ctrl-G',
|
|
722
|
+
exec: function(iSearch) { iSearch.deactivate(true); },
|
|
723
|
+
readOnly: true,
|
|
724
|
+
isIncrementalSearchCommand: true
|
|
725
|
+
}, {
|
|
726
|
+
name: 'occurisearch',
|
|
727
|
+
bindKey: 'Ctrl-O',
|
|
728
|
+
exec: function(iSearch) {
|
|
729
|
+
var options = oop.mixin({}, iSearch.$options);
|
|
730
|
+
iSearch.deactivate();
|
|
731
|
+
occurStartCommand.exec(iSearch.$editor, options);
|
|
732
|
+
},
|
|
733
|
+
readOnly: true,
|
|
734
|
+
isIncrementalSearchCommand: true
|
|
735
|
+
}];
|
|
736
|
+
|
|
737
|
+
function IncrementalSearchKeyboardHandler(iSearch) {
|
|
738
|
+
this.$iSearch = iSearch;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
|
|
742
|
+
|
|
743
|
+
;(function() {
|
|
744
|
+
|
|
745
|
+
this.attach = function(editor) {
|
|
746
|
+
var iSearch = this.$iSearch;
|
|
747
|
+
HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
|
|
748
|
+
this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) {
|
|
749
|
+
if (!e.command.isIncrementalSearchCommand) return undefined;
|
|
750
|
+
e.stopPropagation();
|
|
751
|
+
e.preventDefault();
|
|
752
|
+
return e.command.exec(iSearch, e.args || {});
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
this.detach = function(editor) {
|
|
757
|
+
if (!this.$commandExecHandler) return;
|
|
758
|
+
editor.commands.removeEventListener('exec', this.$commandExecHandler);
|
|
759
|
+
delete this.$commandExecHandler;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
var handleKeyboard$super = this.handleKeyboard;
|
|
763
|
+
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
|
764
|
+
var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
|
|
765
|
+
if (cmd.command) { return cmd; }
|
|
766
|
+
if (hashId == -1) {
|
|
767
|
+
var extendCmd = this.commands.extendSearchTerm;
|
|
768
|
+
if (extendCmd) { return {command: extendCmd, args: key}; }
|
|
769
|
+
}
|
|
770
|
+
return {command: "null", passEvent: hashId == 0 || hashId == 4};
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
}).call(IncrementalSearchKeyboardHandler.prototype);
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
exports.IncrementalSearchKeyboardHandler = IncrementalSearchKeyboardHandler;
|
|
777
|
+
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
define('ace/commands/occur_commands', ['require', 'exports', 'module' , 'ace/config', 'ace/occur', 'ace/keyboard/hash_handler', 'ace/lib/oop'], function(require, exports, module) {
|
|
781
|
+
|
|
782
|
+
var config = require("../config"),
|
|
783
|
+
Occur = require("../occur").Occur;
|
|
784
|
+
var occurStartCommand = {
|
|
785
|
+
name: "occur",
|
|
786
|
+
exec: function(editor, options) {
|
|
787
|
+
var alreadyInOccur = !!editor.session.$occur;
|
|
788
|
+
var occurSessionActive = new Occur().enter(editor, options);
|
|
789
|
+
if (occurSessionActive && !alreadyInOccur)
|
|
790
|
+
OccurKeyboardHandler.installIn(editor);
|
|
791
|
+
},
|
|
792
|
+
readOnly: true
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
var occurCommands = [{
|
|
796
|
+
name: "occurexit",
|
|
797
|
+
bindKey: 'esc|Ctrl-G',
|
|
798
|
+
exec: function(editor) {
|
|
799
|
+
var occur = editor.session.$occur;
|
|
800
|
+
if (!occur) return;
|
|
801
|
+
occur.exit(editor, {});
|
|
802
|
+
if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor);
|
|
803
|
+
},
|
|
804
|
+
readOnly: true
|
|
805
|
+
}, {
|
|
806
|
+
name: "occuraccept",
|
|
807
|
+
bindKey: 'enter',
|
|
808
|
+
exec: function(editor) {
|
|
809
|
+
var occur = editor.session.$occur;
|
|
810
|
+
if (!occur) return;
|
|
811
|
+
occur.exit(editor, {translatePosition: true});
|
|
812
|
+
if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor);
|
|
813
|
+
},
|
|
814
|
+
readOnly: true
|
|
815
|
+
}];
|
|
816
|
+
|
|
817
|
+
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
|
818
|
+
var oop = require("../lib/oop");
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
function OccurKeyboardHandler() {}
|
|
822
|
+
|
|
823
|
+
oop.inherits(OccurKeyboardHandler, HashHandler);
|
|
824
|
+
|
|
825
|
+
;(function() {
|
|
826
|
+
|
|
827
|
+
this.isOccurHandler = true;
|
|
828
|
+
|
|
829
|
+
this.attach = function(editor) {
|
|
830
|
+
HashHandler.call(this, occurCommands, editor.commands.platform);
|
|
831
|
+
this.$editor = editor;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
var handleKeyboard$super = this.handleKeyboard;
|
|
835
|
+
this.handleKeyboard = function(data, hashId, key, keyCode) {
|
|
836
|
+
var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
|
|
837
|
+
return (cmd && cmd.command) ? cmd : undefined;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
}).call(OccurKeyboardHandler.prototype);
|
|
841
|
+
|
|
842
|
+
OccurKeyboardHandler.installIn = function(editor) {
|
|
843
|
+
var handler = new this();
|
|
844
|
+
editor.keyBinding.addKeyboardHandler(handler);
|
|
845
|
+
editor.commands.addCommands(occurCommands);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
OccurKeyboardHandler.uninstallFrom = function(editor) {
|
|
849
|
+
editor.commands.removeCommands(occurCommands);
|
|
850
|
+
var handler = editor.getKeyboardHandler();
|
|
851
|
+
if (handler.isOccurHandler)
|
|
852
|
+
editor.keyBinding.removeKeyboardHandler(handler);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
exports.occurStartCommand = occurStartCommand;
|
|
856
|
+
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
define('ace/occur', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/search', 'ace/edit_session', 'ace/search_highlight', 'ace/lib/dom'], function(require, exports, module) {
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
var oop = require("./lib/oop");
|
|
863
|
+
var Range = require("./range").Range;
|
|
864
|
+
var Search = require("./search").Search;
|
|
865
|
+
var EditSession = require("./edit_session").EditSession;
|
|
866
|
+
var SearchHighlight = require("./search_highlight").SearchHighlight;
|
|
867
|
+
function Occur() {}
|
|
868
|
+
|
|
869
|
+
oop.inherits(Occur, Search);
|
|
870
|
+
|
|
871
|
+
(function() {
|
|
872
|
+
this.enter = function(editor, options) {
|
|
873
|
+
if (!options.needle) return false;
|
|
874
|
+
var pos = editor.getCursorPosition();
|
|
875
|
+
this.displayOccurContent(editor, options);
|
|
876
|
+
var translatedPos = this.originalToOccurPosition(editor.session, pos);
|
|
877
|
+
editor.moveCursorToPosition(translatedPos);
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
this.exit = function(editor, options) {
|
|
881
|
+
var pos = options.translatePosition && editor.getCursorPosition();
|
|
882
|
+
var translatedPos = pos && this.occurToOriginalPosition(editor.session, pos);
|
|
883
|
+
this.displayOriginalContent(editor);
|
|
884
|
+
if (translatedPos)
|
|
885
|
+
editor.moveCursorToPosition(translatedPos);
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
this.highlight = function(sess, regexp) {
|
|
890
|
+
var hl = sess.$occurHighlight = sess.$occurHighlight || sess.addDynamicMarker(
|
|
891
|
+
new SearchHighlight(null, "ace_occur-highlight", "text"));
|
|
892
|
+
hl.setRegexp(regexp);
|
|
893
|
+
sess._emit("changeBackMarker"); // force highlight layer redraw
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
this.displayOccurContent = function(editor, options) {
|
|
897
|
+
this.$originalSession = editor.session;
|
|
898
|
+
var found = this.matchingLines(editor.session, options);
|
|
899
|
+
var lines = found.map(function(foundLine) { return foundLine.content; });
|
|
900
|
+
var occurSession = new EditSession(lines.join('\n'));
|
|
901
|
+
occurSession.$occur = this;
|
|
902
|
+
occurSession.$occurMatchingLines = found;
|
|
903
|
+
editor.setSession(occurSession);
|
|
904
|
+
this.highlight(occurSession, options.re);
|
|
905
|
+
occurSession._emit('changeBackMarker');
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
this.displayOriginalContent = function(editor) {
|
|
909
|
+
editor.setSession(this.$originalSession);
|
|
910
|
+
}
|
|
911
|
+
this.originalToOccurPosition = function(session, pos) {
|
|
912
|
+
var lines = session.$occurMatchingLines;
|
|
913
|
+
var nullPos = {row: 0, column: 0};
|
|
914
|
+
if (!lines) return nullPos;
|
|
915
|
+
for (var i = 0; i < lines.length; i++) {
|
|
916
|
+
if (lines[i].row === pos.row)
|
|
917
|
+
return {row: i, column: pos.column};
|
|
918
|
+
}
|
|
919
|
+
return nullPos;
|
|
920
|
+
}
|
|
921
|
+
this.occurToOriginalPosition = function(session, pos) {
|
|
922
|
+
var lines = session.$occurMatchingLines;
|
|
923
|
+
if (!lines || !lines[pos.row])
|
|
924
|
+
return pos;
|
|
925
|
+
return {row: lines[pos.row].row, column: pos.column};
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
this.matchingLines = function(session, options) {
|
|
929
|
+
options = oop.mixin({}, options);
|
|
930
|
+
if (!session || !options.needle) return [];
|
|
931
|
+
var search = new Search();
|
|
932
|
+
search.set(options);
|
|
933
|
+
return search.findAll(session).reduce(function(lines, range) {
|
|
934
|
+
var row = range.start.row;
|
|
935
|
+
var last = lines[lines.length-1];
|
|
936
|
+
return last && last.row === row ?
|
|
937
|
+
lines :
|
|
938
|
+
lines.concat({row: row, content: session.getLine(row)});
|
|
939
|
+
}, []);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
}).call(Occur.prototype);
|
|
943
|
+
|
|
944
|
+
var dom = require('./lib/dom');
|
|
945
|
+
dom.importCssString(".ace_occur-highlight {\n\
|
|
946
|
+
border-radius: 4px;\n\
|
|
947
|
+
background-color: rgba(87, 255, 8, 0.25);\n\
|
|
948
|
+
position: absolute;\n\
|
|
949
|
+
z-index: 4;\n\
|
|
950
|
+
-moz-box-sizing: border-box;\n\
|
|
951
|
+
-webkit-box-sizing: border-box;\n\
|
|
952
|
+
box-sizing: border-box;\n\
|
|
953
|
+
box-shadow: 0 0 4px rgb(91, 255, 50);\n\
|
|
954
|
+
}\n\
|
|
955
|
+
.ace_dark .ace_occur-highlight {\n\
|
|
956
|
+
background-color: rgb(80, 140, 85);\n\
|
|
957
|
+
box-shadow: 0 0 4px rgb(60, 120, 70);\n\
|
|
958
|
+
}\n", "incremental-occur-highlighting");
|
|
959
|
+
|
|
960
|
+
exports.Occur = Occur;
|
|
961
|
+
|
|
962
|
+
});
|