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,1704 @@
|
|
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/vim', ['require', 'exports', 'module' , 'ace/keyboard/vim/commands', 'ace/keyboard/vim/maps/util', 'ace/lib/useragent'], function(require, exports, module) {
|
32
|
+
|
33
|
+
|
34
|
+
var cmds = require("./vim/commands");
|
35
|
+
var coreCommands = cmds.coreCommands;
|
36
|
+
var util = require("./vim/maps/util");
|
37
|
+
var useragent = require("../lib/useragent");
|
38
|
+
|
39
|
+
var startCommands = {
|
40
|
+
"i": {
|
41
|
+
command: coreCommands.start
|
42
|
+
},
|
43
|
+
"I": {
|
44
|
+
command: coreCommands.startBeginning
|
45
|
+
},
|
46
|
+
"a": {
|
47
|
+
command: coreCommands.append
|
48
|
+
},
|
49
|
+
"A": {
|
50
|
+
command: coreCommands.appendEnd
|
51
|
+
},
|
52
|
+
"ctrl-f": {
|
53
|
+
command: "gotopagedown"
|
54
|
+
},
|
55
|
+
"ctrl-b": {
|
56
|
+
command: "gotopageup"
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
exports.handler = {
|
61
|
+
handleMacRepeat: function(data, hashId, key) {
|
62
|
+
if (hashId == -1) {
|
63
|
+
data.inputChar = key;
|
64
|
+
data.lastEvent = "input";
|
65
|
+
} else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
|
66
|
+
if (data.lastEvent == "input") {
|
67
|
+
data.lastEvent = "input1";
|
68
|
+
} else if (data.lastEvent == "input1") {
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
} else {
|
72
|
+
data.$lastHash = hashId;
|
73
|
+
data.$lastKey = key;
|
74
|
+
data.lastEvent = "keypress";
|
75
|
+
}
|
76
|
+
},
|
77
|
+
|
78
|
+
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
79
|
+
if (hashId != 0 && (key == "" || key == "\x00"))
|
80
|
+
return null;
|
81
|
+
|
82
|
+
if (hashId == 1)
|
83
|
+
key = "ctrl-" + key;
|
84
|
+
|
85
|
+
if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
|
86
|
+
return {command: coreCommands.stop};
|
87
|
+
} else if (data.state == "start") {
|
88
|
+
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
|
89
|
+
hashId = -1;
|
90
|
+
key = data.inputChar;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) {
|
94
|
+
if (cmds.inputBuffer.idle && startCommands[key])
|
95
|
+
return startCommands[key];
|
96
|
+
return {
|
97
|
+
command: {
|
98
|
+
exec: function(editor) {
|
99
|
+
return cmds.inputBuffer.push(editor, key);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
};
|
103
|
+
} // if no modifier || shift: wait for input.
|
104
|
+
else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
|
105
|
+
return {command: "null", passEvent: true};
|
106
|
+
} else if (key == "esc" && hashId == 0) {
|
107
|
+
return {command: coreCommands.stop};
|
108
|
+
}
|
109
|
+
} else {
|
110
|
+
if (key == "ctrl-w") {
|
111
|
+
return {command: "removewordleft"};
|
112
|
+
}
|
113
|
+
}
|
114
|
+
},
|
115
|
+
|
116
|
+
attach: function(editor) {
|
117
|
+
editor.on("click", exports.onCursorMove);
|
118
|
+
if (util.currentMode !== "insert")
|
119
|
+
cmds.coreCommands.stop.exec(editor);
|
120
|
+
editor.$vimModeHandler = this;
|
121
|
+
},
|
122
|
+
|
123
|
+
detach: function(editor) {
|
124
|
+
editor.removeListener("click", exports.onCursorMove);
|
125
|
+
util.noMode(editor);
|
126
|
+
util.currentMode = "normal";
|
127
|
+
},
|
128
|
+
|
129
|
+
actions: cmds.actions,
|
130
|
+
getStatusText: function() {
|
131
|
+
if (util.currentMode == "insert")
|
132
|
+
return "INSERT";
|
133
|
+
if (util.onVisualMode)
|
134
|
+
return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status;
|
135
|
+
return cmds.inputBuffer.status;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
|
140
|
+
exports.onCursorMove = function(e) {
|
141
|
+
cmds.onCursorMove(e.editor, e);
|
142
|
+
exports.onCursorMove.scheduled = false;
|
143
|
+
};
|
144
|
+
|
145
|
+
});
|
146
|
+
|
147
|
+
define('ace/keyboard/vim/commands', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/maps/motions', 'ace/keyboard/vim/maps/operators', 'ace/keyboard/vim/maps/aliases', 'ace/keyboard/vim/registers'], function(require, exports, module) {
|
148
|
+
|
149
|
+
"never use strict";
|
150
|
+
|
151
|
+
var lang = require("../../lib/lang");
|
152
|
+
var util = require("./maps/util");
|
153
|
+
var motions = require("./maps/motions");
|
154
|
+
var operators = require("./maps/operators");
|
155
|
+
var alias = require("./maps/aliases");
|
156
|
+
var registers = require("./registers");
|
157
|
+
|
158
|
+
var NUMBER = 1;
|
159
|
+
var OPERATOR = 2;
|
160
|
+
var MOTION = 3;
|
161
|
+
var ACTION = 4;
|
162
|
+
var HMARGIN = 8; // Minimum amount of line separation between margins;
|
163
|
+
|
164
|
+
var repeat = function repeat(fn, count, args) {
|
165
|
+
while (0 < count--)
|
166
|
+
fn.apply(this, args);
|
167
|
+
};
|
168
|
+
|
169
|
+
var ensureScrollMargin = function(editor) {
|
170
|
+
var renderer = editor.renderer;
|
171
|
+
var pos = renderer.$cursorLayer.getPixelPosition();
|
172
|
+
|
173
|
+
var top = pos.top;
|
174
|
+
|
175
|
+
var margin = HMARGIN * renderer.layerConfig.lineHeight;
|
176
|
+
if (2 * margin > renderer.$size.scrollerHeight)
|
177
|
+
margin = renderer.$size.scrollerHeight / 2;
|
178
|
+
|
179
|
+
if (renderer.scrollTop > top - margin) {
|
180
|
+
renderer.session.setScrollTop(top - margin);
|
181
|
+
}
|
182
|
+
|
183
|
+
if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
|
184
|
+
renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
|
185
|
+
}
|
186
|
+
};
|
187
|
+
|
188
|
+
var actions = exports.actions = {
|
189
|
+
"z": {
|
190
|
+
param: true,
|
191
|
+
fn: function(editor, range, count, param) {
|
192
|
+
switch (param) {
|
193
|
+
case "z":
|
194
|
+
editor.renderer.alignCursor(null, 0.5);
|
195
|
+
break;
|
196
|
+
case "t":
|
197
|
+
editor.renderer.alignCursor(null, 0);
|
198
|
+
break;
|
199
|
+
case "b":
|
200
|
+
editor.renderer.alignCursor(null, 1);
|
201
|
+
break;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
},
|
205
|
+
"r": {
|
206
|
+
param: true,
|
207
|
+
fn: function(editor, range, count, param) {
|
208
|
+
if (param && param.length) {
|
209
|
+
if (param.length > 1)
|
210
|
+
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
|
211
|
+
repeat(function() { editor.insert(param); }, count || 1);
|
212
|
+
editor.navigateLeft();
|
213
|
+
}
|
214
|
+
}
|
215
|
+
},
|
216
|
+
"R": {
|
217
|
+
fn: function(editor, range, count, param) {
|
218
|
+
util.insertMode(editor);
|
219
|
+
editor.setOverwrite(true);
|
220
|
+
}
|
221
|
+
},
|
222
|
+
"~": {
|
223
|
+
fn: function(editor, range, count) {
|
224
|
+
repeat(function() {
|
225
|
+
var range = editor.selection.getRange();
|
226
|
+
if (range.isEmpty())
|
227
|
+
range.end.column++;
|
228
|
+
var text = editor.session.getTextRange(range);
|
229
|
+
var toggled = text.toUpperCase();
|
230
|
+
if (toggled == text)
|
231
|
+
editor.navigateRight();
|
232
|
+
else
|
233
|
+
editor.session.replace(range, toggled);
|
234
|
+
}, count || 1);
|
235
|
+
}
|
236
|
+
},
|
237
|
+
"*": {
|
238
|
+
fn: function(editor, range, count, param) {
|
239
|
+
editor.selection.selectWord();
|
240
|
+
editor.findNext();
|
241
|
+
ensureScrollMargin(editor);
|
242
|
+
var r = editor.selection.getRange();
|
243
|
+
editor.selection.setSelectionRange(r, true);
|
244
|
+
}
|
245
|
+
},
|
246
|
+
"#": {
|
247
|
+
fn: function(editor, range, count, param) {
|
248
|
+
editor.selection.selectWord();
|
249
|
+
editor.findPrevious();
|
250
|
+
ensureScrollMargin(editor);
|
251
|
+
var r = editor.selection.getRange();
|
252
|
+
editor.selection.setSelectionRange(r, true);
|
253
|
+
}
|
254
|
+
},
|
255
|
+
"m": {
|
256
|
+
param: true,
|
257
|
+
fn: function(editor, range, count, param) {
|
258
|
+
var s = editor.session;
|
259
|
+
var markers = s.vimMarkers || (s.vimMarkers = {});
|
260
|
+
var c = editor.getCursorPosition();
|
261
|
+
if (!markers[param]) {
|
262
|
+
markers[param] = editor.session.doc.createAnchor(c);
|
263
|
+
}
|
264
|
+
markers[param].setPosition(c.row, c.column, true);
|
265
|
+
}
|
266
|
+
},
|
267
|
+
"n": {
|
268
|
+
fn: function(editor, range, count, param) {
|
269
|
+
var options = editor.getLastSearchOptions();
|
270
|
+
options.backwards = false;
|
271
|
+
|
272
|
+
editor.selection.moveCursorRight();
|
273
|
+
editor.selection.clearSelection();
|
274
|
+
editor.findNext(options);
|
275
|
+
|
276
|
+
ensureScrollMargin(editor);
|
277
|
+
var r = editor.selection.getRange();
|
278
|
+
r.end.row = r.start.row;
|
279
|
+
r.end.column = r.start.column;
|
280
|
+
editor.selection.setSelectionRange(r, true);
|
281
|
+
}
|
282
|
+
},
|
283
|
+
"N": {
|
284
|
+
fn: function(editor, range, count, param) {
|
285
|
+
var options = editor.getLastSearchOptions();
|
286
|
+
options.backwards = true;
|
287
|
+
|
288
|
+
editor.findPrevious(options);
|
289
|
+
ensureScrollMargin(editor);
|
290
|
+
var r = editor.selection.getRange();
|
291
|
+
r.end.row = r.start.row;
|
292
|
+
r.end.column = r.start.column;
|
293
|
+
editor.selection.setSelectionRange(r, true);
|
294
|
+
}
|
295
|
+
},
|
296
|
+
"v": {
|
297
|
+
fn: function(editor, range, count, param) {
|
298
|
+
editor.selection.selectRight();
|
299
|
+
util.visualMode(editor, false);
|
300
|
+
},
|
301
|
+
acceptsMotion: true
|
302
|
+
},
|
303
|
+
"V": {
|
304
|
+
fn: function(editor, range, count, param) {
|
305
|
+
var row = editor.getCursorPosition().row;
|
306
|
+
editor.selection.clearSelection();
|
307
|
+
editor.selection.moveCursorTo(row, 0);
|
308
|
+
editor.selection.selectLineEnd();
|
309
|
+
editor.selection.visualLineStart = row;
|
310
|
+
|
311
|
+
util.visualMode(editor, true);
|
312
|
+
},
|
313
|
+
acceptsMotion: true
|
314
|
+
},
|
315
|
+
"Y": {
|
316
|
+
fn: function(editor, range, count, param) {
|
317
|
+
util.copyLine(editor);
|
318
|
+
}
|
319
|
+
},
|
320
|
+
"p": {
|
321
|
+
fn: function(editor, range, count, param) {
|
322
|
+
var defaultReg = registers._default;
|
323
|
+
|
324
|
+
editor.setOverwrite(false);
|
325
|
+
if (defaultReg.isLine) {
|
326
|
+
var pos = editor.getCursorPosition();
|
327
|
+
pos.column = editor.session.getLine(pos.row).length;
|
328
|
+
var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
|
329
|
+
editor.session.insert(pos, text);
|
330
|
+
editor.moveCursorTo(pos.row + 1, 0);
|
331
|
+
}
|
332
|
+
else {
|
333
|
+
editor.navigateRight();
|
334
|
+
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
335
|
+
editor.navigateLeft();
|
336
|
+
}
|
337
|
+
editor.setOverwrite(true);
|
338
|
+
editor.selection.clearSelection();
|
339
|
+
}
|
340
|
+
},
|
341
|
+
"P": {
|
342
|
+
fn: function(editor, range, count, param) {
|
343
|
+
var defaultReg = registers._default;
|
344
|
+
editor.setOverwrite(false);
|
345
|
+
|
346
|
+
if (defaultReg.isLine) {
|
347
|
+
var pos = editor.getCursorPosition();
|
348
|
+
pos.column = 0;
|
349
|
+
var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
|
350
|
+
editor.session.insert(pos, text);
|
351
|
+
editor.moveCursorToPosition(pos);
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
355
|
+
}
|
356
|
+
editor.setOverwrite(true);
|
357
|
+
editor.selection.clearSelection();
|
358
|
+
}
|
359
|
+
},
|
360
|
+
"J": {
|
361
|
+
fn: function(editor, range, count, param) {
|
362
|
+
var session = editor.session;
|
363
|
+
range = editor.getSelectionRange();
|
364
|
+
var pos = {row: range.start.row, column: range.start.column};
|
365
|
+
count = count || range.end.row - range.start.row;
|
366
|
+
var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
|
367
|
+
|
368
|
+
range.start.column = session.getLine(pos.row).length;
|
369
|
+
range.end.column = session.getLine(maxRow).length;
|
370
|
+
range.end.row = maxRow;
|
371
|
+
|
372
|
+
var text = "";
|
373
|
+
for (var i = pos.row; i < maxRow; i++) {
|
374
|
+
var nextLine = session.getLine(i + 1);
|
375
|
+
text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
|
376
|
+
}
|
377
|
+
|
378
|
+
session.replace(range, text);
|
379
|
+
editor.moveCursorTo(pos.row, pos.column);
|
380
|
+
}
|
381
|
+
},
|
382
|
+
"u": {
|
383
|
+
fn: function(editor, range, count, param) {
|
384
|
+
count = parseInt(count || 1, 10);
|
385
|
+
for (var i = 0; i < count; i++) {
|
386
|
+
editor.undo();
|
387
|
+
}
|
388
|
+
editor.selection.clearSelection();
|
389
|
+
}
|
390
|
+
},
|
391
|
+
"ctrl-r": {
|
392
|
+
fn: function(editor, range, count, param) {
|
393
|
+
count = parseInt(count || 1, 10);
|
394
|
+
for (var i = 0; i < count; i++) {
|
395
|
+
editor.redo();
|
396
|
+
}
|
397
|
+
editor.selection.clearSelection();
|
398
|
+
}
|
399
|
+
},
|
400
|
+
":": {
|
401
|
+
fn: function(editor, range, count, param) {
|
402
|
+
var val = ":";
|
403
|
+
if (count > 1)
|
404
|
+
val = ".,.+" + count + val;
|
405
|
+
if (editor.showCommandLine)
|
406
|
+
editor.showCommandLine(val);
|
407
|
+
}
|
408
|
+
},
|
409
|
+
"/": {
|
410
|
+
fn: function(editor, range, count, param) {
|
411
|
+
if (editor.showCommandLine)
|
412
|
+
editor.showCommandLine("/");
|
413
|
+
}
|
414
|
+
},
|
415
|
+
"?": {
|
416
|
+
fn: function(editor, range, count, param) {
|
417
|
+
if (editor.showCommandLine)
|
418
|
+
editor.showCommandLine("?");
|
419
|
+
}
|
420
|
+
},
|
421
|
+
".": {
|
422
|
+
fn: function(editor, range, count, param) {
|
423
|
+
util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
|
424
|
+
var previous = inputBuffer.previous;
|
425
|
+
if (previous) // If there is a previous action
|
426
|
+
inputBuffer.exec(editor, previous.action, previous.param);
|
427
|
+
}
|
428
|
+
},
|
429
|
+
"ctrl-x": {
|
430
|
+
fn: function(editor, range, count, param) {
|
431
|
+
editor.modifyNumber(-(count || 1));
|
432
|
+
}
|
433
|
+
},
|
434
|
+
"ctrl-a": {
|
435
|
+
fn: function(editor, range, count, param) {
|
436
|
+
editor.modifyNumber(count || 1);
|
437
|
+
}
|
438
|
+
}
|
439
|
+
};
|
440
|
+
|
441
|
+
var inputBuffer = exports.inputBuffer = {
|
442
|
+
accepting: [NUMBER, OPERATOR, MOTION, ACTION],
|
443
|
+
currentCmd: null,
|
444
|
+
currentCount: "",
|
445
|
+
status: "",
|
446
|
+
operator: null,
|
447
|
+
motion: null,
|
448
|
+
|
449
|
+
lastInsertCommands: [],
|
450
|
+
|
451
|
+
push: function(editor, ch, keyId) {
|
452
|
+
var status = this.status;
|
453
|
+
var isKeyHandled = true;
|
454
|
+
this.idle = false;
|
455
|
+
var wObj = this.waitingForParam;
|
456
|
+
if (/^numpad\d+$/i.test(ch))
|
457
|
+
ch = ch.substr(6);
|
458
|
+
|
459
|
+
if (wObj) {
|
460
|
+
this.exec(editor, wObj, ch);
|
461
|
+
}
|
462
|
+
else if (!(ch === "0" && !this.currentCount.length) &&
|
463
|
+
(/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
|
464
|
+
this.currentCount += ch;
|
465
|
+
this.currentCmd = NUMBER;
|
466
|
+
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
467
|
+
}
|
468
|
+
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
|
469
|
+
this.operator = {
|
470
|
+
ch: ch,
|
471
|
+
count: this.getCount()
|
472
|
+
};
|
473
|
+
this.currentCmd = OPERATOR;
|
474
|
+
this.accepting = [NUMBER, MOTION, ACTION];
|
475
|
+
this.exec(editor, { operator: this.operator });
|
476
|
+
}
|
477
|
+
else if (motions[ch] && this.isAccepting(MOTION)) {
|
478
|
+
this.currentCmd = MOTION;
|
479
|
+
|
480
|
+
var ctx = {
|
481
|
+
operator: this.operator,
|
482
|
+
motion: {
|
483
|
+
ch: ch,
|
484
|
+
count: this.getCount()
|
485
|
+
}
|
486
|
+
};
|
487
|
+
|
488
|
+
if (motions[ch].param)
|
489
|
+
this.waitForParam(ctx);
|
490
|
+
else
|
491
|
+
this.exec(editor, ctx);
|
492
|
+
}
|
493
|
+
else if (alias[ch] && this.isAccepting(MOTION)) {
|
494
|
+
alias[ch].operator.count = this.getCount();
|
495
|
+
this.exec(editor, alias[ch]);
|
496
|
+
}
|
497
|
+
else if (actions[ch] && this.isAccepting(ACTION)) {
|
498
|
+
var actionObj = {
|
499
|
+
action: {
|
500
|
+
fn: actions[ch].fn,
|
501
|
+
count: this.getCount()
|
502
|
+
}
|
503
|
+
};
|
504
|
+
|
505
|
+
if (actions[ch].param) {
|
506
|
+
this.waitForParam(actionObj);
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
this.exec(editor, actionObj);
|
510
|
+
}
|
511
|
+
|
512
|
+
if (actions[ch].acceptsMotion)
|
513
|
+
this.idle = false;
|
514
|
+
}
|
515
|
+
else if (this.operator) {
|
516
|
+
this.operator.count = this.getCount();
|
517
|
+
this.exec(editor, { operator: this.operator }, ch);
|
518
|
+
}
|
519
|
+
else {
|
520
|
+
isKeyHandled = ch.length == 1;
|
521
|
+
this.reset();
|
522
|
+
}
|
523
|
+
|
524
|
+
if (this.waitingForParam || this.motion || this.operator) {
|
525
|
+
this.status += ch;
|
526
|
+
} else if (this.currentCount) {
|
527
|
+
this.status = this.currentCount;
|
528
|
+
} else if (this.status) {
|
529
|
+
this.status = "";
|
530
|
+
}
|
531
|
+
if (this.status != status)
|
532
|
+
editor._emit("changeStatus");
|
533
|
+
return isKeyHandled;
|
534
|
+
},
|
535
|
+
|
536
|
+
waitForParam: function(cmd) {
|
537
|
+
this.waitingForParam = cmd;
|
538
|
+
},
|
539
|
+
|
540
|
+
getCount: function() {
|
541
|
+
var count = this.currentCount;
|
542
|
+
this.currentCount = "";
|
543
|
+
return count && parseInt(count, 10);
|
544
|
+
},
|
545
|
+
|
546
|
+
exec: function(editor, action, param) {
|
547
|
+
var m = action.motion;
|
548
|
+
var o = action.operator;
|
549
|
+
var a = action.action;
|
550
|
+
|
551
|
+
if (!param)
|
552
|
+
param = action.param;
|
553
|
+
|
554
|
+
if (o) {
|
555
|
+
this.previous = {
|
556
|
+
action: action,
|
557
|
+
param: param
|
558
|
+
};
|
559
|
+
}
|
560
|
+
|
561
|
+
if (o && !editor.selection.isEmpty()) {
|
562
|
+
if (operators[o.ch].selFn) {
|
563
|
+
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
564
|
+
this.reset();
|
565
|
+
}
|
566
|
+
return;
|
567
|
+
}
|
568
|
+
else if (!m && !a && o && param) {
|
569
|
+
operators[o.ch].fn(editor, null, o.count, param);
|
570
|
+
this.reset();
|
571
|
+
}
|
572
|
+
else if (m) {
|
573
|
+
var run = function(fn) {
|
574
|
+
if (fn && typeof fn === "function") { // There should always be a motion
|
575
|
+
if (m.count && !motionObj.handlesCount)
|
576
|
+
repeat(fn, m.count, [editor, null, m.count, param]);
|
577
|
+
else
|
578
|
+
fn(editor, null, m.count, param);
|
579
|
+
}
|
580
|
+
};
|
581
|
+
|
582
|
+
var motionObj = motions[m.ch];
|
583
|
+
var selectable = motionObj.sel;
|
584
|
+
|
585
|
+
if (!o) {
|
586
|
+
if ((util.onVisualMode || util.onVisualLineMode) && selectable)
|
587
|
+
run(motionObj.sel);
|
588
|
+
else
|
589
|
+
run(motionObj.nav);
|
590
|
+
}
|
591
|
+
else if (selectable) {
|
592
|
+
repeat(function() {
|
593
|
+
run(motionObj.sel);
|
594
|
+
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
|
595
|
+
}, o.count || 1);
|
596
|
+
}
|
597
|
+
this.reset();
|
598
|
+
}
|
599
|
+
else if (a) {
|
600
|
+
a.fn(editor, editor.getSelectionRange(), a.count, param);
|
601
|
+
this.reset();
|
602
|
+
}
|
603
|
+
handleCursorMove(editor);
|
604
|
+
},
|
605
|
+
|
606
|
+
isAccepting: function(type) {
|
607
|
+
return this.accepting.indexOf(type) !== -1;
|
608
|
+
},
|
609
|
+
|
610
|
+
reset: function() {
|
611
|
+
this.operator = null;
|
612
|
+
this.motion = null;
|
613
|
+
this.currentCount = "";
|
614
|
+
this.status = "";
|
615
|
+
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
616
|
+
this.idle = true;
|
617
|
+
this.waitingForParam = null;
|
618
|
+
}
|
619
|
+
};
|
620
|
+
|
621
|
+
function setPreviousCommand(fn) {
|
622
|
+
inputBuffer.previous = { action: { action: { fn: fn } } };
|
623
|
+
}
|
624
|
+
|
625
|
+
exports.coreCommands = {
|
626
|
+
start: {
|
627
|
+
exec: function start(editor) {
|
628
|
+
util.insertMode(editor);
|
629
|
+
setPreviousCommand(start);
|
630
|
+
}
|
631
|
+
},
|
632
|
+
startBeginning: {
|
633
|
+
exec: function startBeginning(editor) {
|
634
|
+
editor.navigateLineStart();
|
635
|
+
util.insertMode(editor);
|
636
|
+
setPreviousCommand(startBeginning);
|
637
|
+
}
|
638
|
+
},
|
639
|
+
stop: {
|
640
|
+
exec: function stop(editor) {
|
641
|
+
inputBuffer.reset();
|
642
|
+
util.onVisualMode = false;
|
643
|
+
util.onVisualLineMode = false;
|
644
|
+
inputBuffer.lastInsertCommands = util.normalMode(editor);
|
645
|
+
}
|
646
|
+
},
|
647
|
+
append: {
|
648
|
+
exec: function append(editor) {
|
649
|
+
var pos = editor.getCursorPosition();
|
650
|
+
var lineLen = editor.session.getLine(pos.row).length;
|
651
|
+
if (lineLen)
|
652
|
+
editor.navigateRight();
|
653
|
+
util.insertMode(editor);
|
654
|
+
setPreviousCommand(append);
|
655
|
+
}
|
656
|
+
},
|
657
|
+
appendEnd: {
|
658
|
+
exec: function appendEnd(editor) {
|
659
|
+
editor.navigateLineEnd();
|
660
|
+
util.insertMode(editor);
|
661
|
+
setPreviousCommand(appendEnd);
|
662
|
+
}
|
663
|
+
}
|
664
|
+
};
|
665
|
+
|
666
|
+
var handleCursorMove = exports.onCursorMove = function(editor, e) {
|
667
|
+
if (util.currentMode === 'insert' || handleCursorMove.running)
|
668
|
+
return;
|
669
|
+
else if(!editor.selection.isEmpty()) {
|
670
|
+
handleCursorMove.running = true;
|
671
|
+
if (util.onVisualLineMode) {
|
672
|
+
var originRow = editor.selection.visualLineStart;
|
673
|
+
var cursorRow = editor.getCursorPosition().row;
|
674
|
+
if(originRow <= cursorRow) {
|
675
|
+
var endLine = editor.session.getLine(cursorRow);
|
676
|
+
editor.selection.clearSelection();
|
677
|
+
editor.selection.moveCursorTo(originRow, 0);
|
678
|
+
editor.selection.selectTo(cursorRow, endLine.length);
|
679
|
+
} else {
|
680
|
+
var endLine = editor.session.getLine(originRow);
|
681
|
+
editor.selection.clearSelection();
|
682
|
+
editor.selection.moveCursorTo(originRow, endLine.length);
|
683
|
+
editor.selection.selectTo(cursorRow, 0);
|
684
|
+
}
|
685
|
+
}
|
686
|
+
handleCursorMove.running = false;
|
687
|
+
return;
|
688
|
+
}
|
689
|
+
else {
|
690
|
+
if (e && (util.onVisualLineMode || util.onVisualMode)) {
|
691
|
+
editor.selection.clearSelection();
|
692
|
+
util.normalMode(editor);
|
693
|
+
}
|
694
|
+
|
695
|
+
handleCursorMove.running = true;
|
696
|
+
var pos = editor.getCursorPosition();
|
697
|
+
var lineLen = editor.session.getLine(pos.row).length;
|
698
|
+
|
699
|
+
if (lineLen && pos.column === lineLen)
|
700
|
+
editor.navigateLeft();
|
701
|
+
handleCursorMove.running = false;
|
702
|
+
}
|
703
|
+
};
|
704
|
+
});
|
705
|
+
define('ace/keyboard/vim/maps/util', ['require', 'exports', 'module' , 'ace/keyboard/vim/registers', 'ace/lib/dom'], function(require, exports, module) {
|
706
|
+
var registers = require("../registers");
|
707
|
+
|
708
|
+
var dom = require("../../../lib/dom");
|
709
|
+
dom.importCssString('.insert-mode .ace_cursor{\
|
710
|
+
border-left: 2px solid #333333;\
|
711
|
+
}\
|
712
|
+
.ace_dark.insert-mode .ace_cursor{\
|
713
|
+
border-left: 2px solid #eeeeee;\
|
714
|
+
}\
|
715
|
+
.normal-mode .ace_cursor{\
|
716
|
+
border: 0!important;\
|
717
|
+
background-color: red;\
|
718
|
+
opacity: 0.5;\
|
719
|
+
}', 'vimMode');
|
720
|
+
|
721
|
+
module.exports = {
|
722
|
+
onVisualMode: false,
|
723
|
+
onVisualLineMode: false,
|
724
|
+
currentMode: 'normal',
|
725
|
+
noMode: function(editor) {
|
726
|
+
editor.unsetStyle('insert-mode');
|
727
|
+
editor.unsetStyle('normal-mode');
|
728
|
+
if (editor.commands.recording)
|
729
|
+
editor.commands.toggleRecording(editor);
|
730
|
+
editor.setOverwrite(false);
|
731
|
+
},
|
732
|
+
insertMode: function(editor) {
|
733
|
+
this.currentMode = 'insert';
|
734
|
+
editor.setStyle('insert-mode');
|
735
|
+
editor.unsetStyle('normal-mode');
|
736
|
+
|
737
|
+
editor.setOverwrite(false);
|
738
|
+
editor.keyBinding.$data.buffer = "";
|
739
|
+
editor.keyBinding.$data.state = "insertMode";
|
740
|
+
this.onVisualMode = false;
|
741
|
+
this.onVisualLineMode = false;
|
742
|
+
if(this.onInsertReplaySequence) {
|
743
|
+
editor.commands.macro = this.onInsertReplaySequence;
|
744
|
+
editor.commands.replay(editor);
|
745
|
+
this.onInsertReplaySequence = null;
|
746
|
+
this.normalMode(editor);
|
747
|
+
} else {
|
748
|
+
editor._emit("changeStatus");
|
749
|
+
if(!editor.commands.recording)
|
750
|
+
editor.commands.toggleRecording(editor);
|
751
|
+
}
|
752
|
+
},
|
753
|
+
normalMode: function(editor) {
|
754
|
+
this.currentMode = 'normal';
|
755
|
+
|
756
|
+
editor.unsetStyle('insert-mode');
|
757
|
+
editor.setStyle('normal-mode');
|
758
|
+
editor.clearSelection();
|
759
|
+
|
760
|
+
var pos;
|
761
|
+
if (!editor.getOverwrite()) {
|
762
|
+
pos = editor.getCursorPosition();
|
763
|
+
if (pos.column > 0)
|
764
|
+
editor.navigateLeft();
|
765
|
+
}
|
766
|
+
|
767
|
+
editor.setOverwrite(true);
|
768
|
+
editor.keyBinding.$data.buffer = "";
|
769
|
+
editor.keyBinding.$data.state = "start";
|
770
|
+
this.onVisualMode = false;
|
771
|
+
this.onVisualLineMode = false;
|
772
|
+
editor._emit("changeStatus");
|
773
|
+
if (editor.commands.recording) {
|
774
|
+
editor.commands.toggleRecording(editor);
|
775
|
+
return editor.commands.macro;
|
776
|
+
}
|
777
|
+
else {
|
778
|
+
return [];
|
779
|
+
}
|
780
|
+
},
|
781
|
+
visualMode: function(editor, lineMode) {
|
782
|
+
if (
|
783
|
+
(this.onVisualLineMode && lineMode)
|
784
|
+
|| (this.onVisualMode && !lineMode)
|
785
|
+
) {
|
786
|
+
this.normalMode(editor);
|
787
|
+
return;
|
788
|
+
}
|
789
|
+
|
790
|
+
editor.setStyle('insert-mode');
|
791
|
+
editor.unsetStyle('normal-mode');
|
792
|
+
|
793
|
+
editor._emit("changeStatus");
|
794
|
+
if (lineMode) {
|
795
|
+
this.onVisualLineMode = true;
|
796
|
+
} else {
|
797
|
+
this.onVisualMode = true;
|
798
|
+
this.onVisualLineMode = false;
|
799
|
+
}
|
800
|
+
},
|
801
|
+
getRightNthChar: function(editor, cursor, ch, n) {
|
802
|
+
var line = editor.getSession().getLine(cursor.row);
|
803
|
+
var matches = line.substr(cursor.column + 1).split(ch);
|
804
|
+
|
805
|
+
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
|
806
|
+
},
|
807
|
+
getLeftNthChar: function(editor, cursor, ch, n) {
|
808
|
+
var line = editor.getSession().getLine(cursor.row);
|
809
|
+
var matches = line.substr(0, cursor.column).split(ch);
|
810
|
+
|
811
|
+
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
|
812
|
+
},
|
813
|
+
toRealChar: function(ch) {
|
814
|
+
if (ch.length === 1)
|
815
|
+
return ch;
|
816
|
+
|
817
|
+
if (/^shift-./.test(ch))
|
818
|
+
return ch[ch.length - 1].toUpperCase();
|
819
|
+
else
|
820
|
+
return "";
|
821
|
+
},
|
822
|
+
copyLine: function(editor) {
|
823
|
+
var pos = editor.getCursorPosition();
|
824
|
+
editor.selection.clearSelection();
|
825
|
+
editor.moveCursorTo(pos.row, pos.column);
|
826
|
+
editor.selection.selectLine();
|
827
|
+
registers._default.isLine = true;
|
828
|
+
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
829
|
+
editor.selection.clearSelection();
|
830
|
+
editor.moveCursorTo(pos.row, pos.column);
|
831
|
+
}
|
832
|
+
};
|
833
|
+
});
|
834
|
+
|
835
|
+
define('ace/keyboard/vim/registers', ['require', 'exports', 'module' ], function(require, exports, module) {
|
836
|
+
|
837
|
+
"never use strict";
|
838
|
+
|
839
|
+
module.exports = {
|
840
|
+
_default: {
|
841
|
+
text: "",
|
842
|
+
isLine: false
|
843
|
+
}
|
844
|
+
};
|
845
|
+
|
846
|
+
});
|
847
|
+
|
848
|
+
|
849
|
+
define('ace/keyboard/vim/maps/motions', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/search', 'ace/range'], function(require, exports, module) {
|
850
|
+
|
851
|
+
|
852
|
+
var util = require("./util");
|
853
|
+
|
854
|
+
var keepScrollPosition = function(editor, fn) {
|
855
|
+
var scrollTopRow = editor.renderer.getScrollTopRow();
|
856
|
+
var initialRow = editor.getCursorPosition().row;
|
857
|
+
var diff = initialRow - scrollTopRow;
|
858
|
+
fn && fn.call(editor);
|
859
|
+
editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
|
860
|
+
};
|
861
|
+
|
862
|
+
function Motion(m) {
|
863
|
+
if (typeof m == "function") {
|
864
|
+
var getPos = m;
|
865
|
+
m = this;
|
866
|
+
} else {
|
867
|
+
var getPos = m.getPos;
|
868
|
+
}
|
869
|
+
m.nav = function(editor, range, count, param) {
|
870
|
+
var a = getPos(editor, range, count, param, false);
|
871
|
+
if (!a)
|
872
|
+
return;
|
873
|
+
editor.clearSelection();
|
874
|
+
editor.moveCursorTo(a.row, a.column);
|
875
|
+
};
|
876
|
+
m.sel = function(editor, range, count, param) {
|
877
|
+
var a = getPos(editor, range, count, param, true);
|
878
|
+
if (!a)
|
879
|
+
return;
|
880
|
+
editor.selection.selectTo(a.row, a.column);
|
881
|
+
};
|
882
|
+
return m;
|
883
|
+
}
|
884
|
+
|
885
|
+
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
886
|
+
var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
887
|
+
var whiteRe = /\s/;
|
888
|
+
var StringStream = function(editor, cursor) {
|
889
|
+
var sel = editor.selection;
|
890
|
+
this.range = sel.getRange();
|
891
|
+
cursor = cursor || sel.selectionLead;
|
892
|
+
this.row = cursor.row;
|
893
|
+
this.col = cursor.column;
|
894
|
+
var line = editor.session.getLine(this.row);
|
895
|
+
var maxRow = editor.session.getLength();
|
896
|
+
this.ch = line[this.col] || '\n';
|
897
|
+
this.skippedLines = 0;
|
898
|
+
|
899
|
+
this.next = function() {
|
900
|
+
this.ch = line[++this.col] || this.handleNewLine(1);
|
901
|
+
return this.ch;
|
902
|
+
};
|
903
|
+
this.prev = function() {
|
904
|
+
this.ch = line[--this.col] || this.handleNewLine(-1);
|
905
|
+
return this.ch;
|
906
|
+
};
|
907
|
+
this.peek = function(dir) {
|
908
|
+
var ch = line[this.col + dir];
|
909
|
+
if (ch)
|
910
|
+
return ch;
|
911
|
+
if (dir == -1)
|
912
|
+
return '\n';
|
913
|
+
if (this.col == line.length - 1)
|
914
|
+
return '\n';
|
915
|
+
return editor.session.getLine(this.row + 1)[0] || '\n';
|
916
|
+
};
|
917
|
+
|
918
|
+
this.handleNewLine = function(dir) {
|
919
|
+
if (dir == 1){
|
920
|
+
if (this.col == line.length)
|
921
|
+
return '\n';
|
922
|
+
if (this.row == maxRow - 1)
|
923
|
+
return '';
|
924
|
+
this.col = 0;
|
925
|
+
this.row ++;
|
926
|
+
line = editor.session.getLine(this.row);
|
927
|
+
this.skippedLines++;
|
928
|
+
return line[0] || '\n';
|
929
|
+
}
|
930
|
+
if (dir == -1) {
|
931
|
+
if (this.row === 0)
|
932
|
+
return '';
|
933
|
+
this.row --;
|
934
|
+
line = editor.session.getLine(this.row);
|
935
|
+
this.col = line.length;
|
936
|
+
this.skippedLines--;
|
937
|
+
return '\n';
|
938
|
+
}
|
939
|
+
};
|
940
|
+
this.debug = function() {
|
941
|
+
console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
|
942
|
+
};
|
943
|
+
};
|
944
|
+
|
945
|
+
var Search = require("../../../search").Search;
|
946
|
+
var search = new Search();
|
947
|
+
|
948
|
+
function find(editor, needle, dir) {
|
949
|
+
search.$options.needle = needle;
|
950
|
+
search.$options.backwards = dir == -1;
|
951
|
+
return search.find(editor.session);
|
952
|
+
}
|
953
|
+
|
954
|
+
var Range = require("../../../range").Range;
|
955
|
+
|
956
|
+
var LAST_SEARCH_MOTION = {};
|
957
|
+
|
958
|
+
module.exports = {
|
959
|
+
"w": new Motion(function(editor) {
|
960
|
+
var str = new StringStream(editor);
|
961
|
+
|
962
|
+
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
963
|
+
while (str.ch && wordSeparatorRe.test(str.ch))
|
964
|
+
str.next();
|
965
|
+
} else {
|
966
|
+
while (str.ch && !nonWordRe.test(str.ch))
|
967
|
+
str.next();
|
968
|
+
}
|
969
|
+
while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
|
970
|
+
str.next();
|
971
|
+
|
972
|
+
str.skippedLines == 2 && str.prev();
|
973
|
+
return {column: str.col, row: str.row};
|
974
|
+
}),
|
975
|
+
"W": new Motion(function(editor) {
|
976
|
+
var str = new StringStream(editor);
|
977
|
+
while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
|
978
|
+
str.next();
|
979
|
+
if (str.skippedLines == 2)
|
980
|
+
str.prev();
|
981
|
+
else
|
982
|
+
str.next();
|
983
|
+
|
984
|
+
return {column: str.col, row: str.row};
|
985
|
+
}),
|
986
|
+
"b": new Motion(function(editor) {
|
987
|
+
var str = new StringStream(editor);
|
988
|
+
|
989
|
+
str.prev();
|
990
|
+
while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
|
991
|
+
str.prev();
|
992
|
+
|
993
|
+
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
994
|
+
while (str.ch && wordSeparatorRe.test(str.ch))
|
995
|
+
str.prev();
|
996
|
+
} else {
|
997
|
+
while (str.ch && !nonWordRe.test(str.ch))
|
998
|
+
str.prev();
|
999
|
+
}
|
1000
|
+
str.ch && str.next();
|
1001
|
+
return {column: str.col, row: str.row};
|
1002
|
+
}),
|
1003
|
+
"B": new Motion(function(editor) {
|
1004
|
+
var str = new StringStream(editor);
|
1005
|
+
str.prev();
|
1006
|
+
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
|
1007
|
+
str.prev();
|
1008
|
+
|
1009
|
+
if (str.skippedLines == -2)
|
1010
|
+
str.next();
|
1011
|
+
|
1012
|
+
return {column: str.col, row: str.row};
|
1013
|
+
}),
|
1014
|
+
"e": new Motion(function(editor) {
|
1015
|
+
var str = new StringStream(editor);
|
1016
|
+
|
1017
|
+
str.next();
|
1018
|
+
while (str.ch && whiteRe.test(str.ch))
|
1019
|
+
str.next();
|
1020
|
+
|
1021
|
+
if (str.ch && wordSeparatorRe.test(str.ch)) {
|
1022
|
+
while (str.ch && wordSeparatorRe.test(str.ch))
|
1023
|
+
str.next();
|
1024
|
+
} else {
|
1025
|
+
while (str.ch && !nonWordRe.test(str.ch))
|
1026
|
+
str.next();
|
1027
|
+
}
|
1028
|
+
str.ch && str.prev();
|
1029
|
+
return {column: str.col, row: str.row};
|
1030
|
+
}),
|
1031
|
+
"E": new Motion(function(editor) {
|
1032
|
+
var str = new StringStream(editor);
|
1033
|
+
str.next();
|
1034
|
+
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
|
1035
|
+
str.next();
|
1036
|
+
|
1037
|
+
return {column: str.col, row: str.row};
|
1038
|
+
}),
|
1039
|
+
|
1040
|
+
"l": {
|
1041
|
+
nav: function(editor) {
|
1042
|
+
var pos = editor.getCursorPosition();
|
1043
|
+
var col = pos.column;
|
1044
|
+
var lineLen = editor.session.getLine(pos.row).length;
|
1045
|
+
if (lineLen && col !== lineLen)
|
1046
|
+
editor.navigateRight();
|
1047
|
+
},
|
1048
|
+
sel: function(editor) {
|
1049
|
+
var pos = editor.getCursorPosition();
|
1050
|
+
var col = pos.column;
|
1051
|
+
var lineLen = editor.session.getLine(pos.row).length;
|
1052
|
+
if (lineLen && col !== lineLen) //In selection mode you can select the newline
|
1053
|
+
editor.selection.selectRight();
|
1054
|
+
}
|
1055
|
+
},
|
1056
|
+
"h": {
|
1057
|
+
nav: function(editor) {
|
1058
|
+
var pos = editor.getCursorPosition();
|
1059
|
+
if (pos.column > 0)
|
1060
|
+
editor.navigateLeft();
|
1061
|
+
},
|
1062
|
+
sel: function(editor) {
|
1063
|
+
var pos = editor.getCursorPosition();
|
1064
|
+
if (pos.column > 0)
|
1065
|
+
editor.selection.selectLeft();
|
1066
|
+
}
|
1067
|
+
},
|
1068
|
+
"H": {
|
1069
|
+
nav: function(editor) {
|
1070
|
+
var row = editor.renderer.getScrollTopRow();
|
1071
|
+
editor.moveCursorTo(row);
|
1072
|
+
},
|
1073
|
+
sel: function(editor) {
|
1074
|
+
var row = editor.renderer.getScrollTopRow();
|
1075
|
+
editor.selection.selectTo(row);
|
1076
|
+
}
|
1077
|
+
},
|
1078
|
+
"M": {
|
1079
|
+
nav: function(editor) {
|
1080
|
+
var topRow = editor.renderer.getScrollTopRow();
|
1081
|
+
var bottomRow = editor.renderer.getScrollBottomRow();
|
1082
|
+
var row = topRow + ((bottomRow - topRow) / 2);
|
1083
|
+
editor.moveCursorTo(row);
|
1084
|
+
},
|
1085
|
+
sel: function(editor) {
|
1086
|
+
var topRow = editor.renderer.getScrollTopRow();
|
1087
|
+
var bottomRow = editor.renderer.getScrollBottomRow();
|
1088
|
+
var row = topRow + ((bottomRow - topRow) / 2);
|
1089
|
+
editor.selection.selectTo(row);
|
1090
|
+
}
|
1091
|
+
},
|
1092
|
+
"L": {
|
1093
|
+
nav: function(editor) {
|
1094
|
+
var row = editor.renderer.getScrollBottomRow();
|
1095
|
+
editor.moveCursorTo(row);
|
1096
|
+
},
|
1097
|
+
sel: function(editor) {
|
1098
|
+
var row = editor.renderer.getScrollBottomRow();
|
1099
|
+
editor.selection.selectTo(row);
|
1100
|
+
}
|
1101
|
+
},
|
1102
|
+
"k": {
|
1103
|
+
nav: function(editor) {
|
1104
|
+
editor.navigateUp();
|
1105
|
+
},
|
1106
|
+
sel: function(editor) {
|
1107
|
+
editor.selection.selectUp();
|
1108
|
+
}
|
1109
|
+
},
|
1110
|
+
"j": {
|
1111
|
+
nav: function(editor) {
|
1112
|
+
editor.navigateDown();
|
1113
|
+
},
|
1114
|
+
sel: function(editor) {
|
1115
|
+
editor.selection.selectDown();
|
1116
|
+
}
|
1117
|
+
},
|
1118
|
+
|
1119
|
+
"i": {
|
1120
|
+
param: true,
|
1121
|
+
sel: function(editor, range, count, param) {
|
1122
|
+
switch (param) {
|
1123
|
+
case "w":
|
1124
|
+
editor.selection.selectWord();
|
1125
|
+
break;
|
1126
|
+
case "W":
|
1127
|
+
editor.selection.selectAWord();
|
1128
|
+
break;
|
1129
|
+
case "(":
|
1130
|
+
case "{":
|
1131
|
+
case "[":
|
1132
|
+
var cursor = editor.getCursorPosition();
|
1133
|
+
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
1134
|
+
if (!end)
|
1135
|
+
return;
|
1136
|
+
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
1137
|
+
if (!start)
|
1138
|
+
return;
|
1139
|
+
start.column ++;
|
1140
|
+
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
1141
|
+
break;
|
1142
|
+
case "'":
|
1143
|
+
case '"':
|
1144
|
+
case "/":
|
1145
|
+
var end = find(editor, param, 1);
|
1146
|
+
if (!end)
|
1147
|
+
return;
|
1148
|
+
var start = find(editor, param, -1);
|
1149
|
+
if (!start)
|
1150
|
+
return;
|
1151
|
+
editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
|
1152
|
+
break;
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
},
|
1156
|
+
"a": {
|
1157
|
+
param: true,
|
1158
|
+
sel: function(editor, range, count, param) {
|
1159
|
+
switch (param) {
|
1160
|
+
case "w":
|
1161
|
+
editor.selection.selectAWord();
|
1162
|
+
break;
|
1163
|
+
case "W":
|
1164
|
+
editor.selection.selectAWord();
|
1165
|
+
break;
|
1166
|
+
case "(":
|
1167
|
+
case "{":
|
1168
|
+
case "[":
|
1169
|
+
var cursor = editor.getCursorPosition();
|
1170
|
+
var end = editor.session.$findClosingBracket(param, cursor, /paren/);
|
1171
|
+
if (!end)
|
1172
|
+
return;
|
1173
|
+
var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
|
1174
|
+
if (!start)
|
1175
|
+
return;
|
1176
|
+
end.column ++;
|
1177
|
+
editor.selection.setSelectionRange(Range.fromPoints(start, end));
|
1178
|
+
break;
|
1179
|
+
case "'":
|
1180
|
+
case "\"":
|
1181
|
+
case "/":
|
1182
|
+
var end = find(editor, param, 1);
|
1183
|
+
if (!end)
|
1184
|
+
return;
|
1185
|
+
var start = find(editor, param, -1);
|
1186
|
+
if (!start)
|
1187
|
+
return;
|
1188
|
+
end.column ++;
|
1189
|
+
editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
|
1190
|
+
break;
|
1191
|
+
}
|
1192
|
+
}
|
1193
|
+
},
|
1194
|
+
|
1195
|
+
"f": new Motion({
|
1196
|
+
param: true,
|
1197
|
+
handlesCount: true,
|
1198
|
+
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
1199
|
+
if (!isRepeat)
|
1200
|
+
LAST_SEARCH_MOTION = {ch: "f", param: param};
|
1201
|
+
var cursor = editor.getCursorPosition();
|
1202
|
+
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
1203
|
+
|
1204
|
+
if (typeof column === "number") {
|
1205
|
+
cursor.column += column + (isSel ? 2 : 1);
|
1206
|
+
return cursor;
|
1207
|
+
}
|
1208
|
+
}
|
1209
|
+
}),
|
1210
|
+
"F": new Motion({
|
1211
|
+
param: true,
|
1212
|
+
handlesCount: true,
|
1213
|
+
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
1214
|
+
if (!isRepeat)
|
1215
|
+
LAST_SEARCH_MOTION = {ch: "F", param: param};
|
1216
|
+
var cursor = editor.getCursorPosition();
|
1217
|
+
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
1218
|
+
|
1219
|
+
if (typeof column === "number") {
|
1220
|
+
cursor.column -= column + 1;
|
1221
|
+
return cursor;
|
1222
|
+
}
|
1223
|
+
}
|
1224
|
+
}),
|
1225
|
+
"t": new Motion({
|
1226
|
+
param: true,
|
1227
|
+
handlesCount: true,
|
1228
|
+
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
1229
|
+
if (!isRepeat)
|
1230
|
+
LAST_SEARCH_MOTION = {ch: "t", param: param};
|
1231
|
+
var cursor = editor.getCursorPosition();
|
1232
|
+
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
1233
|
+
|
1234
|
+
if (isRepeat && column == 0 && !(count > 1))
|
1235
|
+
var column = util.getRightNthChar(editor, cursor, param, 2);
|
1236
|
+
|
1237
|
+
if (typeof column === "number") {
|
1238
|
+
cursor.column += column + (isSel ? 1 : 0);
|
1239
|
+
return cursor;
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
}),
|
1243
|
+
"T": new Motion({
|
1244
|
+
param: true,
|
1245
|
+
handlesCount: true,
|
1246
|
+
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
1247
|
+
if (!isRepeat)
|
1248
|
+
LAST_SEARCH_MOTION = {ch: "T", param: param};
|
1249
|
+
var cursor = editor.getCursorPosition();
|
1250
|
+
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
1251
|
+
|
1252
|
+
if (isRepeat && column == 0 && !(count > 1))
|
1253
|
+
var column = util.getLeftNthChar(editor, cursor, param, 2);
|
1254
|
+
|
1255
|
+
if (typeof column === "number") {
|
1256
|
+
cursor.column -= column;
|
1257
|
+
return cursor;
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
}),
|
1261
|
+
";": new Motion({
|
1262
|
+
handlesCount: true,
|
1263
|
+
getPos: function(editor, range, count, param, isSel) {
|
1264
|
+
var ch = LAST_SEARCH_MOTION.ch;
|
1265
|
+
if (!ch)
|
1266
|
+
return;
|
1267
|
+
return module.exports[ch].getPos(
|
1268
|
+
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
1269
|
+
);
|
1270
|
+
}
|
1271
|
+
}),
|
1272
|
+
",": new Motion({
|
1273
|
+
handlesCount: true,
|
1274
|
+
getPos: function(editor, range, count, param, isSel) {
|
1275
|
+
var ch = LAST_SEARCH_MOTION.ch;
|
1276
|
+
if (!ch)
|
1277
|
+
return;
|
1278
|
+
var up = ch.toUpperCase();
|
1279
|
+
ch = ch === up ? ch.toLowerCase() : up;
|
1280
|
+
|
1281
|
+
return module.exports[ch].getPos(
|
1282
|
+
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
1283
|
+
);
|
1284
|
+
}
|
1285
|
+
}),
|
1286
|
+
|
1287
|
+
"^": {
|
1288
|
+
nav: function(editor) {
|
1289
|
+
editor.navigateLineStart();
|
1290
|
+
},
|
1291
|
+
sel: function(editor) {
|
1292
|
+
editor.selection.selectLineStart();
|
1293
|
+
}
|
1294
|
+
},
|
1295
|
+
"$": {
|
1296
|
+
nav: function(editor) {
|
1297
|
+
editor.navigateLineEnd();
|
1298
|
+
},
|
1299
|
+
sel: function(editor) {
|
1300
|
+
editor.selection.selectLineEnd();
|
1301
|
+
}
|
1302
|
+
},
|
1303
|
+
"0": new Motion(function(ed) {
|
1304
|
+
return {row: ed.selection.lead.row, column: 0};
|
1305
|
+
}),
|
1306
|
+
"G": {
|
1307
|
+
nav: function(editor, range, count, param) {
|
1308
|
+
if (!count && count !== 0) { // Stupid JS
|
1309
|
+
count = editor.session.getLength();
|
1310
|
+
}
|
1311
|
+
editor.gotoLine(count);
|
1312
|
+
},
|
1313
|
+
sel: function(editor, range, count, param) {
|
1314
|
+
if (!count && count !== 0) { // Stupid JS
|
1315
|
+
count = editor.session.getLength();
|
1316
|
+
}
|
1317
|
+
editor.selection.selectTo(count, 0);
|
1318
|
+
}
|
1319
|
+
},
|
1320
|
+
"g": {
|
1321
|
+
param: true,
|
1322
|
+
nav: function(editor, range, count, param) {
|
1323
|
+
switch(param) {
|
1324
|
+
case "m":
|
1325
|
+
console.log("Middle line");
|
1326
|
+
break;
|
1327
|
+
case "e":
|
1328
|
+
console.log("End of prev word");
|
1329
|
+
break;
|
1330
|
+
case "g":
|
1331
|
+
editor.gotoLine(count || 0);
|
1332
|
+
case "u":
|
1333
|
+
editor.gotoLine(count || 0);
|
1334
|
+
case "U":
|
1335
|
+
editor.gotoLine(count || 0);
|
1336
|
+
}
|
1337
|
+
},
|
1338
|
+
sel: function(editor, range, count, param) {
|
1339
|
+
switch(param) {
|
1340
|
+
case "m":
|
1341
|
+
console.log("Middle line");
|
1342
|
+
break;
|
1343
|
+
case "e":
|
1344
|
+
console.log("End of prev word");
|
1345
|
+
break;
|
1346
|
+
case "g":
|
1347
|
+
editor.selection.selectTo(count || 0, 0);
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
},
|
1351
|
+
"o": {
|
1352
|
+
nav: function(editor, range, count, param) {
|
1353
|
+
count = count || 1;
|
1354
|
+
var content = "";
|
1355
|
+
while (0 < count--)
|
1356
|
+
content += "\n";
|
1357
|
+
|
1358
|
+
if (content.length) {
|
1359
|
+
editor.navigateLineEnd()
|
1360
|
+
editor.insert(content);
|
1361
|
+
util.insertMode(editor);
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
},
|
1365
|
+
"O": {
|
1366
|
+
nav: function(editor, range, count, param) {
|
1367
|
+
var row = editor.getCursorPosition().row;
|
1368
|
+
count = count || 1;
|
1369
|
+
var content = "";
|
1370
|
+
while (0 < count--)
|
1371
|
+
content += "\n";
|
1372
|
+
|
1373
|
+
if (content.length) {
|
1374
|
+
if(row > 0) {
|
1375
|
+
editor.navigateUp();
|
1376
|
+
editor.navigateLineEnd()
|
1377
|
+
editor.insert(content);
|
1378
|
+
} else {
|
1379
|
+
editor.session.insert({row: 0, column: 0}, content);
|
1380
|
+
editor.navigateUp();
|
1381
|
+
}
|
1382
|
+
util.insertMode(editor);
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
},
|
1386
|
+
"%": new Motion(function(editor){
|
1387
|
+
var brRe = /[\[\]{}()]/g;
|
1388
|
+
var cursor = editor.getCursorPosition();
|
1389
|
+
var ch = editor.session.getLine(cursor.row)[cursor.column];
|
1390
|
+
if (!brRe.test(ch)) {
|
1391
|
+
var range = find(editor, brRe);
|
1392
|
+
if (!range)
|
1393
|
+
return;
|
1394
|
+
cursor = range.start;
|
1395
|
+
}
|
1396
|
+
var match = editor.session.findMatchingBracket({
|
1397
|
+
row: cursor.row,
|
1398
|
+
column: cursor.column + 1
|
1399
|
+
});
|
1400
|
+
|
1401
|
+
return match;
|
1402
|
+
}),
|
1403
|
+
"{": new Motion(function(ed) {
|
1404
|
+
var session = ed.session;
|
1405
|
+
var row = session.selection.lead.row;
|
1406
|
+
while(row > 0 && !/\S/.test(session.getLine(row)))
|
1407
|
+
row--;
|
1408
|
+
while(/\S/.test(session.getLine(row)))
|
1409
|
+
row--;
|
1410
|
+
return {column: 0, row: row};
|
1411
|
+
}),
|
1412
|
+
"}": new Motion(function(ed) {
|
1413
|
+
var session = ed.session;
|
1414
|
+
var l = session.getLength();
|
1415
|
+
var row = session.selection.lead.row;
|
1416
|
+
while(row < l && !/\S/.test(session.getLine(row)))
|
1417
|
+
row++;
|
1418
|
+
while(/\S/.test(session.getLine(row)))
|
1419
|
+
row++;
|
1420
|
+
return {column: 0, row: row};
|
1421
|
+
}),
|
1422
|
+
"ctrl-d": {
|
1423
|
+
nav: function(editor, range, count, param) {
|
1424
|
+
editor.selection.clearSelection();
|
1425
|
+
keepScrollPosition(editor, editor.gotoPageDown);
|
1426
|
+
},
|
1427
|
+
sel: function(editor, range, count, param) {
|
1428
|
+
keepScrollPosition(editor, editor.selectPageDown);
|
1429
|
+
}
|
1430
|
+
},
|
1431
|
+
"ctrl-u": {
|
1432
|
+
nav: function(editor, range, count, param) {
|
1433
|
+
editor.selection.clearSelection();
|
1434
|
+
keepScrollPosition(editor, editor.gotoPageUp);
|
1435
|
+
},
|
1436
|
+
sel: function(editor, range, count, param) {
|
1437
|
+
keepScrollPosition(editor, editor.selectPageUp);
|
1438
|
+
}
|
1439
|
+
},
|
1440
|
+
"`": new Motion({
|
1441
|
+
param: true,
|
1442
|
+
handlesCount: true,
|
1443
|
+
getPos: function(editor, range, count, param, isSel) {
|
1444
|
+
var s = editor.session;
|
1445
|
+
var marker = s.vimMarkers && s.vimMarkers[param];
|
1446
|
+
if (marker) {
|
1447
|
+
return marker.getPosition();
|
1448
|
+
}
|
1449
|
+
}
|
1450
|
+
}),
|
1451
|
+
"'": new Motion({
|
1452
|
+
param: true,
|
1453
|
+
handlesCount: true,
|
1454
|
+
getPos: function(editor, range, count, param, isSel) {
|
1455
|
+
var s = editor.session;
|
1456
|
+
var marker = s.vimMarkers && s.vimMarkers[param];
|
1457
|
+
if (marker) {
|
1458
|
+
var pos = marker.getPosition();
|
1459
|
+
var line = editor.session.getLine(pos.row);
|
1460
|
+
pos.column = line.search(/\S/);
|
1461
|
+
if (pos.column == -1)
|
1462
|
+
pos.column = line.length;
|
1463
|
+
return pos;
|
1464
|
+
}
|
1465
|
+
}
|
1466
|
+
})
|
1467
|
+
};
|
1468
|
+
|
1469
|
+
module.exports.backspace = module.exports.left = module.exports.h;
|
1470
|
+
module.exports.space = module.exports.return = module.exports.right = module.exports.l;
|
1471
|
+
module.exports.up = module.exports.k;
|
1472
|
+
module.exports.down = module.exports.j;
|
1473
|
+
module.exports.pagedown = module.exports["ctrl-d"];
|
1474
|
+
module.exports.pageup = module.exports["ctrl-u"];
|
1475
|
+
|
1476
|
+
});
|
1477
|
+
|
1478
|
+
define('ace/keyboard/vim/maps/operators', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/registers'], function(require, exports, module) {
|
1479
|
+
|
1480
|
+
|
1481
|
+
|
1482
|
+
var util = require("./util");
|
1483
|
+
var registers = require("../registers");
|
1484
|
+
|
1485
|
+
module.exports = {
|
1486
|
+
"d": {
|
1487
|
+
selFn: function(editor, range, count, param) {
|
1488
|
+
registers._default.text = editor.getCopyText();
|
1489
|
+
registers._default.isLine = util.onVisualLineMode;
|
1490
|
+
if(util.onVisualLineMode)
|
1491
|
+
editor.removeLines();
|
1492
|
+
else
|
1493
|
+
editor.session.remove(range);
|
1494
|
+
util.normalMode(editor);
|
1495
|
+
},
|
1496
|
+
fn: function(editor, range, count, param) {
|
1497
|
+
count = count || 1;
|
1498
|
+
switch (param) {
|
1499
|
+
case "d":
|
1500
|
+
registers._default.text = "";
|
1501
|
+
registers._default.isLine = true;
|
1502
|
+
for (var i = 0; i < count; i++) {
|
1503
|
+
editor.selection.selectLine();
|
1504
|
+
registers._default.text += editor.getCopyText();
|
1505
|
+
var selRange = editor.getSelectionRange();
|
1506
|
+
if (!selRange.isMultiLine()) {
|
1507
|
+
var row = selRange.start.row - 1;
|
1508
|
+
var col = editor.session.getLine(row).length
|
1509
|
+
selRange.setStart(row, col);
|
1510
|
+
editor.session.remove(selRange);
|
1511
|
+
editor.selection.clearSelection();
|
1512
|
+
break;
|
1513
|
+
}
|
1514
|
+
editor.session.remove(selRange);
|
1515
|
+
editor.selection.clearSelection();
|
1516
|
+
}
|
1517
|
+
registers._default.text = registers._default.text.replace(/\n$/, "");
|
1518
|
+
break;
|
1519
|
+
default:
|
1520
|
+
if (range) {
|
1521
|
+
editor.selection.setSelectionRange(range);
|
1522
|
+
registers._default.text = editor.getCopyText();
|
1523
|
+
registers._default.isLine = false;
|
1524
|
+
editor.session.remove(range);
|
1525
|
+
editor.selection.clearSelection();
|
1526
|
+
}
|
1527
|
+
}
|
1528
|
+
}
|
1529
|
+
},
|
1530
|
+
"c": {
|
1531
|
+
selFn: function(editor, range, count, param) {
|
1532
|
+
editor.session.remove(range);
|
1533
|
+
util.insertMode(editor);
|
1534
|
+
},
|
1535
|
+
fn: function(editor, range, count, param) {
|
1536
|
+
count = count || 1;
|
1537
|
+
switch (param) {
|
1538
|
+
case "c":
|
1539
|
+
for (var i = 0; i < count; i++) {
|
1540
|
+
editor.removeLines();
|
1541
|
+
util.insertMode(editor);
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
break;
|
1545
|
+
default:
|
1546
|
+
if (range) {
|
1547
|
+
editor.session.remove(range);
|
1548
|
+
util.insertMode(editor);
|
1549
|
+
}
|
1550
|
+
}
|
1551
|
+
}
|
1552
|
+
},
|
1553
|
+
"y": {
|
1554
|
+
selFn: function(editor, range, count, param) {
|
1555
|
+
registers._default.text = editor.getCopyText();
|
1556
|
+
registers._default.isLine = util.onVisualLineMode;
|
1557
|
+
editor.selection.clearSelection();
|
1558
|
+
util.normalMode(editor);
|
1559
|
+
},
|
1560
|
+
fn: function(editor, range, count, param) {
|
1561
|
+
count = count || 1;
|
1562
|
+
switch (param) {
|
1563
|
+
case "y":
|
1564
|
+
var pos = editor.getCursorPosition();
|
1565
|
+
editor.selection.selectLine();
|
1566
|
+
for (var i = 0; i < count - 1; i++) {
|
1567
|
+
editor.selection.moveCursorDown();
|
1568
|
+
}
|
1569
|
+
registers._default.text = editor.getCopyText().replace(/\n$/, "");
|
1570
|
+
editor.selection.clearSelection();
|
1571
|
+
registers._default.isLine = true;
|
1572
|
+
editor.moveCursorToPosition(pos);
|
1573
|
+
break;
|
1574
|
+
default:
|
1575
|
+
if (range) {
|
1576
|
+
var pos = editor.getCursorPosition();
|
1577
|
+
editor.selection.setSelectionRange(range);
|
1578
|
+
registers._default.text = editor.getCopyText();
|
1579
|
+
registers._default.isLine = false;
|
1580
|
+
editor.selection.clearSelection();
|
1581
|
+
editor.moveCursorTo(pos.row, pos.column);
|
1582
|
+
}
|
1583
|
+
}
|
1584
|
+
}
|
1585
|
+
},
|
1586
|
+
">": {
|
1587
|
+
selFn: function(editor, range, count, param) {
|
1588
|
+
count = count || 1;
|
1589
|
+
for (var i = 0; i < count; i++) {
|
1590
|
+
editor.indent();
|
1591
|
+
}
|
1592
|
+
util.normalMode(editor);
|
1593
|
+
},
|
1594
|
+
fn: function(editor, range, count, param) {
|
1595
|
+
count = parseInt(count || 1, 10);
|
1596
|
+
switch (param) {
|
1597
|
+
case ">":
|
1598
|
+
var pos = editor.getCursorPosition();
|
1599
|
+
editor.selection.selectLine();
|
1600
|
+
for (var i = 0; i < count - 1; i++) {
|
1601
|
+
editor.selection.moveCursorDown();
|
1602
|
+
}
|
1603
|
+
editor.indent();
|
1604
|
+
editor.selection.clearSelection();
|
1605
|
+
editor.moveCursorToPosition(pos);
|
1606
|
+
editor.navigateLineEnd();
|
1607
|
+
editor.navigateLineStart();
|
1608
|
+
break;
|
1609
|
+
}
|
1610
|
+
}
|
1611
|
+
},
|
1612
|
+
"<": {
|
1613
|
+
selFn: function(editor, range, count, param) {
|
1614
|
+
count = count || 1;
|
1615
|
+
for (var i = 0; i < count; i++) {
|
1616
|
+
editor.blockOutdent();
|
1617
|
+
}
|
1618
|
+
util.normalMode(editor);
|
1619
|
+
},
|
1620
|
+
fn: function(editor, range, count, param) {
|
1621
|
+
count = count || 1;
|
1622
|
+
switch (param) {
|
1623
|
+
case "<":
|
1624
|
+
var pos = editor.getCursorPosition();
|
1625
|
+
editor.selection.selectLine();
|
1626
|
+
for (var i = 0; i < count - 1; i++) {
|
1627
|
+
editor.selection.moveCursorDown();
|
1628
|
+
}
|
1629
|
+
editor.blockOutdent();
|
1630
|
+
editor.selection.clearSelection();
|
1631
|
+
editor.moveCursorToPosition(pos);
|
1632
|
+
editor.navigateLineEnd();
|
1633
|
+
editor.navigateLineStart();
|
1634
|
+
break;
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
}
|
1638
|
+
};
|
1639
|
+
});
|
1640
|
+
|
1641
|
+
"use strict"
|
1642
|
+
|
1643
|
+
define('ace/keyboard/vim/maps/aliases', ['require', 'exports', 'module' ], function(require, exports, module) {
|
1644
|
+
module.exports = {
|
1645
|
+
"x": {
|
1646
|
+
operator: {
|
1647
|
+
ch: "d",
|
1648
|
+
count: 1
|
1649
|
+
},
|
1650
|
+
motion: {
|
1651
|
+
ch: "l",
|
1652
|
+
count: 1
|
1653
|
+
}
|
1654
|
+
},
|
1655
|
+
"X": {
|
1656
|
+
operator: {
|
1657
|
+
ch: "d",
|
1658
|
+
count: 1
|
1659
|
+
},
|
1660
|
+
motion: {
|
1661
|
+
ch: "h",
|
1662
|
+
count: 1
|
1663
|
+
}
|
1664
|
+
},
|
1665
|
+
"D": {
|
1666
|
+
operator: {
|
1667
|
+
ch: "d",
|
1668
|
+
count: 1
|
1669
|
+
},
|
1670
|
+
motion: {
|
1671
|
+
ch: "$",
|
1672
|
+
count: 1
|
1673
|
+
}
|
1674
|
+
},
|
1675
|
+
"C": {
|
1676
|
+
operator: {
|
1677
|
+
ch: "c",
|
1678
|
+
count: 1
|
1679
|
+
},
|
1680
|
+
motion: {
|
1681
|
+
ch: "$",
|
1682
|
+
count: 1
|
1683
|
+
}
|
1684
|
+
},
|
1685
|
+
"s": {
|
1686
|
+
operator: {
|
1687
|
+
ch: "c",
|
1688
|
+
count: 1
|
1689
|
+
},
|
1690
|
+
motion: {
|
1691
|
+
ch: "l",
|
1692
|
+
count: 1
|
1693
|
+
}
|
1694
|
+
},
|
1695
|
+
"S": {
|
1696
|
+
operator: {
|
1697
|
+
ch: "c",
|
1698
|
+
count: 1
|
1699
|
+
},
|
1700
|
+
param: "c"
|
1701
|
+
}
|
1702
|
+
};
|
1703
|
+
});
|
1704
|
+
|