9
9
*--------------------------------------------------------------------------------------------*/
10
10
11
11
import { Disposable } from 'vs/base/common/lifecycle' ;
12
- import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
13
12
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
14
- import { EditorOption } from 'vs/editor/common/config/editorOptions' ;
15
- import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings' ;
16
- import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode' ;
17
13
import { localize } from 'vs/nls' ;
18
14
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
19
15
import { AccessibilityVerbositySettingId , AccessibleViewProviderId , accessibleViewIsShown } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration' ;
20
16
import * as strings from 'vs/base/common/strings' ;
21
- import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
22
17
import { ICommandService } from 'vs/platform/commands/common/commands' ;
23
- import { NEW_UNTITLED_FILE_COMMAND_ID } from 'vs/workbench/contrib/files/browser/fileConstants' ;
24
18
import { ModesHoverController } from 'vs/editor/contrib/hover/browser/hover' ;
25
19
import { IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
26
20
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
27
21
import { getNotificationFromContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands' ;
28
22
import { IListService , WorkbenchList } from 'vs/platform/list/browser/listService' ;
29
23
import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys' ;
30
- import { IAccessibleViewService , IAccessibleContentProvider , IAccessibleViewOptions , AccessibleViewType } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
24
+ import { IAccessibleViewService , IAccessibleViewOptions , AccessibleViewType } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
31
25
import { IHoverService } from 'vs/workbench/services/hover/browser/hover' ;
32
26
import { alert } from 'vs/base/browser/ui/aria/aria' ;
33
27
import { AccessibilityHelpAction , AccessibleViewAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions' ;
@@ -37,124 +31,10 @@ import { ThemeIcon } from 'vs/base/common/themables';
37
31
import { Codicon } from 'vs/base/common/codicons' ;
38
32
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController' ;
39
33
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys' ;
40
- import { ContextKeyExpr , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
41
- import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys' ;
42
- import { CommentAccessibilityHelpNLS } from 'vs/workbench/contrib/comments/browser/comments.contribution' ;
43
- import { CommentCommandId } from 'vs/workbench/contrib/comments/common/commentCommandIds' ;
44
- import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
45
- import { AudioCue } from 'vs/platform/audioCues/browser/audioCueService' ;
34
+ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
46
35
import { AccessibleNotificationEvent , IAccessibleNotificationService } from 'vs/platform/accessibility/common/accessibility' ;
47
36
48
- export class EditorAccessibilityHelpContribution extends Disposable {
49
- static ID : 'editorAccessibilityHelpContribution' ;
50
- constructor ( ) {
51
- super ( ) ;
52
- this . _register ( AccessibilityHelpAction . addImplementation ( 95 , 'editor' , async accessor => {
53
- const codeEditorService = accessor . get ( ICodeEditorService ) ;
54
- const accessibleViewService = accessor . get ( IAccessibleViewService ) ;
55
- const instantiationService = accessor . get ( IInstantiationService ) ;
56
- const commandService = accessor . get ( ICommandService ) ;
57
- let codeEditor = codeEditorService . getActiveCodeEditor ( ) || codeEditorService . getFocusedCodeEditor ( ) ;
58
- if ( ! codeEditor ) {
59
- await commandService . executeCommand ( NEW_UNTITLED_FILE_COMMAND_ID ) ;
60
- codeEditor = codeEditorService . getActiveCodeEditor ( ) ! ;
61
- }
62
- accessibleViewService . show ( instantiationService . createInstance ( EditorAccessibilityHelpProvider , codeEditor ) ) ;
63
- } , EditorContextKeys . focus ) ) ;
64
- }
65
- }
66
-
67
- class EditorAccessibilityHelpProvider implements IAccessibleContentProvider {
68
- id = AccessibleViewProviderId . Editor ;
69
- onClose ( ) {
70
- this . _editor . focus ( ) ;
71
- }
72
- options : IAccessibleViewOptions = { type : AccessibleViewType . Help , readMoreUrl : 'https://go.microsoft.com/fwlink/?linkid=851010' } ;
73
- verbositySettingKey = AccessibilityVerbositySettingId . Editor ;
74
- constructor (
75
- private readonly _editor : ICodeEditor ,
76
- @IKeybindingService private readonly _keybindingService : IKeybindingService ,
77
- @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
78
- @IConfigurationService private readonly _configurationService : IConfigurationService
79
- ) {
80
- }
81
-
82
- provideContent ( ) : string {
83
- const options = this . _editor . getOptions ( ) ;
84
- const content = [ ] ;
85
-
86
- if ( options . get ( EditorOption . inDiffEditor ) ) {
87
- if ( options . get ( EditorOption . readOnly ) ) {
88
- content . push ( AccessibilityHelpNLS . readonlyDiffEditor ) ;
89
- } else {
90
- content . push ( AccessibilityHelpNLS . editableDiffEditor ) ;
91
- }
92
- } else {
93
- if ( options . get ( EditorOption . readOnly ) ) {
94
- content . push ( AccessibilityHelpNLS . readonlyEditor ) ;
95
- } else {
96
- content . push ( AccessibilityHelpNLS . editableEditor ) ;
97
- }
98
- }
99
- const saveAudioCue = this . _configurationService . getValue ( AudioCue . save . settingsKey ) ;
100
- switch ( saveAudioCue ) {
101
- case 'never' :
102
- content . push ( AccessibilityHelpNLS . saveAudioCueDisabled ) ;
103
- break ;
104
- case 'always' :
105
- content . push ( AccessibilityHelpNLS . saveAudioCueAlways ) ;
106
- break ;
107
- case 'userGesture' :
108
- content . push ( AccessibilityHelpNLS . saveAudioCueUserGesture ) ;
109
- break ;
110
- }
111
- const formatAudioCue = this . _configurationService . getValue ( AudioCue . format . settingsKey ) ;
112
- switch ( formatAudioCue ) {
113
- case 'never' :
114
- content . push ( AccessibilityHelpNLS . formatAudioCueDisabled ) ;
115
- break ;
116
- case 'always' :
117
- content . push ( AccessibilityHelpNLS . formatAudioCueAlways ) ;
118
- break ;
119
- case 'userGesture' :
120
- content . push ( AccessibilityHelpNLS . formatAudioCueUserGesture ) ;
121
- break ;
122
- }
123
-
124
- const commentCommandInfo = getCommentCommandInfo ( this . _keybindingService , this . _contextKeyService , this . _editor ) ;
125
- if ( commentCommandInfo ) {
126
- content . push ( commentCommandInfo ) ;
127
- }
128
-
129
- if ( options . get ( EditorOption . stickyScroll ) . enabled ) {
130
- content . push ( descriptionForCommand ( 'editor.action.focusStickyScroll' , AccessibilityHelpNLS . stickScrollKb , AccessibilityHelpNLS . stickScrollNoKb , this . _keybindingService ) ) ;
131
- }
132
-
133
- if ( options . get ( EditorOption . tabFocusMode ) ) {
134
- content . push ( descriptionForCommand ( ToggleTabFocusModeAction . ID , AccessibilityHelpNLS . tabFocusModeOnMsg , AccessibilityHelpNLS . tabFocusModeOnMsgNoKb , this . _keybindingService ) ) ;
135
- } else {
136
- content . push ( descriptionForCommand ( ToggleTabFocusModeAction . ID , AccessibilityHelpNLS . tabFocusModeOffMsg , AccessibilityHelpNLS . tabFocusModeOffMsgNoKb , this . _keybindingService ) ) ;
137
- }
138
- return content . join ( '\n\n' ) ;
139
- }
140
- }
141
-
142
- export function getCommentCommandInfo ( keybindingService : IKeybindingService , contextKeyService : IContextKeyService , editor : ICodeEditor ) : string | undefined {
143
- const editorContext = contextKeyService . getContext ( editor . getDomNode ( ) ! ) ;
144
- if ( editorContext . getValue < boolean > ( CommentContextKeys . activeEditorHasCommentingRange . key ) ) {
145
- const commentCommandInfo : string [ ] = [ ] ;
146
- commentCommandInfo . push ( CommentAccessibilityHelpNLS . intro ) ;
147
- commentCommandInfo . push ( descriptionForCommand ( CommentCommandId . Add , CommentAccessibilityHelpNLS . addComment , CommentAccessibilityHelpNLS . addCommentNoKb , keybindingService ) ) ;
148
- commentCommandInfo . push ( descriptionForCommand ( CommentCommandId . NextThread , CommentAccessibilityHelpNLS . nextCommentThreadKb , CommentAccessibilityHelpNLS . nextCommentThreadNoKb , keybindingService ) ) ;
149
- commentCommandInfo . push ( descriptionForCommand ( CommentCommandId . PreviousThread , CommentAccessibilityHelpNLS . previousCommentThreadKb , CommentAccessibilityHelpNLS . previousCommentThreadNoKb , keybindingService ) ) ;
150
- commentCommandInfo . push ( descriptionForCommand ( CommentCommandId . NextRange , CommentAccessibilityHelpNLS . nextRange , CommentAccessibilityHelpNLS . nextRangeNoKb , keybindingService ) ) ;
151
- commentCommandInfo . push ( descriptionForCommand ( CommentCommandId . PreviousRange , CommentAccessibilityHelpNLS . previousRange , CommentAccessibilityHelpNLS . previousRangeNoKb , keybindingService ) ) ;
152
- return commentCommandInfo . join ( '\n' ) ;
153
- }
154
- return ;
155
- }
156
-
157
- function descriptionForCommand ( commandId : string , msg : string , noKbMsg : string , keybindingService : IKeybindingService ) : string {
37
+ export function descriptionForCommand ( commandId : string , msg : string , noKbMsg : string , keybindingService : IKeybindingService ) : string {
158
38
const kb = keybindingService . lookupKeybinding ( commandId ) ;
159
39
if ( kb ) {
160
40
return strings . format ( msg , kb . getAriaLabel ( ) ) ;
0 commit comments