Skip to content

Commit

Permalink
[keyboard] align with file and event naming conventions
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Apr 10, 2019
1 parent 8d73840 commit 3415c78
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/browser/keybinding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let disableJSDOM = enableJSDOM();

import { Container, injectable, ContainerModule } from 'inversify';
import { bindContributionProvider } from '../common/contribution-provider';
import { KeyboardLayoutProvider, NativeKeyboardLayout, KeyboardLayoutChangeNotifier } from '../common/keyboard/layout-provider';
import { KeyboardLayoutProvider, NativeKeyboardLayout, KeyboardLayoutChangeNotifier } from '../common/keyboard/keyboard-layout-provider';
import { ILogger } from '../common/logger';
import { KeybindingRegistry, KeybindingContext, Keybinding, KeybindingContribution, KeybindingScope } from './keybinding';
import { KeyCode, Key, KeyModifier, KeySequence } from './keyboard/keys';
Expand Down Expand Up @@ -355,7 +355,7 @@ class MockKeyboardLayoutProvider implements KeyboardLayoutProvider {
@injectable()
class MockKeyboardLayoutChangeNotifier implements KeyboardLayoutChangeNotifier {
private emitter = new Emitter<NativeKeyboardLayout>();
get onNativeLayoutChanged() {
get onDidChangeNativeLayout() {
return this.emitter.event;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { injectable, postConstruct } from 'inversify';
import { isOSX, isWindows } from '../../common/os';
import { Emitter } from '../../common/event';
import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/layout-provider';
import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/keyboard-layout-provider';

@injectable()
export class BrowserKeyboardLayoutProvider implements KeyboardLayoutProvider, KeyboardLayoutChangeNotifier {
Expand All @@ -37,14 +37,14 @@ export class BrowserKeyboardLayoutProvider implements KeyboardLayoutProvider, Ke
];
}

protected nativeLayoutChanged = new Emitter<NativeKeyboardLayout>();
protected readonly nativeLayoutChanged = new Emitter<NativeKeyboardLayout>();

get onNativeLayoutChanged() {
get onDidChangeNativeLayout() {
return this.nativeLayoutChanged.event;
}

@postConstruct()
protected initialize() {
protected initialize(): void {
const keyboard = (navigator as NavigatorExtension).keyboard;
if (keyboard && keyboard.addEventListener) {
keyboard.addEventListener('layoutchange', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/keyboard/browser-keyboard-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
********************************************************************************/

import { ContainerModule } from 'inversify';
import { KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/layout-provider';
import { BrowserKeyboardLayoutProvider } from './keyboard-browser';
import { KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/keyboard-layout-provider';
import { BrowserKeyboardLayoutProvider } from './browser-keyboard-layout-provider';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(BrowserKeyboardLayoutProvider).toSelf().inSingletonScope();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/keyboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

export * from './keys';
export * from './keyboard-layout-service';
export * from './keyboard-browser';
export * from './browser-keyboard-layout-provider';
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Container, injectable } from 'inversify';
import { Emitter } from '../../common/event';
import { KeyCode } from './keys';
import { KeyboardLayoutService } from './keyboard-layout-service';
import { KeyboardLayoutProvider, NativeKeyboardLayout, KeyboardLayoutChangeNotifier } from '../../common/keyboard/layout-provider';
import { KeyboardLayoutProvider, NativeKeyboardLayout, KeyboardLayoutChangeNotifier } from '../../common/keyboard/keyboard-layout-provider';
import * as os from '../../common/os';
import * as chai from 'chai';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('keyboard layout service', function () {
@injectable()
class MockLayoutProvider implements KeyboardLayoutProvider, KeyboardLayoutChangeNotifier {
emitter = new Emitter<NativeKeyboardLayout>();
get onNativeLayoutChanged() {
get onDidChangeNativeLayout() {
return this.emitter.event;
}
getNativeLayout(): Promise<NativeKeyboardLayout> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/keyboard/keyboard-layout-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { injectable, inject } from 'inversify';
import { IWindowsKeyMapping } from 'native-keymap';
import { isWindows } from '../../common/os';
import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/layout-provider';
import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier } from '../../common/keyboard/keyboard-layout-provider';
import { Emitter } from '../../common/event';
import { KeyCode, Key } from './keys';

Expand Down Expand Up @@ -59,7 +59,7 @@ export class KeyboardLayoutService {
}

async initialize(): Promise<void> {
this.layoutChangeNotifier.onNativeLayoutChanged(newLayout => this.updateLayout(newLayout));
this.layoutChangeNotifier.onDidChangeNativeLayout(newLayout => this.updateLayout(newLayout));
const initialLayout = await this.layoutProvider.getNativeLayout();
this.updateLayout(initialLayout);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface KeyboardLayoutProvider {
export const KeyboardLayoutChangeNotifier = Symbol('KeyboardLayoutChangeNotifier');

export interface KeyboardLayoutChangeNotifier {
onNativeLayoutChanged: Event<NativeKeyboardLayout>;
onDidChangeNativeLayout: Event<NativeKeyboardLayout>;
}

export interface NativeKeyboardLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { postConstruct, injectable } from 'inversify';
import { ipcRenderer } from 'electron';
import { KeyboardLayoutChangeNotifier, NativeKeyboardLayout } from '../../common/keyboard/layout-provider';
import { KeyboardLayoutChangeNotifier, NativeKeyboardLayout } from '../../common/keyboard/keyboard-layout-provider';
import { Emitter } from '../../common/event';

/**
Expand All @@ -26,14 +26,14 @@ import { Emitter } from '../../common/event';
@injectable()
export class ElectronKeyboardLayoutChangeNotifier implements KeyboardLayoutChangeNotifier {

protected nativeLayoutChanged = new Emitter<NativeKeyboardLayout>();
protected readonly nativeLayoutChanged = new Emitter<NativeKeyboardLayout>();

get onNativeLayoutChanged() {
get onDidChangeNativeLayout() {
return this.nativeLayoutChanged.event;
}

@postConstruct()
protected initialize() {
protected initialize(): void {
ipcRenderer.on('keyboardLayoutChanged', (event: Event, newLayout: NativeKeyboardLayout) => this.nativeLayoutChanged.fire(newLayout));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
********************************************************************************/

import { ContainerModule } from 'inversify';
import { KeyboardLayoutProvider, keyboardPath, KeyboardLayoutChangeNotifier } from '../../common/keyboard/layout-provider';
import { KeyboardLayoutProvider, keyboardPath, KeyboardLayoutChangeNotifier } from '../../common/keyboard/keyboard-layout-provider';
import { WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider';
import { ElectronKeyboardLayoutChangeNotifier } from './change-notifier';
import { ElectronKeyboardLayoutChangeNotifier } from './electron-keyboard-layout-change-notifier';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(KeyboardLayoutProvider).toDynamicValue(ctx =>
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/node/backend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { EnvVariablesServer, envVariablesPath } from './../common/env-variables'
import { EnvVariablesServerImpl } from './env-variables';
import { ConnectionContainerModule } from './messaging/connection-container-module';
import { QuickPickService, quickPickServicePath } from '../common/quick-pick-service';
import { KeyboardLayoutProvider, keyboardPath } from '../common/keyboard/layout-provider';
import { NativeKeyboardLayoutProvider } from './keyboard/native-layout';
import { KeyboardLayoutProvider, keyboardPath } from '../common/keyboard/keyboard-layout-provider';
import { NativeKeyboardLayoutProvider } from './keyboard/native-keyboard-layout-provider';

decorate(injectable(), ApplicationPackage);

Expand Down Expand Up @@ -90,5 +90,5 @@ export const backendApplicationModule = new ContainerModule(bind => {
new JsonRpcConnectionHandler(keyboardPath, () =>
ctx.container.get(KeyboardLayoutProvider)
)
);
).inSingletonScope();
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as nativeKeymap from 'native-keymap';
import { injectable } from 'inversify';
import { KeyboardLayoutProvider, NativeKeyboardLayout } from '../../common/keyboard/layout-provider';
import { KeyboardLayoutProvider, NativeKeyboardLayout } from '../../common/keyboard/keyboard-layout-provider';

@injectable()
export class NativeKeyboardLayoutProvider implements KeyboardLayoutProvider {
Expand Down

0 comments on commit 3415c78

Please sign in to comment.