UNPKG

105 kBTypeScriptView Raw
1declare namespace AceAjax {
2 export interface Delta {
3 action: "insert" | "remove";
4 start: Position;
5 end: Position;
6 lines: string[];
7 }
8
9 export interface EditorCommand {
10 name?: string | undefined;
11 bindKey?: string | { mac?: string | undefined; win?: string | undefined } | undefined;
12 exec: (editor: Editor, args?: any) => void;
13 readOnly?: boolean | undefined;
14 }
15
16 interface CommandMap {
17 [name: string]: EditorCommand;
18 }
19
20 type execEventHandler = (obj: {
21 editor: Editor;
22 command: EditorCommand;
23 args: any[];
24 }) => void;
25
26 type CommandLike = EditorCommand | ((editor: Editor) => void);
27
28 export interface CommandManager {
29 byName: CommandMap;
30 commands: CommandMap;
31 on(name: "exec", callback: execEventHandler): Function;
32 on(name: "afterExec", callback: execEventHandler): Function;
33 once(name: string, callback: Function): void;
34 setDefaultHandler(name: string, callback: Function): void;
35 removeDefaultHandler(name: string, callback: Function): void;
36 on(name: string, callback: Function, capturing?: boolean): Function;
37 addEventListener(name: string, callback: Function, capturing?: boolean): void;
38 off(name: string, callback: Function): void;
39 removeListener(name: string, callback: Function): void;
40 removeEventListener(name: string, callback: Function): void;
41 exec(command: string, editor: Editor, args: any): boolean;
42 toggleRecording(editor: Editor): void;
43 replay(editor: Editor): void;
44 addCommand(command: EditorCommand): void;
45 addCommands(commands: EditorCommand[]): void;
46 removeCommand(command: EditorCommand | string, keepCommand?: boolean): void;
47 removeCommands(command: EditorCommand[]): void;
48 bindKey(
49 key: string | { mac?: string | undefined; win?: string | undefined },
50 command: CommandLike,
51 position?: number,
52 ): void;
53 bindKeys(keys: { [s: string]: Function }): void;
54 parseKeys(keyPart: string): { key: string; hashId: number };
55 findKeyCommand(hashId: number, keyString: string): string | undefined;
56 handleKeyboard(
57 data: {},
58 hashId: number,
59 keyString: string,
60 keyCode: string | number,
61 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
62 ): void | { command: string };
63 getStatusText(editor: Editor, data: {}): string;
64 platform: string;
65 }
66
67 export interface Annotation {
68 row?: number | undefined;
69 column?: number | undefined;
70 text: string;
71 type: string;
72 }
73
74 export interface TokenInfo {
75 type: string;
76 value: string;
77 index?: number | undefined;
78 start?: number | undefined;
79 }
80
81 export interface Position {
82 row: number;
83 column: number;
84 }
85
86 export interface KeyboardHandler {
87 handleKeyboard: Function;
88 }
89
90 export interface KeyBinding {
91 setDefaultHandler(kb: KeyboardHandler): void;
92 setKeyboardHandler(kb: KeyboardHandler): void;
93 addKeyboardHandler(kb: KeyboardHandler, pos: number): void;
94 removeKeyboardHandler(kb: KeyboardHandler): boolean;
95 getKeyboardHandler(): KeyboardHandler;
96 onCommandKey(e: any, hashId: number, keyCode: number): boolean;
97 onTextInput(text: string): boolean;
98 }
99
100 export interface TextMode {
101 getTokenizer(): Tokenizer;
102 toggleCommentLines(state: any, session: IEditSession, startRow: number, endRow: number): void;
103 toggleBlockComment(state: any, session: IEditSession, range: Range, cursor: Position): void;
104 getNextLineIndent(state: any, line: string, tab: string): string;
105 checkOutdent(state: any, line: string, input: string): boolean;
106 autoOutdent(state: any, doc: Document, row: number): void;
107 createWorker(session: IEditSession): any;
108 createModeDelegates(mapping: { [key: string]: string }): void;
109 transformAction(state: string, action: string, editor: Editor, session: IEditSession, text: string): any;
110 getKeywords(append?: boolean): Array<string | RegExp>;
111 getCompletions(state: string, session: IEditSession, pos: Position, prefix: string): Completion[];
112 }
113
114 export interface OptionProvider {
115 /**
116 * Sets a Configuration Option
117 */
118 setOption(optionName: string, optionValue: any): void;
119
120 /**
121 * Sets Configuration Options
122 */
123 setOptions(keyValueTuples: { [key: string]: any }): void;
124
125 /**
126 * Get a Configuration Option
127 */
128 getOption(name: string): any;
129
130 /**
131 * Get Configuration Options
132 */
133 getOptions(optionNames?: string[] | { [key: string]: any }): { [key: string]: any };
134 }
135
136 ////////////////
137 /// Ace
138 ////////////////
139
140 /**
141 * The main class required to set up an Ace instance in the browser.
142 */
143 export interface Ace {
144 /**
145 * Provides access to require in packed noconflict mode
146 * @param moduleName
147 */
148 require(moduleName: string): any;
149
150 /**
151 * Embeds the Ace editor into the DOM, at the element provided by `el`.
152 * @param el Either the id of an element, or the element itself
153 */
154 edit(el: string): Editor;
155
156 /**
157 * Embeds the Ace editor into the DOM, at the element provided by `el`.
158 * @param el Either the id of an element, or the element itself
159 */
160 edit(el: HTMLElement): Editor;
161
162 /**
163 * Creates a new [[EditSession]], and returns the associated [[Document]].
164 * @param text {:textParam}
165 * @param mode {:modeParam}
166 */
167 createEditSession(text: Document, mode: TextMode): IEditSession;
168
169 /**
170 * Creates a new [[EditSession]], and returns the associated [[Document]].
171 * @param text {:textParam}
172 * @param mode {:modeParam}
173 */
174 createEditSession(text: string, mode: TextMode): IEditSession;
175 }
176
177 ////////////////
178 /// Anchor
179 ////////////////
180
181 /**
182 * Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.
183 */
184 export interface Anchor {
185 on(event: string, fn: (e: any) => any): void;
186
187 /**
188 * Returns an object identifying the `row` and `column` position of the current anchor.
189 */
190 getPosition(): Position;
191
192 /**
193 * Returns the current document.
194 */
195 getDocument(): Document;
196
197 /**
198 * Fires whenever the anchor position changes.
199 * Both of these objects have a `row` and `column` property corresponding to the position.
200 * Events that can trigger this function include [[Anchor.setPosition `setPosition()`]].
201 * @param e An object containing information about the anchor position. It has two properties:
202 * - `old`: An object describing the old Anchor position
203 * - `value`: An object describing the new Anchor position
204 */
205 onChange(e: any): void;
206
207 /**
208 * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
209 * @param row The row index to move the anchor to
210 * @param column The column index to move the anchor to
211 * @param noClip Identifies if you want the position to be clipped
212 */
213 setPosition(row: number, column: number, noClip?: boolean): void;
214
215 /**
216 * When called, the `'change'` event listener is removed.
217 */
218 detach(): void;
219
220 attach(doc: Document): void;
221 }
222 var Anchor: {
223 /**
224 * Creates a new `Anchor` and associates it with a document.
225 * @param doc The document to associate with the anchor
226 * @param row The starting row position
227 * @param column The starting column position
228 */
229 new(doc: Document, row: number, column: number): Anchor;
230 };
231
232 ////////////////////////////////
233 /// BackgroundTokenizer
234 ////////////////////////////////
235
236 /**
237 * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use.
238 * If a certain row is changed, everything below that row is re-tokenized.
239 */
240 export interface BackgroundTokenizer {
241 states: any[];
242
243 /**
244 * Sets a new tokenizer for this object.
245 * @param tokenizer The new tokenizer to use
246 */
247 setTokenizer(tokenizer: Tokenizer): void;
248
249 /**
250 * Sets a new document to associate with this object.
251 * @param doc The new document to associate with
252 */
253 setDocument(doc: Document): void;
254
255 /**
256 * Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
257 * @param firstRow The starting row region
258 * @param lastRow The final row region
259 */
260 fireUpdateEvent(firstRow: number, lastRow: number): void;
261
262 /**
263 * Starts tokenizing at the row indicated.
264 * @param startRow The row to start at
265 */
266 start(startRow: number): void;
267
268 /**
269 * Stops tokenizing.
270 */
271 stop(): void;
272
273 /**
274 * Gives list of tokens of the row. (tokens are cached)
275 * @param row The row to get tokens at
276 */
277 getTokens(row: number): TokenInfo[];
278
279 /**
280 * [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState}
281 * @param row The row to get state at
282 */
283 getState(row: number): string;
284 }
285 var BackgroundTokenizer: {
286 /**
287 * Creates a new `BackgroundTokenizer` object.
288 * @param tokenizer The tokenizer to use
289 * @param editor The editor to associate with
290 */
291 new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer;
292 };
293
294 ////////////////
295 /// Document
296 ////////////////
297
298 /**
299 * Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s.
300 * At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
301 */
302
303 type NewLineMode = "auto" | "unix" | "windows";
304
305 export interface Document {
306 on(event: string, fn: (e: any) => any): void;
307
308 /**
309 * Replaces all the lines in the current `Document` with the value of `text`.
310 * @param text The text to use
311 */
312 setValue(text: string): void;
313
314 /**
315 * Returns all the lines in the document as a single string, split by the new line character.
316 */
317 getValue(): string;
318
319 /**
320 * Creates a new `Anchor` to define a floating point in the document.
321 * @param row The row number to use
322 * @param column The column number to use
323 */
324 createAnchor(row: number, column: number): void;
325
326 /**
327 * Returns the newline character that's being used, depending on the value of `newLineMode`.
328 */
329 getNewLineCharacter(): string;
330
331 /**
332 * [Sets the new line mode.]{: #Document.setNewLineMode.desc}
333 * @param newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
334 */
335 setNewLineMode(newLineMode: NewLineMode): void;
336
337 /**
338 * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
339 */
340 getNewLineMode(): NewLineMode;
341
342 /**
343 * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
344 * @param text The text to check
345 */
346 isNewLine(text: string): boolean;
347
348 /**
349 * Returns a verbatim copy of the given line as it is in the document
350 * @param row The row index to retrieve
351 */
352 getLine(row: number): string;
353
354 /**
355 * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
356 * @param firstRow The first row index to retrieve
357 * @param lastRow The final row index to retrieve
358 */
359 getLines(firstRow: number, lastRow: number): string[];
360
361 /**
362 * Returns all lines in the document as string array. Warning: The caller should not modify this array!
363 */
364 getAllLines(): string[];
365
366 /**
367 * Returns the number of rows in the document.
368 */
369 getLength(): number;
370
371 /**
372 * [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
373 * @param range The range to work with
374 */
375 getTextRange(range: Range): string;
376
377 getLinesForRange(range: Range): string[];
378
379 /**
380 * Inserts a block of `text` and the indicated `position`.
381 * @param position The position to start inserting at
382 * @param text A chunk of text to insert
383 */
384 insert(position: Position, text: string): Position;
385
386 /**
387 * @deprecated Use the insertFullLines method instead.
388 */
389 insertLines(row: number, lines: string[]): Position;
390
391 /**
392 * Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event.
393 * @param {Number} row The index of the row to insert at
394 * @param {Array} lines An array of strings
395 * @returns {Object} Contains the final row and column, like this:
396 * ```
397 * {row: endRow, column: 0}
398 * ```
399 * If `lines` is empty, this function returns an object containing the current row, and column, like this:
400 * ```
401 * {row: row, column: 0}
402 * ```
403 */
404 insertFullLines(row: number, lines: string[]): void;
405
406 /**
407 * @deprecated Use insertMergedLines(position, ['', '']) instead.
408 */
409 insertNewLine(position: Position): Position;
410
411 /**
412 * Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event.
413 * @param {Number} row The index of the row to insert at
414 * @param {Array} lines An array of strings
415 * @returns {Object} Contains the final row and column, like this:
416 * ```
417 * {row: endRow, column: 0}
418 * ```
419 * If `lines` is empty, this function returns an object containing the current row, and column, like this:
420 * ```
421 * {row: row, column: 0}
422 * ```
423 */
424 insertMergedLines(row: number, lines: string[]): Position;
425
426 /**
427 * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
428 * @param position The position to insert at
429 * @param text A chunk of text
430 */
431 insertInLine(position: Position, text: string): Position;
432
433 clippedPos(row: number, column: number): Position;
434 clonePos(pos: Position): Position;
435 pos(row: number, column: number): Position;
436
437 /**
438 * Removes the `range` from the document.
439 * @param range A specified Range to remove
440 */
441 remove(range: Range): Position;
442
443 /**
444 * Removes the specified columns from the `row`. This method also triggers the `'change'` event.
445 * @param row The row to remove from
446 * @param startColumn The column to start removing at
447 * @param endColumn The column to stop removing at
448 */
449 removeInLine(row: number, startColumn: number, endColumn: number): Position;
450
451 /**
452 * @deprecated Use the removeFullLines method instead.
453 */
454 removeLines(firstRow: number, lastRow: number): string[];
455
456 /**
457 * Removes a range of full lines. This method also triggers the `"change"` event.
458 * @param {Number} firstRow The first row to be removed
459 * @param {Number} lastRow The last row to be removed
460 * @returns {[String]} Returns all the removed lines.
461 */
462 removeFullLines(firstRow: number, lastRow: number): string[];
463
464 /**
465 * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
466 * @param row The row to check
467 */
468 removeNewLine(row: number): void;
469
470 /**
471 * Replaces a range in the document with the new `text`.
472 * @param range A specified Range to replace
473 * @param text The new text to use as a replacement
474 */
475 replace(range: Range, text: string): Position;
476
477 /**
478 * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
479 */
480 applyDeltas(deltas: Delta[]): void;
481
482 /**
483 * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
484 */
485 revertDeltas(deltas: Delta[]): void;
486
487 /**
488 * Converts an index position in a document to a `{row, column}` object.
489 * Index refers to the "absolute position" of a character in the document. For example:
490 * ```javascript
491 * var x = 0; // 10 characters, plus one for newline
492 * var y = -1;
493 * ```
494 * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second.
495 * @param index An index to convert
496 * @param startRow=0 The row from which to start the conversion
497 */
498 indexToPosition(index: number, startRow: number): Position;
499
500 /**
501 * Converts the `{row, column}` position in a document to the character's index.
502 * Index refers to the "absolute position" of a character in the document. For example:
503 * ```javascript
504 * var x = 0; // 10 characters, plus one for newline
505 * var y = -1;
506 * ```
507 * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second.
508 * @param pos The `{row, column}` to convert
509 * @param startRow=0 The row from which to start the conversion
510 */
511 positionToIndex(pos: Position, startRow?: number): number;
512 }
513 var Document: {
514 /**
515 * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
516 * @param text The starting text
517 */
518 new(text?: string): Document;
519 /**
520 * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
521 * @param text The starting text
522 */
523 new(text?: string[]): Document;
524 };
525
526 ////////////////////////////////
527 /// EditSession
528 ////////////////////////////////
529
530 /**
531 * Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state.
532 * `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s.
533 */
534 export interface IEditSession extends OptionProvider {
535 selection: Selection;
536
537 bgTokenizer: BackgroundTokenizer;
538
539 doc: Document;
540
541 on(event: string, fn: (e: any) => any): void;
542
543 findMatchingBracket(position: Position): void;
544
545 addFold(text: string, range: Range): void;
546
547 getFoldAt(row: number, column: number): any;
548
549 removeFold(arg: any): void;
550
551 expandFold(arg: any): void;
552
553 foldAll(startRow?: number, endRow?: number, depth?: number): void;
554
555 unfold(arg1: any, arg2: boolean): void;
556
557 screenToDocumentColumn(row: number, column: number): void;
558
559 getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any;
560
561 getFoldsInRange(range: Range): any;
562
563 highlight(text: string): void;
564
565 /**
566 * Highlight lines from `startRow` to `EndRow`.
567 * @param startRow Define the start line of the highlight
568 * @param endRow Define the end line of the highlight
569 * @param clazz Set the CSS class for the marker
570 * @param inFront Set to `true` to establish a front marker
571 */
572 highlightLines(startRow: number, endRow: number, clazz: string, inFront: boolean): Range;
573
574 /**
575 * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`.
576 * @param doc The new `Document` to use
577 */
578 setDocument(doc: Document): void;
579
580 /**
581 * Returns the `Document` associated with this session.
582 */
583 getDocument(): Document;
584
585 /**
586 * undefined
587 * @param row The row to work with
588 */
589 $resetRowCache(row: number): void;
590
591 /**
592 * Sets the session text.
593 * @param text The new text to place
594 */
595 setValue(text: string): void;
596
597 setMode(mode: string): void;
598
599 /**
600 * Returns the current [[Document `Document`]] as a string.
601 */
602 getValue(): string;
603
604 /**
605 * Returns the string of the current selection.
606 */
607 getSelection(): Selection;
608
609 /**
610 * {:BackgroundTokenizer.getState}
611 * @param row The row to start at
612 */
613 getState(row: number): string;
614
615 /**
616 * Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
617 * @param row The row to start at
618 */
619 getTokens(row: number): TokenInfo[];
620
621 /**
622 * Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
623 * @param row The row number to retrieve from
624 * @param column The column number to retrieve from
625 */
626 getTokenAt(row: number, column: number): TokenInfo | null;
627
628 /**
629 * Sets the undo manager.
630 * @param undoManager The new undo manager
631 */
632 setUndoManager(undoManager: UndoManager): void;
633
634 /**
635 * Returns the current undo manager.
636 */
637 getUndoManager(): UndoManager;
638
639 /**
640 * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]): void; otherwise it's simply `'\t'`.
641 */
642 getTabString(): string;
643
644 /**
645 * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`).
646 * @param useSoftTabs Value indicating whether or not to use soft tabs
647 */
648 setUseSoftTabs(useSoftTabs: boolean): void;
649
650 /**
651 * Returns `true` if soft tabs are being used, `false` otherwise.
652 */
653 getUseSoftTabs(): boolean;
654
655 /**
656 * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event.
657 * @param tabSize The new tab size
658 */
659 setTabSize(tabSize: number): void;
660
661 /**
662 * Returns the current tab size.
663 */
664 getTabSize(): number;
665
666 /**
667 * Returns `true` if the character at the position is a soft tab.
668 * @param position The position to check
669 */
670 isTabStop(position: any): boolean;
671
672 /**
673 * Pass in `true` to enable overwrites in your session, or `false` to disable.
674 * If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
675 * @param overwrite Defines wheter or not to set overwrites
676 */
677 setOverwrite(overwrite: boolean): void;
678
679 /**
680 * Returns `true` if overwrites are enabled; `false` otherwise.
681 */
682 getOverwrite(): boolean;
683
684 /**
685 * Sets the value of overwrite to the opposite of whatever it currently is.
686 */
687 toggleOverwrite(): void;
688
689 /**
690 * Adds `className` to the `row`, to be used for CSS stylings and whatnot.
691 * @param row The row number
692 * @param className The class to add
693 */
694 addGutterDecoration(row: number, className: string): void;
695
696 /**
697 * Removes `className` from the `row`.
698 * @param row The row number
699 * @param className The class to add
700 */
701 removeGutterDecoration(row: number, className: string): void;
702
703 /**
704 * Returns an array of numbers, indicating which rows have breakpoints.
705 */
706 getBreakpoints(): number[];
707
708 /**
709 * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
710 * @param rows An array of row indices
711 */
712 setBreakpoints(rows: any[]): void;
713
714 /**
715 * Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event.
716 */
717 clearBreakpoints(): void;
718
719 /**
720 * Sets a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
721 * @param row A row index
722 * @param className Class of the breakpoint
723 */
724 setBreakpoint(row: number, className: string): void;
725
726 /**
727 * Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
728 * @param row A row index
729 */
730 clearBreakpoint(row: number): void;
731
732 /**
733 * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
734 * @param range Define the range of the marker
735 * @param clazz Set the CSS class for the marker
736 * @param type Identify the type of the marker
737 * @param inFront Set to `true` to establish a front marker
738 */
739 addMarker(range: Range, clazz: string, type: Function, inFront: boolean): number;
740
741 /**
742 * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
743 * @param range Define the range of the marker
744 * @param clazz Set the CSS class for the marker
745 * @param type Identify the type of the marker
746 * @param inFront Set to `true` to establish a front marker
747 */
748 addMarker(range: Range, clazz: string, type: string, inFront: boolean): number;
749
750 /**
751 * Adds a dynamic marker to the session.
752 * @param marker object with update method
753 * @param inFront Set to `true` to establish a front marker
754 */
755 addDynamicMarker(marker: any, inFront: boolean): void;
756
757 /**
758 * Removes the marker with the specified ID. If this marker was in front, the `'changeFrontMarker'` event is emitted. If the marker was in the back, the `'changeBackMarker'` event is emitted.
759 * @param markerId A number representing a marker
760 */
761 removeMarker(markerId: number): void;
762
763 /**
764 * Returns an array containing the IDs of all the markers, either front or back.
765 * @param inFront If `true`, indicates you only want front markers; `false` indicates only back markers
766 */
767 getMarkers(inFront: boolean): any[];
768
769 /**
770 * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
771 * @param annotations A list of annotations
772 */
773 setAnnotations(annotations: Annotation[]): void;
774
775 /**
776 * Returns the annotations for the `EditSession`.
777 */
778 getAnnotations(): any;
779
780 /**
781 * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event.
782 */
783 clearAnnotations(): void;
784
785 /**
786 * If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value.
787 * @param text A block of text
788 */
789 $detectNewLine(text: string): void;
790
791 /**
792 * Given a starting row and column, this method returns the `Range` of the first word boundary it finds.
793 * @param row The row to start at
794 * @param column The column to start at
795 */
796 getWordRange(row: number, column: number): Range;
797
798 /**
799 * Gets the range of a word, including its right whitespace.
800 * @param row The row number to start from
801 * @param column The column number to start from
802 */
803 getAWordRange(row: number, column: number): any;
804
805 /**
806 * {:Document.setNewLineMode.desc}
807 * @param newLineMode {:Document.setNewLineMode.param}
808 */
809 setNewLineMode(newLineMode: string): void;
810
811 /**
812 * Returns the current new line mode.
813 */
814 getNewLineMode(): string;
815
816 /**
817 * Identifies if you want to use a worker for the `EditSession`.
818 * @param useWorker Set to `true` to use a worker
819 */
820 setUseWorker(useWorker: boolean): void;
821
822 /**
823 * Returns `true` if workers are being used.
824 */
825 getUseWorker(): boolean;
826
827 /**
828 * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event.
829 */
830 onReloadTokenizer(): void;
831
832 /**
833 * Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted.
834 * @param mode Set a new text mode
835 */
836 $mode(mode: TextMode): void;
837
838 /**
839 * Returns the current text mode.
840 */
841 getMode(): TextMode;
842
843 /**
844 * This function sets the scroll top value. It also emits the `'changeScrollTop'` event.
845 * @param scrollTop The new scroll top value
846 */
847 setScrollTop(scrollTop: number): void;
848
849 /**
850 * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}
851 */
852 getScrollTop(): number;
853
854 /**
855 * [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}
856 * @param scrollLeft The new scroll left value
857 */
858 setScrollLeft(scrollLeft: number): void;
859
860 /**
861 * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}
862 */
863 getScrollLeft(): number;
864
865 /**
866 * Returns the width of the screen.
867 */
868 getScreenWidth(): number;
869
870 /**
871 * Returns a verbatim copy of the given line as it is in the document
872 * @param row The row to retrieve from
873 */
874 getLine(row: number): string;
875
876 /**
877 * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
878 * @param firstRow The first row index to retrieve
879 * @param lastRow The final row index to retrieve
880 */
881 getLines(firstRow: number, lastRow: number): string[];
882
883 /**
884 * Returns the number of rows in the document.
885 */
886 getLength(): number;
887
888 /**
889 * {:Document.getTextRange.desc}
890 * @param range The range to work with
891 */
892 getTextRange(range: Range): string;
893
894 /**
895 * Inserts a block of `text` and the indicated `position`.
896 * @param position The position {row, column} to start inserting at
897 * @param text A chunk of text to insert
898 */
899 insert(position: Position, text: string): any;
900
901 /**
902 * Removes the `range` from the document.
903 * @param range A specified Range to remove
904 */
905 remove(range: Range): any;
906
907 /**
908 * Reverts previous changes to your document.
909 * @param deltas An array of previous changes
910 * @param dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect}
911 */
912 undoChanges(deltas: any[], dontSelect: boolean): Range;
913
914 /**
915 * Re-implements a previously undone change to your document.
916 * @param deltas An array of previous changes
917 * @param dontSelect {:dontSelect}
918 */
919 redoChanges(deltas: any[], dontSelect: boolean): Range;
920
921 /**
922 * Enables or disables highlighting of the range where an undo occured.
923 * @param enable If `true`, selects the range of the reinserted change
924 */
925 setUndoSelect(enable: boolean): void;
926
927 /**
928 * Replaces a range in the document with the new `text`.
929 * @param range A specified Range to replace
930 * @param text The new text to use as a replacement
931 */
932 replace(range: Range, text: string): any;
933
934 /**
935 * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this:
936 * ```json
937 * { row: newRowLocation, column: newColumnLocation }
938 * ```
939 * @param fromRange The range of text you want moved within the document
940 * @param toPosition The location (row and column) where you want to move the text to
941 */
942 moveText(fromRange: Range, toPosition: any): Range;
943
944 /**
945 * Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`.
946 * If `indentString` contains the `'\t'` character, it's replaced by whatever is defined by [[EditSession.getTabString `getTabString()`]].
947 * @param startRow Starting row
948 * @param endRow Ending row
949 * @param indentString The indent token
950 */
951 indentRows(startRow: number, endRow: number, indentString: string): void;
952
953 /**
954 * Outdents all the rows defined by the `start` and `end` properties of `range`.
955 * @param range A range of rows
956 */
957 outdentRows(range: Range): void;
958
959 /**
960 * Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`.
961 * @param firstRow The starting row to move up
962 * @param lastRow The final row to move up
963 */
964 moveLinesUp(firstRow: number, lastRow: number): number;
965
966 /**
967 * Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`.
968 * @param firstRow The starting row to move down
969 * @param lastRow The final row to move down
970 */
971 moveLinesDown(firstRow: number, lastRow: number): number;
972
973 /**
974 * Duplicates all the text between `firstRow` and `lastRow`.
975 * @param firstRow The starting row to duplicate
976 * @param lastRow The final row to duplicate
977 */
978 duplicateLines(firstRow: number, lastRow: number): number;
979
980 /**
981 * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted.
982 * @param useWrapMode Enable (or disable) wrap mode
983 */
984 setUseWrapMode(useWrapMode: boolean): void;
985
986 /**
987 * Returns `true` if wrap mode is being used; `false` otherwise.
988 */
989 getUseWrapMode(): boolean;
990
991 /**
992 * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event.
993 * @param min The minimum wrap value (the left side wrap)
994 * @param max The maximum wrap value (the right side wrap)
995 */
996 setWrapLimitRange(min: number, max: number): void;
997
998 /**
999 * This should generally only be called by the renderer when a resize is detected.
1000 * @param desiredLimit The new wrap limit
1001 */
1002 adjustWrapLimit(desiredLimit: number): boolean;
1003
1004 /**
1005 * Returns the value of wrap limit.
1006 */
1007 getWrapLimit(): number;
1008
1009 /**
1010 * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this:
1011 * { min: wrapLimitRange_min, max: wrapLimitRange_max }
1012 */
1013 getWrapLimitRange(): any;
1014
1015 /**
1016 * Given a string, returns an array of the display characters, including tabs and spaces.
1017 * @param str The string to check
1018 * @param offset The value to start at
1019 */
1020 $getDisplayTokens(str: string, offset: number): void;
1021
1022 /**
1023 * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen.
1024 * @param str The string to calculate the screen width of
1025 * @param maxScreenColumn
1026 * @param screenColumn
1027 */
1028 $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[];
1029
1030 /**
1031 * Returns number of screenrows in a wrapped line.
1032 * @param row The row number to check
1033 */
1034 getRowLength(row: number): number;
1035
1036 /**
1037 * Returns the position (on screen) for the last character in the provided screen row.
1038 * @param screenRow The screen row to check
1039 */
1040 getScreenLastRowColumn(screenRow: number): number;
1041
1042 /**
1043 * For the given document row and column, this returns the column position of the last screen row.
1044 * @param docRow
1045 * @param docColumn
1046 */
1047 getDocumentLastRowColumn(docRow: number, docColumn: number): number;
1048
1049 /**
1050 * For the given document row and column, this returns the document position of the last row.
1051 * @param docRow
1052 * @param docColumn
1053 */
1054 getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number;
1055
1056 /**
1057 * For the given row, this returns the split data.
1058 */
1059 getRowSplitData(): string;
1060
1061 /**
1062 * The distance to the next tab stop at the specified screen column.
1063 * @param screenColumn The screen column to check
1064 */
1065 getScreenTabSize(screenColumn: number): number;
1066
1067 /**
1068 * Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}
1069 * @param screenRow The screen row to check
1070 * @param screenColumn The screen column to check
1071 */
1072 screenToDocumentPosition(screenRow: number, screenColumn: number): any;
1073
1074 /**
1075 * Converts document coordinates to screen coordinates. {:conversionConsiderations}
1076 * @param docRow The document row to check
1077 * @param docColumn The document column to check
1078 */
1079 documentToScreenPosition(docRow: number, docColumn: number): any;
1080
1081 /**
1082 * For the given document row and column, returns the screen column.
1083 * @param row
1084 * @param docColumn
1085 */
1086 documentToScreenColumn(row: number, docColumn: number): number;
1087
1088 /**
1089 * For the given document row and column, returns the screen row.
1090 * @param docRow
1091 * @param docColumn
1092 */
1093 documentToScreenRow(docRow: number, docColumn: number): void;
1094
1095 /**
1096 * Returns the length of the screen.
1097 */
1098 getScreenLength(): number;
1099 }
1100 var EditSession: {
1101 /**
1102 * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`.
1103 * @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam}
1104 * @param mode [The inital language mode to use for the document]{: #modeParam}
1105 */
1106 new(text: string, mode?: TextMode): IEditSession;
1107
1108 new(content: string, mode?: string): IEditSession;
1109
1110 new(text: string[], mode?: string): IEditSession;
1111 };
1112
1113 ////////////////////////////////
1114 /// Editor
1115 ////////////////////////////////
1116
1117 /**
1118 * The main entry point into the Ace functionality.
1119 * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.
1120 * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
1121 */
1122 export interface Editor extends OptionProvider {
1123 on(ev: string, callback: (e: any) => any): void;
1124
1125 addEventListener(ev: "change", callback: (ev: EditorChangeEvent) => any): void;
1126 addEventListener(ev: string, callback: Function): void;
1127
1128 off(ev: string, callback: Function): void;
1129
1130 removeListener(ev: string, callback: Function): void;
1131
1132 removeEventListener(ev: string, callback: Function): void;
1133
1134 inMultiSelectMode: boolean;
1135
1136 selectMoreLines(n: number): void;
1137
1138 onTextInput(text: string): void;
1139
1140 onCommandKey(e: any, hashId: number, keyCode: number): void;
1141
1142 commands: CommandManager;
1143
1144 session: IEditSession;
1145
1146 selection: Selection;
1147
1148 renderer: VirtualRenderer;
1149
1150 keyBinding: KeyBinding;
1151
1152 container: HTMLElement;
1153
1154 onSelectionChange(e: any): void;
1155
1156 onChangeMode(e?: any): void;
1157
1158 execCommand(command: string, args?: any): void;
1159
1160 /**
1161 * Get rid of console warning by setting this to Infinity
1162 */
1163 $blockScrolling: number;
1164
1165 /**
1166 * Sets a new key handler, such as "vim" or "windows".
1167 * @param keyboardHandler The new key handler
1168 */
1169 setKeyboardHandler(keyboardHandler: string): void;
1170
1171 /**
1172 * Returns the keyboard handler, such as "vim" or "windows".
1173 */
1174 getKeyboardHandler(): string;
1175
1176 /**
1177 * Sets a new editsession to use. This method also emits the `'changeSession'` event.
1178 * @param session The new session to use
1179 */
1180 setSession(session: IEditSession): void;
1181
1182 /**
1183 * Returns the current session being used.
1184 */
1185 getSession(): IEditSession;
1186
1187 /**
1188 * Sets the current document to `val`.
1189 * @param val The new value to set for the document
1190 * @param cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end
1191 */
1192 setValue(val: string, cursorPos?: number): string;
1193
1194 /**
1195 * Returns the current session's content.
1196 */
1197 getValue(): string;
1198
1199 /**
1200 * Returns the currently highlighted selection.
1201 */
1202 getSelection(): Selection;
1203
1204 /**
1205 * {:VirtualRenderer.onResize}
1206 * @param force If `true`, recomputes the size, even if the height and width haven't changed
1207 */
1208 resize(force?: boolean): void;
1209
1210 /**
1211 * {:VirtualRenderer.setTheme}
1212 * @param theme The path to a theme
1213 */
1214 setTheme(theme: string): void;
1215
1216 /**
1217 * {:VirtualRenderer.getTheme}
1218 */
1219 getTheme(): string;
1220
1221 /**
1222 * {:VirtualRenderer.setStyle}
1223 * @param style A class name
1224 */
1225 setStyle(style: string): void;
1226
1227 /**
1228 * {:VirtualRenderer.unsetStyle}
1229 */
1230 unsetStyle(): void;
1231
1232 /**
1233 * Set a new font size (in pixels) for the editor text.
1234 * @param size A font size ( _e.g._ "12px")
1235 */
1236 setFontSize(size: string): void;
1237
1238 /**
1239 * Brings the current `textInput` into focus.
1240 */
1241 focus(): void;
1242
1243 /**
1244 * Returns `true` if the current `textInput` is in focus.
1245 */
1246 isFocused(): boolean;
1247
1248 /**
1249 * Blurs the current `textInput`.
1250 */
1251 blur(): void;
1252
1253 /**
1254 * Emitted once the editor comes into focus.
1255 */
1256 onFocus(): void;
1257
1258 /**
1259 * Emitted once the editor has been blurred.
1260 */
1261 onBlur(): void;
1262
1263 /**
1264 * Emitted whenever the document is changed.
1265 * @param e Contains a single property, `data`, which has the delta of changes
1266 */
1267 onDocumentChange(e: any): void;
1268
1269 /**
1270 * Emitted when the selection changes.
1271 */
1272 onCursorChange(): void;
1273
1274 /**
1275 * Returns the string of text currently highlighted.
1276 */
1277 getCopyText(): string;
1278
1279 /**
1280 * Called whenever a text "copy" happens.
1281 */
1282 onCopy(): void;
1283
1284 /**
1285 * Called whenever a text "cut" happens.
1286 */
1287 onCut(): void;
1288
1289 /**
1290 * Called whenever a text "paste" happens.
1291 * @param text The pasted text
1292 */
1293 onPaste(text: string): void;
1294
1295 /**
1296 * Inserts `text` into wherever the cursor is pointing.
1297 * @param text The new text to add
1298 */
1299 insert(text: string): void;
1300
1301 /**
1302 * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
1303 * @param overwrite Defines wheter or not to set overwrites
1304 */
1305 setOverwrite(overwrite: boolean): void;
1306
1307 /**
1308 * Returns `true` if overwrites are enabled; `false` otherwise.
1309 */
1310 getOverwrite(): boolean;
1311
1312 /**
1313 * Sets the value of overwrite to the opposite of whatever it currently is.
1314 */
1315 toggleOverwrite(): void;
1316
1317 /**
1318 * Sets how fast the mouse scrolling should do.
1319 * @param speed A value indicating the new speed (in milliseconds)
1320 */
1321 setScrollSpeed(speed: number): void;
1322
1323 /**
1324 * Returns the value indicating how fast the mouse scroll speed is (in milliseconds).
1325 */
1326 getScrollSpeed(): number;
1327
1328 /**
1329 * Sets the delay (in milliseconds) of the mouse drag.
1330 * @param dragDelay A value indicating the new delay
1331 */
1332 setDragDelay(dragDelay: number): void;
1333
1334 /**
1335 * Returns the current mouse drag delay.
1336 */
1337 getDragDelay(): number;
1338
1339 /**
1340 * Indicates how selections should occur.
1341 * By default, selections are set to "line". There are no other styles at the moment,
1342 * although this code change in the future.
1343 * This function also emits the `'changeSelectionStyle'` event.
1344 * @param style The new selection style
1345 */
1346 setSelectionStyle(style: string): void;
1347
1348 /**
1349 * Returns the current selection style.
1350 */
1351 getSelectionStyle(): string;
1352
1353 /**
1354 * Determines whether or not the current line should be highlighted.
1355 * @param shouldHighlight Set to `true` to highlight the current line
1356 */
1357 setHighlightActiveLine(shouldHighlight: boolean): void;
1358
1359 /**
1360 * Returns `true` if current lines are always highlighted.
1361 */
1362 getHighlightActiveLine(): boolean;
1363
1364 /**
1365 * Determines if the currently selected word should be highlighted.
1366 * @param shouldHighlight Set to `true` to highlight the currently selected word
1367 */
1368 setHighlightSelectedWord(shouldHighlight: boolean): void;
1369
1370 /**
1371 * Returns `true` if currently highlighted words are to be highlighted.
1372 */
1373 getHighlightSelectedWord(): boolean;
1374
1375 /**
1376 * If `showInvisibiles` is set to `true`, invisible characters&mdash;like spaces or new lines&mdash;are show in the editor.
1377 * @param showInvisibles Specifies whether or not to show invisible characters
1378 */
1379 setShowInvisibles(showInvisibles: boolean): void;
1380
1381 /**
1382 * Returns `true` if invisible characters are being shown.
1383 */
1384 getShowInvisibles(): boolean;
1385
1386 /**
1387 * If `showPrintMargin` is set to `true`, the print margin is shown in the editor.
1388 * @param showPrintMargin Specifies whether or not to show the print margin
1389 */
1390 setShowPrintMargin(showPrintMargin: boolean): void;
1391
1392 /**
1393 * Returns `true` if the print margin is being shown.
1394 */
1395 getShowPrintMargin(): boolean;
1396
1397 /**
1398 * Sets the column defining where the print margin should be.
1399 * @param showPrintMargin Specifies the new print margin
1400 */
1401 setPrintMarginColumn(showPrintMargin: number): void;
1402
1403 /**
1404 * Returns the column number of where the print margin is.
1405 */
1406 getPrintMarginColumn(): number;
1407
1408 /**
1409 * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change.
1410 * @param readOnly Specifies whether the editor can be modified or not
1411 */
1412 setReadOnly(readOnly: boolean): void;
1413
1414 /**
1415 * Returns `true` if the editor is set to read-only mode.
1416 */
1417 getReadOnly(): boolean;
1418
1419 /**
1420 * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef}
1421 * @param enabled Enables or disables behaviors
1422 */
1423 setBehavioursEnabled(enabled: boolean): void;
1424
1425 /**
1426 * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef}
1427 */
1428 getBehavioursEnabled(): boolean;
1429
1430 /**
1431 * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets
1432 * when such a character is typed in.
1433 * @param enabled Enables or disables wrapping behaviors
1434 */
1435 setWrapBehavioursEnabled(enabled: boolean): void;
1436
1437 /**
1438 * Returns `true` if the wrapping behaviors are currently enabled.
1439 */
1440 getWrapBehavioursEnabled(): void;
1441
1442 /**
1443 * Indicates whether the fold widgets are shown or not.
1444 * @param show Specifies whether the fold widgets are shown
1445 */
1446 setShowFoldWidgets(show: boolean): void;
1447
1448 /**
1449 * Returns `true` if the fold widgets are shown.
1450 */
1451 getShowFoldWidgets(): void;
1452
1453 /**
1454 * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.
1455 * @param dir The direction of the deletion to occur, either "left" or "right"
1456 */
1457 remove(dir: string): void;
1458
1459 /**
1460 * Removes the word directly to the right of the current selection.
1461 */
1462 removeWordRight(): void;
1463
1464 /**
1465 * Removes the word directly to the left of the current selection.
1466 */
1467 removeWordLeft(): void;
1468
1469 /**
1470 * Removes all the words to the left of the current selection, until the start of the line.
1471 */
1472 removeToLineStart(): void;
1473
1474 /**
1475 * Removes all the words to the right of the current selection, until the end of the line.
1476 */
1477 removeToLineEnd(): void;
1478
1479 /**
1480 * Splits the line at the current selection (by inserting an `'\n'`).
1481 */
1482 splitLine(): void;
1483
1484 /**
1485 * Transposes current line.
1486 */
1487 transposeLetters(): void;
1488
1489 /**
1490 * Converts the current selection entirely into lowercase.
1491 */
1492 toLowerCase(): void;
1493
1494 /**
1495 * Converts the current selection entirely into uppercase.
1496 */
1497 toUpperCase(): void;
1498
1499 /**
1500 * Inserts an indentation into the current cursor position or indents the selected lines.
1501 */
1502 indent(): void;
1503
1504 /**
1505 * Indents the current line.
1506 */
1507 blockIndent(): void;
1508
1509 /**
1510 * Outdents the current line.
1511 */
1512 blockOutdent(arg?: string): void;
1513
1514 /**
1515 * Given the currently selected range, this function either comments all the lines, or uncomments all of them.
1516 */
1517 toggleCommentLines(): void;
1518
1519 /**
1520 * Works like [[EditSession.getTokenAt]], except it returns a number.
1521 */
1522 getNumberAt(): number;
1523
1524 /**
1525 * If the character before the cursor is a number, this functions changes its value by `amount`.
1526 * @param amount The value to change the numeral by (can be negative to decrease value)
1527 */
1528 modifyNumber(amount: number): void;
1529
1530 /**
1531 * Removes all the lines in the current selection
1532 */
1533 removeLines(): void;
1534
1535 /**
1536 * Shifts all the selected lines down one row.
1537 */
1538 moveLinesDown(): number;
1539
1540 /**
1541 * Shifts all the selected lines up one row.
1542 */
1543 moveLinesUp(): number;
1544
1545 /**
1546 * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this:
1547 * ```json
1548 * { row: newRowLocation, column: newColumnLocation }
1549 * ```
1550 * @param fromRange The range of text you want moved within the document
1551 * @param toPosition The location (row and column) where you want to move the text to
1552 */
1553 moveText(fromRange: Range, toPosition: any): Range;
1554
1555 /**
1556 * Copies all the selected lines up one row.
1557 */
1558 copyLinesUp(): number;
1559
1560 /**
1561 * Copies all the selected lines down one row.
1562 */
1563 copyLinesDown(): number;
1564
1565 /**
1566 * {:VirtualRenderer.getFirstVisibleRow}
1567 */
1568 getFirstVisibleRow(): number;
1569
1570 /**
1571 * {:VirtualRenderer.getLastVisibleRow}
1572 */
1573 getLastVisibleRow(): number;
1574
1575 /**
1576 * Indicates if the row is currently visible on the screen.
1577 * @param row The row to check
1578 */
1579 isRowVisible(row: number): boolean;
1580
1581 /**
1582 * Indicates if the entire row is currently visible on the screen.
1583 * @param row The row to check
1584 */
1585 isRowFullyVisible(row: number): boolean;
1586
1587 /**
1588 * Selects the text from the current position of the document until where a "page down" finishes.
1589 */
1590 selectPageDown(): void;
1591
1592 /**
1593 * Selects the text from the current position of the document until where a "page up" finishes.
1594 */
1595 selectPageUp(): void;
1596
1597 /**
1598 * Shifts the document to wherever "page down" is, as well as moving the cursor position.
1599 */
1600 gotoPageDown(): void;
1601
1602 /**
1603 * Shifts the document to wherever "page up" is, as well as moving the cursor position.
1604 */
1605 gotoPageUp(): void;
1606
1607 /**
1608 * Scrolls the document to wherever "page down" is, without changing the cursor position.
1609 */
1610 scrollPageDown(): void;
1611
1612 /**
1613 * Scrolls the document to wherever "page up" is, without changing the cursor position.
1614 */
1615 scrollPageUp(): void;
1616
1617 /**
1618 * Moves the editor to the specified row.
1619 */
1620 scrollToRow(): void;
1621
1622 /**
1623 * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to).
1624 * @param line The line to scroll to
1625 * @param center If `true`
1626 * @param animate If `true` animates scrolling
1627 * @param callback Function to be called when the animation has finished
1628 */
1629 scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
1630
1631 /**
1632 * Attempts to center the current selection on the screen.
1633 */
1634 centerSelection(): void;
1635
1636 /**
1637 * Gets the current position of the cursor.
1638 */
1639 getCursorPosition(): Position;
1640
1641 /**
1642 * Returns the screen position of the cursor.
1643 */
1644 getCursorPositionScreen(): number;
1645
1646 /**
1647 * {:Selection.getRange}
1648 */
1649 getSelectionRange(): Range;
1650
1651 /**
1652 * Selects all the text in editor.
1653 */
1654 selectAll(): void;
1655
1656 /**
1657 * {:Selection.clearSelection}
1658 */
1659 clearSelection(): void;
1660
1661 /**
1662 * Moves the cursor to the specified row and column. Note that this does not de-select the current selection.
1663 * @param row The new row number
1664 * @param column The new column number
1665 */
1666 moveCursorTo(row: number, column?: number, animate?: boolean): void;
1667
1668 /**
1669 * Moves the cursor to the position indicated by `pos.row` and `pos.column`.
1670 * @param position An object with two properties, row and column
1671 */
1672 moveCursorToPosition(position: Position): void;
1673
1674 /**
1675 * Moves the cursor's row and column to the next matching bracket.
1676 */
1677 jumpToMatching(): void;
1678
1679 /**
1680 * Moves the cursor to the specified line number, and also into the indiciated column.
1681 * @param lineNumber The line number to go to
1682 * @param column A column number to go to
1683 * @param animate If `true` animates scolling
1684 */
1685 gotoLine(lineNumber: number, column?: number, animate?: boolean): void;
1686
1687 /**
1688 * Moves the cursor to the specified row and column. Note that this does de-select the current selection.
1689 * @param row The new row number
1690 * @param column The new column number
1691 */
1692 navigateTo(row: number, column: number): void;
1693
1694 /**
1695 * Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.
1696 * @param times The number of times to change navigation
1697 */
1698 navigateUp(times?: number): void;
1699
1700 /**
1701 * Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.
1702 * @param times The number of times to change navigation
1703 */
1704 navigateDown(times?: number): void;
1705
1706 /**
1707 * Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.
1708 * @param times The number of times to change navigation
1709 */
1710 navigateLeft(times?: number): void;
1711
1712 /**
1713 * Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.
1714 * @param times The number of times to change navigation
1715 */
1716 navigateRight(times: number): void;
1717
1718 /**
1719 * Moves the cursor to the start of the current line. Note that this does de-select the current selection.
1720 */
1721 navigateLineStart(): void;
1722
1723 /**
1724 * Moves the cursor to the end of the current line. Note that this does de-select the current selection.
1725 */
1726 navigateLineEnd(): void;
1727
1728 /**
1729 * Moves the cursor to the end of the current file. Note that this does de-select the current selection.
1730 */
1731 navigateFileEnd(): void;
1732
1733 /**
1734 * Moves the cursor to the start of the current file. Note that this does de-select the current selection.
1735 */
1736 navigateFileStart(): void;
1737
1738 /**
1739 * Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.
1740 */
1741 navigateWordRight(): void;
1742
1743 /**
1744 * Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.
1745 */
1746 navigateWordLeft(): void;
1747
1748 /**
1749 * Replaces the first occurance of `options.needle` with the value in `replacement`.
1750 * @param replacement The text to replace with
1751 * @param options The [[Search `Search`]] options to use
1752 */
1753 replace(replacement: string, options?: any): void;
1754
1755 /**
1756 * Replaces all occurances of `options.needle` with the value in `replacement`.
1757 * @param replacement The text to replace with
1758 * @param options The [[Search `Search`]] options to use
1759 */
1760 replaceAll(replacement: string, options?: any): void;
1761
1762 /**
1763 * {:Search.getOptions} For more information on `options`, see [[Search `Search`]].
1764 */
1765 getLastSearchOptions(): any;
1766
1767 /**
1768 * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]].
1769 * @param needle The text to search for (optional)
1770 * @param options An object defining various search properties
1771 * @param animate If `true` animate scrolling
1772 */
1773 find(needle: string, options?: any, animate?: boolean): void;
1774
1775 /**
1776 * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]].
1777 * @param options search options
1778 * @param animate If `true` animate scrolling
1779 */
1780 findNext(options?: any, animate?: boolean): void;
1781
1782 /**
1783 * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]].
1784 * @param options search options
1785 * @param animate If `true` animate scrolling
1786 */
1787 findPrevious(options?: any, animate?: boolean): void;
1788
1789 /**
1790 * {:UndoManager.undo}
1791 */
1792 undo(): void;
1793
1794 /**
1795 * {:UndoManager.redo}
1796 */
1797 redo(): void;
1798
1799 /**
1800 * Cleans up the entire editor.
1801 */
1802 destroy(): void;
1803 }
1804
1805 var Editor: {
1806 /**
1807 * Creates a new `Editor` object.
1808 * @param renderer Associated `VirtualRenderer` that draws everything
1809 * @param session The `EditSession` to refer to
1810 */
1811 new(renderer: VirtualRenderer, session?: IEditSession): Editor;
1812 };
1813
1814 interface EditorChangeEvent {
1815 start: Position;
1816 end: Position;
1817 action: string; // insert, remove
1818 lines: any[];
1819 }
1820
1821 ////////////////////////////////
1822 /// PlaceHolder
1823 ////////////////////////////////
1824
1825 export interface PlaceHolder {
1826 on(event: string, fn: (e: any) => any): void;
1827
1828 /**
1829 * PlaceHolder.setup()
1830 * TODO
1831 */
1832 setup(): void;
1833
1834 /**
1835 * PlaceHolder.showOtherMarkers()
1836 * TODO
1837 */
1838 showOtherMarkers(): void;
1839
1840 /**
1841 * PlaceHolder.hideOtherMarkers()
1842 * Hides all over markers in the [[EditSession `EditSession`]] that are not the currently selected one.
1843 */
1844 hideOtherMarkers(): void;
1845
1846 /**
1847 * PlaceHolder@onUpdate(e)
1848 * Emitted when the place holder updates.
1849 */
1850 onUpdate(): void;
1851
1852 /**
1853 * PlaceHolder@onCursorChange(e)
1854 * Emitted when the cursor changes.
1855 */
1856 onCursorChange(): void;
1857
1858 /**
1859 * PlaceHolder.detach()
1860 * TODO
1861 */
1862 detach(): void;
1863
1864 /**
1865 * PlaceHolder.cancel()
1866 * TODO
1867 */
1868 cancel(): void;
1869 }
1870 var PlaceHolder: {
1871 /**
1872 * - @param session (Document): The document to associate with the anchor
1873 * - @param length (Number): The starting row position
1874 * - @param pos (Number): The starting column position
1875 * - @param others (String):
1876 * - @param mainClass (String):
1877 * - @param othersClass (String):
1878 */
1879 new(
1880 session: Document,
1881 length: number,
1882 pos: number,
1883 others: string,
1884 mainClass: string,
1885 othersClass: string,
1886 ): PlaceHolder;
1887
1888 new(session: IEditSession, length: number, pos: Position, positions: Position[]): PlaceHolder;
1889 };
1890
1891 ////////////////
1892 /// RangeList
1893 ////////////////
1894
1895 export interface IRangeList {
1896 ranges: Range[];
1897
1898 pointIndex(pos: Position, startIndex?: number): void;
1899
1900 addList(ranges: Range[]): void;
1901
1902 add(ranges: Range): void;
1903
1904 merge(): Range[];
1905
1906 substractPoint(pos: Position): void;
1907 }
1908 export var RangeList: {
1909 new(): IRangeList;
1910 };
1911
1912 ////////////////
1913 /// Range
1914 ////////////////
1915
1916 /**
1917 * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column.
1918 */
1919 export interface Range {
1920 startRow: number;
1921
1922 startColumn: number;
1923
1924 endRow: number;
1925
1926 endColumn: number;
1927
1928 start: Position;
1929
1930 end: Position;
1931
1932 isEmpty(): boolean;
1933
1934 /**
1935 * Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`.
1936 * @param range A range to check against
1937 */
1938 isEqual(range: Range): void;
1939
1940 /**
1941 * Returns a string containing the range's row and column information, given like this:
1942 * ```
1943 * [start.row/start.column] -> [end.row/end.column]
1944 * ```
1945 */
1946 toString(): void;
1947
1948 /**
1949 * Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if:
1950 * ```javascript
1951 * this.start.row <= row <= this.end.row &&
1952 * this.start.column <= column <= this.end.column
1953 * ```
1954 * @param row A row to check for
1955 * @param column A column to check for
1956 */
1957 contains(row: number, column: number): boolean;
1958
1959 /**
1960 * Compares `this` range (A) with another range (B).
1961 * @param range A range to compare with
1962 */
1963 compareRange(range: Range): number;
1964
1965 /**
1966 * Checks the row and column points of `p` with the row and column points of the calling range.
1967 * @param p A point to compare with
1968 */
1969 comparePoint(p: Range): number;
1970
1971 /**
1972 * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.
1973 * @param range A range to compare with
1974 */
1975 containsRange(range: Range): boolean;
1976
1977 /**
1978 * Returns `true` if passed in `range` intersects with the one calling this method.
1979 * @param range A range to compare with
1980 */
1981 intersects(range: Range): boolean;
1982
1983 /**
1984 * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.
1985 * @param row A row point to compare with
1986 * @param column A column point to compare with
1987 */
1988 isEnd(row: number, column: number): boolean;
1989
1990 /**
1991 * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.
1992 * @param row A row point to compare with
1993 * @param column A column point to compare with
1994 */
1995 isStart(row: number, column: number): boolean;
1996
1997 /**
1998 * Sets the starting row and column for the range.
1999 * @param row A row point to set
2000 * @param column A column point to set
2001 */
2002 setStart(row: number, column: number): void;
2003
2004 /**
2005 * Sets the starting row and column for the range.
2006 * @param row A row point to set
2007 * @param column A column point to set
2008 */
2009 setEnd(row: number, column: number): void;
2010
2011 /**
2012 * Returns `true` if the `row` and `column` are within the given range.
2013 * @param row A row point to compare with
2014 * @param column A column point to compare with
2015 */
2016 inside(row: number, column: number): boolean;
2017
2018 /**
2019 * Returns `true` if the `row` and `column` are within the given range's starting points.
2020 * @param row A row point to compare with
2021 * @param column A column point to compare with
2022 */
2023 insideStart(row: number, column: number): boolean;
2024
2025 /**
2026 * Returns `true` if the `row` and `column` are within the given range's ending points.
2027 * @param row A row point to compare with
2028 * @param column A column point to compare with
2029 */
2030 insideEnd(row: number, column: number): boolean;
2031
2032 /**
2033 * Checks the row and column points with the row and column points of the calling range.
2034 * @param row A row point to compare with
2035 * @param column A column point to compare with
2036 */
2037 compare(row: number, column: number): number;
2038
2039 /**
2040 * Checks the row and column points with the row and column points of the calling range.
2041 * @param row A row point to compare with
2042 * @param column A column point to compare with
2043 */
2044 compareStart(row: number, column: number): number;
2045
2046 /**
2047 * Checks the row and column points with the row and column points of the calling range.
2048 * @param row A row point to compare with
2049 * @param column A column point to compare with
2050 */
2051 compareEnd(row: number, column: number): number;
2052
2053 /**
2054 * Checks the row and column points with the row and column points of the calling range.
2055 * @param row A row point to compare with
2056 * @param column A column point to compare with
2057 */
2058 compareInside(row: number, column: number): number;
2059
2060 /**
2061 * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.
2062 * @param firstRow The starting row
2063 * @param lastRow The ending row
2064 */
2065 clipRows(firstRow: number, lastRow: number): Range;
2066
2067 /**
2068 * Changes the row and column points for the calling range for both the starting and ending points.
2069 * @param row A new row to extend to
2070 * @param column A new column to extend to
2071 */
2072 extend(row: number, column: number): Range;
2073
2074 /**
2075 * Returns `true` if the range spans across multiple lines.
2076 */
2077 isMultiLine(): boolean;
2078
2079 /**
2080 * Returns a duplicate of the calling range.
2081 */
2082 clone(): Range;
2083
2084 /**
2085 * Returns a range containing the starting and ending rows of the original range, but with a column value of `0`.
2086 */
2087 collapseRows(): Range;
2088
2089 /**
2090 * Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object.
2091 * @param session The `EditSession` to retrieve coordinates from
2092 */
2093 toScreenRange(session: IEditSession): Range;
2094
2095 /**
2096 * Creates and returns a new `Range` based on the row and column of the given parameters.
2097 * @param start A starting point to use
2098 * @param end An ending point to use
2099 */
2100 fromPoints(start: Range, end: Range): Range;
2101 }
2102 /**
2103 * Creates a new `Range` object with the given starting and ending row and column points.
2104 * @param startRow The starting row
2105 * @param startColumn The starting column
2106 * @param endRow The ending row
2107 * @param endColumn The ending column
2108 */
2109 var Range: {
2110 fromPoints(pos1: Position, pos2: Position): Range;
2111 new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
2112 };
2113
2114 ////////////////
2115 /// RenderLoop
2116 ////////////////
2117
2118 export interface RenderLoop {}
2119 var RenderLoop: {
2120 new(): RenderLoop;
2121 };
2122
2123 ////////////////
2124 /// ScrollBar
2125 ////////////////
2126
2127 /**
2128 * A set of methods for setting and retrieving the editor's scrollbar.
2129 */
2130 export interface ScrollBar {
2131 /**
2132 * Emitted when the scroll bar, well, scrolls.
2133 * @param e Contains one property, `"data"`, which indicates the current scroll top position
2134 */
2135 onScroll(e: any): void;
2136
2137 /**
2138 * Returns the width of the scroll bar.
2139 */
2140 getWidth(): number;
2141
2142 /**
2143 * Sets the height of the scroll bar, in pixels.
2144 * @param height The new height
2145 */
2146 setHeight(height: number): void;
2147
2148 /**
2149 * Sets the inner height of the scroll bar, in pixels.
2150 * @param height The new inner height
2151 */
2152 setInnerHeight(height: number): void;
2153
2154 /**
2155 * Sets the scroll top of the scroll bar.
2156 * @param scrollTop The new scroll top
2157 */
2158 setScrollTop(scrollTop: number): void;
2159 }
2160 var ScrollBar: {
2161 /**
2162 * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
2163 * @param parent A DOM element
2164 */
2165 new(parent: HTMLElement): ScrollBar;
2166 };
2167
2168 ////////////////
2169 /// Search
2170 ////////////////
2171
2172 /**
2173 * A class designed to handle all sorts of text searches within a [[Document `Document`]].
2174 */
2175 export interface Search {
2176 /**
2177 * Sets the search options via the `options` parameter.
2178 * @param options An object containing all the new search properties
2179 */
2180 set(options: any): Search;
2181
2182 /**
2183 * [Returns an object containing all the search options.]{: #Search.getOptions}
2184 */
2185 getOptions(): any;
2186
2187 /**
2188 * Sets the search options via the `options` parameter.
2189 * @param An object containing all the search propertie
2190 */
2191 setOptions(An: any): void;
2192
2193 /**
2194 * Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
2195 * @param session The session to search with
2196 */
2197 find(session: IEditSession): Range;
2198
2199 /**
2200 * Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
2201 * @param session The session to search with
2202 */
2203 findAll(session: IEditSession): Range[];
2204
2205 /**
2206 * Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`.
2207 * @param input The text to search in
2208 * @param replacement The replacing text
2209 * + (String): If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.<br/>
2210 * If `options.needle` was not found, this function returns `null`.
2211 */
2212 replace(input: string, replacement: string): string;
2213 }
2214 var Search: {
2215 /**
2216 * Creates a new `Search` object. The following search options are avaliable:
2217 * - `needle`: The string or regular expression you're looking for
2218 * - `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`.
2219 * - `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`.
2220 * - `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`.
2221 * - `wholeWord`: Whether the search matches only on whole words. Defaults to `false`.
2222 * - `range`: The [[Range]] to search within. Set this to `null` for the whole document
2223 * - `regExp`: Whether the search is a regular expression or not. Defaults to `false`.
2224 * - `start`: The starting [[Range]] or cursor position to begin the search
2225 * - `skipCurrent`: Whether or not to include the current line in the search. Default to `false`.
2226 */
2227 new(): Search;
2228 };
2229
2230 ////////////////
2231 /// Search
2232 ////////////////
2233
2234 /**
2235 * Contains the cursor position and the text selection of an edit session.
2236 * The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.
2237 */
2238 export interface Selection {
2239 on(ev: string, callback: Function): void;
2240
2241 addEventListener(ev: string, callback: Function): void;
2242
2243 off(ev: string, callback: Function): void;
2244
2245 removeListener(ev: string, callback: Function): void;
2246
2247 removeEventListener(ev: string, callback: Function): void;
2248
2249 moveCursorWordLeft(): void;
2250
2251 moveCursorWordRight(): void;
2252
2253 fromOrientedRange(range: Range): void;
2254
2255 setSelectionRange(match: any): void;
2256
2257 getAllRanges(): Range[];
2258
2259 on(event: string, fn: (e: any) => any): void;
2260
2261 addRange(range: Range): void;
2262
2263 /**
2264 * Returns `true` if the selection is empty.
2265 */
2266 isEmpty(): boolean;
2267
2268 /**
2269 * Returns `true` if the selection is a multi-line.
2270 */
2271 isMultiLine(): boolean;
2272
2273 /**
2274 * Gets the current position of the cursor.
2275 */
2276 getCursor(): Position;
2277
2278 /**
2279 * Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event.
2280 * @param row The new row
2281 * @param column The new column
2282 */
2283 setSelectionAnchor(row: number, column: number): void;
2284
2285 /**
2286 * Returns an object containing the `row` and `column` of the calling selection anchor.
2287 */
2288 getSelectionAnchor(): any;
2289
2290 /**
2291 * Returns an object containing the `row` and `column` of the calling selection lead.
2292 */
2293 getSelectionLead(): any;
2294
2295 /**
2296 * Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
2297 * @param columns The number of columns to shift by
2298 */
2299 shiftSelection(columns: number): void;
2300
2301 /**
2302 * Returns `true` if the selection is going backwards in the document.
2303 */
2304 isBackwards(): boolean;
2305
2306 /**
2307 * [Returns the [[Range]] for the selected text.]{: #Selection.getRange}
2308 */
2309 getRange(): Range;
2310
2311 /**
2312 * [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection}
2313 */
2314 clearSelection(): void;
2315
2316 /**
2317 * Selects all the text in the document.
2318 */
2319 selectAll(): void;
2320
2321 /**
2322 * Sets the selection to the provided range.
2323 * @param range The range of text to select
2324 * @param reverse Indicates if the range should go backwards (`true`) or not
2325 */
2326 setRange(range: Range, reverse: boolean): void;
2327
2328 /**
2329 * Moves the selection cursor to the indicated row and column.
2330 * @param row The row to select to
2331 * @param column The column to select to
2332 */
2333 selectTo(row: number, column: number): void;
2334
2335 /**
2336 * Moves the selection cursor to the row and column indicated by `pos`.
2337 * @param pos An object containing the row and column
2338 */
2339 selectToPosition(pos: any): void;
2340
2341 /**
2342 * Moves the selection up one row.
2343 */
2344 selectUp(): void;
2345
2346 /**
2347 * Moves the selection down one row.
2348 */
2349 selectDown(): void;
2350
2351 /**
2352 * Moves the selection right one column.
2353 */
2354 selectRight(): void;
2355
2356 /**
2357 * Moves the selection left one column.
2358 */
2359 selectLeft(): void;
2360
2361 /**
2362 * Moves the selection to the beginning of the current line.
2363 */
2364 selectLineStart(): void;
2365
2366 /**
2367 * Moves the selection to the end of the current line.
2368 */
2369 selectLineEnd(): void;
2370
2371 /**
2372 * Moves the selection to the end of the file.
2373 */
2374 selectFileEnd(): void;
2375
2376 /**
2377 * Moves the selection to the start of the file.
2378 */
2379 selectFileStart(): void;
2380
2381 /**
2382 * Moves the selection to the first word on the right.
2383 */
2384 selectWordRight(): void;
2385
2386 /**
2387 * Moves the selection to the first word on the left.
2388 */
2389 selectWordLeft(): void;
2390
2391 /**
2392 * Moves the selection to highlight the entire word.
2393 */
2394 getWordRange(): void;
2395
2396 /**
2397 * Selects an entire word boundary.
2398 */
2399 selectWord(): void;
2400
2401 /**
2402 * Selects a word, including its right whitespace.
2403 */
2404 selectAWord(): void;
2405
2406 /**
2407 * Selects the entire line.
2408 */
2409 selectLine(): void;
2410
2411 /**
2412 * Moves the cursor up one row.
2413 */
2414 moveCursorUp(): void;
2415
2416 /**
2417 * Moves the cursor down one row.
2418 */
2419 moveCursorDown(): void;
2420
2421 /**
2422 * Moves the cursor left one column.
2423 */
2424 moveCursorLeft(): void;
2425
2426 /**
2427 * Moves the cursor right one column.
2428 */
2429 moveCursorRight(): void;
2430
2431 /**
2432 * Moves the cursor to the start of the line.
2433 */
2434 moveCursorLineStart(): void;
2435
2436 /**
2437 * Moves the cursor to the end of the line.
2438 */
2439 moveCursorLineEnd(): void;
2440
2441 /**
2442 * Moves the cursor to the end of the file.
2443 */
2444 moveCursorFileEnd(): void;
2445
2446 /**
2447 * Moves the cursor to the start of the file.
2448 */
2449 moveCursorFileStart(): void;
2450
2451 /**
2452 * Moves the cursor to the word on the right.
2453 */
2454 moveCursorLongWordRight(): void;
2455
2456 /**
2457 * Moves the cursor to the word on the left.
2458 */
2459 moveCursorLongWordLeft(): void;
2460
2461 /**
2462 * Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.
2463 * @param rows The number of rows to move by
2464 * @param chars The number of characters to move by
2465 */
2466 moveCursorBy(rows: number, chars: number): void;
2467
2468 /**
2469 * Moves the selection to the position indicated by its `row` and `column`.
2470 * @param position The position to move to
2471 */
2472 moveCursorToPosition(position: any): void;
2473
2474 /**
2475 * Moves the cursor to the row and column provided. [If `preventUpdateDesiredColumn` is `true`, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc}
2476 * @param row The row to move to
2477 * @param column The column to move to
2478 * @param keepDesiredColumn [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool}
2479 */
2480 moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void;
2481
2482 /**
2483 * Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc}
2484 * @param row The row to move to
2485 * @param column The column to move to
2486 * @param keepDesiredColumn {:preventUpdateBool}
2487 */
2488 moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void;
2489 }
2490 var Selection: {
2491 /**
2492 * Creates a new `Selection` object.
2493 * @param session The session to use
2494 */
2495 new(session: IEditSession): Selection;
2496 };
2497
2498 ////////////////
2499 /// Split
2500 ////////////////
2501
2502 export interface Split {
2503 BELOW: number;
2504 BESIDE: number;
2505
2506 /**
2507 * Returns the number of splits.
2508 */
2509 getSplits(): number;
2510
2511 /**
2512 * Set the number of splits.
2513 * @param splits The number of splits
2514 */
2515 setSplits(splits?: number): void;
2516
2517 /**
2518 * Returns the editor identified by the index `idx`.
2519 * @param idx The index of the editor you want
2520 */
2521 getEditor(idx: number): Editor;
2522
2523 /**
2524 * Returns the current editor.
2525 */
2526 getCurrentEditor(): Editor;
2527
2528 /**
2529 * Focuses the current editor.
2530 */
2531 focus(): void;
2532
2533 /**
2534 * Blurs the current editor.
2535 */
2536 blur(): void;
2537
2538 /**
2539 * Sets a theme for each of the available editors.
2540 * @param theme The name of the theme to set
2541 */
2542 setTheme(theme: string): void;
2543
2544 /**
2545 * Sets the keyboard handler for the editor.
2546 * @param keybinding
2547 */
2548 setKeyboardHandler(keybinding: string): void;
2549
2550 /**
2551 * Executes `callback` on all of the available editors.
2552 * @param callback A callback function to execute
2553 * @param scope The default scope for the callback
2554 */
2555 forEach(callback: Function, scope: string): void;
2556
2557 /**
2558 * Sets the font size, in pixels, for all the available editors.
2559 * @param size The new font size
2560 */
2561 setFontSize(size: number): void;
2562
2563 /**
2564 * Sets a new [[EditSession `EditSession`]] for the indicated editor.
2565 * @param session The new edit session
2566 * @param idx The editor's index you're interested in
2567 */
2568 setSession(session: IEditSession, idx: number): void;
2569
2570 /**
2571 * Returns the orientation.
2572 */
2573 getOrientation(): number;
2574
2575 /**
2576 * Sets the orientation.
2577 * @param orientation The new orientation value
2578 */
2579 setOrientation(orientation: number): void;
2580
2581 /**
2582 * Resizes the editor.
2583 */
2584 resize(): void;
2585 }
2586 var Split: {
2587 Split(container: HTMLElement, theme?: any, splits?: number): void;
2588 };
2589
2590 //////////////////
2591 /// TokenIterator
2592 //////////////////
2593
2594 /**
2595 * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens.
2596 */
2597 export interface TokenIterator {
2598 /**
2599 * Tokenizes all the items from the current point to the row prior in the document.
2600 */
2601 stepBackward(): string[];
2602
2603 /**
2604 * Tokenizes all the items from the current point until the next row in the document. If the current point is at the end of the file, this function returns `null`. Otherwise, it returns the tokenized string.
2605 */
2606 stepForward(): string;
2607
2608 /**
2609 * Returns the current tokenized string.
2610 */
2611 getCurrentToken(): TokenInfo;
2612
2613 /**
2614 * Returns the current row.
2615 */
2616 getCurrentTokenRow(): number;
2617
2618 /**
2619 * Returns the current column.
2620 */
2621 getCurrentTokenColumn(): number;
2622 }
2623 var TokenIterator: {
2624 /**
2625 * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates.
2626 * @param session The session to associate with
2627 * @param initialRow The row to start the tokenizing at
2628 * @param initialColumn The column to start the tokenizing at
2629 */
2630 new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator;
2631 };
2632
2633 //////////////////
2634 /// Tokenizer
2635 //////////////////
2636
2637 /**
2638 * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
2639 */
2640 export interface Tokenizer {
2641 /**
2642 * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state.
2643 */
2644 removeCapturingGroups(src: string): string;
2645 createSplitterRegexp(src: string, flag?: string): RegExp;
2646 getLineTokens(line: string, startState: string | string[]): TokenInfo[];
2647 }
2648 var Tokenizer: {
2649 /**
2650 * Constructs a new tokenizer based on the given rules and flags.
2651 * @param rules The highlighting rules
2652 * @param flag Any additional regular expression flags to pass (like "i" for case insensitive)
2653 */
2654 new(rules: any, flag: string): Tokenizer;
2655 };
2656
2657 //////////////////
2658 /// UndoManager
2659 //////////////////
2660
2661 /**
2662 * This object maintains the undo stack for an [[EditSession `EditSession`]].
2663 */
2664 export interface UndoManager {
2665 /**
2666 * [Perform an undo operation on the document, reverting the last change.]{: #UndoManager.undo}
2667 * @param session {:session}
2668 * @param dontSelect {:dontSelect}
2669 */
2670 undo(session?: IEditSession, dontSelect?: boolean): Range;
2671
2672 /**
2673 * [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo}
2674 * @param session {:session}
2675 * @param dontSelect {:dontSelect}
2676 */
2677 redo(session?: IEditSession, dontSelect?: boolean): void;
2678
2679 /**
2680 * Destroys the stack of undo and redo redo operations.
2681 */
2682 reset(): void;
2683
2684 /**
2685 * Returns `true` if there are undo operations left to perform.
2686 */
2687 canUndo(): boolean;
2688 /**
2689 * Alias for canUndo
2690 */
2691 hasUndo(): boolean;
2692
2693 /**
2694 * Returns `true` if there are redo operations left to perform.
2695 */
2696 canRedo(): boolean;
2697 /**
2698 * Alias for canRedo
2699 */
2700 hasRedo(): boolean;
2701
2702 /**
2703 * Returns if the current status is clean
2704 */
2705 isAtBookmark(): boolean;
2706 /**
2707 * Alias for isAtBookmark
2708 */
2709 isClean(): boolean;
2710
2711 /**
2712 * Marks the current status clean
2713 * @param rev {:rev}
2714 */
2715 bookmark(rev?: number): void;
2716 /**
2717 * Alias for bookmark
2718 */
2719 markClean(rev?: number): void;
2720 }
2721 var UndoManager: {
2722 /**
2723 * Resets the current undo state and creates a new `UndoManager`.
2724 */
2725 new(): UndoManager;
2726 };
2727
2728 ////////////////////
2729 /// VirtualRenderer
2730 ////////////////////
2731
2732 /**
2733 * The class that is responsible for drawing everything you see on the screen!
2734 */
2735 export interface VirtualRenderer extends OptionProvider {
2736 scroller: any;
2737
2738 characterWidth: number;
2739
2740 lineHeight: number;
2741
2742 $cursorLayer: Layer.Cursor;
2743
2744 setScrollMargin(top: number, bottom: number, left: number, right: number): void;
2745
2746 screenToTextCoordinates(left: number, top: number): void;
2747
2748 /**
2749 * Associates the renderer with an [[EditSession `EditSession`]].
2750 */
2751 setSession(session: IEditSession): void;
2752
2753 /**
2754 * Triggers a partial update of the text, from the range given by the two parameters.
2755 * @param firstRow The first row to update
2756 * @param lastRow The last row to update
2757 */
2758 updateLines(firstRow: number, lastRow: number): void;
2759
2760 /**
2761 * Triggers a full update of the text, for all the rows.
2762 */
2763 updateText(): void;
2764
2765 /**
2766 * Triggers a full update of all the layers, for all the rows.
2767 * @param force If `true`, forces the changes through
2768 */
2769 updateFull(force: boolean): void;
2770
2771 /**
2772 * Updates the font size.
2773 */
2774 updateFontSize(): void;
2775
2776 /**
2777 * [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
2778 * @param force If `true`, recomputes the size, even if the height and width haven't changed
2779 * @param gutterWidth The width of the gutter in pixels
2780 * @param width The width of the editor in pixels
2781 * @param height The hiehgt of the editor, in pixels
2782 */
2783 onResize(force: boolean, gutterWidth: number, width: number, height: number): void;
2784
2785 /**
2786 * Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen.
2787 */
2788 adjustWrapLimit(): void;
2789
2790 /**
2791 * Identifies whether you want to have an animated scroll or not.
2792 * @param shouldAnimate Set to `true` to show animated scrolls
2793 */
2794 setAnimatedScroll(shouldAnimate: boolean): void;
2795
2796 /**
2797 * Returns whether an animated scroll happens or not.
2798 */
2799 getAnimatedScroll(): boolean;
2800
2801 /**
2802 * Identifies whether you want to show invisible characters or not.
2803 * @param showInvisibles Set to `true` to show invisibles
2804 */
2805 setShowInvisibles(showInvisibles: boolean): void;
2806
2807 /**
2808 * Returns whether invisible characters are being shown or not.
2809 */
2810 getShowInvisibles(): boolean;
2811
2812 /**
2813 * Identifies whether you want to show the print margin or not.
2814 * @param showPrintMargin Set to `true` to show the print margin
2815 */
2816 setShowPrintMargin(showPrintMargin: boolean): void;
2817
2818 /**
2819 * Returns whether the print margin is being shown or not.
2820 */
2821 getShowPrintMargin(): boolean;
2822
2823 /**
2824 * Identifies whether you want to show the print margin column or not.
2825 * @param showPrintMargin Set to `true` to show the print margin column
2826 */
2827 setPrintMarginColumn(showPrintMargin: boolean): void;
2828
2829 /**
2830 * Returns whether the print margin column is being shown or not.
2831 */
2832 getPrintMarginColumn(): boolean;
2833
2834 /**
2835 * Returns `true` if the gutter is being shown.
2836 */
2837 getShowGutter(): boolean;
2838
2839 /**
2840 * Identifies whether you want to show the gutter or not.
2841 * @param show Set to `true` to show the gutter
2842 */
2843 setShowGutter(show: boolean): void;
2844
2845 /**
2846 * Returns the root element containing this renderer.
2847 */
2848 getContainerElement(): HTMLElement;
2849
2850 /**
2851 * Returns the element that the mouse events are attached to
2852 */
2853 getMouseEventTarget(): HTMLElement;
2854
2855 /**
2856 * Returns the element to which the hidden text area is added.
2857 */
2858 getTextAreaContainer(): HTMLElement;
2859
2860 /**
2861 * [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow}
2862 */
2863 getFirstVisibleRow(): number;
2864
2865 /**
2866 * Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
2867 */
2868 getFirstFullyVisibleRow(): number;
2869
2870 /**
2871 * Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
2872 */
2873 getLastFullyVisibleRow(): number;
2874
2875 /**
2876 * [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow}
2877 */
2878 getLastVisibleRow(): number;
2879
2880 /**
2881 * Sets the padding for all the layers.
2882 * @param padding A new padding value (in pixels)
2883 */
2884 setPadding(padding: number): void;
2885
2886 /**
2887 * Returns whether the horizontal scrollbar is set to be always visible.
2888 */
2889 getHScrollBarAlwaysVisible(): boolean;
2890
2891 /**
2892 * Identifies whether you want to show the horizontal scrollbar or not.
2893 * @param alwaysVisible Set to `true` to make the horizontal scroll bar visible
2894 */
2895 setHScrollBarAlwaysVisible(alwaysVisible: boolean): void;
2896
2897 /**
2898 * Schedules an update to all the front markers in the document.
2899 */
2900 updateFrontMarkers(): void;
2901
2902 /**
2903 * Schedules an update to all the back markers in the document.
2904 */
2905 updateBackMarkers(): void;
2906
2907 /**
2908 * Deprecated; (moved to [[EditSession]])
2909 */
2910 addGutterDecoration(): void;
2911
2912 /**
2913 * Deprecated; (moved to [[EditSession]])
2914 */
2915 removeGutterDecoration(): void;
2916
2917 /**
2918 * Redraw breakpoints.
2919 */
2920 updateBreakpoints(): void;
2921
2922 /**
2923 * Sets annotations for the gutter.
2924 * @param annotations An array containing annotations
2925 */
2926 setAnnotations(annotations: any[]): void;
2927
2928 /**
2929 * Updates the cursor icon.
2930 */
2931 updateCursor(): void;
2932
2933 /**
2934 * Hides the cursor icon.
2935 */
2936 hideCursor(): void;
2937
2938 /**
2939 * Shows the cursor icon.
2940 */
2941 showCursor(): void;
2942
2943 /**
2944 * Scrolls the cursor into the first visibile area of the editor
2945 */
2946 scrollCursorIntoView(): void;
2947
2948 /**
2949 * {:EditSession.getScrollTop}
2950 */
2951 getScrollTop(): number;
2952
2953 /**
2954 * {:EditSession.getScrollLeft}
2955 */
2956 getScrollLeft(): number;
2957
2958 /**
2959 * Returns the first visible row, regardless of whether it's fully visible or not.
2960 */
2961 getScrollTopRow(): number;
2962
2963 /**
2964 * Returns the last visible row, regardless of whether it's fully visible or not.
2965 */
2966 getScrollBottomRow(): number;
2967
2968 /**
2969 * Gracefully scrolls from the top of the editor to the row indicated.
2970 * @param row A row id
2971 */
2972 scrollToRow(row: number): void;
2973
2974 /**
2975 * Gracefully scrolls the editor to the row indicated.
2976 * @param line A line number
2977 * @param center If `true`, centers the editor the to indicated line
2978 * @param animate If `true` animates scrolling
2979 * @param callback Function to be called after the animation has finished
2980 */
2981 scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
2982
2983 /**
2984 * Scrolls the editor to the y pixel indicated.
2985 * @param scrollTop The position to scroll to
2986 */
2987 scrollToY(scrollTop: number): number;
2988
2989 /**
2990 * Scrolls the editor across the x-axis to the pixel indicated.
2991 * @param scrollLeft The position to scroll to
2992 */
2993 scrollToX(scrollLeft: number): number;
2994
2995 /**
2996 * Scrolls the editor across both x- and y-axes.
2997 * @param deltaX The x value to scroll by
2998 * @param deltaY The y value to scroll by
2999 */
3000 scrollBy(deltaX: number, deltaY: number): void;
3001
3002 /**
3003 * Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line.
3004 * @param deltaX The x value to scroll by
3005 * @param deltaY The y value to scroll by
3006 */
3007 isScrollableBy(deltaX: number, deltaY: number): boolean;
3008
3009 /**
3010 * Returns an object containing the `pageX` and `pageY` coordinates of the document position.
3011 * @param row The document row position
3012 * @param column The document column position
3013 */
3014 textToScreenCoordinates(row: number, column: number): any;
3015
3016 /**
3017 * Focuses the current container.
3018 */
3019 visualizeFocus(): void;
3020
3021 /**
3022 * Blurs the current container.
3023 */
3024 visualizeBlur(): void;
3025
3026 /**
3027 * undefined
3028 * @param position
3029 */
3030 showComposition(position: number): void;
3031
3032 /**
3033 * Sets the inner text of the current composition to `text`.
3034 * @param text A string of text to use
3035 */
3036 setCompositionText(text: string): void;
3037
3038 /**
3039 * Hides the current composition.
3040 */
3041 hideComposition(): void;
3042
3043 /**
3044 * [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
3045 * @param theme The path to a theme
3046 */
3047 setTheme(theme: string): void;
3048
3049 /**
3050 * [Returns the path of the current theme.]{: #VirtualRenderer.getTheme}
3051 */
3052 getTheme(): string;
3053
3054 /**
3055 * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
3056 * @param style A class name
3057 */
3058 setStyle(style: string): void;
3059
3060 /**
3061 * [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
3062 * @param style A class name
3063 */
3064 unsetStyle(style: string): void;
3065
3066 /**
3067 * Destroys the text and cursor layers for this renderer.
3068 */
3069 destroy(): void;
3070 }
3071 var VirtualRenderer: {
3072 /**
3073 * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`.
3074 * @param container The root element of the editor
3075 * @param theme The starting theme
3076 */
3077 new(container: HTMLElement, theme?: string): VirtualRenderer;
3078 };
3079
3080 export interface Completer {
3081 /**
3082 * Provides possible completion results asynchronously using the given callback.
3083 * @param editor The editor to associate with
3084 * @param session The `EditSession` to refer to
3085 * @param pos An object containing the row and column
3086 * @param prefix The prefixing string before the current position
3087 * @param callback Function to provide the results or error
3088 */
3089 getCompletions: (
3090 editor: Editor,
3091 session: IEditSession,
3092 pos: Position,
3093 prefix: string,
3094 callback: CompletionCallback,
3095 ) => void;
3096
3097 /**
3098 * Provides tooltip information about a completion result.
3099 * @param item The completion result
3100 */
3101 getDocTooltip?: ((item: Completion) => void) | undefined;
3102 }
3103
3104 export interface Completion {
3105 value: string;
3106 meta: string;
3107 type?: string | undefined;
3108 caption?: string | undefined;
3109 snippet?: any;
3110 score?: number | undefined;
3111 exactMatch?: number | undefined;
3112 docHTML?: string | undefined;
3113 }
3114
3115 export type CompletionCallback = (error: Error | null, results: Completion[]) => void;
3116
3117 ////////////////////
3118 /// Layer
3119 ////////////////////
3120
3121 export namespace Layer {
3122 ////////////////////
3123 /// Cursor
3124 ////////////////////
3125
3126 export interface Cursor {
3127 setBlinking(blinking: boolean): void;
3128 setBlinkInterval(blinkInterval: number): void;
3129 hideCursor(): void;
3130 showCursor(): void;
3131 }
3132 }
3133}
3134
3135declare var ace: AceAjax.Ace;
3136
\No newline at end of file