datagram 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,441 @@
|
|
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/ext/searchbox', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/event', 'ace/keyboard/hash_handler', 'ace/lib/keys'], function(require, exports, module) {
|
32
|
+
|
33
|
+
|
34
|
+
var dom = require("../lib/dom");
|
35
|
+
var lang = require("../lib/lang");
|
36
|
+
var event = require("../lib/event");
|
37
|
+
var searchboxCss = "\
|
38
|
+
/* ------------------------------------------------------------------------------------------\
|
39
|
+
* Editor Search Form\
|
40
|
+
* --------------------------------------------------------------------------------------- */\
|
41
|
+
.ace_search {\
|
42
|
+
background-color: #ddd;\
|
43
|
+
border: 1px solid #cbcbcb;\
|
44
|
+
border-top: 0 none;\
|
45
|
+
max-width: 297px;\
|
46
|
+
overflow: hidden;\
|
47
|
+
margin: 0;\
|
48
|
+
padding: 4px;\
|
49
|
+
padding-right: 6px;\
|
50
|
+
padding-bottom: 0;\
|
51
|
+
position: absolute;\
|
52
|
+
top: 0px;\
|
53
|
+
z-index: 99;\
|
54
|
+
}\
|
55
|
+
.ace_search.left {\
|
56
|
+
border-left: 0 none;\
|
57
|
+
border-radius: 0px 0px 5px 0px;\
|
58
|
+
left: 0;\
|
59
|
+
}\
|
60
|
+
.ace_search.right {\
|
61
|
+
border-radius: 0px 0px 0px 5px;\
|
62
|
+
border-right: 0 none;\
|
63
|
+
right: 0;\
|
64
|
+
}\
|
65
|
+
.ace_search_form, .ace_replace_form {\
|
66
|
+
border-radius: 3px;\
|
67
|
+
border: 1px solid #cbcbcb;\
|
68
|
+
float: left;\
|
69
|
+
margin-bottom: 4px;\
|
70
|
+
overflow: hidden;\
|
71
|
+
}\
|
72
|
+
.ace_search_form.ace_nomatch {\
|
73
|
+
outline: 1px solid red;\
|
74
|
+
}\
|
75
|
+
.ace_search_field {\
|
76
|
+
background-color: white;\
|
77
|
+
border-right: 1px solid #cbcbcb;\
|
78
|
+
border: 0 none;\
|
79
|
+
-webkit-box-sizing: border-box;\
|
80
|
+
-moz-box-sizing: border-box;\
|
81
|
+
box-sizing: border-box;\
|
82
|
+
display: block;\
|
83
|
+
float: left;\
|
84
|
+
height: 22px;\
|
85
|
+
outline: 0;\
|
86
|
+
padding: 0 7px;\
|
87
|
+
width: 214px;\
|
88
|
+
margin: 0;\
|
89
|
+
}\
|
90
|
+
.ace_searchbtn,\
|
91
|
+
.ace_replacebtn {\
|
92
|
+
background: #fff;\
|
93
|
+
border: 0 none;\
|
94
|
+
border-left: 1px solid #dcdcdc;\
|
95
|
+
cursor: pointer;\
|
96
|
+
display: block;\
|
97
|
+
float: left;\
|
98
|
+
height: 22px;\
|
99
|
+
margin: 0;\
|
100
|
+
padding: 0;\
|
101
|
+
position: relative;\
|
102
|
+
}\
|
103
|
+
.ace_searchbtn:last-child,\
|
104
|
+
.ace_replacebtn:last-child {\
|
105
|
+
border-top-right-radius: 3px;\
|
106
|
+
border-bottom-right-radius: 3px;\
|
107
|
+
}\
|
108
|
+
.ace_searchbtn:disabled {\
|
109
|
+
background: none;\
|
110
|
+
cursor: default;\
|
111
|
+
}\
|
112
|
+
.ace_searchbtn {\
|
113
|
+
background-position: 50% 50%;\
|
114
|
+
background-repeat: no-repeat;\
|
115
|
+
width: 27px;\
|
116
|
+
}\
|
117
|
+
.ace_searchbtn.prev {\
|
118
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); \
|
119
|
+
}\
|
120
|
+
.ace_searchbtn.next {\
|
121
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); \
|
122
|
+
}\
|
123
|
+
.ace_searchbtn_close {\
|
124
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
|
125
|
+
border-radius: 50%;\
|
126
|
+
border: 0 none;\
|
127
|
+
color: #656565;\
|
128
|
+
cursor: pointer;\
|
129
|
+
display: block;\
|
130
|
+
float: right;\
|
131
|
+
font-family: Arial;\
|
132
|
+
font-size: 16px;\
|
133
|
+
height: 14px;\
|
134
|
+
line-height: 16px;\
|
135
|
+
margin: 5px 1px 9px 5px;\
|
136
|
+
padding: 0;\
|
137
|
+
text-align: center;\
|
138
|
+
width: 14px;\
|
139
|
+
}\
|
140
|
+
.ace_searchbtn_close:hover {\
|
141
|
+
background-color: #656565;\
|
142
|
+
background-position: 50% 100%;\
|
143
|
+
color: white;\
|
144
|
+
}\
|
145
|
+
.ace_replacebtn.prev {\
|
146
|
+
width: 54px\
|
147
|
+
}\
|
148
|
+
.ace_replacebtn.next {\
|
149
|
+
width: 27px\
|
150
|
+
}\
|
151
|
+
.ace_button {\
|
152
|
+
margin-left: 2px;\
|
153
|
+
cursor: pointer;\
|
154
|
+
-webkit-user-select: none;\
|
155
|
+
-moz-user-select: none;\
|
156
|
+
-o-user-select: none;\
|
157
|
+
-ms-user-select: none;\
|
158
|
+
user-select: none;\
|
159
|
+
overflow: hidden;\
|
160
|
+
opacity: 0.7;\
|
161
|
+
border: 1px solid rgba(100,100,100,0.23);\
|
162
|
+
padding: 1px;\
|
163
|
+
-moz-box-sizing: border-box;\
|
164
|
+
box-sizing: border-box;\
|
165
|
+
color: black;\
|
166
|
+
}\
|
167
|
+
.ace_button:hover {\
|
168
|
+
background-color: #eee;\
|
169
|
+
opacity:1;\
|
170
|
+
}\
|
171
|
+
.ace_button:active {\
|
172
|
+
background-color: #ddd;\
|
173
|
+
}\
|
174
|
+
.ace_button.checked {\
|
175
|
+
border-color: #3399ff;\
|
176
|
+
opacity:1;\
|
177
|
+
}\
|
178
|
+
.ace_search_options{\
|
179
|
+
margin-bottom: 3px;\
|
180
|
+
text-align: right;\
|
181
|
+
-webkit-user-select: none;\
|
182
|
+
-moz-user-select: none;\
|
183
|
+
-o-user-select: none;\
|
184
|
+
-ms-user-select: none;\
|
185
|
+
user-select: none;\
|
186
|
+
}";
|
187
|
+
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
188
|
+
var keyUtil = require("../lib/keys");
|
189
|
+
|
190
|
+
dom.importCssString(searchboxCss, "ace_searchbox");
|
191
|
+
|
192
|
+
var html = '<div class="ace_search right">\
|
193
|
+
<button type="button" action="hide" class="ace_searchbtn_close"></button>\
|
194
|
+
<div class="ace_search_form">\
|
195
|
+
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
|
196
|
+
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
|
197
|
+
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
|
198
|
+
</div>\
|
199
|
+
<div class="ace_replace_form">\
|
200
|
+
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
|
201
|
+
<button type="button" action="replace" class="ace_replacebtn">Replace</button>\
|
202
|
+
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\
|
203
|
+
</div>\
|
204
|
+
<div class="ace_search_options">\
|
205
|
+
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\
|
206
|
+
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\
|
207
|
+
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\
|
208
|
+
</div>\
|
209
|
+
</div>'.replace(/>\s+/g, ">");
|
210
|
+
|
211
|
+
var SearchBox = function(editor, range, showReplaceForm) {
|
212
|
+
var div = dom.createElement("div");
|
213
|
+
div.innerHTML = html;
|
214
|
+
this.element = div.firstChild;
|
215
|
+
|
216
|
+
this.$init();
|
217
|
+
this.setEditor(editor);
|
218
|
+
};
|
219
|
+
|
220
|
+
(function() {
|
221
|
+
this.setEditor = function(editor) {
|
222
|
+
editor.searchBox = this;
|
223
|
+
editor.container.appendChild(this.element);
|
224
|
+
this.editor = editor;
|
225
|
+
};
|
226
|
+
|
227
|
+
this.$init = function() {
|
228
|
+
var sb = this.element;
|
229
|
+
|
230
|
+
this.searchBox = sb.querySelector(".ace_search_form");
|
231
|
+
this.replaceBox = sb.querySelector(".ace_replace_form");
|
232
|
+
this.searchOptions = sb.querySelector(".ace_search_options");
|
233
|
+
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
234
|
+
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
235
|
+
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
236
|
+
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
237
|
+
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
238
|
+
|
239
|
+
var _this = this;
|
240
|
+
event.addListener(sb, "mousedown", function(e) {
|
241
|
+
setTimeout(function(){
|
242
|
+
_this.activeInput.focus();
|
243
|
+
}, 0);
|
244
|
+
event.stopPropagation(e);
|
245
|
+
});
|
246
|
+
event.addListener(sb, "click", function(e) {
|
247
|
+
var t = e.target;
|
248
|
+
var action = t.getAttribute("action");
|
249
|
+
if (action && _this[action])
|
250
|
+
_this[action]();
|
251
|
+
else if (_this.$searchBarKb.commands[action])
|
252
|
+
_this.$searchBarKb.commands[action].exec(_this);
|
253
|
+
event.stopPropagation(e);
|
254
|
+
});
|
255
|
+
|
256
|
+
event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
|
257
|
+
var keyString = keyUtil.keyCodeToString(keyCode);
|
258
|
+
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
|
259
|
+
if (command && command.exec) {
|
260
|
+
command.exec(_this);
|
261
|
+
event.stopEvent(e);
|
262
|
+
}
|
263
|
+
});
|
264
|
+
|
265
|
+
this.$onChange = lang.delayedCall(function() {
|
266
|
+
_this.find(false, false);
|
267
|
+
});
|
268
|
+
|
269
|
+
event.addListener(this.searchInput, "input", function() {
|
270
|
+
_this.$onChange.schedule(20);
|
271
|
+
});
|
272
|
+
event.addListener(this.searchInput, "focus", function() {
|
273
|
+
_this.activeInput = _this.searchInput;
|
274
|
+
});
|
275
|
+
event.addListener(this.replaceInput, "focus", function() {
|
276
|
+
_this.activeInput = _this.replaceInput;
|
277
|
+
});
|
278
|
+
};
|
279
|
+
this.$closeSearchBarKb = new HashHandler([{
|
280
|
+
bindKey: "Esc",
|
281
|
+
name: "closeSearchBar",
|
282
|
+
exec: function(editor) {
|
283
|
+
editor.searchBox.hide();
|
284
|
+
}
|
285
|
+
}]);
|
286
|
+
this.$searchBarKb = new HashHandler();
|
287
|
+
this.$searchBarKb.bindKeys({
|
288
|
+
"Ctrl-f|Command-f|Ctrl-H|Command-Option-F": function(sb) {
|
289
|
+
var isReplace = sb.isReplace = !sb.isReplace;
|
290
|
+
sb.replaceBox.style.display = isReplace ? "" : "none";
|
291
|
+
sb[isReplace ? "replaceInput" : "searchInput"].focus();
|
292
|
+
},
|
293
|
+
"Ctrl-G|Command-G": function(sb) {
|
294
|
+
sb.findNext();
|
295
|
+
},
|
296
|
+
"Ctrl-Shift-G|Command-Shift-G": function(sb) {
|
297
|
+
sb.findPrev();
|
298
|
+
},
|
299
|
+
"esc": function(sb) {
|
300
|
+
setTimeout(function() { sb.hide();});
|
301
|
+
},
|
302
|
+
"Return": function(sb) {
|
303
|
+
if (sb.activeInput == sb.replaceInput)
|
304
|
+
sb.replace();
|
305
|
+
sb.findNext();
|
306
|
+
},
|
307
|
+
"Shift-Return": function(sb) {
|
308
|
+
if (sb.activeInput == sb.replaceInput)
|
309
|
+
sb.replace();
|
310
|
+
sb.findPrev();
|
311
|
+
},
|
312
|
+
"Tab": function(sb) {
|
313
|
+
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
314
|
+
}
|
315
|
+
});
|
316
|
+
|
317
|
+
this.$searchBarKb.addCommands([{
|
318
|
+
name: "toggleRegexpMode",
|
319
|
+
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
320
|
+
exec: function(sb) {
|
321
|
+
sb.regExpOption.checked = !sb.regExpOption.checked;
|
322
|
+
sb.$syncOptions();
|
323
|
+
}
|
324
|
+
}, {
|
325
|
+
name: "toggleCaseSensitive",
|
326
|
+
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
327
|
+
exec: function(sb) {
|
328
|
+
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
329
|
+
sb.$syncOptions();
|
330
|
+
}
|
331
|
+
}, {
|
332
|
+
name: "toggleWholeWords",
|
333
|
+
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
334
|
+
exec: function(sb) {
|
335
|
+
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
336
|
+
sb.$syncOptions();
|
337
|
+
}
|
338
|
+
}]);
|
339
|
+
|
340
|
+
this.$syncOptions = function() {
|
341
|
+
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
342
|
+
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
343
|
+
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
344
|
+
this.find(false, false);
|
345
|
+
};
|
346
|
+
|
347
|
+
this.find = function(skipCurrent, backwards) {
|
348
|
+
var range = this.editor.find(this.searchInput.value, {
|
349
|
+
skipCurrent: skipCurrent,
|
350
|
+
backwards: backwards,
|
351
|
+
wrap: true,
|
352
|
+
regExp: this.regExpOption.checked,
|
353
|
+
caseSensitive: this.caseSensitiveOption.checked,
|
354
|
+
wholeWord: this.wholeWordOption.checked
|
355
|
+
});
|
356
|
+
dom.setCssClass(this.searchBox, "ace_nomatch", !range && this.searchInput.value);
|
357
|
+
this.editor.session.highlight(this.editor.$search.$options.re);
|
358
|
+
};
|
359
|
+
this.findNext = function() {
|
360
|
+
this.find(true, false);
|
361
|
+
};
|
362
|
+
this.findPrev = function() {
|
363
|
+
this.find(true, true);
|
364
|
+
};
|
365
|
+
this.replace = function() {
|
366
|
+
this.editor.replace(this.replaceInput.value);
|
367
|
+
};
|
368
|
+
this.replaceAll = function() {
|
369
|
+
this.editor.replaceAll(this.replaceInput.value);
|
370
|
+
};
|
371
|
+
|
372
|
+
this.hide = function () {
|
373
|
+
this.element.style.display = "none";
|
374
|
+
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
|
375
|
+
this.editor.focus();
|
376
|
+
};
|
377
|
+
this.show = function(value, isReplace) {
|
378
|
+
this.element.style.display = "";
|
379
|
+
this.replaceBox.style.display = isReplace ? "" : "none";
|
380
|
+
|
381
|
+
this.isReplace = isReplace;
|
382
|
+
|
383
|
+
if (value)
|
384
|
+
this.searchInput.value = value;
|
385
|
+
this.searchInput.focus();
|
386
|
+
this.searchInput.select();
|
387
|
+
|
388
|
+
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
389
|
+
};
|
390
|
+
|
391
|
+
}).call(SearchBox.prototype);
|
392
|
+
|
393
|
+
exports.SearchBox = SearchBox;
|
394
|
+
|
395
|
+
exports.Search = function(editor, isReplace) {
|
396
|
+
var sb = editor.searchBox || new SearchBox(editor);
|
397
|
+
sb.show(editor.session.getTextRange(), isReplace);
|
398
|
+
};
|
399
|
+
|
400
|
+
|
401
|
+
exports.ISearch = function(session, options) {
|
402
|
+
this.$changeListener = this.$changeListener.bind(this);
|
403
|
+
this.startRange = session.selection.toOrientedRange();
|
404
|
+
this.options = options || {};
|
405
|
+
};
|
406
|
+
|
407
|
+
(function(){
|
408
|
+
this.setSession = function(session) {
|
409
|
+
if (this.session) {
|
410
|
+
this.session.removeListener(this.$changeListener);
|
411
|
+
}
|
412
|
+
this.session = session;
|
413
|
+
this.session.addListener(this.$changeListener);
|
414
|
+
};
|
415
|
+
this.setSearchString = function() {
|
416
|
+
|
417
|
+
};
|
418
|
+
this.getValue = function() {
|
419
|
+
if (this.value == null)
|
420
|
+
this.value = this.session.getValue();
|
421
|
+
return this.value;
|
422
|
+
};
|
423
|
+
this.$changeListener = function() {
|
424
|
+
this.value = null;
|
425
|
+
};
|
426
|
+
this.find = function() {
|
427
|
+
|
428
|
+
};
|
429
|
+
this.$edgeBefore = function() {
|
430
|
+
this.cursor = this.startRange[this.options.backwards ? "start" : "end"];
|
431
|
+
};
|
432
|
+
this.$edgeAfter = function() {
|
433
|
+
|
434
|
+
};
|
435
|
+
this.next = function(dir) {
|
436
|
+
|
437
|
+
};
|
438
|
+
}).call(exports.ISearch.prototype);
|
439
|
+
|
440
|
+
|
441
|
+
});
|
@@ -0,0 +1,67 @@
|
|
1
|
+
define('ace/ext/spellcheck', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/editor', 'ace/config'], function(require, exports, module) {
|
2
|
+
|
3
|
+
var event = require("../lib/event");
|
4
|
+
|
5
|
+
exports.contextMenuHandler = function(e){
|
6
|
+
var host = e.target;
|
7
|
+
var text = host.textInput.getElement();
|
8
|
+
if (!host.selection.isEmpty())
|
9
|
+
return;
|
10
|
+
var c = host.getCursorPosition();
|
11
|
+
var r = host.session.getWordRange(c.row, c.column);
|
12
|
+
var w = host.session.getTextRange(r);
|
13
|
+
|
14
|
+
host.session.tokenRe.lastIndex = 0;
|
15
|
+
if (!host.session.tokenRe.test(w))
|
16
|
+
return;
|
17
|
+
var PLACEHOLDER = "\x01\x01";
|
18
|
+
var value = w + " " + PLACEHOLDER;
|
19
|
+
text.value = value;
|
20
|
+
text.setSelectionRange(w.length + 1, w.length + 1);
|
21
|
+
text.setSelectionRange(0, 0);
|
22
|
+
|
23
|
+
var afterKeydown = false;
|
24
|
+
event.addListener(text, "keydown", function onKeydown() {
|
25
|
+
event.removeListener(text, "keydown", onKeydown);
|
26
|
+
afterKeydown = true;
|
27
|
+
});
|
28
|
+
|
29
|
+
host.textInput.setInputHandler(function(newVal) {
|
30
|
+
console.log(newVal , value, text.selectionStart, text.selectionEnd)
|
31
|
+
if (newVal == value)
|
32
|
+
return '';
|
33
|
+
if (newVal.lastIndexOf(value, 0) === 0)
|
34
|
+
return newVal.slice(value.length);
|
35
|
+
if (newVal.substr(text.selectionEnd) == value)
|
36
|
+
return newVal.slice(0, -value.length);
|
37
|
+
if (newVal.slice(-2) == PLACEHOLDER) {
|
38
|
+
var val = newVal.slice(0, -2);
|
39
|
+
if (val.slice(-1) == " ") {
|
40
|
+
if (afterKeydown)
|
41
|
+
return val.substring(0, text.selectionEnd);
|
42
|
+
val = val.slice(0, -1);
|
43
|
+
host.session.replace(r, val);
|
44
|
+
return "";
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return newVal;
|
49
|
+
});
|
50
|
+
};
|
51
|
+
var Editor = require("../editor").Editor;
|
52
|
+
require("../config").defineOptions(Editor.prototype, "editor", {
|
53
|
+
spellcheck: {
|
54
|
+
set: function(val) {
|
55
|
+
var text = this.textInput.getElement();
|
56
|
+
text.spellcheck = !!val;
|
57
|
+
if (!val)
|
58
|
+
this.removeListener("nativecontextmenu", exports.contextMenuHandler);
|
59
|
+
else
|
60
|
+
this.on("nativecontextmenu", exports.contextMenuHandler);
|
61
|
+
},
|
62
|
+
value: true
|
63
|
+
}
|
64
|
+
});
|
65
|
+
|
66
|
+
});
|
67
|
+
|
@@ -0,0 +1,96 @@
|
|
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/ext/static_highlight', ['require', 'exports', 'module' , 'ace/edit_session', 'ace/layer/text'], function(require, exports, module) {
|
32
|
+
|
33
|
+
|
34
|
+
var EditSession = require("../edit_session").EditSession;
|
35
|
+
var TextLayer = require("../layer/text").Text;
|
36
|
+
var baseStyles = ".ace_editor {\
|
37
|
+
font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace;\
|
38
|
+
font-size: 12px;\
|
39
|
+
}\
|
40
|
+
.ace_editor .ace_gutter { \
|
41
|
+
width: 25px !important;\
|
42
|
+
display: block;\
|
43
|
+
float: left;\
|
44
|
+
text-align: right; \
|
45
|
+
padding: 0 3px 0 0; \
|
46
|
+
margin-right: 3px;\
|
47
|
+
}\
|
48
|
+
.ace_line { clear: both; }\
|
49
|
+
*.ace_gutter-cell {\
|
50
|
+
-moz-user-select: -moz-none;\
|
51
|
+
-khtml-user-select: none;\
|
52
|
+
-webkit-user-select: none;\
|
53
|
+
user-select: none;\
|
54
|
+
}";
|
55
|
+
|
56
|
+
exports.render = function(input, mode, theme, lineStart, disableGutter) {
|
57
|
+
lineStart = parseInt(lineStart || 1, 10);
|
58
|
+
|
59
|
+
var session = new EditSession("");
|
60
|
+
session.setMode(mode);
|
61
|
+
session.setUseWorker(false);
|
62
|
+
|
63
|
+
var textLayer = new TextLayer(document.createElement("div"));
|
64
|
+
textLayer.setSession(session);
|
65
|
+
textLayer.config = {
|
66
|
+
characterWidth: 10,
|
67
|
+
lineHeight: 20
|
68
|
+
};
|
69
|
+
|
70
|
+
session.setValue(input);
|
71
|
+
|
72
|
+
var stringBuilder = [];
|
73
|
+
var length = session.getLength();
|
74
|
+
|
75
|
+
for(var ix = 0; ix < length; ix++) {
|
76
|
+
stringBuilder.push("<div class='ace_line'>");
|
77
|
+
if (!disableGutter)
|
78
|
+
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
|
79
|
+
textLayer.$renderLine(stringBuilder, ix, true, false);
|
80
|
+
stringBuilder.push("</div>");
|
81
|
+
}
|
82
|
+
var html = "<div class=':cssClass'>\
|
83
|
+
<div class='ace_editor ace_scroller ace_text-layer'>\
|
84
|
+
:code\
|
85
|
+
</div>\
|
86
|
+
</div>".replace(/:cssClass/, theme.cssClass).replace(/:code/, stringBuilder.join(""));
|
87
|
+
|
88
|
+
textLayer.destroy();
|
89
|
+
|
90
|
+
return {
|
91
|
+
css: baseStyles + theme.cssText,
|
92
|
+
html: html
|
93
|
+
};
|
94
|
+
};
|
95
|
+
|
96
|
+
});
|