Skip to content

Commit 6a358f7

Browse files
committed
Update types, fix debug logging and handler xterm calls
1 parent f20eb76 commit 6a358f7

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

src/typings/xterm.d.ts

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ declare module 'xterm' {
1515
*/
1616
export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
1717

18+
/**
19+
* A string representing log level.
20+
*/
21+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
22+
1823
/**
1924
* A string representing a renderer type.
2025
*/
@@ -107,6 +112,18 @@ declare module 'xterm' {
107112
*/
108113
lineHeight?: number;
109114

115+
/**
116+
* What log level to use, this will log for all levels below and including
117+
* what is set:
118+
*
119+
* 1. debug
120+
* 2. info (default)
121+
* 3. warn
122+
* 4. error
123+
* 5. off
124+
*/
125+
logLevel?: LogLevel;
126+
110127
/**
111128
* Whether to treat option as the meta key.
112129
*/
@@ -177,6 +194,12 @@ declare module 'xterm' {
177194
* not whitespace.
178195
*/
179196
windowsMode?: boolean;
197+
198+
/**
199+
* A string containing all characters that are considered word separated by the
200+
* double click to select work logic.
201+
*/
202+
wordSeparator?: string;
180203
}
181204

182205
/**
@@ -191,7 +214,7 @@ declare module 'xterm' {
191214
cursor?: string,
192215
/** The accent color of the cursor (fg color for a block cursor) */
193216
cursorAccent?: string,
194-
/** The selection color (can be transparent) */
217+
/** The selection background color (can be transparent) */
195218
selection?: string,
196219
/** ANSI black (eg. `\x1b[30m`) */
197220
black?: string,
@@ -483,12 +506,14 @@ declare module 'xterm' {
483506
* final character (e.g "m" for SGR) of the CSI sequence.
484507
* @param callback The function to handle the escape sequence. The callback
485508
* is called with the numerical params, as well as the special characters
486-
* (e.g. "$" for DECSCPP). Return true if the sequence was handled; false if
509+
* (e.g. "$" for DECSCPP). If the sequence has subparams the array will
510+
* contain subarrays with their numercial values.
511+
* Return true if the sequence was handled; false if
487512
* we should try a previous handler (set by addCsiHandler or setCsiHandler).
488513
* The most recently-added handler is tried first.
489514
* @return An IDisposable you can call to remove this handler.
490515
*/
491-
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
516+
addCsiHandler(flag: string, callback: (params: (number | number[])[], collect: string) => boolean): IDisposable;
492517

493518
/**
494519
* (EXPERIMENTAL) Adds a handler for OSC escape sequences.
@@ -668,12 +693,12 @@ declare module 'xterm' {
668693
* Retrieves an option's value from the terminal.
669694
* @param key The option key.
670695
*/
671-
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'rendererType' | 'termName'): string;
696+
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
672697
/**
673698
* Retrieves an option's value from the terminal.
674699
* @param key The option key.
675700
*/
676-
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode'): boolean;
701+
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode'): boolean;
677702
/**
678703
* Retrieves an option's value from the terminal.
679704
* @param key The option key.
@@ -700,13 +725,19 @@ declare module 'xterm' {
700725
* @param key The option key.
701726
* @param value The option value.
702727
*/
703-
setOption(key: 'fontFamily' | 'termName' | 'bellSound', value: string): void;
728+
setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
704729
/**
705730
* Sets an option on the terminal.
706731
* @param key The option key.
707732
* @param value The option value.
708733
*/
709734
setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'): void;
735+
/**
736+
* Sets an option on the terminal.
737+
* @param key The option key.
738+
* @param value The option value.
739+
*/
740+
setOption(key: 'logLevel', value: LogLevel): void;
710741
/**
711742
* Sets an option on the terminal.
712743
* @param key The option key.
@@ -724,7 +755,7 @@ declare module 'xterm' {
724755
* @param key The option key.
725756
* @param value The option value.
726757
*/
727-
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode', value: boolean): void;
758+
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode', value: boolean): void;
728759
/**
729760
* Sets an option on the terminal.
730761
* @param key The option key.
@@ -929,16 +960,16 @@ declare module 'xterm' {
929960
// Modifications to official .d.ts below
930961
declare module 'xterm' {
931962
interface TerminalCore {
932-
debug: boolean;
933-
934-
handler(text: string): void;
935-
936963
_onScroll: IEventEmitter<number>;
937964
_onKey: IEventEmitter<{ key: string }>;
938965

939966
_charSizeService: {
940967
width: number;
941968
height: number;
969+
};
970+
971+
_coreService: {
972+
triggerDataEvent(data: string, wasUserInput?: boolean): void;
942973
}
943974

944975
_renderService: {

src/vs/platform/driver/electron-browser/driver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class WindowDriver implements IWindowDriver {
206206
throw new Error(`Xterm not found: ${selector}`);
207207
}
208208

209-
xterm._core.handler(text);
209+
xterm._core._coreService.triggerDataEvent(text);
210210
}
211211

212212
async openDevTools(): Promise<void> {

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,7 @@ export class TerminalInstance implements ITerminalInstance {
14201420
}
14211421

14221422
public toggleEscapeSequenceLogging(): void {
1423-
this._xterm._core.debug = !this._xterm._core.debug;
1424-
this._xterm.setOption('debug', this._xterm._core.debug);
1423+
this._xterm.setOption('logLevel', 'debug');
14251424
}
14261425

14271426
public getInitialCwd(): Promise<string> {

0 commit comments

Comments
 (0)