"Fossies" - the Fresh Open Source Software Archive

Member "vscode-1.49.1/src/vs/platform/accessibility/common/accessibilityService.ts" (16 Sep 2020, 2660 Bytes) of package /linux/misc/vscode-1.49.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*---------------------------------------------------------------------------------------------
    2  *  Copyright (c) Microsoft Corporation. All rights reserved.
    3  *  Licensed under the MIT License. See License.txt in the project root for license information.
    4  *--------------------------------------------------------------------------------------------*/
    5 
    6 import { Disposable } from 'vs/base/common/lifecycle';
    7 import { IAccessibilityService, AccessibilitySupport, CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
    8 import { Event, Emitter } from 'vs/base/common/event';
    9 import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
   10 import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
   11 
   12 export class AccessibilityService extends Disposable implements IAccessibilityService {
   13     declare readonly _serviceBrand: undefined;
   14 
   15     private _accessibilityModeEnabledContext: IContextKey<boolean>;
   16     protected _accessibilitySupport = AccessibilitySupport.Unknown;
   17     protected readonly _onDidChangeScreenReaderOptimized = new Emitter<void>();
   18 
   19     constructor(
   20         @IContextKeyService private readonly _contextKeyService: IContextKeyService,
   21         @IConfigurationService protected readonly _configurationService: IConfigurationService,
   22     ) {
   23         super();
   24         this._accessibilityModeEnabledContext = CONTEXT_ACCESSIBILITY_MODE_ENABLED.bindTo(this._contextKeyService);
   25         const updateContextKey = () => this._accessibilityModeEnabledContext.set(this.isScreenReaderOptimized());
   26         this._register(this._configurationService.onDidChangeConfiguration(e => {
   27             if (e.affectsConfiguration('editor.accessibilitySupport')) {
   28                 updateContextKey();
   29                 this._onDidChangeScreenReaderOptimized.fire();
   30             }
   31         }));
   32         updateContextKey();
   33         this.onDidChangeScreenReaderOptimized(() => updateContextKey());
   34     }
   35 
   36     get onDidChangeScreenReaderOptimized(): Event<void> {
   37         return this._onDidChangeScreenReaderOptimized.event;
   38     }
   39 
   40     isScreenReaderOptimized(): boolean {
   41         const config = this._configurationService.getValue('editor.accessibilitySupport');
   42         return config === 'on' || (config === 'auto' && this._accessibilitySupport === AccessibilitySupport.Enabled);
   43     }
   44 
   45     getAccessibilitySupport(): AccessibilitySupport {
   46         return this._accessibilitySupport;
   47     }
   48 
   49     alwaysUnderlineAccessKeys(): Promise<boolean> {
   50         return Promise.resolve(false);
   51     }
   52 
   53     setAccessibilitySupport(accessibilitySupport: AccessibilitySupport): void {
   54         if (this._accessibilitySupport === accessibilitySupport) {
   55             return;
   56         }
   57 
   58         this._accessibilitySupport = accessibilitySupport;
   59         this._onDidChangeScreenReaderOptimized.fire();
   60     }
   61 }