1
|
ace.define("ace/keyboard/sublime",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
5
|
|
6
|
function moveBySubWords(editor, direction, extend) {
|
7
|
var selection = editor.selection;
|
8
|
var row = selection.lead.row;
|
9
|
var column = selection.lead.column;
|
10
|
|
11
|
var line = editor.session.getLine(row);
|
12
|
if (!line[column + direction]) {
|
13
|
var method = (extend ? "selectWord" : "moveCursorShortWord")
|
14
|
+ (direction == 1 ? "Right" : "Left");
|
15
|
return editor.selection[method]();
|
16
|
}
|
17
|
if (direction == -1) column--;
|
18
|
while (line[column]) {
|
19
|
var type = getType(line[column]) + getType(line[column + direction]);
|
20
|
column += direction;
|
21
|
if (direction == 1) {
|
22
|
if (type == "WW" && getType(line[column + 1]) == "w")
|
23
|
break;
|
24
|
}
|
25
|
else {
|
26
|
if (type == "wW") {
|
27
|
if (getType(line[column - 1]) == "W") {
|
28
|
column -= 1;
|
29
|
break;
|
30
|
} else {
|
31
|
continue;
|
32
|
}
|
33
|
}
|
34
|
if (type == "Ww")
|
35
|
break;
|
36
|
}
|
37
|
if (/w[s_oW]|_[sWo]|o[s_wW]|s[W]|W[so]/.test(type))
|
38
|
break;
|
39
|
}
|
40
|
if (direction == -1) column++;
|
41
|
if (extend)
|
42
|
editor.selection.moveCursorTo(row, column);
|
43
|
else
|
44
|
editor.selection.moveTo(row, column);
|
45
|
|
46
|
function getType(x) {
|
47
|
if (!x) return "-";
|
48
|
if (/\s/.test(x)) return "s";
|
49
|
if (x == "_") return "_";
|
50
|
if (x.toUpperCase() == x && x.toLowerCase() != x) return "W";
|
51
|
if (x.toUpperCase() != x && x.toLowerCase() == x) return "w";
|
52
|
return "o";
|
53
|
}
|
54
|
}
|
55
|
|
56
|
exports.handler = new HashHandler();
|
57
|
|
58
|
exports.handler.addCommands([{
|
59
|
name: "find_all_under",
|
60
|
exec: function(editor) {
|
61
|
if (editor.selection.isEmpty())
|
62
|
editor.selection.selectWord();
|
63
|
editor.findAll();
|
64
|
},
|
65
|
readOnly: true
|
66
|
}, {
|
67
|
name: "find_under",
|
68
|
exec: function(editor) {
|
69
|
if (editor.selection.isEmpty())
|
70
|
editor.selection.selectWord();
|
71
|
editor.findNext();
|
72
|
},
|
73
|
readOnly: true
|
74
|
}, {
|
75
|
name: "find_under_prev",
|
76
|
exec: function(editor) {
|
77
|
if (editor.selection.isEmpty())
|
78
|
editor.selection.selectWord();
|
79
|
editor.findPrevious();
|
80
|
},
|
81
|
readOnly: true
|
82
|
}, {
|
83
|
name: "find_under_expand",
|
84
|
exec: function(editor) {
|
85
|
editor.selectMore(1, false, true);
|
86
|
},
|
87
|
scrollIntoView: "animate",
|
88
|
readOnly: true
|
89
|
}, {
|
90
|
name: "find_under_expand_skip",
|
91
|
exec: function(editor) {
|
92
|
editor.selectMore(1, true, true);
|
93
|
},
|
94
|
scrollIntoView: "animate",
|
95
|
readOnly: true
|
96
|
}, {
|
97
|
name: "delete_to_hard_bol",
|
98
|
exec: function(editor) {
|
99
|
var pos = editor.selection.getCursor();
|
100
|
editor.session.remove({
|
101
|
start: { row: pos.row, column: 0 },
|
102
|
end: pos
|
103
|
});
|
104
|
},
|
105
|
multiSelectAction: "forEach",
|
106
|
scrollIntoView: "cursor"
|
107
|
}, {
|
108
|
name: "delete_to_hard_eol",
|
109
|
exec: function(editor) {
|
110
|
var pos = editor.selection.getCursor();
|
111
|
editor.session.remove({
|
112
|
start: pos,
|
113
|
end: { row: pos.row, column: Infinity }
|
114
|
});
|
115
|
},
|
116
|
multiSelectAction: "forEach",
|
117
|
scrollIntoView: "cursor"
|
118
|
}, {
|
119
|
name: "moveToWordStartLeft",
|
120
|
exec: function(editor) {
|
121
|
editor.selection.moveCursorLongWordLeft();
|
122
|
editor.clearSelection();
|
123
|
},
|
124
|
multiSelectAction: "forEach",
|
125
|
scrollIntoView: "cursor"
|
126
|
}, {
|
127
|
name: "moveToWordEndRight",
|
128
|
exec: function(editor) {
|
129
|
editor.selection.moveCursorLongWordRight();
|
130
|
editor.clearSelection();
|
131
|
},
|
132
|
multiSelectAction: "forEach",
|
133
|
scrollIntoView: "cursor"
|
134
|
}, {
|
135
|
name: "selectToWordStartLeft",
|
136
|
exec: function(editor) {
|
137
|
var sel = editor.selection;
|
138
|
sel.$moveSelection(sel.moveCursorLongWordLeft);
|
139
|
},
|
140
|
multiSelectAction: "forEach",
|
141
|
scrollIntoView: "cursor"
|
142
|
}, {
|
143
|
name: "selectToWordEndRight",
|
144
|
exec: function(editor) {
|
145
|
var sel = editor.selection;
|
146
|
sel.$moveSelection(sel.moveCursorLongWordRight);
|
147
|
},
|
148
|
multiSelectAction: "forEach",
|
149
|
scrollIntoView: "cursor"
|
150
|
}, {
|
151
|
name: "selectSubWordRight",
|
152
|
exec: function(editor) {
|
153
|
moveBySubWords(editor, 1, true);
|
154
|
},
|
155
|
multiSelectAction: "forEach",
|
156
|
scrollIntoView: "cursor",
|
157
|
readOnly: true
|
158
|
}, {
|
159
|
name: "selectSubWordLeft",
|
160
|
exec: function(editor) {
|
161
|
moveBySubWords(editor, -1, true);
|
162
|
},
|
163
|
multiSelectAction: "forEach",
|
164
|
scrollIntoView: "cursor",
|
165
|
readOnly: true
|
166
|
}, {
|
167
|
name: "moveSubWordRight",
|
168
|
exec: function(editor) {
|
169
|
moveBySubWords(editor, 1);
|
170
|
},
|
171
|
multiSelectAction: "forEach",
|
172
|
scrollIntoView: "cursor",
|
173
|
readOnly: true
|
174
|
}, {
|
175
|
name: "moveSubWordLeft",
|
176
|
exec: function(editor) {
|
177
|
moveBySubWords(editor, -1);
|
178
|
},
|
179
|
multiSelectAction: "forEach",
|
180
|
scrollIntoView: "cursor",
|
181
|
readOnly: true
|
182
|
}]);
|
183
|
|
184
|
|
185
|
[{
|
186
|
bindKey: { mac: "cmd-k cmd-backspace|cmd-backspace", win: "ctrl-shift-backspace|ctrl-k ctrl-backspace" },
|
187
|
name: "removetolinestarthard"
|
188
|
}, {
|
189
|
bindKey: { mac: "cmd-k cmd-k|cmd-delete|ctrl-k", win: "ctrl-shift-delete|ctrl-k ctrl-k" },
|
190
|
name: "removetolineendhard"
|
191
|
}, {
|
192
|
bindKey: { mac: "cmd-shift-d", win: "ctrl-shift-d" },
|
193
|
name: "duplicateSelection"
|
194
|
}, {
|
195
|
bindKey: { mac: "cmd-l", win: "ctrl-l" },
|
196
|
name: "expandtoline"
|
197
|
},
|
198
|
{
|
199
|
bindKey: {mac: "cmd-shift-a", win: "ctrl-shift-a"},
|
200
|
name: "expandSelection",
|
201
|
args: {to: "tag"}
|
202
|
}, {
|
203
|
bindKey: {mac: "cmd-shift-j", win: "ctrl-shift-j"},
|
204
|
name: "expandSelection",
|
205
|
args: {to: "indentation"}
|
206
|
}, {
|
207
|
bindKey: {mac: "ctrl-shift-m", win: "ctrl-shift-m"},
|
208
|
name: "expandSelection",
|
209
|
args: {to: "brackets"}
|
210
|
}, {
|
211
|
bindKey: {mac: "cmd-shift-space", win: "ctrl-shift-space"},
|
212
|
name: "expandSelection",
|
213
|
args: {to: "scope"}
|
214
|
},
|
215
|
{
|
216
|
bindKey: { mac: "ctrl-cmd-g", win: "alt-f3" },
|
217
|
name: "find_all_under"
|
218
|
}, {
|
219
|
bindKey: { mac: "alt-cmd-g", win: "ctrl-f3" },
|
220
|
name: "find_under"
|
221
|
}, {
|
222
|
bindKey: { mac: "shift-alt-cmd-g", win: "ctrl-shift-f3" },
|
223
|
name: "find_under_prev"
|
224
|
}, {
|
225
|
bindKey: { mac: "cmd-g", win: "f3" },
|
226
|
name: "findnext"
|
227
|
}, {
|
228
|
bindKey: { mac: "shift-cmd-g", win: "shift-f3" },
|
229
|
name: "findprevious"
|
230
|
}, {
|
231
|
bindKey: { mac: "cmd-d", win: "ctrl-d" },
|
232
|
name: "find_under_expand"
|
233
|
}, {
|
234
|
bindKey: { mac: "cmd-k cmd-d", win: "ctrl-k ctrl-d" },
|
235
|
name: "find_under_expand_skip"
|
236
|
},
|
237
|
{
|
238
|
bindKey: { mac: "cmd-alt-[", win: "ctrl-shift-[" },
|
239
|
name: "toggleFoldWidget"
|
240
|
}, {
|
241
|
bindKey: { mac: "cmd-alt-]", win: "ctrl-shift-]" },
|
242
|
name: "unfold"
|
243
|
}, {
|
244
|
bindKey: { mac: "cmd-k cmd-0|cmd-k cmd-j", win: "ctrl-k ctrl-0|ctrl-k ctrl-j" },
|
245
|
name: "unfoldall"
|
246
|
}, {
|
247
|
bindKey: { mac: "cmd-k cmd-1", win: "ctrl-k ctrl-1" },
|
248
|
name: "foldOther",
|
249
|
args: { level: 1 }
|
250
|
},
|
251
|
{
|
252
|
bindKey: { win: "ctrl-left", mac: "alt-left" },
|
253
|
name: "moveToWordStartLeft"
|
254
|
}, {
|
255
|
bindKey: { win: "ctrl-right", mac: "alt-right" },
|
256
|
name: "moveToWordEndRight"
|
257
|
}, {
|
258
|
bindKey: { win: "ctrl-shift-left", mac: "alt-shift-left" },
|
259
|
name: "selectToWordStartLeft"
|
260
|
}, {
|
261
|
bindKey: { win: "ctrl-shift-right", mac: "alt-shift-right" },
|
262
|
name: "selectToWordEndRight"
|
263
|
},
|
264
|
{
|
265
|
bindKey: {mac: "ctrl-alt-shift-right|ctrl-shift-right", win: "alt-shift-right"},
|
266
|
name: "selectSubWordRight"
|
267
|
}, {
|
268
|
bindKey: {mac: "ctrl-alt-shift-left|ctrl-shift-left", win: "alt-shift-left"},
|
269
|
name: "selectSubWordLeft"
|
270
|
}, {
|
271
|
bindKey: {mac: "ctrl-alt-right|ctrl-right", win: "alt-right"},
|
272
|
name: "moveSubWordRight"
|
273
|
}, {
|
274
|
bindKey: {mac: "ctrl-alt-left|ctrl-left", win: "alt-left"},
|
275
|
name: "moveSubWordLeft"
|
276
|
},
|
277
|
{
|
278
|
bindKey: { mac: "ctrl-m", win: "ctrl-m" },
|
279
|
name: "jumptomatching",
|
280
|
args: { to: "brackets" }
|
281
|
},
|
282
|
{
|
283
|
bindKey: { mac: "ctrl-f6", win: "ctrl-f6" },
|
284
|
name: "goToNextError"
|
285
|
}, {
|
286
|
bindKey: { mac: "ctrl-shift-f6", win: "ctrl-shift-f6" },
|
287
|
name: "goToPreviousError"
|
288
|
},
|
289
|
|
290
|
{
|
291
|
bindKey: { mac: "ctrl-o" },
|
292
|
name: "splitline"
|
293
|
},
|
294
|
{
|
295
|
bindKey: {mac: "ctrl-shift-w", win: "alt-shift-w"},
|
296
|
name: "surrowndWithTag"
|
297
|
},{
|
298
|
bindKey: {mac: "cmd-alt-.", win: "alt-."},
|
299
|
name: "close_tag"
|
300
|
},
|
301
|
{
|
302
|
bindKey: { mac: "cmd-j", win: "ctrl-j" },
|
303
|
name: "joinlines"
|
304
|
},
|
305
|
|
306
|
{
|
307
|
bindKey: {mac: "ctrl--", win: "alt--"},
|
308
|
name: "jumpBack"
|
309
|
}, {
|
310
|
bindKey: {mac: "ctrl-shift--", win: "alt-shift--"},
|
311
|
name: "jumpForward"
|
312
|
},
|
313
|
|
314
|
{
|
315
|
bindKey: { mac: "cmd-k cmd-l", win: "ctrl-k ctrl-l" },
|
316
|
name: "tolowercase"
|
317
|
}, {
|
318
|
bindKey: { mac: "cmd-k cmd-u", win: "ctrl-k ctrl-u" },
|
319
|
name: "touppercase"
|
320
|
},
|
321
|
|
322
|
{
|
323
|
bindKey: {mac: "cmd-shift-v", win: "ctrl-shift-v"},
|
324
|
name: "paste_and_indent"
|
325
|
}, {
|
326
|
bindKey: {mac: "cmd-k cmd-v|cmd-alt-v", win: "ctrl-k ctrl-v"},
|
327
|
name: "paste_from_history"
|
328
|
},
|
329
|
|
330
|
{
|
331
|
bindKey: { mac: "cmd-shift-enter", win: "ctrl-shift-enter" },
|
332
|
name: "addLineBefore"
|
333
|
}, {
|
334
|
bindKey: { mac: "cmd-enter", win: "ctrl-enter" },
|
335
|
name: "addLineAfter"
|
336
|
}, {
|
337
|
bindKey: { mac: "ctrl-shift-k", win: "ctrl-shift-k" },
|
338
|
name: "removeline"
|
339
|
}, {
|
340
|
bindKey: { mac: "ctrl-alt-up", win: "ctrl-up" },
|
341
|
name: "scrollup"
|
342
|
}, {
|
343
|
bindKey: { mac: "ctrl-alt-down", win: "ctrl-down" },
|
344
|
name: "scrolldown"
|
345
|
}, {
|
346
|
bindKey: { mac: "cmd-a", win: "ctrl-a" },
|
347
|
name: "selectall"
|
348
|
}, {
|
349
|
bindKey: { linux: "alt-shift-down", mac: "ctrl-shift-down", win: "ctrl-alt-down" },
|
350
|
name: "addCursorBelow"
|
351
|
}, {
|
352
|
bindKey: { linux: "alt-shift-up", mac: "ctrl-shift-up", win: "ctrl-alt-up" },
|
353
|
name: "addCursorAbove"
|
354
|
},
|
355
|
|
356
|
|
357
|
{
|
358
|
bindKey: { mac: "cmd-k cmd-c|ctrl-l", win: "ctrl-k ctrl-c" },
|
359
|
name: "centerselection"
|
360
|
},
|
361
|
|
362
|
{
|
363
|
bindKey: { mac: "f5", win: "f9" },
|
364
|
name: "sortlines"
|
365
|
},
|
366
|
{
|
367
|
bindKey: {mac: "ctrl-f5", win: "ctrl-f9"},
|
368
|
name: "sortlines",
|
369
|
args: {caseSensitive: true}
|
370
|
},
|
371
|
{
|
372
|
bindKey: { mac: "cmd-shift-l", win: "ctrl-shift-l" },
|
373
|
name: "splitSelectionIntoLines"
|
374
|
}, {
|
375
|
bindKey: { mac: "ctrl-cmd-down", win: "ctrl-shift-down" },
|
376
|
name: "movelinesdown"
|
377
|
}, {
|
378
|
bindKey: { mac: "ctrl-cmd-up", win: "ctrl-shift-up" },
|
379
|
name: "movelinesup"
|
380
|
}, {
|
381
|
bindKey: { mac: "alt-down", win: "alt-down" },
|
382
|
name: "modifyNumberDown"
|
383
|
}, {
|
384
|
bindKey: { mac: "alt-up", win: "alt-up" },
|
385
|
name: "modifyNumberUp"
|
386
|
}, {
|
387
|
bindKey: { mac: "cmd-/", win: "ctrl-/" },
|
388
|
name: "togglecomment"
|
389
|
}, {
|
390
|
bindKey: { mac: "cmd-alt-/", win: "ctrl-shift-/" },
|
391
|
name: "toggleBlockComment"
|
392
|
},
|
393
|
|
394
|
|
395
|
{
|
396
|
bindKey: { linux: "ctrl-alt-q", mac: "ctrl-q", win: "ctrl-q" },
|
397
|
name: "togglerecording"
|
398
|
}, {
|
399
|
bindKey: { linux: "ctrl-alt-shift-q", mac: "ctrl-shift-q", win: "ctrl-shift-q" },
|
400
|
name: "replaymacro"
|
401
|
},
|
402
|
|
403
|
{
|
404
|
bindKey: { mac: "ctrl-t", win: "ctrl-t" },
|
405
|
name: "transpose"
|
406
|
}
|
407
|
|
408
|
].forEach(function(binding) {
|
409
|
var command = exports.handler.commands[binding.name];
|
410
|
if (command)
|
411
|
command.bindKey = binding.bindKey;
|
412
|
exports.handler.bindKey(binding.bindKey, command || binding.name);
|
413
|
});
|
414
|
|
415
|
}); (function() {
|
416
|
ace.require(["ace/keyboard/sublime"], function(m) {
|
417
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
418
|
module.exports = m;
|
419
|
}
|
420
|
});
|
421
|
})();
|
422
|
|