-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.d.ts
409 lines (399 loc) · 10 KB
/
index.d.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
import { EventEmitter } from 'events';
import { Nvim } from 'promised-neovim-client';
import { Dispatcher } from 'flux';
import cp = require('child_process');
import NvimClient = require('promised-neovim-client');
export declare type RPCValue = NvimClient.Buffer | NvimClient.Window | NvimClient.Tabpage | number | boolean | string | any[] | {
[key: string]: any;
};
export interface HighlightSet {
background?: number;
bg?: string;
bold?: boolean;
fg?: string;
special?: string;
foreground?: number;
italic?: boolean;
reverse?: boolean;
undercurl?: boolean;
underline?: boolean;
}
export interface Region {
top: number;
left: number;
right: number;
bottom: number;
}
export declare enum Kind {
Bell = 0,
BusyStart = 1,
BusyStop = 2,
ChangeCursorDrawDelay = 3,
ClearAll = 4,
ClearEOL = 5,
CompositionStart = 6,
CompositionEnd = 7,
Cursor = 8,
DisableMouse = 9,
DisableAltKey = 10,
DisableMetaKey = 11,
DragEnd = 12,
DragStart = 13,
DragUpdate = 14,
EnableMouse = 15,
Highlight = 16,
Input = 17,
Mode = 18,
PutText = 19,
Resize = 20,
ScrollScreen = 21,
SetIcon = 22,
SetScrollRegion = 23,
SetTitle = 24,
StartBlinkCursor = 25,
StopBlinkCursor = 26,
UpdateBG = 27,
UpdateFG = 28,
UpdateSP = 29,
UpdateFontFace = 30,
updateLineHeight = 31,
UpdateFontPx = 32,
UpdateFontSize = 33,
UpdateScreenBounds = 34,
UpdateScreenSize = 35,
WheelScroll = 36,
FocusChanged = 37,
}
export interface ActionType {
type: Kind;
col?: number;
color?: number;
cols?: number;
delay?: number;
disabled?: boolean;
draw_width?: number;
draw_height?: number;
event?: MouseEvent | WheelEvent;
focused?: boolean;
font_face?: string;
font_px?: number;
height?: number;
highlight?: HighlightSet;
icon_path?: string;
input?: string;
line?: number;
lines?: number;
mode?: string;
region?: Region;
text?: string[][];
title?: string;
visual?: boolean;
width?: number;
}
export declare function putText(text: string[][]): {
type: Kind;
text: string[][];
};
export declare function cursor(line: number, col: number): {
type: Kind;
line: number;
col: number;
};
export declare function highlight(highlight: HighlightSet): {
type: Kind;
highlight: HighlightSet;
};
export declare function clearAll(): {
type: Kind;
};
export declare function clearEndOfLine(): {
type: Kind;
};
export declare function compositionStart(): {
type: Kind;
};
export declare function compositionEnd(): {
type: Kind;
};
export declare function resize(lines: number, cols: number): {
type: Kind;
lines: number;
cols: number;
};
export declare function updateForeground(color: number): {
type: Kind;
color: number;
};
export declare function updateBackground(color: number): {
type: Kind;
color: number;
};
export declare function updateSpecialColor(color: number): {
type: Kind;
color: number;
};
export declare function changeMode(mode: string): {
type: Kind;
mode: string;
};
export declare function startBusy(): {
type: Kind;
};
export declare function stopBusy(): {
type: Kind;
};
export declare function updateFontSize(draw_width: number, draw_height: number, width: number, height: number): {
type: Kind;
draw_width: number;
draw_height: number;
width: number;
height: number;
};
export declare function inputToNeovim(input: string): {
type: Kind;
input: string;
};
export declare function updateFontPx(font_px: number): {
type: Kind;
font_px: number;
};
export declare function updateFontFace(font_face: string): {
type: Kind;
font_face: string;
};
export declare function updateScreenSize(width: number, height: number): {
type: Kind;
width: number;
height: number;
};
export declare function updateScreenBounds(lines: number, cols: number): {
type: Kind;
lines: number;
cols: number;
};
export declare function enableMouse(): {
type: Kind;
};
export declare function disableMouse(): {
type: Kind;
};
export declare function dragStart(event: MouseEvent): {
type: Kind;
event: MouseEvent;
};
export declare function dragUpdate(event: MouseEvent): {
type: Kind;
event: MouseEvent;
};
export declare function dragEnd(event: MouseEvent): {
type: Kind;
event: MouseEvent;
};
export declare function bell(visual: boolean): {
type: Kind;
visual: boolean;
};
export declare function setTitle(title: string): {
type: Kind;
title: string;
};
export declare function setIcon(icon_path: string): {
type: Kind;
icon_path: string;
};
export declare function wheelScroll(event: WheelEvent): {
type: Kind;
event: WheelEvent;
};
export declare function scrollScreen(cols: number): {
type: Kind;
cols: number;
};
export declare function setScrollRegion(region: Region): {
type: Kind;
region: Region;
};
export declare function notifyFocusChanged(focused: boolean): {
type: Kind;
focused: boolean;
};
export declare function disableAltKey(disabled: boolean): {
type: Kind;
disabled: boolean;
};
export declare function disableMetaKey(disabled: boolean): {
type: Kind;
disabled: boolean;
};
export declare function changeCursorDrawDelay(delay: number): {
type: Kind;
delay: number;
};
export declare function startBlinkCursor(): {
type: Kind;
};
export declare function stopBlinkCursor(): {
type: Kind;
};
export class NeovimCursor {
constructor(store: NeovimStore, screen_ctx: CanvasRenderingContext2D);
updateSize(): void;
redraw(): void;
onModeChanged(): void;
updateCursorPos(): void;
}
export class NeovimInput {
element: HTMLInputElement;
ime_running: boolean;
static shouldHandleModifier(event: KeyboardEvent): boolean;
static getVimSpecialChar(code: number, shift: boolean): string;
constructor(store: NeovimStore);
startComposition(event: Event): void;
endComposition(event: Event): void;
focus(): void;
onInsertControlChar(event: KeyboardEvent): void;
inputToNeovim(input: string, event: Event): void;
onInsertNormalChar(event: KeyboardEvent): void;
}
export class NeovimProcess {
command: string;
argv: string[];
neovim_process: cp.ChildProcess;
client: NvimClient.Nvim;
started: boolean;
constructor(store: NeovimStore, command: string, argv: string[]);
attach(lines: number, columns: number): Promise<void>;
onRequested(method: string, args: RPCValue[], response: RPCValue): void;
onNotified(method: string, args: RPCValue[]): void;
onDisconnected(): void;
finalize(): Promise<void>;
}
export class ScreenDrag {
line: number;
col: number;
static buildInputOf(e: MouseEvent, type: string, line: number, col: number): string;
constructor(store: NeovimStore);
start(down_event: MouseEvent): string;
drag(move_event: MouseEvent): string;
end(up_event: MouseEvent): string;
}
export class ScreenWheel {
x: number;
y: number;
shift: boolean;
ctrl: boolean;
constructor(store: NeovimStore);
handleEvent(e: WheelEvent): string;
}
export class NeovimScreen {
canvas: HTMLCanvasElement;
ctx: CanvasRenderingContext2D;
cursor: NeovimCursor;
input: NeovimInput;
constructor(store: NeovimStore, canvas: HTMLCanvasElement);
wheel(e: WheelEvent): void;
mouseDown(e: MouseEvent): void;
mouseUp(e: MouseEvent): void;
mouseMove(e: MouseEvent): void;
resizeWithPixels(width_px: number, height_px: number): void;
resize(lines: number, cols: number): void;
changeFontSize(specified_px: number): void;
changeLineHeight(new_value: number): void;
scroll(cols_delta: number): void;
focus(): void;
clearAll(): void;
clearEol(): void;
convertPositionToLocation(line: number, col: number): {
x: number;
y: number;
};
convertLocationToPosition(x: number, y: number): {
line: number;
col: number;
};
checkShouldResize(): void;
}
export interface Size {
lines: number;
cols: number;
width: number;
height: number;
}
export interface Cursor {
line: number;
col: number;
}
export interface FontAttributes {
fg: string;
bg: string;
sp: string;
bold: boolean;
italic: boolean;
underline: boolean;
undercurl: boolean;
draw_width: number;
draw_height: number;
width: number;
height: number;
face: string;
specified_px: number;
}
export declare type DispatcherType = Dispatcher<ActionType>;
export class NeovimStore extends EventEmitter {
blink_cursor: boolean;
cursor_blink_interval: number;
cursor_draw_delay: number;
dispatch_token: string;
size: Size;
focused: boolean;
font_attr: FontAttributes;
line_height: number;
fg_color: string;
bg_color: string;
cursor: Cursor;
mode: string;
busy: boolean;
mouse_enabled: boolean;
dragging: ScreenDrag;
title: string;
icon_path: string;
wheel_scrolling: ScreenWheel;
scroll_region: Region;
dispatcher: Dispatcher<ActionType>;
}
export class Neovim extends EventEmitter {
process: NeovimProcess;
screen: NeovimScreen;
store: NeovimStore;
constructor(
command: string,
argv: string[],
font: string,
font_size: number,
line_height: number,
blink_cursor: boolean,
window_title: string,
);
attachCanvas(width: number, height: number, canvas: HTMLCanvasElement): void;
quit(): void;
getClient(): Nvim;
focus(): void;
setArgv(argv: string[]): Promise<void>;
}
export class NeovimElement extends HTMLElement {
disableAltKey: boolean;
drawDelay: number;
editor: Neovim;
width: number;
height: number;
fontSize: number;
font: string;
lineHeight: number;
noBlinkCursor: boolean;
windowTitle: string;
nvimCmd: string;
argv: string[];
onProcessAttached: () => void;
onQuit: () => void;
onError: (err: Error) => void;
}