forked from susisu/mte-kernel
-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
text-editor.ts
104 lines (94 loc) · 2.84 KB
/
text-editor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { Point } from './point';
import { Range } from './range';
/**
* The `ITextEditor` represents an interface to a text editor.
*
* @interface
*/
export class ITextEditor {
/**
* Gets the current cursor position.
*
* @returns A point object that represents the cursor position.
*/
public getCursorPosition(): Point {
throw new Error('Not implemented: getCursorPosition');
}
/**
* Sets the cursor position to a specified one.
*/
public setCursorPosition(pos: Point): void {
throw new Error('Not implemented: setCursorPosition');
}
/**
* Sets the selection range.
* This method also expects the cursor position to be moved as the end of the selection range.
*/
public setSelectionRange(range: Range): void {
throw new Error('Not implemented: setSelectionRange');
}
/**
* Gets the last row index of the text editor.
*/
public getLastRow(): number {
throw new Error('Not implemented: getLastRow');
}
/**
* Checks if the editor accepts a table at a row to be editted.
* It should return `false` if, for example, the row is in a code block (not Markdown).
*
* @param row - A row index in the text editor.
* @returns `true` if the table at the row can be editted.
*/
public acceptsTableEdit(row: number): boolean {
throw new Error('Not implemented: acceptsTableEdit');
}
/**
* Gets a line string at a row.
*
* @param row - Row index, starts from `0`.
* @returns The line at the specified row.
* The line must not contain an EOL like `"\n"` or `"\r"`.
*/
public getLine(row: number): string {
throw new Error('Not implemented: getLine');
}
/**
* Inserts a line at a specified row.
*
* @param row - Row index, starts from `0`.
* @param line - A string to be inserted.
* This must not contain an EOL like `"\n"` or `"\r"`.
*/
public insertLine(row: number, line: string): void {
throw new Error('Not implemented: insertLine');
}
/**
* Deletes a line at a specified row.
*
* @param row - Row index, starts from `0`.
*/
public deleteLine(row: number): void {
throw new Error('Not implemented: deleteLine');
}
/**
* Replace lines in a specified range.
*
* @param startRow - Start row index, starts from `0`.
* @param endRow - End row index.
* Lines from `startRow` to `endRow - 1` is replaced.
* @param lines - An array of string.
* Each strings must not contain an EOL like `"\n"` or `"\r"`.
*/
public replaceLines(startRow: number, endRow: number, lines: string[]): void {
throw new Error('Not implemented: replaceLines');
}
/**
* Batches multiple operations as a single undo/redo step.
*
* @param func - A callback function that executes some operations on the text editor.
*/
public transact(func: () => void): void {
throw new Error('Not implemented: transact');
}
}