6
6
import { getFontSnippets } from '../../../../base/browser/fonts.js' ;
7
7
import { KeyCode , KeyMod } from '../../../../base/common/keyCodes.js' ;
8
8
import { Schemas } from '../../../../base/common/network.js' ;
9
- import { isIOS , isWindows } from '../../../../base/common/platform.js' ;
10
9
import { URI } from '../../../../base/common/uri.js' ;
11
- import './media/terminal.css' ;
12
- import './media/terminalVoice.css' ;
13
- import './media/widgets.css' ;
14
- import './media/xterm.css' ;
15
10
import * as nls from '../../../../nls.js' ;
16
- import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../../../../platform/accessibility/common/accessibility.js' ;
17
- import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js' ;
18
11
import { Extensions as DragAndDropExtensions , IDragAndDropContributionRegistry , IDraggedResourceEditorInput } from '../../../../platform/dnd/browser/dnd.js' ;
19
12
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js' ;
20
13
import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
21
14
import { Registry } from '../../../../platform/registry/common/platform.js' ;
22
- import { GeneralShellType , ITerminalLogService , WindowsShellType } from '../../../../platform/terminal/common/terminal.js' ;
15
+ import { ITerminalLogService } from '../../../../platform/terminal/common/terminal.js' ;
23
16
import { TerminalLogService } from '../../../../platform/terminal/common/terminalLogService.js' ;
24
17
import { registerTerminalPlatformConfiguration } from '../../../../platform/terminal/common/terminalPlatformConfiguration.js' ;
25
18
import { EditorPaneDescriptor , IEditorPaneRegistry } from '../../../browser/editor.js' ;
26
19
import { ViewPaneContainer } from '../../../browser/parts/views/viewPaneContainer.js' ;
27
20
import { WorkbenchPhase , registerWorkbenchContribution2 } from '../../../common/contributions.js' ;
28
21
import { EditorExtensions , IEditorFactoryRegistry } from '../../../common/editor.js' ;
29
22
import { IViewContainersRegistry , IViewsRegistry , Extensions as ViewContainerExtensions , ViewContainerLocation } from '../../../common/views.js' ;
23
+ import { ITerminalProfileService , TERMINAL_VIEW_ID , TerminalCommandId } from '../common/terminal.js' ;
24
+ import { registerColors } from '../common/terminalColorRegistry.js' ;
25
+ import { registerTerminalConfiguration } from '../common/terminalConfiguration.js' ;
26
+ import { terminalStrings } from '../common/terminalStrings.js' ;
27
+ import './media/terminal.css' ;
28
+ import './media/terminalVoice.css' ;
29
+ import './media/widgets.css' ;
30
+ import './media/xterm.css' ;
30
31
import { RemoteTerminalBackendContribution } from './remoteTerminalBackend.js' ;
31
32
import { ITerminalConfigurationService , ITerminalEditorService , ITerminalGroupService , ITerminalInstanceService , ITerminalService , TerminalDataTransfers , terminalEditorId } from './terminal.js' ;
32
33
import { registerTerminalActions } from './terminalActions.js' ;
@@ -43,14 +44,8 @@ import { TerminalMainContribution } from './terminalMainContribution.js';
43
44
import { setupTerminalMenus } from './terminalMenus.js' ;
44
45
import { TerminalProfileService } from './terminalProfileService.js' ;
45
46
import { TerminalService } from './terminalService.js' ;
46
- import { TerminalViewPane } from './terminalView.js' ;
47
- import { ITerminalProfileService , TERMINAL_VIEW_ID , TerminalCommandId } from '../common/terminal.js' ;
48
- import { registerColors } from '../common/terminalColorRegistry.js' ;
49
- import { registerTerminalConfiguration } from '../common/terminalConfiguration.js' ;
50
- import { TerminalContextKeyStrings , TerminalContextKeys } from '../common/terminalContextKey.js' ;
51
- import { terminalStrings } from '../common/terminalStrings.js' ;
52
- import { registerSendSequenceKeybinding } from './terminalKeybindings.js' ;
53
47
import { TerminalTelemetryContribution } from './terminalTelemetry.js' ;
48
+ import { TerminalViewPane } from './terminalView.js' ;
54
49
55
50
// Register services
56
51
registerSingleton ( ITerminalLogService , TerminalLogService , InstantiationType . Delayed ) ;
@@ -133,120 +128,8 @@ Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).registerViews
133
128
}
134
129
} ] , VIEW_CONTAINER ) ;
135
130
136
- // Register actions
137
131
registerTerminalActions ( ) ;
138
132
139
- const enum Constants {
140
- /** The text representation of `^<letter>` is `'A'.charCodeAt(0) + 1`. */
141
- CtrlLetterOffset = 64
142
- }
143
-
144
- // An extra Windows-only ctrl+v keybinding is used for pwsh that sends ctrl+v directly to the
145
- // shell, this gets handled by PSReadLine which properly handles multi-line pastes. This is
146
- // disabled in accessibility mode as PowerShell does not run PSReadLine when it detects a screen
147
- // reader. This works even when clipboard.readText is not supported.
148
- if ( isWindows ) {
149
- registerSendSequenceKeybinding ( String . fromCharCode ( 'V' . charCodeAt ( 0 ) - Constants . CtrlLetterOffset ) , { // ctrl+v
150
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
151
- primary : KeyMod . CtrlCmd | KeyCode . KeyV
152
- } ) ;
153
- }
154
-
155
- // Map certain keybindings in pwsh to unused keys which get handled by PSReadLine handlers in the
156
- // shell integration script. This allows keystrokes that cannot be sent via VT sequences to work.
157
- // See https://github.com/microsoft/terminal/issues/879#issuecomment-497775007
158
- registerSendSequenceKeybinding ( '\x1b[24~a' , { // F12,a -> ctrl+space (MenuComplete)
159
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
160
- primary : KeyMod . CtrlCmd | KeyCode . Space ,
161
- mac : { primary : KeyMod . WinCtrl | KeyCode . Space }
162
- } ) ;
163
- registerSendSequenceKeybinding ( '\x1b[24~b' , { // F12,b -> alt+space (SetMark)
164
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
165
- primary : KeyMod . Alt | KeyCode . Space
166
- } ) ;
167
- registerSendSequenceKeybinding ( '\x1b[24~c' , { // F12,c -> shift+enter (AddLine)
168
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
169
- primary : KeyMod . Shift | KeyCode . Enter
170
- } ) ;
171
- registerSendSequenceKeybinding ( '\x1b[24~d' , { // F12,d -> shift+end (SelectLine) - HACK: \x1b[1;2F is supposed to work but it doesn't
172
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) , TerminalContextKeys . terminalShellIntegrationEnabled , CONTEXT_ACCESSIBILITY_MODE_ENABLED . negate ( ) ) ,
173
- mac : { primary : KeyMod . Shift | KeyMod . CtrlCmd | KeyCode . RightArrow }
174
- } ) ;
175
-
176
- // Always on pwsh keybindings
177
- registerSendSequenceKeybinding ( '\x1b[1;2H' , { // Shift+home
178
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , GeneralShellType . PowerShell ) ) ,
179
- mac : { primary : KeyMod . Shift | KeyMod . CtrlCmd | KeyCode . LeftArrow }
180
- } ) ;
181
-
182
- // Map ctrl+alt+r -> ctrl+r when in accessibility mode due to default run recent command keybinding
183
- registerSendSequenceKeybinding ( '\x12' , {
184
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , CONTEXT_ACCESSIBILITY_MODE_ENABLED ) ,
185
- primary : KeyMod . CtrlCmd | KeyMod . Alt | KeyCode . KeyR ,
186
- mac : { primary : KeyMod . WinCtrl | KeyMod . Alt | KeyCode . KeyR }
187
- } ) ;
188
-
189
- // Map ctrl+alt+g -> ctrl+g due to default go to recent directory keybinding
190
- registerSendSequenceKeybinding ( '\x07' , {
191
- when : TerminalContextKeys . focus ,
192
- primary : KeyMod . CtrlCmd | KeyMod . Alt | KeyCode . KeyG ,
193
- mac : { primary : KeyMod . WinCtrl | KeyMod . Alt | KeyCode . KeyG }
194
- } ) ;
195
-
196
- // send ctrl+c to the iPad when the terminal is focused and ctrl+c is pressed to kill the process (work around for #114009)
197
- if ( isIOS ) {
198
- registerSendSequenceKeybinding ( String . fromCharCode ( 'C' . charCodeAt ( 0 ) - Constants . CtrlLetterOffset ) , { // ctrl+c
199
- when : ContextKeyExpr . and ( TerminalContextKeys . focus ) ,
200
- primary : KeyMod . WinCtrl | KeyCode . KeyC
201
- } ) ;
202
- }
203
-
204
- // Delete word left: ctrl+w
205
- registerSendSequenceKeybinding ( String . fromCharCode ( 'W' . charCodeAt ( 0 ) - Constants . CtrlLetterOffset ) , {
206
- primary : KeyMod . CtrlCmd | KeyCode . Backspace ,
207
- mac : { primary : KeyMod . Alt | KeyCode . Backspace }
208
- } ) ;
209
- if ( isWindows ) {
210
- // Delete word left: ctrl+h
211
- // Windows cmd.exe requires ^H to delete full word left
212
- registerSendSequenceKeybinding ( String . fromCharCode ( 'H' . charCodeAt ( 0 ) - Constants . CtrlLetterOffset ) , {
213
- when : ContextKeyExpr . and ( TerminalContextKeys . focus , ContextKeyExpr . equals ( TerminalContextKeyStrings . ShellType , WindowsShellType . CommandPrompt ) ) ,
214
- primary : KeyMod . CtrlCmd | KeyCode . Backspace ,
215
- } ) ;
216
- }
217
- // Delete word right: alt+d [27, 100]
218
- registerSendSequenceKeybinding ( '\u001bd' , {
219
- primary : KeyMod . CtrlCmd | KeyCode . Delete ,
220
- mac : { primary : KeyMod . Alt | KeyCode . Delete }
221
- } ) ;
222
- // Delete to line start: ctrl+u
223
- registerSendSequenceKeybinding ( '\u0015' , {
224
- mac : { primary : KeyMod . CtrlCmd | KeyCode . Backspace }
225
- } ) ;
226
- // Move to line start: ctrl+A
227
- registerSendSequenceKeybinding ( String . fromCharCode ( 'A' . charCodeAt ( 0 ) - 64 ) , {
228
- mac : { primary : KeyMod . CtrlCmd | KeyCode . LeftArrow }
229
- } ) ;
230
- // Move to line end: ctrl+E
231
- registerSendSequenceKeybinding ( String . fromCharCode ( 'E' . charCodeAt ( 0 ) - 64 ) , {
232
- mac : { primary : KeyMod . CtrlCmd | KeyCode . RightArrow }
233
- } ) ;
234
- // NUL: ctrl+shift+2
235
- registerSendSequenceKeybinding ( '\u0000' , {
236
- primary : KeyMod . CtrlCmd | KeyMod . Shift | KeyCode . Digit2 ,
237
- mac : { primary : KeyMod . WinCtrl | KeyMod . Shift | KeyCode . Digit2 }
238
- } ) ;
239
- // RS: ctrl+shift+6
240
- registerSendSequenceKeybinding ( '\u001e' , {
241
- primary : KeyMod . CtrlCmd | KeyMod . Shift | KeyCode . Digit6 ,
242
- mac : { primary : KeyMod . WinCtrl | KeyMod . Shift | KeyCode . Digit6 }
243
- } ) ;
244
- // US (Undo): ctrl+/
245
- registerSendSequenceKeybinding ( '\u001f' , {
246
- primary : KeyMod . CtrlCmd | KeyCode . Slash ,
247
- mac : { primary : KeyMod . WinCtrl | KeyCode . Slash }
248
- } ) ;
249
-
250
133
setupTerminalCommands ( ) ;
251
134
252
135
setupTerminalMenus ( ) ;
0 commit comments