lexgui 8.3.0 → 8.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,466 +1,521 @@
1
- interface Token {
2
- type: string;
3
- value: string;
4
- }
5
- interface TokenRule {
6
- match: RegExp;
7
- type: string;
8
- next?: string;
9
- pop?: boolean | number;
10
- }
11
- interface LanguageDef {
12
- name: string;
13
- extensions: string[];
14
- states: Record<string, TokenRule[]>;
15
- lineComment?: string;
16
- icon?: string | Record<string, string>;
17
- reservedWords: string[];
18
- }
19
- interface TokenizerState {
20
- stack: string[];
21
- }
22
- interface TokenizeResult {
23
- tokens: Token[];
24
- state: TokenizerState;
25
- }
26
- export declare class Tokenizer {
27
- private static languages;
28
- private static extensionMap;
29
- static registerLanguage(def: LanguageDef): void;
30
- static getLanguage(name: string): LanguageDef | undefined;
31
- static getLanguageByExtension(ext: string): LanguageDef | undefined;
32
- static getRegisteredLanguages(): string[];
33
- static initialState(): TokenizerState;
34
- /**
35
- * Tokenize a single line given a language and the state from the previous line.
36
- * Returns the tokens and the updated state for the next line.
37
- */
38
- static tokenizeLine(line: string, language: LanguageDef, state: TokenizerState): TokenizeResult;
39
- /**
40
- * Merge consecutive tokens with the same type into one.
41
- */
42
- private static _mergeTokens;
43
- }
44
- declare class CodeDocument {
45
- private onChange;
46
- private _lines;
47
- get lineCount(): number;
48
- constructor(onChange?: (doc: CodeDocument) => void);
49
- getLine(n: number): string;
50
- getText(separator?: string): string;
51
- setText(text: string): void;
52
- getCharAt(line: number, col: number): string | undefined;
53
- /**
54
- * Get the word at a given position. Returns [word, startCol, endCol].
55
- */
56
- getWordAt(line: number, col: number): [string, number, number];
57
- /**
58
- * Get the indentation level (number of leading spaces) of a line.
59
- */
60
- getIndent(line: number): number;
61
- /**
62
- * Find the next occurrence of 'text' starting after (line, col). Returns null if no match.
63
- */
64
- findNext(text: string, startLine: number, startCol: number): {
65
- line: number;
66
- col: number;
67
- } | null;
68
- /**
69
- * Insert text at a position (handles newlines in the inserted text).
70
- */
71
- insert(line: number, col: number, text: string): EditOperation;
72
- /**
73
- * Delete `length` characters forward from a position (handles crossing line boundaries).
74
- */
75
- delete(line: number, col: number, length: number): EditOperation;
76
- /**
77
- * Insert a new line after 'afterLine'. If afterLine is -1, inserts at the beginning.
78
- */
79
- insertLine(afterLine: number, text?: string): EditOperation;
80
- /**
81
- * Remove an entire line and its trailing newline.
82
- */
83
- removeLine(line: number): EditOperation;
84
- replaceLine(line: number, newText: string): EditOperation;
85
- /**
86
- * Apply an edit operation (used by undo/redo).
87
- */
88
- applyInverse(op: EditOperation): EditOperation;
89
- }
90
- interface EditOperation {
91
- type: 'insert' | 'delete' | 'replaceLine';
92
- line: number;
93
- col: number;
94
- text: string;
95
- oldText?: string;
96
- }
97
- declare class UndoManager {
98
- private _undoStack;
99
- private _redoStack;
100
- private _pendingOps;
101
- private _pendingCursorsBefore;
102
- private _pendingCursorsAfter;
103
- private _lastPushTime;
104
- private _groupThresholdMs;
105
- private _maxSteps;
106
- constructor(groupThresholdMs?: number, maxSteps?: number);
107
- /**
108
- * Record an edit operation. Consecutive operations within the time threshold
109
- * are grouped into a single undo step.
110
- */
111
- record(op: EditOperation, cursors: CursorPosition[]): void;
112
- /**
113
- * Force-flush pending operations into a final undo step.
114
- */
115
- flush(cursorsAfter?: CursorPosition[]): void;
116
- /**
117
- * Undo the last step. Stores the operations to apply inversely, and returns the cursor state to restore.
118
- */
119
- undo(doc: CodeDocument, currentCursors?: CursorPosition[]): {
120
- cursors: CursorPosition[];
121
- } | null;
122
- /**
123
- * Redo the last undone step. Returns the cursor state to restore.
124
- */
125
- redo(doc: CodeDocument): {
126
- cursors: CursorPosition[];
127
- } | null;
128
- canUndo(): boolean;
129
- canRedo(): boolean;
130
- clear(): void;
131
- private _flush;
132
- }
133
- interface CursorPosition {
134
- line: number;
135
- col: number;
136
- }
137
- interface Selection {
138
- anchor: CursorPosition;
139
- head: CursorPosition;
140
- }
141
- declare class CursorSet {
142
- cursors: Selection[];
143
- constructor();
144
- getPrimary(): Selection;
145
- /**
146
- * Set a single cursor position. Clears all secondary cursors and selections.
147
- */
148
- set(line: number, col: number): void;
149
- moveLeft(doc: CodeDocument, selecting?: boolean): void;
150
- moveRight(doc: CodeDocument, selecting?: boolean): void;
151
- moveUp(doc: CodeDocument, selecting?: boolean): void;
152
- moveDown(doc: CodeDocument, selecting?: boolean): void;
153
- moveToLineStart(doc: CodeDocument, selecting?: boolean, noIndent?: boolean): void;
154
- moveToLineEnd(doc: CodeDocument, selecting?: boolean): void;
155
- moveWordLeft(doc: CodeDocument, selecting?: boolean): void;
156
- moveWordRight(doc: CodeDocument, selecting?: boolean): void;
157
- selectAll(doc: CodeDocument): void;
158
- addCursor(line: number, col: number): void;
159
- removeSecondaryCursors(): void;
160
- /**
161
- * Returns cursor indices sorted by head position, bottom-to-top (last in doc first)
162
- * to ensure earlier cursors' positions stay valid.
163
- */
164
- sortedIndicesBottomUp(): number[];
165
- /**
166
- * After editing at (line, col), shift all other cursors on the same line
167
- * that are at or after `afterCol` by `colDelta`. Also handles line shifts
168
- * for multi-line inserts/deletes via `lineDelta`.
169
- */
170
- adjustOthers(skipIdx: number, line: number, afterCol: number, colDelta: number, lineDelta?: number): void;
171
- hasSelection(index?: number): boolean;
172
- getSelectedText(doc: CodeDocument, index?: number): string;
173
- getCursorPositions(): CursorPosition[];
174
- private _moveHead;
175
- private _moveVertical;
176
- /**
177
- * Merge overlapping cursors/selections. Keeps the first one when duplicates exist.
178
- */
179
- private _merge;
180
- }
181
- interface Symbol {
182
- name: string;
183
- kind: string;
184
- scope: string;
185
- line: number;
186
- col?: number;
187
- }
188
- interface ScopeInfo {
189
- name: string;
190
- type: string;
191
- line: number;
192
- }
193
- /**
194
- * Manages code symbols for autocomplete, navigation, and outlining.
195
- * Incrementally updates as lines change.
196
- */
197
- declare class SymbolTable {
198
- private _symbols;
199
- private _lineSymbols;
200
- private _scopeStack;
201
- private _lineScopes;
202
- get currentScope(): string;
203
- get currentScopeType(): string;
204
- getScopeAtLine(line: number): ScopeInfo[];
205
- getSymbols(name: string): Symbol[];
206
- getAllSymbolNames(): string[];
207
- getAllSymbols(): Symbol[];
208
- getLineSymbols(line: number): Symbol[];
209
- /** Update scope stack for a line (call before parsing symbols) */
210
- updateScopeForLine(line: number, lineText: string): void;
211
- /** Name the most recent anonymous scope (called when detecting class/function) */
212
- nameCurrentScope(name: string, type: string): void;
213
- /** Remove symbols from a line (before reparsing) */
214
- removeLineSymbols(line: number): void;
215
- addSymbol(symbol: Symbol): void;
216
- /** Reset scope stack (e.g. when document structure changes significantly) */
217
- resetScopes(): void;
218
- clear(): void;
219
- }
220
- declare const Area: any;
221
- declare const Panel: any;
222
- declare const Tabs: any;
223
- declare const NodeTree: any;
224
- interface CodeTab {
225
- name: string;
226
- dom: HTMLElement;
227
- doc: CodeDocument;
228
- cursorSet: CursorSet;
229
- undoManager: UndoManager;
230
- language: string;
231
- title?: string;
232
- path?: string;
233
- }
234
- declare class ScrollBar {
235
- static SIZE: number;
236
- root: HTMLElement;
237
- thumb: HTMLElement;
238
- private _vertical;
239
- private _thumbPos;
240
- private _thumbRatio;
241
- private _lastMouse;
242
- private _onDrag;
243
- get visible(): boolean;
244
- get isVertical(): boolean;
245
- constructor(vertical: boolean, onDrag: (delta: number) => void);
246
- setThumbRatio(ratio: number): void;
247
- syncToScroll(scrollPos: number, scrollMax: number): void;
248
- applyDragDelta(delta: number, scrollMax: number): number;
249
- private _applyPosition;
250
- private _onMouseDown;
251
- }
252
- /**
253
- * @class CodeEditor
254
- * The main editor class. Wires Document, Tokenizer, CursorSet, UndoManager
255
- * together with the DOM.
256
- */
257
- export declare class CodeEditor {
258
- static __instances: CodeEditor[];
259
- language: LanguageDef;
260
- symbolTable: SymbolTable;
261
- area: typeof Area;
262
- baseArea: typeof Area;
263
- codeArea: typeof Area;
264
- explorerArea: typeof Area;
265
- tabs: typeof Tabs;
266
- root: HTMLElement;
267
- codeScroller: HTMLElement;
268
- codeSizer: HTMLElement;
269
- cursorsLayer: HTMLElement;
270
- selectionsLayer: HTMLElement;
271
- lineGutter: HTMLElement;
272
- vScrollbar: ScrollBar;
273
- hScrollbar: ScrollBar;
274
- searchBox: HTMLElement | null;
275
- searchLineBox: HTMLElement | null;
276
- autocomplete: HTMLElement | null;
277
- currentTab: CodeTab | null;
278
- statusPanel: typeof Panel;
279
- leftStatusPanel: typeof Panel;
280
- rightStatusPanel: typeof Panel;
281
- explorer: typeof NodeTree | null;
282
- charWidth: number;
283
- lineHeight: number;
284
- fontSize: number;
285
- xPadding: number;
286
- private _cachedTabsHeight;
287
- private _cachedStatusPanelHeight;
288
- skipInfo: boolean;
289
- disableEdition: boolean;
290
- skipTabs: boolean;
291
- useFileExplorer: boolean;
292
- useAutoComplete: boolean;
293
- allowAddScripts: boolean;
294
- allowClosingTabs: boolean;
295
- allowLoadingFiles: boolean;
296
- tabSize: number;
297
- highlight: string;
298
- newTabOptions: any[] | null;
299
- customSuggestions: any[];
300
- explorerName: string;
301
- onSave: (text: string, editor: CodeEditor) => void;
302
- onRun: (text: string, editor: CodeEditor) => void;
303
- onCtrlSpace: (text: string, editor: CodeEditor) => void;
304
- onCreateStatusPanel: (panel: typeof Panel, editor: CodeEditor) => void;
305
- onContextMenu: any;
306
- onNewTab: (event: MouseEvent) => void;
307
- onSelectTab: (name: string, editor: CodeEditor) => void;
308
- onReady: ((editor: CodeEditor) => void) | undefined;
309
- onCreateFile: ((editor: CodeEditor) => void) | undefined;
310
- onCodeChange: ((doc: CodeDocument) => void) | undefined;
311
- private _inputArea;
312
- private _lineStates;
313
- private _lineElements;
314
- private _openedTabs;
315
- private _loadedTabs;
316
- private _storedTabs;
317
- private _focused;
318
- private _composing;
319
- private _keyChain;
320
- private _wasPaired;
321
- private _lastAction;
322
- private _blinkerInterval;
323
- private _cursorVisible;
324
- private _cursorBlinkRate;
325
- private _clickCount;
326
- private _lastClickTime;
327
- private _lastClickLine;
328
- private _isSearchBoxActive;
329
- private _isSearchLineBoxActive;
330
- private _searchMatchCase;
331
- private _lastTextFound;
332
- private _lastSearchPos;
333
- private _discardScroll;
334
- private _isReady;
335
- private _lastMaxLineLength;
336
- private _lastLineCount;
337
- private _isAutoCompleteActive;
338
- private _selectedAutocompleteIndex;
339
- private _displayObservers;
340
- private static readonly CODE_MIN_FONT_SIZE;
341
- private static readonly CODE_MAX_FONT_SIZE;
342
- private static readonly PAIR_KEYS;
343
- get doc(): CodeDocument;
344
- get undoManager(): UndoManager;
345
- get cursorSet(): CursorSet;
346
- get codeContainer(): HTMLElement;
347
- static getInstances(): CodeEditor[];
348
- constructor(area: typeof Area, options?: Record<string, any>);
349
- private _init;
350
- clear(): void;
351
- addExplorerItem(item: any): void;
352
- setText(text: string): void;
353
- appendText(text: string): void;
354
- getText(): string;
355
- setLanguage(name: string, extension?: string): void;
356
- focus(): void;
357
- addTab(name: string, options?: Record<string, any>): CodeTab;
358
- loadTab(name: string): void;
359
- closeTab(name: string): void;
360
- setCustomSuggestions(suggestions: string[]): void;
361
- loadFile(file: File | string, options?: Record<string, any>): void;
362
- loadFiles(files: string[], onComplete?: (editor: CodeEditor, results: any[], total: number) => void, async?: boolean): Promise<void>;
363
- _setupEditorWhenVisible(): Promise<void>;
364
- private _onSelectTab;
365
- private _onNewTab;
366
- private _onCreateNewFile;
367
- private _onContextMenuTab;
368
- private _measureChar;
369
- private _createStatusPanel;
370
- private _updateDataInfoPanel;
371
- /**
372
- * Tokenize a line and return its innerHTML with syntax highlighting spans.
373
- */
374
- private _tokenizeLine;
375
- /**
376
- * Update symbol table for a line.
377
- */
378
- private _updateSymbolsForLine;
379
- /**
380
- * Render all lines from scratch.
381
- */
382
- private _renderAllLines;
383
- /**
384
- * Gets the html for the line gutter.
385
- */
386
- private _getGutterHtml;
387
- /**
388
- * Create and append a <pre> element for a line.
389
- */
390
- private _appendLineElement;
391
- /**
392
- * Re-render a single line's content (after editing).
393
- */
394
- private _updateLine;
395
- /**
396
- * Rebuild line elements after structural changes (insert/delete lines).
397
- */
398
- private _rebuildLines;
399
- private _statesEqual;
400
- private _updateActiveLine;
401
- private _renderCursors;
402
- private _renderSelections;
403
- private _setFocused;
404
- private _startBlinker;
405
- private _stopBlinker;
406
- private _resetBlinker;
407
- private _setCursorVisibility;
408
- private _onKeyDown;
409
- private _flushIfActionChanged;
410
- private _flushAction;
411
- private _doInsertChar;
412
- private _getAffectedLines;
413
- private _commentLines;
414
- private _uncommentLines;
415
- private _doFindNextOcurrence;
416
- private _doOpenSearch;
417
- private _doOpenLineSearch;
418
- /**
419
- * Returns true if visibility changed.
420
- */
421
- private _doHideSearch;
422
- private _doSearch;
423
- private _doGotoLine;
424
- private _encloseSelection;
425
- private _doBackspace;
426
- private _doDelete;
427
- private _doEnter;
428
- private _doTab;
429
- private _deleteSelectionIfAny;
430
- private _doCopy;
431
- private _doCut;
432
- private _swapLine;
433
- private _duplicateLine;
434
- private _doPaste;
435
- private _doUndo;
436
- private _doRedo;
437
- private _onMouseDown;
438
- private _onContextMenu;
439
- /**
440
- * Get word at cursor position for autocomplete.
441
- */
442
- private _getWordAtCursor;
443
- /**
444
- * Open autocomplete box with suggestions from symbols and custom suggestions.
445
- */
446
- private _doOpenAutocomplete;
447
- private _doHideAutocomplete;
448
- /**
449
- * Insert the selected autocomplete word at cursor.
450
- */
451
- private _doAutocompleteWord;
452
- private _getSelectedAutoCompleteWord;
453
- private _afterCursorMove;
454
- private _scrollCursorIntoView;
455
- private _resetGutter;
456
- getMaxLineLength(): number;
457
- resize(force?: boolean): void;
458
- private _resizeScrollBars;
459
- private _syncScrollBars;
460
- private _doLoadFromFile;
461
- private _setFontSize;
462
- private _applyFontSizeOffset;
463
- private _increaseFontSize;
464
- private _decreaseFontSize;
465
- }
466
- export {};
1
+ interface Token {
2
+ type: string;
3
+ value: string;
4
+ }
5
+ interface TokenRule {
6
+ match: RegExp;
7
+ type: string;
8
+ next?: string;
9
+ pop?: boolean | number;
10
+ }
11
+ interface LanguageDef {
12
+ name: string;
13
+ extensions: string[];
14
+ states: Record<string, TokenRule[]>;
15
+ lineComment?: string;
16
+ icon?: string | Record<string, string>;
17
+ reservedWords: string[];
18
+ }
19
+ interface TokenizerState {
20
+ stack: string[];
21
+ }
22
+ interface TokenizeResult {
23
+ tokens: Token[];
24
+ state: TokenizerState;
25
+ }
26
+ export declare class Tokenizer {
27
+ private static languages;
28
+ private static extensionMap;
29
+ static registerLanguage(def: LanguageDef): void;
30
+ static getLanguage(name: string): LanguageDef | undefined;
31
+ static getLanguageByExtension(ext: string): LanguageDef | undefined;
32
+ static getRegisteredLanguages(): string[];
33
+ static initialState(): TokenizerState;
34
+ /**
35
+ * Tokenize a single line given a language and the state from the previous line.
36
+ * Returns the tokens and the updated state for the next line.
37
+ */
38
+ static tokenizeLine(line: string, language: LanguageDef, state: TokenizerState): TokenizeResult;
39
+ /**
40
+ * Merge consecutive tokens with the same type into one.
41
+ */
42
+ private static _mergeTokens;
43
+ }
44
+ declare class CodeDocument {
45
+ private onChange;
46
+ private _lines;
47
+ get lineCount(): number;
48
+ constructor(onChange?: (doc: CodeDocument) => void);
49
+ getLine(n: number): string;
50
+ getText(separator?: string): string;
51
+ setText(text: string): void;
52
+ getCharAt(line: number, col: number): string | undefined;
53
+ /**
54
+ * Get the word at a given position. Returns [word, startCol, endCol].
55
+ */
56
+ getWordAt(line: number, col: number): [string, number, number];
57
+ /**
58
+ * Get the indentation level (number of leading spaces) of a line.
59
+ */
60
+ getIndent(line: number): number;
61
+ /**
62
+ * Find the next occurrence of 'text' starting after (line, col). Returns null if no match.
63
+ */
64
+ findNext(text: string, startLine: number, startCol: number): {
65
+ line: number;
66
+ col: number;
67
+ } | null;
68
+ /**
69
+ * Insert text at a position (handles newlines in the inserted text).
70
+ */
71
+ insert(line: number, col: number, text: string): EditOperation;
72
+ /**
73
+ * Delete `length` characters forward from a position (handles crossing line boundaries).
74
+ */
75
+ delete(line: number, col: number, length: number): EditOperation;
76
+ /**
77
+ * Insert a new line after 'afterLine'. If afterLine is -1, inserts at the beginning.
78
+ */
79
+ insertLine(afterLine: number, text?: string): EditOperation;
80
+ /**
81
+ * Remove an entire line and its trailing newline.
82
+ */
83
+ removeLine(line: number): EditOperation;
84
+ replaceLine(line: number, newText: string): EditOperation;
85
+ /**
86
+ * Apply an edit operation (used by undo/redo).
87
+ */
88
+ applyInverse(op: EditOperation): EditOperation;
89
+ }
90
+ interface EditOperation {
91
+ type: 'insert' | 'delete' | 'replaceLine';
92
+ line: number;
93
+ col: number;
94
+ text: string;
95
+ oldText?: string;
96
+ }
97
+ declare class UndoManager {
98
+ private _undoStack;
99
+ private _redoStack;
100
+ private _pendingOps;
101
+ private _pendingCursorsBefore;
102
+ private _pendingCursorsAfter;
103
+ private _lastPushTime;
104
+ private _groupThresholdMs;
105
+ private _maxSteps;
106
+ constructor(groupThresholdMs?: number, maxSteps?: number);
107
+ /**
108
+ * Record an edit operation. Consecutive operations within the time threshold
109
+ * are grouped into a single undo step.
110
+ */
111
+ record(op: EditOperation, cursors: CursorPosition[]): void;
112
+ /**
113
+ * Force-flush pending operations into a final undo step.
114
+ */
115
+ flush(cursorsAfter?: CursorPosition[]): void;
116
+ /**
117
+ * Undo the last step. Stores the operations to apply inversely, and returns the cursor state to restore.
118
+ */
119
+ undo(doc: CodeDocument, currentCursors?: CursorPosition[]): {
120
+ cursors: CursorPosition[];
121
+ } | null;
122
+ /**
123
+ * Redo the last undone step. Returns the cursor state to restore.
124
+ */
125
+ redo(doc: CodeDocument): {
126
+ cursors: CursorPosition[];
127
+ } | null;
128
+ canUndo(): boolean;
129
+ canRedo(): boolean;
130
+ clear(): void;
131
+ private _flush;
132
+ }
133
+ interface CursorPosition {
134
+ line: number;
135
+ col: number;
136
+ }
137
+ interface Selection {
138
+ anchor: CursorPosition;
139
+ head: CursorPosition;
140
+ }
141
+ declare class CursorSet {
142
+ cursors: Selection[];
143
+ constructor();
144
+ getPrimary(): Selection;
145
+ /**
146
+ * Set a single cursor position. Clears all secondary cursors and selections.
147
+ */
148
+ set(line: number, col: number): void;
149
+ moveLeft(doc: CodeDocument, selecting?: boolean): void;
150
+ moveRight(doc: CodeDocument, selecting?: boolean): void;
151
+ moveUp(doc: CodeDocument, selecting?: boolean): void;
152
+ moveDown(doc: CodeDocument, selecting?: boolean): void;
153
+ moveToLineStart(doc: CodeDocument, selecting?: boolean, noIndent?: boolean): void;
154
+ moveToLineEnd(doc: CodeDocument, selecting?: boolean): void;
155
+ moveWordLeft(doc: CodeDocument, selecting?: boolean): void;
156
+ moveWordRight(doc: CodeDocument, selecting?: boolean): void;
157
+ selectAll(doc: CodeDocument): void;
158
+ addCursor(line: number, col: number): void;
159
+ removeSecondaryCursors(): void;
160
+ /**
161
+ * Returns cursor indices sorted by head position, bottom-to-top (last in doc first)
162
+ * to ensure earlier cursors' positions stay valid.
163
+ */
164
+ sortedIndicesBottomUp(): number[];
165
+ /**
166
+ * After editing at (line, col), shift all other cursors on the same line
167
+ * that are at or after `afterCol` by `colDelta`. Also handles line shifts
168
+ * for multi-line inserts/deletes via `lineDelta`.
169
+ */
170
+ adjustOthers(skipIdx: number, line: number, afterCol: number, colDelta: number, lineDelta?: number): void;
171
+ hasSelection(index?: number): boolean;
172
+ getSelectedText(doc: CodeDocument, index?: number): string;
173
+ getCursorPositions(): CursorPosition[];
174
+ private _moveHead;
175
+ private _moveVertical;
176
+ /**
177
+ * Merge overlapping cursors/selections. Keeps the first one when duplicates exist.
178
+ */
179
+ private _merge;
180
+ }
181
+ interface Symbol {
182
+ name: string;
183
+ kind: string;
184
+ scope: string;
185
+ line: number;
186
+ col?: number;
187
+ }
188
+ interface ScopeInfo {
189
+ name: string;
190
+ type: string;
191
+ line: number;
192
+ }
193
+ /**
194
+ * Manages code symbols for autocomplete, navigation, and outlining.
195
+ * Incrementally updates as lines change.
196
+ */
197
+ declare class SymbolTable {
198
+ private _symbols;
199
+ private _lineSymbols;
200
+ private _scopeStack;
201
+ private _lineScopes;
202
+ private _lineScopesEnd;
203
+ get currentScope(): string;
204
+ get currentScopeType(): string;
205
+ getScopeAtLine(line: number): ScopeInfo[];
206
+ getLineScopeEnd(line: number): ScopeInfo[];
207
+ getSymbols(name: string): Symbol[];
208
+ getAllSymbolNames(): string[];
209
+ getAllSymbols(): Symbol[];
210
+ getLineSymbols(line: number): Symbol[];
211
+ /** Update scope stack for a line (call before parsing symbols) */
212
+ updateScopeForLine(line: number, lineText: string): void;
213
+ /** Name the most recent anonymous scope (called when detecting class/function) */
214
+ nameCurrentScope(name: string, type: string): void;
215
+ /** Remove symbols from a line (before reparsing) */
216
+ removeLineSymbols(line: number): void;
217
+ addSymbol(symbol: Symbol): void;
218
+ /** Reset scope stack (e.g. when document structure changes significantly) */
219
+ resetScopes(): void;
220
+ clear(): void;
221
+ }
222
+ declare const Area: any;
223
+ declare const Panel: any;
224
+ declare const Tabs: any;
225
+ declare const NodeTree: any;
226
+ interface CodeTab {
227
+ name: string;
228
+ dom: HTMLElement;
229
+ doc: CodeDocument;
230
+ cursorSet: CursorSet;
231
+ undoManager: UndoManager;
232
+ language: string;
233
+ title?: string;
234
+ path?: string;
235
+ }
236
+ export interface CodeSuggestion {
237
+ label: string;
238
+ kind?: string;
239
+ scope?: string;
240
+ detail?: string;
241
+ insertText?: string;
242
+ filterText?: string;
243
+ sortText?: string;
244
+ icon?: string;
245
+ iconClass?: string;
246
+ }
247
+ export interface HoverSymbolInfo {
248
+ word: string;
249
+ tokenType: string;
250
+ symbols: Symbol[];
251
+ }
252
+ declare class ScrollBar {
253
+ static SIZE: number;
254
+ root: HTMLElement;
255
+ thumb: HTMLElement;
256
+ private _vertical;
257
+ private _thumbPos;
258
+ private _thumbRatio;
259
+ private _lastMouse;
260
+ private _onDrag;
261
+ get visible(): boolean;
262
+ get isVertical(): boolean;
263
+ constructor(vertical: boolean, onDrag: (delta: number) => void);
264
+ setThumbRatio(ratio: number): void;
265
+ syncToScroll(scrollPos: number, scrollMax: number): void;
266
+ applyDragDelta(delta: number, scrollMax: number): number;
267
+ private _applyPosition;
268
+ private _onMouseDown;
269
+ }
270
+ /**
271
+ * @class CodeEditor
272
+ * The main editor class. Wires Document, Tokenizer, CursorSet, UndoManager
273
+ * together with the DOM.
274
+ */
275
+ export declare class CodeEditor {
276
+ static __instances: CodeEditor[];
277
+ language: LanguageDef;
278
+ symbolTable: SymbolTable;
279
+ area: typeof Area;
280
+ baseArea: typeof Area;
281
+ codeArea: typeof Area;
282
+ explorerArea: typeof Area;
283
+ tabs: typeof Tabs;
284
+ root: HTMLElement;
285
+ codeScroller: HTMLElement;
286
+ codeSizer: HTMLElement;
287
+ cursorsLayer: HTMLElement;
288
+ selectionsLayer: HTMLElement;
289
+ lineGutter: HTMLElement;
290
+ vScrollbar: ScrollBar;
291
+ hScrollbar: ScrollBar;
292
+ searchBox: HTMLElement | null;
293
+ searchLineBox: HTMLElement | null;
294
+ autocomplete: HTMLElement | null;
295
+ currentTab: CodeTab | null;
296
+ statusPanel: typeof Panel;
297
+ leftStatusPanel: typeof Panel;
298
+ rightStatusPanel: typeof Panel;
299
+ explorer: typeof NodeTree | null;
300
+ charWidth: number;
301
+ lineHeight: number;
302
+ fontSize: number;
303
+ xPadding: number;
304
+ private _cachedTabsHeight;
305
+ private _cachedStatusPanelHeight;
306
+ skipInfo: boolean;
307
+ disableEdition: boolean;
308
+ skipTabs: boolean;
309
+ useFileExplorer: boolean;
310
+ useAutoComplete: boolean;
311
+ allowAddScripts: boolean;
312
+ allowClosingTabs: boolean;
313
+ allowLoadingFiles: boolean;
314
+ tabSize: number;
315
+ highlight: string;
316
+ newTabOptions: any[] | null;
317
+ customSuggestions: CodeSuggestion[];
318
+ explorerName: string;
319
+ onSave: (text: string, editor: CodeEditor) => void;
320
+ onRun: (text: string, editor: CodeEditor) => void;
321
+ onCtrlSpace: (text: string, editor: CodeEditor) => void;
322
+ onCreateStatusPanel: (panel: typeof Panel, editor: CodeEditor) => void;
323
+ onContextMenu: any;
324
+ onNewTab: (event: MouseEvent) => void;
325
+ onSelectTab: (name: string, editor: CodeEditor) => void;
326
+ onReady: ((editor: CodeEditor) => void) | undefined;
327
+ onCreateFile: ((editor: CodeEditor) => void) | undefined;
328
+ onCodeChange: ((doc: CodeDocument) => void) | undefined;
329
+ onHoverSymbol: ((info: HoverSymbolInfo, editor: CodeEditor) => string | HTMLElement | null | undefined) | undefined;
330
+ private _inputArea;
331
+ private _lineStates;
332
+ private _lineElements;
333
+ private _bracketOpenLine;
334
+ private _bracketCloseLine;
335
+ private _hoverTimer;
336
+ private _hoverPopup;
337
+ private _hoverWord;
338
+ private _colorPopover;
339
+ private _openedTabs;
340
+ private _loadedTabs;
341
+ private _storedTabs;
342
+ private _focused;
343
+ private _composing;
344
+ private _keyChain;
345
+ private _wasPaired;
346
+ private _lastAction;
347
+ private _blinkerInterval;
348
+ private _cursorVisible;
349
+ private _cursorBlinkRate;
350
+ private _clickCount;
351
+ private _lastClickTime;
352
+ private _lastClickLine;
353
+ private _isSearchBoxActive;
354
+ private _isSearchLineBoxActive;
355
+ private _searchMatchCase;
356
+ private _lastTextFound;
357
+ private _lastSearchPos;
358
+ private _discardScroll;
359
+ private _isReady;
360
+ private _lastMaxLineLength;
361
+ private _lastLineCount;
362
+ private _isAutoCompleteActive;
363
+ private _selectedAutocompleteIndex;
364
+ private _displayObservers;
365
+ private static readonly CODE_MIN_FONT_SIZE;
366
+ private static readonly CODE_MAX_FONT_SIZE;
367
+ private static readonly PAIR_KEYS;
368
+ get doc(): CodeDocument;
369
+ get undoManager(): UndoManager;
370
+ get cursorSet(): CursorSet;
371
+ get codeContainer(): HTMLElement;
372
+ static getInstances(): CodeEditor[];
373
+ constructor(area: typeof Area, options?: Record<string, any>);
374
+ private _init;
375
+ clear(): void;
376
+ addExplorerItem(item: any): void;
377
+ setText(text: string, language?: string, detectLang?: boolean): void;
378
+ private _detectLanguage;
379
+ appendText(text: string): void;
380
+ getText(): string;
381
+ setLanguage(name: string, extension?: string): void;
382
+ focus(): void;
383
+ addTab(name: string, options?: Record<string, any>): CodeTab;
384
+ loadTab(name: string): void;
385
+ closeTab(name: string): void;
386
+ setCustomSuggestions(suggestions: CodeSuggestion[] | string[]): void;
387
+ loadFile(file: File | string, options?: Record<string, any>): void;
388
+ loadFiles(files: string[], onComplete?: (editor: CodeEditor, results: any[], total: number) => void, async?: boolean): Promise<void>;
389
+ _setupEditorWhenVisible(): Promise<void>;
390
+ private _onSelectTab;
391
+ private _onNewTab;
392
+ private _onCreateNewFile;
393
+ private _onContextMenuTab;
394
+ private _measureChar;
395
+ private _createStatusPanel;
396
+ private _updateDataInfoPanel;
397
+ /**
398
+ * Tokenize a line and return its innerHTML with syntax highlighting spans.
399
+ */
400
+ private _tokenizeLine;
401
+ /**
402
+ * Update symbol table for a line.
403
+ */
404
+ private _updateSymbolsForLine;
405
+ /**
406
+ * Render all lines from scratch.
407
+ */
408
+ private _renderAllLines;
409
+ /**
410
+ * Gets the html for the line gutter.
411
+ */
412
+ private _getGutterHtml;
413
+ /**
414
+ * Create and append a <pre> element for a line.
415
+ */
416
+ private _appendLineElement;
417
+ /**
418
+ * Re-render a single line's content (after editing).
419
+ */
420
+ private _updateLine;
421
+ /**
422
+ * Rebuild line elements after structural changes (insert/delete lines).
423
+ */
424
+ private _rebuildLines;
425
+ private _statesEqual;
426
+ private _updateActiveLine;
427
+ private _renderCursors;
428
+ private _renderSelections;
429
+ private _setFocused;
430
+ private _startBlinker;
431
+ private _stopBlinker;
432
+ private _resetBlinker;
433
+ private _setCursorVisibility;
434
+ private _onKeyDown;
435
+ private _flushIfActionChanged;
436
+ private _flushAction;
437
+ private _doInsertChar;
438
+ private _getAffectedLines;
439
+ private _commentLines;
440
+ private _uncommentLines;
441
+ private _doFindNextOcurrence;
442
+ private _doOpenSearch;
443
+ private _doOpenLineSearch;
444
+ /**
445
+ * Returns true if visibility changed.
446
+ */
447
+ private _doHideSearch;
448
+ private _doSearch;
449
+ private _doGotoLine;
450
+ private _encloseSelection;
451
+ private _doBackspace;
452
+ private _doDelete;
453
+ private _doEnter;
454
+ private _doTab;
455
+ private _deleteSelectionIfAny;
456
+ private _doCopy;
457
+ private _doCut;
458
+ private _swapLine;
459
+ private _duplicateLine;
460
+ /**
461
+ * Normalize external text before inserting into the document:
462
+ * - Unify line endings to \n
463
+ * - Replace tab characters with the configured number of spaces
464
+ */
465
+ private _normalizeText;
466
+ private _doPaste;
467
+ private _doUndo;
468
+ private _doRedo;
469
+ private _onMouseDown;
470
+ private _onContextMenu;
471
+ /**
472
+ * Get word at cursor position for autocomplete.
473
+ */
474
+ private _getWordAtCursor;
475
+ /**
476
+ * Open autocomplete box with suggestions from symbols and custom suggestions.
477
+ */
478
+ private _doOpenAutocomplete;
479
+ private _doHideAutocomplete;
480
+ /**
481
+ * Insert the selected autocomplete word at cursor.
482
+ */
483
+ private _doAutocompleteWord;
484
+ private _getSelectedAutoCompleteWord;
485
+ private _afterCursorMove;
486
+ /**
487
+ * Returns the scope stack at the exact cursor position (line + column).
488
+ * Basically starts from getScopeAtLine and then counts real braces up to the cursor column.
489
+ */
490
+ private _getScopeAtCursor;
491
+ private _updateBracketHighlight;
492
+ private _onColorSwatchClick;
493
+ /**
494
+ * Extracts the parameter list from a function/method declaration line.
495
+ */
496
+ private _getSymbolParams;
497
+ /**
498
+ * Starting from the line where a class is defined, scans forward to find
499
+ * the constructor signature and returns its parameter list.
500
+ */
501
+ private _findConstructorParams;
502
+ /**
503
+ * Given multiple symbols with the same name, pick the most likely one for
504
+ * the hovered position using the available context data.
505
+ */
506
+ private _pickBestSymbol;
507
+ private _clearHoverPopup;
508
+ private _onCodeAreaMouseMove;
509
+ private _scrollCursorIntoView;
510
+ private _resetGutter;
511
+ getMaxLineLength(): number;
512
+ resize(force?: boolean): void;
513
+ private _resizeScrollBars;
514
+ private _syncScrollBars;
515
+ private _doLoadFromFile;
516
+ private _setFontSize;
517
+ private _applyFontSizeOffset;
518
+ private _increaseFontSize;
519
+ private _decreaseFontSize;
520
+ }
521
+ export {};