yks-element 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/lib/019e34e85139cfc611bf23efa096c980.js +18 -0
  2. package/lib/07567125b93045706d81f17f7d04e262.js +120 -0
  3. package/lib/0d56a1f26e052a1bafd10a87782fc74b.js +3380 -0
  4. package/lib/27846e85433e54a3ec0ab34d62233dc5.js +186 -0
  5. package/lib/2f25a4dc442bc9aebc58cae30c50c3e2.js +192 -0
  6. package/lib/2f55cddc8eb85b63ee5b4ce0e5488230.js +67 -0
  7. package/lib/2fe2904fc024afaf81732563cb83e547.js +116 -0
  8. package/lib/3b02cca9e95276a74f3ed2bbc7a64ce6.js +409 -0
  9. package/lib/70efbabef77fb217f904f41dbf7fe8bf.js +380 -0
  10. package/lib/7cec85e554cfaf2464511da505025098.js +74 -0
  11. package/lib/852f0ecd7b17e3bfd700a821ff438f7e.js +330 -0
  12. package/lib/88730abfeb4a23e692ac7933882f12eb.js +255 -0
  13. package/lib/8b8336037f074d9dcbd20eab535b803f.js +227 -0
  14. package/lib/9979f39c4d2773e02151a6cf1558101b.js +768 -0
  15. package/lib/af6e31c060c273848b5fec9fdba8814d.js +3066 -0
  16. package/lib/babd8df6809ef43238f1b280c2cebfe3.js +265 -0
  17. package/lib/bb1365c0983ce5ad50060b24788b9630.js +459 -0
  18. package/lib/c0a8aa1d5e0611259e47c2008cb203ee.js +197 -0
  19. package/lib/c530988d2b1966fd10a4d99fa3877e1b.js +9 -0
  20. package/lib/c8acc93023012737a3bf8fb767b66838.js +1293 -0
  21. package/lib/d0415105402964718010284fcfa8b2ea.js +48 -0
  22. package/lib/d11ab4aa7dd9123fdecb075ff5c5a748.js +790 -0
  23. package/lib/d1907231dc06c32481fefd6d47da973b.js +344 -0
  24. package/lib/d429602e0ebf3c1ec040e070e9b05b9b.js +184 -0
  25. package/lib/e4fc956693373117f057fe9914e983fc.js +7090 -0
  26. package/lib/f15362a7feef894b2e7f706252e6c510.js +45 -0
  27. package/lib/f666b5647087bcfdf6623f8b14d56657.js +136 -0
  28. package/lib/fac0ce75e0690947a9e9e6f5b35c1ea8.js +1067 -0
  29. package/lib/fec23c6964d6cf25681d1f3e24b076a4.js +56 -0
  30. package/lib/yks.js +1 -1
  31. package/package.json +1 -1
  32. package/lib/6c6d192b6860b4508a14c2d04769a35e.js +0 -15404
  33. package/lib/c3832579be376308fa819b04e7b0c66f.js +0 -3788
@@ -0,0 +1,1067 @@
1
+ ace.define("ace/occur",["require","exports","module","ace/lib/oop","ace/search","ace/edit_session","ace/search_highlight","ace/lib/dom"], function(require, exports, module){"use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var oop = require("./lib/oop");
18
+ var Search = require("./search").Search;
19
+ var EditSession = require("./edit_session").EditSession;
20
+ var SearchHighlight = require("./search_highlight").SearchHighlight;
21
+ var Occur = /** @class */ (function (_super) {
22
+ __extends(Occur, _super);
23
+ function Occur() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ Occur.prototype.enter = function (editor, options) {
27
+ if (!options.needle)
28
+ return false;
29
+ var pos = editor.getCursorPosition();
30
+ this.displayOccurContent(editor, options);
31
+ var translatedPos = this.originalToOccurPosition(editor.session, pos);
32
+ editor.moveCursorToPosition(translatedPos);
33
+ return true;
34
+ };
35
+ Occur.prototype.exit = function (editor, options) {
36
+ var pos = options.translatePosition && editor.getCursorPosition();
37
+ var translatedPos = pos && this.occurToOriginalPosition(editor.session, pos);
38
+ this.displayOriginalContent(editor);
39
+ if (translatedPos)
40
+ editor.moveCursorToPosition(translatedPos);
41
+ return true;
42
+ };
43
+ Occur.prototype.highlight = function (sess, regexp) {
44
+ var hl = sess.$occurHighlight = sess.$occurHighlight || sess.addDynamicMarker(new SearchHighlight(null, "ace_occur-highlight", "text"));
45
+ hl.setRegexp(regexp);
46
+ sess._emit("changeBackMarker"); // force highlight layer redraw
47
+ };
48
+ Occur.prototype.displayOccurContent = function (editor, options) {
49
+ this.$originalSession = editor.session;
50
+ var found = this.matchingLines(editor.session, options);
51
+ var lines = found.map(function (foundLine) { return foundLine.content; });
52
+ var occurSession = new EditSession(lines.join('\n'));
53
+ occurSession.$occur = this;
54
+ occurSession.$occurMatchingLines = found;
55
+ editor.setSession(occurSession);
56
+ this.$useEmacsStyleLineStart = this.$originalSession.$useEmacsStyleLineStart;
57
+ occurSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
58
+ this.highlight(occurSession, options.re);
59
+ occurSession._emit('changeBackMarker');
60
+ };
61
+ Occur.prototype.displayOriginalContent = function (editor) {
62
+ editor.setSession(this.$originalSession);
63
+ this.$originalSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
64
+ };
65
+ Occur.prototype.originalToOccurPosition = function (session, pos) {
66
+ var lines = session.$occurMatchingLines;
67
+ var nullPos = { row: 0, column: 0 };
68
+ if (!lines)
69
+ return nullPos;
70
+ for (var i = 0; i < lines.length; i++) {
71
+ if (lines[i].row === pos.row)
72
+ return { row: i, column: pos.column };
73
+ }
74
+ return nullPos;
75
+ };
76
+ Occur.prototype.occurToOriginalPosition = function (session, pos) {
77
+ var lines = session.$occurMatchingLines;
78
+ if (!lines || !lines[pos.row])
79
+ return pos;
80
+ return { row: lines[pos.row].row, column: pos.column };
81
+ };
82
+ Occur.prototype.matchingLines = function (session, options) {
83
+ options = oop.mixin({}, options);
84
+ if (!session || !options.needle)
85
+ return [];
86
+ var search = new Search();
87
+ search.set(options);
88
+ return search.findAll(session).reduce(function (lines, range) {
89
+ var row = range.start.row;
90
+ var last = lines[lines.length - 1];
91
+ return last && last.row === row ?
92
+ lines :
93
+ lines.concat({ row: row, content: session.getLine(row) });
94
+ }, []);
95
+ };
96
+ return Occur;
97
+ }(Search));
98
+ var dom = require('./lib/dom');
99
+ dom.importCssString(".ace_occur-highlight {\n\
100
+ border-radius: 4px;\n\
101
+ background-color: rgba(87, 255, 8, 0.25);\n\
102
+ position: absolute;\n\
103
+ z-index: 4;\n\
104
+ box-sizing: border-box;\n\
105
+ box-shadow: 0 0 4px rgb(91, 255, 50);\n\
106
+ }\n\
107
+ .ace_dark .ace_occur-highlight {\n\
108
+ background-color: rgb(80, 140, 85);\n\
109
+ box-shadow: 0 0 4px rgb(60, 120, 70);\n\
110
+ }\n", "incremental-occur-highlighting", false);
111
+ exports.Occur = Occur;
112
+
113
+ });
114
+
115
+ ace.define("ace/commands/occur_commands",["require","exports","module","ace/config","ace/occur","ace/keyboard/hash_handler","ace/lib/oop"], function(require, exports, module){var config = require("../config"), Occur = require("../occur").Occur;
116
+ var occurStartCommand = {
117
+ name: "occur",
118
+ exec: function (editor, options) {
119
+ var alreadyInOccur = !!editor.session.$occur;
120
+ var occurSessionActive = new Occur().enter(editor, options);
121
+ if (occurSessionActive && !alreadyInOccur)
122
+ OccurKeyboardHandler.installIn(editor);
123
+ },
124
+ readOnly: true
125
+ };
126
+ var occurCommands = [{
127
+ name: "occurexit",
128
+ bindKey: 'esc|Ctrl-G',
129
+ exec: function (editor) {
130
+ var occur = editor.session.$occur;
131
+ if (!occur)
132
+ return;
133
+ occur.exit(editor, {});
134
+ if (!editor.session.$occur)
135
+ OccurKeyboardHandler.uninstallFrom(editor);
136
+ },
137
+ readOnly: true
138
+ }, {
139
+ name: "occuraccept",
140
+ bindKey: 'enter',
141
+ exec: function (editor) {
142
+ var occur = editor.session.$occur;
143
+ if (!occur)
144
+ return;
145
+ occur.exit(editor, { translatePosition: true });
146
+ if (!editor.session.$occur)
147
+ OccurKeyboardHandler.uninstallFrom(editor);
148
+ },
149
+ readOnly: true
150
+ }];
151
+ var HashHandler = require("../keyboard/hash_handler").HashHandler;
152
+ var oop = require("../lib/oop");
153
+ function OccurKeyboardHandler() { }
154
+ oop.inherits(OccurKeyboardHandler, HashHandler);
155
+ (function () {
156
+ this.isOccurHandler = true;
157
+ this.attach = function (editor) {
158
+ HashHandler.call(this, occurCommands, editor.commands.platform);
159
+ this.$editor = editor;
160
+ };
161
+ var handleKeyboard$super = this.handleKeyboard;
162
+ this.handleKeyboard = function (data, hashId, key, keyCode) {
163
+ var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
164
+ return (cmd && cmd.command) ? cmd : undefined;
165
+ };
166
+ }).call(OccurKeyboardHandler.prototype);
167
+ OccurKeyboardHandler.installIn = function (editor) {
168
+ var handler = new this();
169
+ editor.keyBinding.addKeyboardHandler(handler);
170
+ editor.commands.addCommands(occurCommands);
171
+ };
172
+ OccurKeyboardHandler.uninstallFrom = function (editor) {
173
+ editor.commands.removeCommands(occurCommands);
174
+ var handler = editor.getKeyboardHandler();
175
+ if (handler.isOccurHandler)
176
+ editor.keyBinding.removeKeyboardHandler(handler);
177
+ };
178
+ exports.occurStartCommand = occurStartCommand;
179
+
180
+ });
181
+
182
+ ace.define("ace/commands/incremental_search_commands",["require","exports","module","ace/config","ace/lib/oop","ace/keyboard/hash_handler","ace/commands/occur_commands"], function(require, exports, module){var config = require("../config");
183
+ var oop = require("../lib/oop");
184
+ var HashHandler = require("../keyboard/hash_handler").HashHandler;
185
+ var occurStartCommand = require("./occur_commands").occurStartCommand;
186
+ exports.iSearchStartCommands = [{
187
+ name: "iSearch",
188
+ bindKey: { win: "Ctrl-F", mac: "Command-F" },
189
+ exec: function (editor, options) {
190
+ config.loadModule(["core", "ace/incremental_search"], function (e) {
191
+ var iSearch = e.iSearch = e.iSearch || new e.IncrementalSearch();
192
+ iSearch.activate(editor, options.backwards);
193
+ if (options.jumpToFirstMatch)
194
+ iSearch.next(options);
195
+ });
196
+ },
197
+ readOnly: true
198
+ }, {
199
+ name: "iSearchBackwards",
200
+ exec: function (editor, jumpToNext) { editor.execCommand('iSearch', { backwards: true }); },
201
+ readOnly: true
202
+ }, {
203
+ name: "iSearchAndGo",
204
+ bindKey: { win: "Ctrl-K", mac: "Command-G" },
205
+ exec: function (editor, jumpToNext) { editor.execCommand('iSearch', { jumpToFirstMatch: true, useCurrentOrPrevSearch: true }); },
206
+ readOnly: true
207
+ }, {
208
+ name: "iSearchBackwardsAndGo",
209
+ bindKey: { win: "Ctrl-Shift-K", mac: "Command-Shift-G" },
210
+ exec: function (editor) { editor.execCommand('iSearch', { jumpToFirstMatch: true, backwards: true, useCurrentOrPrevSearch: true }); },
211
+ readOnly: true
212
+ }];
213
+ exports.iSearchCommands = [{
214
+ name: "restartSearch",
215
+ bindKey: { win: "Ctrl-F", mac: "Command-F" },
216
+ exec: function (iSearch) {
217
+ iSearch.cancelSearch(true);
218
+ }
219
+ }, {
220
+ name: "searchForward",
221
+ bindKey: { win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G" },
222
+ exec: function (iSearch, options) {
223
+ options.useCurrentOrPrevSearch = true;
224
+ iSearch.next(options);
225
+ }
226
+ }, {
227
+ name: "searchBackward",
228
+ bindKey: { win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G" },
229
+ exec: function (iSearch, options) {
230
+ options.useCurrentOrPrevSearch = true;
231
+ options.backwards = true;
232
+ iSearch.next(options);
233
+ }
234
+ }, {
235
+ name: "extendSearchTerm",
236
+ exec: function (iSearch, string) {
237
+ iSearch.addString(string);
238
+ }
239
+ }, {
240
+ name: "extendSearchTermSpace",
241
+ bindKey: "space",
242
+ exec: function (iSearch) { iSearch.addString(' '); }
243
+ }, {
244
+ name: "shrinkSearchTerm",
245
+ bindKey: "backspace",
246
+ exec: function (iSearch) {
247
+ iSearch.removeChar();
248
+ }
249
+ }, {
250
+ name: 'confirmSearch',
251
+ bindKey: 'return',
252
+ exec: function (iSearch) { iSearch.deactivate(); }
253
+ }, {
254
+ name: 'cancelSearch',
255
+ bindKey: 'esc|Ctrl-G',
256
+ exec: function (iSearch) { iSearch.deactivate(true); }
257
+ }, {
258
+ name: 'occurisearch',
259
+ bindKey: 'Ctrl-O',
260
+ exec: function (iSearch) {
261
+ var options = oop.mixin({}, iSearch.$options);
262
+ iSearch.deactivate();
263
+ occurStartCommand.exec(iSearch.$editor, options);
264
+ }
265
+ }, {
266
+ name: "yankNextWord",
267
+ bindKey: "Ctrl-w",
268
+ exec: function (iSearch) {
269
+ var ed = iSearch.$editor, range = ed.selection.getRangeOfMovements(function (sel) { sel.moveCursorWordRight(); }), string = ed.session.getTextRange(range);
270
+ iSearch.addString(string);
271
+ }
272
+ }, {
273
+ name: "yankNextChar",
274
+ bindKey: "Ctrl-Alt-y",
275
+ exec: function (iSearch) {
276
+ var ed = iSearch.$editor, range = ed.selection.getRangeOfMovements(function (sel) { sel.moveCursorRight(); }), string = ed.session.getTextRange(range);
277
+ iSearch.addString(string);
278
+ }
279
+ }, {
280
+ name: 'recenterTopBottom',
281
+ bindKey: 'Ctrl-l',
282
+ exec: function (iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
283
+ }, {
284
+ name: 'selectAllMatches',
285
+ bindKey: 'Ctrl-space',
286
+ exec: function (iSearch) {
287
+ var ed = iSearch.$editor, hl = ed.session.$isearchHighlight, ranges = hl && hl.cache ? hl.cache
288
+ .reduce(function (ranges, ea) {
289
+ return ranges.concat(ea ? ea : []);
290
+ }, []) : [];
291
+ iSearch.deactivate(false);
292
+ ranges.forEach(ed.selection.addRange.bind(ed.selection));
293
+ }
294
+ }, {
295
+ name: 'searchAsRegExp',
296
+ bindKey: 'Alt-r',
297
+ exec: function (iSearch) {
298
+ iSearch.convertNeedleToRegExp();
299
+ }
300
+ }].map(function (cmd) {
301
+ cmd.readOnly = true;
302
+ cmd.isIncrementalSearchCommand = true;
303
+ cmd.scrollIntoView = "animate-cursor";
304
+ return cmd;
305
+ });
306
+ function IncrementalSearchKeyboardHandler(iSearch) {
307
+ this.$iSearch = iSearch;
308
+ }
309
+ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
310
+ (function () {
311
+ this.attach = function (editor) {
312
+ var iSearch = this.$iSearch;
313
+ HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
314
+ this.$commandExecHandler = editor.commands.on('exec', function (e) {
315
+ if (!e.command.isIncrementalSearchCommand)
316
+ return iSearch.deactivate();
317
+ e.stopPropagation();
318
+ e.preventDefault();
319
+ var scrollTop = editor.session.getScrollTop();
320
+ var result = e.command.exec(iSearch, e.args || {});
321
+ editor.renderer.scrollCursorIntoView(null, 0.5);
322
+ editor.renderer.animateScrolling(scrollTop);
323
+ return result;
324
+ });
325
+ };
326
+ this.detach = function (editor) {
327
+ if (!this.$commandExecHandler)
328
+ return;
329
+ editor.commands.off('exec', this.$commandExecHandler);
330
+ delete this.$commandExecHandler;
331
+ };
332
+ var handleKeyboard$super = this.handleKeyboard;
333
+ this.handleKeyboard = function (data, hashId, key, keyCode) {
334
+ if (((hashId === 1 /*ctrl*/ || hashId === 8 /*command*/) && key === 'v')
335
+ || (hashId === 1 /*ctrl*/ && key === 'y'))
336
+ return null;
337
+ var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
338
+ if (cmd && cmd.command) {
339
+ return cmd;
340
+ }
341
+ if (hashId == -1) {
342
+ var extendCmd = this.commands.extendSearchTerm;
343
+ if (extendCmd) {
344
+ return { command: extendCmd, args: key };
345
+ }
346
+ }
347
+ return false;
348
+ };
349
+ }).call(IncrementalSearchKeyboardHandler.prototype);
350
+ exports.IncrementalSearchKeyboardHandler = IncrementalSearchKeyboardHandler;
351
+
352
+ });
353
+
354
+ ace.define("ace/incremental_search",["require","exports","module","ace/range","ace/search","ace/search_highlight","ace/commands/incremental_search_commands","ace/lib/dom","ace/commands/command_manager","ace/editor","ace/config"], function(require, exports, module){"use strict";
355
+ var __extends = (this && this.__extends) || (function () {
356
+ var extendStatics = function (d, b) {
357
+ extendStatics = Object.setPrototypeOf ||
358
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
359
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
360
+ return extendStatics(d, b);
361
+ };
362
+ return function (d, b) {
363
+ if (typeof b !== "function" && b !== null)
364
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
365
+ extendStatics(d, b);
366
+ function __() { this.constructor = d; }
367
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
368
+ };
369
+ })();
370
+ var Range = require("./range").Range;
371
+ var Search = require("./search").Search;
372
+ var SearchHighlight = require("./search_highlight").SearchHighlight;
373
+ var iSearchCommandModule = require("./commands/incremental_search_commands");
374
+ var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler;
375
+ function isRegExp(obj) {
376
+ return obj instanceof RegExp;
377
+ }
378
+ function regExpToObject(re) {
379
+ var string = String(re), start = string.indexOf('/'), flagStart = string.lastIndexOf('/');
380
+ return {
381
+ expression: string.slice(start + 1, flagStart),
382
+ flags: string.slice(flagStart + 1)
383
+ };
384
+ }
385
+ function stringToRegExp(string, flags) {
386
+ try {
387
+ return new RegExp(string, flags);
388
+ }
389
+ catch (e) {
390
+ return string;
391
+ }
392
+ }
393
+ function objectToRegExp(obj) {
394
+ return stringToRegExp(obj.expression, obj.flags);
395
+ }
396
+ var IncrementalSearch = /** @class */ (function (_super) {
397
+ __extends(IncrementalSearch, _super);
398
+ function IncrementalSearch() {
399
+ var _this = _super.call(this) || this;
400
+ _this.$options = { wrap: false, skipCurrent: false };
401
+ _this.$keyboardHandler = new ISearchKbd(_this);
402
+ return _this;
403
+ }
404
+ IncrementalSearch.prototype.activate = function (editor, backwards) {
405
+ this.$editor = editor;
406
+ this.$startPos = this.$currentPos = editor.getCursorPosition();
407
+ this.$options.needle = '';
408
+ this.$options.backwards = backwards;
409
+ editor.keyBinding.addKeyboardHandler(this.$keyboardHandler);
410
+ this.$originalEditorOnPaste = editor.onPaste;
411
+ editor.onPaste = this.onPaste.bind(this);
412
+ this.$mousedownHandler = editor.on('mousedown', this.onMouseDown.bind(this));
413
+ this.selectionFix(editor);
414
+ this.statusMessage(true);
415
+ };
416
+ IncrementalSearch.prototype.deactivate = function (reset) {
417
+ this.cancelSearch(reset);
418
+ var editor = this.$editor;
419
+ editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler);
420
+ if (this.$mousedownHandler) {
421
+ editor.off('mousedown', this.$mousedownHandler);
422
+ delete this.$mousedownHandler;
423
+ }
424
+ editor.onPaste = this.$originalEditorOnPaste;
425
+ this.message('');
426
+ };
427
+ IncrementalSearch.prototype.selectionFix = function (editor) {
428
+ if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
429
+ editor.clearSelection();
430
+ }
431
+ };
432
+ IncrementalSearch.prototype.highlight = function (regexp) {
433
+ var sess = this.$editor.session, hl = sess.$isearchHighlight = sess.$isearchHighlight || sess.addDynamicMarker(new SearchHighlight(null, "ace_isearch-result", "text"));
434
+ hl.setRegexp(regexp);
435
+ sess._emit("changeBackMarker"); // force highlight layer redraw
436
+ };
437
+ IncrementalSearch.prototype.cancelSearch = function (reset) {
438
+ var e = this.$editor;
439
+ this.$prevNeedle = this.$options.needle;
440
+ this.$options.needle = '';
441
+ if (reset) {
442
+ e.moveCursorToPosition(this.$startPos);
443
+ this.$currentPos = this.$startPos;
444
+ }
445
+ else {
446
+ e.pushEmacsMark && e.pushEmacsMark(this.$startPos, false);
447
+ }
448
+ this.highlight(null);
449
+ return Range.fromPoints(this.$currentPos, this.$currentPos);
450
+ };
451
+ IncrementalSearch.prototype.highlightAndFindWithNeedle = function (moveToNext, needleUpdateFunc) {
452
+ if (!this.$editor)
453
+ return null;
454
+ var options = this.$options;
455
+ if (needleUpdateFunc) {
456
+ options.needle = needleUpdateFunc.call(this, options.needle || '') || '';
457
+ }
458
+ if (options.needle.length === 0) {
459
+ this.statusMessage(true);
460
+ return this.cancelSearch(true);
461
+ }
462
+ options.start = this.$currentPos;
463
+ var session = this.$editor.session, found = this.find(session), shouldSelect = this.$editor.emacsMark ?
464
+ !!this.$editor.emacsMark() : !this.$editor.selection.isEmpty();
465
+ if (found) {
466
+ if (options.backwards)
467
+ found = Range.fromPoints(found.end, found.start);
468
+ this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
469
+ if (moveToNext)
470
+ this.$currentPos = found.end;
471
+ this.highlight(options.re);
472
+ }
473
+ this.statusMessage(found);
474
+ return found;
475
+ };
476
+ IncrementalSearch.prototype.addString = function (s) {
477
+ return this.highlightAndFindWithNeedle(false, function (needle) {
478
+ if (!isRegExp(needle))
479
+ return needle + s;
480
+ var reObj = regExpToObject(needle);
481
+ reObj.expression += s;
482
+ return objectToRegExp(reObj);
483
+ });
484
+ };
485
+ IncrementalSearch.prototype.removeChar = function (c) {
486
+ return this.highlightAndFindWithNeedle(false, function (needle) {
487
+ if (!isRegExp(needle))
488
+ return needle.substring(0, needle.length - 1);
489
+ var reObj = regExpToObject(needle);
490
+ reObj.expression = reObj.expression.substring(0, reObj.expression.length - 1);
491
+ return objectToRegExp(reObj);
492
+ });
493
+ };
494
+ IncrementalSearch.prototype.next = function (options) {
495
+ options = options || {};
496
+ this.$options.backwards = !!options.backwards;
497
+ this.$currentPos = this.$editor.getCursorPosition();
498
+ return this.highlightAndFindWithNeedle(true, function (needle) {
499
+ return options.useCurrentOrPrevSearch && needle.length === 0 ?
500
+ this.$prevNeedle || '' : needle;
501
+ });
502
+ };
503
+ IncrementalSearch.prototype.onMouseDown = function (evt) {
504
+ this.deactivate();
505
+ return true;
506
+ };
507
+ IncrementalSearch.prototype.onPaste = function (text) {
508
+ this.addString(text);
509
+ };
510
+ IncrementalSearch.prototype.convertNeedleToRegExp = function () {
511
+ return this.highlightAndFindWithNeedle(false, function (needle) {
512
+ return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
513
+ });
514
+ };
515
+ IncrementalSearch.prototype.convertNeedleToString = function () {
516
+ return this.highlightAndFindWithNeedle(false, function (needle) {
517
+ return isRegExp(needle) ? regExpToObject(needle).expression : needle;
518
+ });
519
+ };
520
+ IncrementalSearch.prototype.statusMessage = function (found) {
521
+ var options = this.$options, msg = '';
522
+ msg += options.backwards ? 'reverse-' : '';
523
+ msg += 'isearch: ' + options.needle;
524
+ msg += found ? '' : ' (not found)';
525
+ this.message(msg);
526
+ };
527
+ IncrementalSearch.prototype.message = function (msg) {
528
+ if (this.$editor.showCommandLine) {
529
+ this.$editor.showCommandLine(msg);
530
+ this.$editor.focus();
531
+ }
532
+ };
533
+ return IncrementalSearch;
534
+ }(Search));
535
+ exports.IncrementalSearch = IncrementalSearch;
536
+ var dom = require('./lib/dom');
537
+ dom.importCssString("\n.ace_marker-layer .ace_isearch-result {\n position: absolute;\n z-index: 6;\n box-sizing: border-box;\n}\ndiv.ace_isearch-result {\n border-radius: 4px;\n background-color: rgba(255, 200, 0, 0.5);\n box-shadow: 0 0 4px rgb(255, 200, 0);\n}\n.ace_dark div.ace_isearch-result {\n background-color: rgb(100, 110, 160);\n box-shadow: 0 0 4px rgb(80, 90, 140);\n}", "incremental-search-highlighting", false);
538
+ var commands = require("./commands/command_manager");
539
+ (function () {
540
+ this.setupIncrementalSearch = function (editor, val) {
541
+ if (this.usesIncrementalSearch == val)
542
+ return;
543
+ this.usesIncrementalSearch = val;
544
+ var iSearchCommands = iSearchCommandModule.iSearchStartCommands;
545
+ var method = val ? 'addCommands' : 'removeCommands';
546
+ this[method](iSearchCommands);
547
+ };
548
+ }).call(commands.CommandManager.prototype);
549
+ var Editor = require("./editor").Editor;
550
+ require("./config").defineOptions(Editor.prototype, "editor", {
551
+ useIncrementalSearch: {
552
+ set: function (val) {
553
+ this.keyBinding.$handlers.forEach(function (handler) {
554
+ if (handler.setupIncrementalSearch) {
555
+ handler.setupIncrementalSearch(this, val);
556
+ }
557
+ });
558
+ this._emit('incrementalSearchSettingChanged', { isEnabled: val });
559
+ }
560
+ }
561
+ });
562
+
563
+ });
564
+
565
+ ace.define("ace/keyboard/emacs",["require","exports","module","ace/lib/dom","ace/incremental_search","ace/commands/incremental_search_commands","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module){"use strict";
566
+ var dom = require("../lib/dom");
567
+ require("../incremental_search");
568
+ var iSearchCommandModule = require("../commands/incremental_search_commands");
569
+ var HashHandler = require("./hash_handler").HashHandler;
570
+ exports.handler = new HashHandler();
571
+ exports.handler.isEmacs = true;
572
+ exports.handler.$id = "ace/keyboard/emacs";
573
+ dom.importCssString("\n.emacs-mode .ace_cursor{\n border: 1px rgba(50,250,50,0.8) solid!important;\n box-sizing: border-box!important;\n background-color: rgba(0,250,0,0.9);\n opacity: 0.5;\n}\n.emacs-mode .ace_hidden-cursors .ace_cursor{\n opacity: 1;\n background-color: transparent;\n}\n.emacs-mode .ace_overwrite-cursors .ace_cursor {\n opacity: 1;\n background-color: transparent;\n border-width: 0 0 2px 2px !important;\n}\n.emacs-mode .ace_text-layer {\n z-index: 4\n}\n.emacs-mode .ace_cursor-layer {\n z-index: 2\n}", 'emacsMode');
574
+ var $formerLongWords;
575
+ var $formerLineStart;
576
+ exports.handler.attach = function (editor) {
577
+ $formerLongWords = editor.session.$selectLongWords;
578
+ editor.session.$selectLongWords = true;
579
+ $formerLineStart = editor.session.$useEmacsStyleLineStart;
580
+ editor.session.$useEmacsStyleLineStart = true;
581
+ editor.session.$emacsMark = null; // the active mark
582
+ editor.session.$emacsMarkRing = editor.session.$emacsMarkRing || [];
583
+ editor.emacsMark = function () {
584
+ return this.session.$emacsMark;
585
+ };
586
+ editor.setEmacsMark = function (p) {
587
+ this.session.$emacsMark = p;
588
+ };
589
+ editor.pushEmacsMark = function (p, activate) {
590
+ var prevMark = this.session.$emacsMark;
591
+ if (prevMark)
592
+ pushUnique(this.session.$emacsMarkRing, prevMark);
593
+ if (!p || activate)
594
+ this.setEmacsMark(p);
595
+ else
596
+ pushUnique(this.session.$emacsMarkRing, p);
597
+ };
598
+ editor.popEmacsMark = function () {
599
+ var mark = this.emacsMark();
600
+ if (mark) {
601
+ this.setEmacsMark(null);
602
+ return mark;
603
+ }
604
+ return this.session.$emacsMarkRing.pop();
605
+ };
606
+ editor.getLastEmacsMark = function (p) {
607
+ return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0];
608
+ };
609
+ editor.emacsMarkForSelection = function (replacement) {
610
+ var sel = this.selection, multiRangeLength = this.multiSelect ?
611
+ this.multiSelect.getAllRanges().length : 1, selIndex = sel.index || 0, markRing = this.session.$emacsMarkRing, markIndex = markRing.length - (multiRangeLength - selIndex), lastMark = markRing[markIndex] || sel.anchor;
612
+ if (replacement) {
613
+ markRing.splice(markIndex, 1, "row" in replacement && "column" in replacement ?
614
+ replacement : undefined);
615
+ }
616
+ return lastMark;
617
+ };
618
+ editor.on("click", $resetMarkMode);
619
+ editor.on("changeSession", $kbSessionChange);
620
+ editor.renderer.$blockCursor = true;
621
+ editor.setStyle("emacs-mode");
622
+ editor.commands.addCommands(commands);
623
+ exports.handler.platform = editor.commands.platform;
624
+ editor.$emacsModeHandler = this;
625
+ editor.on('copy', this.onCopy);
626
+ editor.on('paste', this.onPaste);
627
+ };
628
+ function pushUnique(ring, mark) {
629
+ var last = ring[ring.length - 1];
630
+ if (last && last.row === mark.row && last.column === mark.column) {
631
+ return;
632
+ }
633
+ ring.push(mark);
634
+ }
635
+ exports.handler.detach = function (editor) {
636
+ editor.renderer.$blockCursor = false;
637
+ editor.session.$selectLongWords = $formerLongWords;
638
+ editor.session.$useEmacsStyleLineStart = $formerLineStart;
639
+ editor.off("click", $resetMarkMode);
640
+ editor.off("changeSession", $kbSessionChange);
641
+ editor.unsetStyle("emacs-mode");
642
+ editor.commands.removeCommands(commands);
643
+ editor.off('copy', this.onCopy);
644
+ editor.off('paste', this.onPaste);
645
+ editor.$emacsModeHandler = null;
646
+ };
647
+ var $kbSessionChange = function (e) {
648
+ if (e.oldSession) {
649
+ e.oldSession.$selectLongWords = $formerLongWords;
650
+ e.oldSession.$useEmacsStyleLineStart = $formerLineStart;
651
+ }
652
+ $formerLongWords = e.session.$selectLongWords;
653
+ e.session.$selectLongWords = true;
654
+ $formerLineStart = e.session.$useEmacsStyleLineStart;
655
+ e.session.$useEmacsStyleLineStart = true;
656
+ if (!e.session.hasOwnProperty('$emacsMark'))
657
+ e.session.$emacsMark = null;
658
+ if (!e.session.hasOwnProperty('$emacsMarkRing'))
659
+ e.session.$emacsMarkRing = [];
660
+ };
661
+ var $resetMarkMode = function (e) {
662
+ e.editor.session.$emacsMark = null;
663
+ };
664
+ var keys = require("../lib/keys").KEY_MODS;
665
+ var eMods = { C: "ctrl", S: "shift", M: "alt", CMD: "command" };
666
+ var combinations = ["C-S-M-CMD",
667
+ "S-M-CMD", "C-M-CMD", "C-S-CMD", "C-S-M",
668
+ "M-CMD", "S-CMD", "S-M", "C-CMD", "C-M", "C-S",
669
+ "CMD", "M", "S", "C"];
670
+ combinations.forEach(function (c) {
671
+ var hashId = 0;
672
+ c.split("-").forEach(function (c) {
673
+ hashId = hashId | keys[eMods[c]];
674
+ });
675
+ eMods[hashId] = c.toLowerCase() + "-";
676
+ });
677
+ exports.handler.onCopy = function (e, editor) {
678
+ if (editor.$handlesEmacsOnCopy)
679
+ return;
680
+ editor.$handlesEmacsOnCopy = true;
681
+ exports.handler.commands.killRingSave.exec(editor);
682
+ editor.$handlesEmacsOnCopy = false;
683
+ };
684
+ exports.handler.onPaste = function (e, editor) {
685
+ editor.pushEmacsMark(editor.getCursorPosition());
686
+ };
687
+ exports.handler.bindKey = function (key, command) {
688
+ if (typeof key == "object")
689
+ key = key[this.platform];
690
+ if (!key)
691
+ return;
692
+ var ckb = this.commandKeyBinding;
693
+ key.split("|").forEach(function (keyPart) {
694
+ keyPart = keyPart.toLowerCase();
695
+ ckb[keyPart] = command;
696
+ var keyParts = keyPart.split(" ").slice(0, -1);
697
+ keyParts.reduce(function (keyMapKeys, keyPart, i) {
698
+ var prefix = keyMapKeys[i - 1] ? keyMapKeys[i - 1] + ' ' : '';
699
+ return keyMapKeys.concat([prefix + keyPart]);
700
+ }, []).forEach(function (keyPart) {
701
+ if (!ckb[keyPart])
702
+ ckb[keyPart] = "null";
703
+ });
704
+ }, this);
705
+ };
706
+ exports.handler.getStatusText = function (editor, data) {
707
+ var str = "";
708
+ if (data.count)
709
+ str += data.count;
710
+ if (data.keyChain)
711
+ str += " " + data.keyChain;
712
+ return str;
713
+ };
714
+ exports.handler.handleKeyboard = function (data, hashId, key, keyCode) {
715
+ if (keyCode === -1)
716
+ return undefined;
717
+ var editor = data.editor;
718
+ editor._signal("changeStatus");
719
+ if (hashId == -1) {
720
+ editor.pushEmacsMark();
721
+ if (data.count) {
722
+ var str = new Array(data.count + 1).join(key);
723
+ data.count = null;
724
+ return { command: "insertstring", args: str };
725
+ }
726
+ }
727
+ var modifier = eMods[hashId];
728
+ if (modifier == "c-" || data.count) {
729
+ var count = parseInt(key[key.length - 1]);
730
+ if (typeof count === 'number' && !isNaN(count)) {
731
+ data.count = Math.max(data.count, 0) || 0;
732
+ data.count = 10 * data.count + count;
733
+ return { command: "null" };
734
+ }
735
+ }
736
+ if (modifier)
737
+ key = modifier + key;
738
+ if (data.keyChain)
739
+ key = data.keyChain += " " + key;
740
+ var command = this.commandKeyBinding[key];
741
+ data.keyChain = command == "null" ? key : "";
742
+ if (!command)
743
+ return undefined;
744
+ if (command === "null")
745
+ return { command: "null" };
746
+ if (command === "universalArgument") {
747
+ data.count = -4;
748
+ return { command: "null" };
749
+ }
750
+ var args;
751
+ if (typeof command !== "string") {
752
+ args = command.args;
753
+ if (command.command)
754
+ command = command.command;
755
+ if (command === "goorselect") {
756
+ command = editor.emacsMark() ? args[1] : args[0];
757
+ args = null;
758
+ }
759
+ }
760
+ if (typeof command === "string") {
761
+ if (command === "insertstring" ||
762
+ command === "splitline" ||
763
+ command === "togglecomment") {
764
+ editor.pushEmacsMark();
765
+ }
766
+ command = this.commands[command] || editor.commands.commands[command];
767
+ if (!command)
768
+ return undefined;
769
+ }
770
+ if (!command.readOnly && !command.isYank)
771
+ data.lastCommand = null;
772
+ if (!command.readOnly && editor.emacsMark())
773
+ editor.setEmacsMark(null);
774
+ if (data.count) {
775
+ var count = data.count;
776
+ data.count = 0;
777
+ if (!command || !command.handlesCount) {
778
+ return {
779
+ args: args,
780
+ command: {
781
+ exec: function (editor, args) {
782
+ for (var i = 0; i < count; i++)
783
+ command.exec(editor, args);
784
+ },
785
+ multiSelectAction: command.multiSelectAction
786
+ }
787
+ };
788
+ }
789
+ else {
790
+ if (!args)
791
+ args = {};
792
+ if (typeof args === 'object')
793
+ args.count = count;
794
+ }
795
+ }
796
+ return { command: command, args: args };
797
+ };
798
+ exports.emacsKeys = {
799
+ "Up|C-p": { command: "goorselect", args: ["golineup", "selectup"] },
800
+ "Down|C-n": { command: "goorselect", args: ["golinedown", "selectdown"] },
801
+ "Left|C-b": { command: "goorselect", args: ["gotoleft", "selectleft"] },
802
+ "Right|C-f": { command: "goorselect", args: ["gotoright", "selectright"] },
803
+ "C-Left|M-b": { command: "goorselect", args: ["gotowordleft", "selectwordleft"] },
804
+ "C-Right|M-f": { command: "goorselect", args: ["gotowordright", "selectwordright"] },
805
+ "Home|C-a": { command: "goorselect", args: ["gotolinestart", "selecttolinestart"] },
806
+ "End|C-e": { command: "goorselect", args: ["gotolineend", "selecttolineend"] },
807
+ "C-Home|S-M-,": { command: "goorselect", args: ["gotostart", "selecttostart"] },
808
+ "C-End|S-M-.": { command: "goorselect", args: ["gotoend", "selecttoend"] },
809
+ "S-Up|S-C-p": "selectup",
810
+ "S-Down|S-C-n": "selectdown",
811
+ "S-Left|S-C-b": "selectleft",
812
+ "S-Right|S-C-f": "selectright",
813
+ "S-C-Left|S-M-b": "selectwordleft",
814
+ "S-C-Right|S-M-f": "selectwordright",
815
+ "S-Home|S-C-a": "selecttolinestart",
816
+ "S-End|S-C-e": "selecttolineend",
817
+ "S-C-Home": "selecttostart",
818
+ "S-C-End": "selecttoend",
819
+ "C-l": "recenterTopBottom",
820
+ "M-s": "centerselection",
821
+ "M-g": "gotoline",
822
+ "C-x C-p": "selectall",
823
+ "C-Down": { command: "goorselect", args: ["gotopagedown", "selectpagedown"] },
824
+ "C-Up": { command: "goorselect", args: ["gotopageup", "selectpageup"] },
825
+ "PageDown|C-v": { command: "goorselect", args: ["gotopagedown", "selectpagedown"] },
826
+ "PageUp|M-v": { command: "goorselect", args: ["gotopageup", "selectpageup"] },
827
+ "S-C-Down": "selectpagedown",
828
+ "S-C-Up": "selectpageup",
829
+ "C-s": "iSearch",
830
+ "C-r": "iSearchBackwards",
831
+ "M-C-s": "findnext",
832
+ "M-C-r": "findprevious",
833
+ "S-M-5": "replace",
834
+ "Backspace": "backspace",
835
+ "Delete|C-d": "del",
836
+ "Return|C-m": { command: "insertstring", args: "\n" }, // "newline"
837
+ "C-o": "splitline",
838
+ "M-d|C-Delete": { command: "killWord", args: "right" },
839
+ "C-Backspace|M-Backspace|M-Delete": { command: "killWord", args: "left" },
840
+ "C-k": "killLine",
841
+ "C-y|S-Delete": "yank",
842
+ "M-y": "yankRotate",
843
+ "C-g": "keyboardQuit",
844
+ "C-w|C-S-W": "killRegion",
845
+ "M-w": "killRingSave",
846
+ "C-Space": "setMark",
847
+ "C-x C-x": "exchangePointAndMark",
848
+ "C-t": "transposeletters",
849
+ "M-u": "touppercase", // Doesn't work
850
+ "M-l": "tolowercase",
851
+ "M-/": "autocomplete", // Doesn't work
852
+ "C-u": "universalArgument",
853
+ "M-;": "togglecomment",
854
+ "C-/|C-x u|S-C--|C-z": "undo",
855
+ "S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
856
+ "C-x r": "selectRectangularRegion",
857
+ "M-x": { command: "focusCommandLine", args: "M-x " }
858
+ };
859
+ exports.handler.bindKeys(exports.emacsKeys);
860
+ exports.handler.addCommands({
861
+ recenterTopBottom: function (editor) {
862
+ var renderer = editor.renderer;
863
+ var pos = renderer.$cursorLayer.getPixelPosition();
864
+ var h = renderer.$size.scrollerHeight - renderer.lineHeight;
865
+ var scrollTop = renderer.scrollTop;
866
+ if (Math.abs(pos.top - scrollTop) < 2) {
867
+ scrollTop = pos.top - h;
868
+ }
869
+ else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) {
870
+ scrollTop = pos.top;
871
+ }
872
+ else {
873
+ scrollTop = pos.top - h * 0.5;
874
+ }
875
+ editor.session.setScrollTop(scrollTop);
876
+ },
877
+ selectRectangularRegion: function (editor) {
878
+ editor.multiSelect.toggleBlockSelection();
879
+ },
880
+ setMark: {
881
+ exec: function (editor, args) {
882
+ if (args && args.count) {
883
+ if (editor.inMultiSelectMode)
884
+ editor.forEachSelection(moveToMark);
885
+ else
886
+ moveToMark();
887
+ moveToMark();
888
+ return;
889
+ }
890
+ var mark = editor.emacsMark(), ranges = editor.selection.getAllRanges(), rangePositions = ranges.map(function (r) { return { row: r.start.row, column: r.start.column }; }), transientMarkModeActive = true, hasNoSelection = ranges.every(function (range) { return range.isEmpty(); });
891
+ if (transientMarkModeActive && (mark || !hasNoSelection)) {
892
+ if (editor.inMultiSelectMode)
893
+ editor.forEachSelection({ exec: editor.clearSelection.bind(editor) });
894
+ else
895
+ editor.clearSelection();
896
+ if (mark)
897
+ editor.pushEmacsMark(null);
898
+ return;
899
+ }
900
+ if (!mark) {
901
+ rangePositions.forEach(function (pos) { editor.pushEmacsMark(pos); });
902
+ editor.setEmacsMark(rangePositions[rangePositions.length - 1]);
903
+ return;
904
+ }
905
+ function moveToMark() {
906
+ var mark = editor.popEmacsMark();
907
+ mark && editor.moveCursorToPosition(mark);
908
+ }
909
+ },
910
+ readOnly: true,
911
+ handlesCount: true
912
+ },
913
+ exchangePointAndMark: {
914
+ exec: function exchangePointAndMark$exec(editor, args) {
915
+ var sel = editor.selection;
916
+ if (!args.count && !sel.isEmpty()) { // just invert selection
917
+ sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
918
+ return;
919
+ }
920
+ if (args.count) { // replace mark and point
921
+ var pos = { row: sel.lead.row, column: sel.lead.column };
922
+ sel.clearSelection();
923
+ sel.moveCursorToPosition(editor.emacsMarkForSelection(pos));
924
+ }
925
+ else { // create selection to last mark
926
+ sel.selectToPosition(editor.emacsMarkForSelection());
927
+ }
928
+ },
929
+ readOnly: true,
930
+ handlesCount: true,
931
+ multiSelectAction: "forEach"
932
+ },
933
+ killWord: {
934
+ exec: function (editor, dir) {
935
+ editor.clearSelection();
936
+ if (dir == "left")
937
+ editor.selection.selectWordLeft();
938
+ else
939
+ editor.selection.selectWordRight();
940
+ var range = editor.getSelectionRange();
941
+ var text = editor.session.getTextRange(range);
942
+ exports.killRing.add(text);
943
+ editor.session.remove(range);
944
+ editor.clearSelection();
945
+ },
946
+ multiSelectAction: "forEach"
947
+ },
948
+ killLine: function (editor) {
949
+ editor.pushEmacsMark(null);
950
+ editor.clearSelection();
951
+ var range = editor.getSelectionRange();
952
+ var line = editor.session.getLine(range.start.row);
953
+ range.end.column = line.length;
954
+ line = line.substr(range.start.column);
955
+ var foldLine = editor.session.getFoldLine(range.start.row);
956
+ if (foldLine && range.end.row != foldLine.end.row) {
957
+ range.end.row = foldLine.end.row;
958
+ line = "x";
959
+ }
960
+ if (/^\s*$/.test(line)) {
961
+ range.end.row++;
962
+ line = editor.session.getLine(range.end.row);
963
+ range.end.column = /^\s*$/.test(line) ? line.length : 0;
964
+ }
965
+ var text = editor.session.getTextRange(range);
966
+ if (editor.prevOp.command == this)
967
+ exports.killRing.append(text);
968
+ else
969
+ exports.killRing.add(text);
970
+ editor.session.remove(range);
971
+ editor.clearSelection();
972
+ },
973
+ yank: function (editor) {
974
+ editor.onPaste(exports.killRing.get() || '');
975
+ editor.keyBinding.$data.lastCommand = "yank";
976
+ },
977
+ yankRotate: function (editor) {
978
+ if (editor.keyBinding.$data.lastCommand != "yank")
979
+ return;
980
+ editor.undo();
981
+ editor.session.$emacsMarkRing.pop(); // also undo recording mark
982
+ editor.onPaste(exports.killRing.rotate());
983
+ editor.keyBinding.$data.lastCommand = "yank";
984
+ },
985
+ killRegion: {
986
+ exec: function (editor) {
987
+ exports.killRing.add(editor.getCopyText());
988
+ editor.commands.byName.cut.exec(editor);
989
+ editor.setEmacsMark(null);
990
+ },
991
+ readOnly: true,
992
+ multiSelectAction: "forEach"
993
+ },
994
+ killRingSave: {
995
+ exec: function (editor) {
996
+ editor.$handlesEmacsOnCopy = true;
997
+ var marks = editor.session.$emacsMarkRing.slice(), deselectedMarks = [];
998
+ exports.killRing.add(editor.getCopyText());
999
+ setTimeout(function () {
1000
+ function deselect() {
1001
+ var sel = editor.selection, range = sel.getRange(), pos = sel.isBackwards() ? range.end : range.start;
1002
+ deselectedMarks.push({ row: pos.row, column: pos.column });
1003
+ sel.clearSelection();
1004
+ }
1005
+ editor.$handlesEmacsOnCopy = false;
1006
+ if (editor.inMultiSelectMode)
1007
+ editor.forEachSelection({ exec: deselect });
1008
+ else
1009
+ deselect();
1010
+ editor.setEmacsMark(null);
1011
+ editor.session.$emacsMarkRing = marks.concat(deselectedMarks.reverse());
1012
+ }, 0);
1013
+ },
1014
+ readOnly: true
1015
+ },
1016
+ keyboardQuit: function (editor) {
1017
+ editor.selection.clearSelection();
1018
+ editor.setEmacsMark(null);
1019
+ editor.keyBinding.$data.count = null;
1020
+ },
1021
+ focusCommandLine: function (editor, arg) {
1022
+ if (editor.showCommandLine)
1023
+ editor.showCommandLine(arg);
1024
+ }
1025
+ });
1026
+ exports.handler.addCommands(iSearchCommandModule.iSearchStartCommands);
1027
+ var commands = exports.handler.commands;
1028
+ commands.yank.isYank = true;
1029
+ commands.yankRotate.isYank = true;
1030
+ exports.killRing = {
1031
+ $data: [],
1032
+ add: function (str) {
1033
+ str && this.$data.push(str);
1034
+ if (this.$data.length > 30)
1035
+ this.$data.shift();
1036
+ },
1037
+ append: function (str) {
1038
+ var idx = this.$data.length - 1;
1039
+ var text = this.$data[idx] || "";
1040
+ if (str)
1041
+ text += str;
1042
+ if (text)
1043
+ this.$data[idx] = text;
1044
+ },
1045
+ get: function (n) {
1046
+ n = n || 1;
1047
+ return this.$data.slice(this.$data.length - n, this.$data.length).reverse().join('\n');
1048
+ },
1049
+ pop: function () {
1050
+ if (this.$data.length > 1)
1051
+ this.$data.pop();
1052
+ return this.get();
1053
+ },
1054
+ rotate: function () {
1055
+ this.$data.unshift(this.$data.pop());
1056
+ return this.get();
1057
+ }
1058
+ };
1059
+
1060
+ }); (function() {
1061
+ ace.require(["ace/keyboard/emacs"], function(m) {
1062
+ if (typeof module == "object" && typeof exports == "object" && module) {
1063
+ module.exports = m;
1064
+ }
1065
+ });
1066
+ })();
1067
+