/
tokens.ts
174 lines (149 loc) · 3.88 KB
/
tokens.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
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
import { Terminal } from '@jupyterlab/services';
import { Token } from '@lumino/coreutils';
import { Widget } from '@lumino/widgets';
/**
* A class that tracks editor widgets.
*/
export interface ITerminalTracker
extends IWidgetTracker<MainAreaWidget<ITerminal.ITerminal>> {}
/**
* The editor tracker token.
*/
export const ITerminalTracker = new Token<ITerminalTracker>(
'@jupyterlab/terminal:ITerminalTracker',
`A widget tracker for terminals.
Use this if you want to be able to iterate over and interact with terminals
created by the application.`
);
/**
* The namespace for terminals. Separated from the widget so it can be lazy
* loaded.
*/
export namespace ITerminal {
export interface ITerminal extends Widget {
/**
* The terminal session associated with the widget.
*/
session: Terminal.ITerminalConnection;
/**
* Get a config option for the terminal.
*/
getOption<K extends keyof IOptions>(option: K): IOptions[K];
/**
* Set a config option for the terminal.
*/
setOption<K extends keyof IOptions>(option: K, value: IOptions[K]): void;
/**
* Refresh the terminal session.
*/
refresh(): Promise<void>;
/**
* Check if terminal has any text selected.
*/
hasSelection(): boolean;
/**
* Paste text into terminal.
*/
paste(data: string): void;
/**
* Get selected text from terminal.
*/
getSelection(): string | null;
}
/**
* Options for the terminal widget.
*/
export interface IOptions {
/**
* The font family used to render text.
*/
fontFamily?: string;
/**
* The font size of the terminal in pixels.
*/
fontSize: number;
/**
* The line height used to render text.
*/
lineHeight?: number;
/**
* The theme of the terminal.
*/
theme: Theme;
/**
* The amount of buffer scrollback to be used
* with the terminal
*/
scrollback?: number;
/**
* Whether to shut down the session when closing a terminal or not.
*/
shutdownOnClose: boolean;
/**
* Whether to close the widget when exiting a terminal or not.
*/
closeOnExit: boolean;
/**
* Whether to blink the cursor. Can only be set at startup.
*/
cursorBlink: boolean;
/**
* An optional command to run when the session starts.
*/
initialCommand: string;
/**
* Whether to enable screen reader support.
*/
screenReaderMode: boolean;
/**
* Whether to enable using Ctrl+V to paste.
*
* This setting has no effect on macOS, where Cmd+V is available.
*/
pasteWithCtrlV: boolean;
/**
* Whether to auto-fit the terminal to its host element size.
*/
autoFit?: boolean;
/**
* Treat option as meta key on macOS.
*/
macOptionIsMeta?: boolean;
}
/**
* The default options used for creating terminals.
*/
export const defaultOptions: IOptions = {
theme: 'inherit',
fontFamily: 'Menlo, Consolas, "DejaVu Sans Mono", monospace',
fontSize: 13,
lineHeight: 1.0,
scrollback: 1000,
shutdownOnClose: false,
closeOnExit: true,
cursorBlink: true,
initialCommand: '',
screenReaderMode: false, // False by default, can cause scrollbar mouse interaction issues.
pasteWithCtrlV: true,
autoFit: true,
macOptionIsMeta: false
};
/**
* A type for the terminal theme.
*/
export type Theme = 'light' | 'dark' | 'inherit';
/**
* A type for the terminal theme.
*/
export interface IThemeObject {
foreground: string;
background: string;
cursor: string;
cursorAccent: string;
selectionBackground: string;
selectionInactiveBackground: string;
}
}