diff --git a/packages/console/src/browser/console-frontend-module.ts b/packages/console/src/browser/console-frontend-module.ts index 2cee38f9362e3..899417c992a86 100644 --- a/packages/console/src/browser/console-frontend-module.ts +++ b/packages/console/src/browser/console-frontend-module.ts @@ -16,19 +16,14 @@ import { ContainerModule } from '@theia/core/shared/inversify'; import { CommandContribution, MenuContribution } from '@theia/core'; -import { FrontendApplicationContribution, KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser'; +import { FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser'; import { ConsoleContribution } from './console-contribution'; import { ConsoleManager } from './console-manager'; -import { ConsoleInputFocusContext, ConsoleNavigationBackEnabled, ConsoleNavigationForwardEnabled, ConsoleContentFocusContext } from './console-keybinding-contexts'; import '../../src/browser/style/index.css'; export default new ContainerModule(bind => { bind(ConsoleManager).toSelf().inSingletonScope(); - bind(KeybindingContext).to(ConsoleInputFocusContext).inSingletonScope(); - bind(KeybindingContext).to(ConsoleContentFocusContext).inSingletonScope(); - bind(KeybindingContext).to(ConsoleNavigationBackEnabled).inSingletonScope(); - bind(KeybindingContext).to(ConsoleNavigationForwardEnabled).inSingletonScope(); bind(ConsoleContribution).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(ConsoleContribution); bind(CommandContribution).toService(ConsoleContribution); diff --git a/packages/console/src/browser/console-keybinding-contexts.ts b/packages/console/src/browser/console-keybinding-contexts.ts deleted file mode 100644 index 755c569707bbb..0000000000000 --- a/packages/console/src/browser/console-keybinding-contexts.ts +++ /dev/null @@ -1,107 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 TypeFox and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable, inject } from '@theia/core/shared/inversify'; -import { KeybindingContext } from '@theia/core/lib/browser'; -import { ConsoleManager } from './console-manager'; -import { ConsoleWidget } from './console-widget'; - -export namespace ConsoleKeybindingContexts { - - /** - * ID of a keybinding context that is enabled when the console content has the focus. - */ - export const consoleContentFocus = 'consoleContentFocus'; - - /** - * ID of a keybinding context that is enabled when the console input has the focus. - */ - export const consoleInputFocus = 'consoleInputFocus'; - - /** - * ID of a keybinding context that is enabled when the console history navigation back is enabled. - */ - export const consoleNavigationBackEnabled = 'consoleNavigationBackEnabled'; - - /** - * ID of a keybinding context that is enabled when the console history navigation forward is enabled. - */ - export const consoleNavigationForwardEnabled = 'consoleNavigationForwardEnabled'; - -} - -@injectable() -export class ConsoleInputFocusContext implements KeybindingContext { - - readonly id: string = ConsoleKeybindingContexts.consoleInputFocus; - - @inject(ConsoleManager) - protected readonly manager: ConsoleManager; - - isEnabled(): boolean { - const console = this.manager.activeConsole; - return !!console && this.isConsoleEnabled(console); - } - - protected isConsoleEnabled(console: ConsoleWidget): boolean { - return console.hasInputFocus(); - } - -} - -@injectable() -export class ConsoleContentFocusContext extends ConsoleInputFocusContext { - - override readonly id: string = ConsoleKeybindingContexts.consoleContentFocus; - - protected override isConsoleEnabled(console: ConsoleWidget): boolean { - return !console.input.isFocused(); - } - -} - -@injectable() -export class ConsoleNavigationBackEnabled extends ConsoleInputFocusContext { - - override readonly id: string = ConsoleKeybindingContexts.consoleNavigationBackEnabled; - - protected override isConsoleEnabled(console: ConsoleWidget): boolean { - if (!super.isConsoleEnabled(console)) { - return false; - } - const editor = console.input.getControl(); - return editor.getPosition()!.equals({ lineNumber: 1, column: 1 }); - } - -} - -@injectable() -export class ConsoleNavigationForwardEnabled extends ConsoleInputFocusContext { - - override readonly id: string = ConsoleKeybindingContexts.consoleNavigationForwardEnabled; - - protected override isConsoleEnabled(console: ConsoleWidget): boolean { - if (!super.isConsoleEnabled(console)) { - return false; - } - const editor = console.input.getControl(); - const model = console.input.getControl().getModel()!; - const lineNumber = model.getLineCount(); - const column = model.getLineMaxColumn(lineNumber); - return editor.getPosition()!.equals({ lineNumber, column }); - } - -} diff --git a/packages/debug/src/browser/debug-frontend-module.ts b/packages/debug/src/browser/debug-frontend-module.ts index f645edb64657c..d00eb179a8a9f 100644 --- a/packages/debug/src/browser/debug-frontend-module.ts +++ b/packages/debug/src/browser/debug-frontend-module.ts @@ -22,7 +22,7 @@ import { DebugWidget } from './view/debug-widget'; import { DebugPath, DebugService } from '../common/debug-service'; import { WidgetFactory, WebSocketConnectionProvider, FrontendApplicationContribution, - bindViewContribution, KeybindingContext + bindViewContribution } from '@theia/core/lib/browser'; import { DebugSessionManager } from './debug-session-manager'; import { DebugResourceResolver } from './debug-resource'; @@ -39,7 +39,6 @@ import { DebugFrontendApplicationContribution } from './debug-frontend-applicati import { DebugConsoleContribution } from './console/debug-console-contribution'; import { BreakpointManager } from './breakpoint/breakpoint-manager'; import { DebugEditorService } from './editor/debug-editor-service'; -import { InDebugModeContext, BreakpointWidgetInputFocusContext, BreakpointWidgetInputStrictFocusContext } from './debug-keybinding-contexts'; import { DebugEditorModelFactory, DebugEditorModel } from './editor/debug-editor-model'; import { bindDebugPreferences } from './debug-preferences'; import { DebugSchemaUpdater } from './debug-schema-updater'; @@ -100,9 +99,6 @@ export default new ContainerModule((bind: interfaces.Bind) => { bind(DebugResourceResolver).toSelf().inSingletonScope(); bind(ResourceResolver).toService(DebugResourceResolver); - bind(KeybindingContext).to(InDebugModeContext).inSingletonScope(); - bind(KeybindingContext).to(BreakpointWidgetInputFocusContext).inSingletonScope(); - bind(KeybindingContext).to(BreakpointWidgetInputStrictFocusContext).inSingletonScope(); bindViewContribution(bind, DebugFrontendApplicationContribution); bind(FrontendApplicationContribution).toService(DebugFrontendApplicationContribution); bind(TabBarToolbarContribution).toService(DebugFrontendApplicationContribution); diff --git a/packages/debug/src/browser/debug-keybinding-contexts.ts b/packages/debug/src/browser/debug-keybinding-contexts.ts deleted file mode 100644 index 6c8ea255ba896..0000000000000 --- a/packages/debug/src/browser/debug-keybinding-contexts.ts +++ /dev/null @@ -1,75 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 TypeFox and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable, inject } from '@theia/core/shared/inversify'; -import { KeybindingContext } from '@theia/core/lib/browser'; -import { DebugSessionManager } from './debug-session-manager'; -import { DebugEditorService } from './editor/debug-editor-service'; -import { DebugEditorModel } from './editor/debug-editor-model'; - -export namespace DebugKeybindingContexts { - - export const inDebugMode = 'inDebugMode'; - - export const breakpointWidgetInputFocus = 'breakpointWidgetInputFocus'; - - export const breakpointWidgetInputStrictFocus = 'breakpointWidgetInputStrictFocus'; - -} - -@injectable() -export class InDebugModeContext implements KeybindingContext { - - readonly id: string = DebugKeybindingContexts.inDebugMode; - - @inject(DebugSessionManager) - protected readonly manager: DebugSessionManager; - - isEnabled(): boolean { - return this.manager.inDebugMode; - } - -} - -@injectable() -export class BreakpointWidgetInputFocusContext implements KeybindingContext { - - readonly id: string = DebugKeybindingContexts.breakpointWidgetInputFocus; - - @inject(DebugEditorService) - protected readonly editors: DebugEditorService; - - isEnabled(): boolean { - const model = this.editors.model; - return !!model && !!model.breakpointWidget.position && this.isFocused(model); - } - - protected isFocused(model: DebugEditorModel): boolean { - return !!model.breakpointWidget.input && model.breakpointWidget.input.isFocused({ strict: true }); - } - -} - -@injectable() -export class BreakpointWidgetInputStrictFocusContext extends BreakpointWidgetInputFocusContext { - - override readonly id: string = DebugKeybindingContexts.breakpointWidgetInputStrictFocus; - - protected override isFocused(model: DebugEditorModel): boolean { - return super.isFocused(model) || model.editor.isFocused({ strict: true }); - } - -} diff --git a/packages/editor/src/browser/editor-frontend-module.ts b/packages/editor/src/browser/editor-frontend-module.ts index fea78996564e9..19b52d56b6120 100644 --- a/packages/editor/src/browser/editor-frontend-module.ts +++ b/packages/editor/src/browser/editor-frontend-module.ts @@ -19,13 +19,12 @@ import '../../src/browser/language-status/editor-language-status.css'; import { ContainerModule } from '@theia/core/shared/inversify'; import { CommandContribution, MenuContribution } from '@theia/core/lib/common'; -import { OpenHandler, WidgetFactory, FrontendApplicationContribution, KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser'; +import { OpenHandler, WidgetFactory, FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser'; import { VariableContribution } from '@theia/variable-resolver/lib/browser'; import { EditorManager, EditorAccess, ActiveEditorAccess, CurrentEditorAccess } from './editor-manager'; import { EditorContribution } from './editor-contribution'; import { EditorMenuContribution } from './editor-menu'; import { EditorCommandContribution } from './editor-command'; -import { EditorTextFocusContext, StrictEditorTextFocusContext, DiffEditorTextFocusContext } from './editor-keybinding-contexts'; import { EditorKeybindingContribution } from './editor-keybinding'; import { bindEditorPreferences } from './editor-preferences'; import { EditorWidgetFactory } from './editor-widget-factory'; @@ -54,10 +53,6 @@ export default new ContainerModule(bind => { bind(EditorMenuContribution).toSelf().inSingletonScope(); bind(MenuContribution).toService(EditorMenuContribution); - bind(StrictEditorTextFocusContext).toSelf().inSingletonScope(); - bind(KeybindingContext).toService(StrictEditorTextFocusContext); - bind(KeybindingContext).to(EditorTextFocusContext).inSingletonScope(); - bind(KeybindingContext).to(DiffEditorTextFocusContext).inSingletonScope(); bind(EditorKeybindingContribution).toSelf().inSingletonScope(); bind(KeybindingContribution).toService(EditorKeybindingContribution); diff --git a/packages/editor/src/browser/editor-keybinding-contexts.ts b/packages/editor/src/browser/editor-keybinding-contexts.ts deleted file mode 100644 index 9d478f5387411..0000000000000 --- a/packages/editor/src/browser/editor-keybinding-contexts.ts +++ /dev/null @@ -1,87 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 TypeFox and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable, inject } from '@theia/core/shared/inversify'; -import { KeybindingContext } from '@theia/core/lib/browser/keybinding'; -import { EditorManager } from './editor-manager'; -import { EditorWidget } from './editor-widget'; -import { DiffUris } from '@theia/core/lib/browser'; - -export namespace EditorKeybindingContexts { - - /** - * ID of a keybinding context that is enabled when the active text editor has the focus. - */ - export const editorTextFocus = 'editorTextFocus'; - - /** - * ID of a keybinding context that is enabled when the active diff editor has the focus. - */ - export const diffEditorTextFocus = 'diffEditorTextFocus'; - - /** - * Unique identifier of a keybinding context that is enabled if the active editor has the focus but it does not have any overlaying widgets, such as the content assist widget. - */ - export const strictEditorTextFocus = 'strictEditorTextFocus'; -} - -@injectable() -export class EditorTextFocusContext implements KeybindingContext { - - readonly id: string = EditorKeybindingContexts.editorTextFocus; - - @inject(EditorManager) - protected readonly editorManager: EditorManager; - - isEnabled(): boolean { - return !!this.getEditor(); - } - - protected getEditor(): EditorWidget | undefined { - const widget = this.editorManager.activeEditor; - if (widget && this.canHandle(widget)) { - return widget; - } - return undefined; - } - - protected canHandle(widget: EditorWidget): boolean { - return widget.editor.isFocused(); - } - -} - -@injectable() -export class DiffEditorTextFocusContext extends EditorTextFocusContext { - - override readonly id: string = EditorKeybindingContexts.diffEditorTextFocus; - - protected override canHandle(widget: EditorWidget): boolean { - return super.canHandle(widget) && DiffUris.isDiffUri(widget.editor.uri); - } - -} - -/** - * Keybinding context that is enabled when the active text editor has the focus **AND** it does not - * have any widgets (for example, the content assist widget) overlaying the active editor. - */ -@injectable() -export class StrictEditorTextFocusContext extends EditorTextFocusContext { - - override readonly id: string = EditorKeybindingContexts.strictEditorTextFocus; - -} diff --git a/packages/editor/src/browser/index.ts b/packages/editor/src/browser/index.ts index 93f40bd14bf8d..fa5faf6f67aa4 100644 --- a/packages/editor/src/browser/index.ts +++ b/packages/editor/src/browser/index.ts @@ -20,7 +20,6 @@ export * from './editor-widget'; export * from './editor-manager'; export * from './editor-command'; export * from './editor-menu'; -export * from './editor-keybinding-contexts'; export * from './editor-frontend-module'; export * from './editor-preferences'; export * from './decorations'; diff --git a/packages/git/src/browser/blame/blame-contribution.ts b/packages/git/src/browser/blame/blame-contribution.ts index cc3b1d5fdab3f..b35eed05637e3 100644 --- a/packages/git/src/browser/blame/blame-contribution.ts +++ b/packages/git/src/browser/blame/blame-contribution.ts @@ -18,7 +18,7 @@ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify' import { KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser'; import { CommandContribution, CommandRegistry, Command, MenuContribution, MenuModelRegistry, DisposableCollection } from '@theia/core/lib/common'; import { BlameDecorator } from './blame-decorator'; -import { EditorManager, EditorWidget, EditorTextFocusContext, StrictEditorTextFocusContext } from '@theia/editor/lib/browser'; +import { EditorManager, EditorWidget } from '@theia/editor/lib/browser'; import { BlameManager } from './blame-manager'; import URI from '@theia/core/lib/common/uri'; import { EDITOR_CONTEXT_MENU_SCM } from '@theia/scm-extra/lib/browser/scm-extra-contribution'; @@ -185,23 +185,3 @@ export class BlameContribution implements CommandContribution, KeybindingContrib } } - -@injectable() -export class BlameAnnotationsKeybindingContext extends EditorTextFocusContext { - - @inject(BlameContribution) - protected readonly blameContribution: BlameContribution; - - @inject(StrictEditorTextFocusContext) - protected readonly base: StrictEditorTextFocusContext; - - override id = BlameAnnotationsKeybindingContext.showsBlameAnnotations; - - protected override canHandle(widget: EditorWidget): boolean { - return this.base.isEnabled() && this.blameContribution.showsBlameAnnotations(widget.editor.uri); - } -} - -export namespace BlameAnnotationsKeybindingContext { - export const showsBlameAnnotations = 'showsBlameAnnotations'; -} diff --git a/packages/git/src/browser/blame/blame-module.ts b/packages/git/src/browser/blame/blame-module.ts index c2b5924658e30..af028178b21cb 100644 --- a/packages/git/src/browser/blame/blame-module.ts +++ b/packages/git/src/browser/blame/blame-module.ts @@ -15,9 +15,9 @@ // ***************************************************************************** import { interfaces } from '@theia/core/shared/inversify'; -import { KeybindingContribution, KeybindingContext } from '@theia/core/lib/browser'; +import { KeybindingContribution } from '@theia/core/lib/browser'; import { CommandContribution, MenuContribution } from '@theia/core/lib/common'; -import { BlameContribution, BlameAnnotationsKeybindingContext } from './blame-contribution'; +import { BlameContribution } from './blame-contribution'; import { BlameDecorator } from './blame-decorator'; import { BlameManager } from './blame-manager'; @@ -28,6 +28,4 @@ export function bindBlame(bind: interfaces.Bind): void { for (const serviceIdentifier of [CommandContribution, KeybindingContribution, MenuContribution]) { bind(serviceIdentifier).toService(BlameContribution); } - bind(BlameAnnotationsKeybindingContext).toSelf().inSingletonScope(); - bind(KeybindingContext).toService(BlameAnnotationsKeybindingContext); } diff --git a/packages/messages/src/browser/messages-frontend-module.ts b/packages/messages/src/browser/messages-frontend-module.ts index 2367036f8f8df..5a7fa32963998 100644 --- a/packages/messages/src/browser/messages-frontend-module.ts +++ b/packages/messages/src/browser/messages-frontend-module.ts @@ -21,8 +21,8 @@ import { MessageClient } from '@theia/core/lib/common'; import { NotificationManager } from './notifications-manager'; import { bindNotificationPreferences } from './notification-preferences'; import { NotificationsRenderer } from './notifications-renderer'; -import { NotificationsContribution, NotificationsKeybindingContext } from './notifications-contribution'; -import { FrontendApplicationContribution, KeybindingContribution, KeybindingContext, StylingParticipant } from '@theia/core/lib/browser'; +import { NotificationsContribution } from './notifications-contribution'; +import { FrontendApplicationContribution, KeybindingContribution, StylingParticipant } from '@theia/core/lib/browser'; import { CommandContribution } from '@theia/core'; import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution'; import { NotificationContentRenderer } from './notification-content-renderer'; @@ -36,8 +36,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(KeybindingContribution).toService(NotificationsContribution); bind(ColorContribution).toService(NotificationsContribution); bind(StylingParticipant).toService(NotificationsContribution); - bind(NotificationsKeybindingContext).toSelf().inSingletonScope(); - bind(KeybindingContext).toService(NotificationsKeybindingContext); bind(NotificationManager).toSelf().inSingletonScope(); rebind(MessageClient).toService(NotificationManager); bindNotificationPreferences(bind); diff --git a/packages/messages/src/browser/notifications-contribution.ts b/packages/messages/src/browser/notifications-contribution.ts index 6de74350e0bb5..b152f9c828c54 100644 --- a/packages/messages/src/browser/notifications-contribution.ts +++ b/packages/messages/src/browser/notifications-contribution.ts @@ -17,9 +17,8 @@ import { injectable, inject } from '@theia/core/shared/inversify'; import { FrontendApplicationContribution, StatusBar, FrontendApplication, StatusBarAlignment, - KeybindingContribution, KeybindingRegistry, KeybindingContext, StylingParticipant, ColorTheme, CssStyleCollector + KeybindingContribution, KeybindingRegistry, StylingParticipant, ColorTheme, CssStyleCollector } from '@theia/core/lib/browser'; -import { Keybinding } from '@theia/core/lib/common/keybinding'; import { NotificationsCommands } from './notifications-commands'; import { CommandContribution, CommandRegistry } from '@theia/core'; import { NotificationManager } from './notifications-manager'; @@ -217,19 +216,3 @@ export class NotificationsContribution implements FrontendApplicationContributio } } } - -@injectable() -export class NotificationsKeybindingContext implements KeybindingContext { - - @inject(NotificationManager) - protected readonly manager: NotificationManager; - - readonly id = NotificationsKeybindingContext.notificationsVisible; - isEnabled(_arg: Keybinding): boolean { - return this.manager.centerVisible || this.manager.toastsVisible; - } - -} -export namespace NotificationsKeybindingContext { - export const notificationsVisible = 'notificationsVisible'; -} diff --git a/packages/monaco/src/browser/monaco-frontend-module.ts b/packages/monaco/src/browser/monaco-frontend-module.ts index e0124adf42501..bf384e0d51a8d 100644 --- a/packages/monaco/src/browser/monaco-frontend-module.ts +++ b/packages/monaco/src/browser/monaco-frontend-module.ts @@ -39,7 +39,6 @@ import { PreferenceScope, PreferenceChange, OVERRIDE_PROPERTY_PATTERN, QuickInputService, StylingParticipant } from '@theia/core/lib/browser'; import { TextEditorProvider, DiffNavigatorProvider, TextEditor } from '@theia/editor/lib/browser'; -import { StrictEditorTextFocusContext } from '@theia/editor/lib/browser/editor-keybinding-contexts'; import { MonacoEditorProvider, MonacoEditorFactory } from './monaco-editor-provider'; import { MonacoEditorMenuContribution } from './monaco-menu'; import { MonacoEditorCommandHandlers } from './monaco-command'; @@ -54,7 +53,6 @@ import { MonacoStatusBarContribution } from './monaco-status-bar-contribution'; import { MonacoCommandService, MonacoCommandServiceFactory } from './monaco-command-service'; import { MonacoCommandRegistry } from './monaco-command-registry'; import { MonacoDiffNavigatorFactory } from './monaco-diff-navigator-factory'; -import { MonacoStrictEditorTextFocusContext } from './monaco-keybinding-contexts'; import { MonacoFrontendApplicationContribution } from './monaco-frontend-application-contribution'; import MonacoTextmateModuleBinder from './textmate/monaco-textmate-frontend-bindings'; import { MonacoBulkEditService } from './monaco-bulk-edit-service'; @@ -159,7 +157,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(MenuContribution).toService(MonacoEditorMenuContribution); bind(MonacoKeybindingContribution).toSelf().inSingletonScope(); bind(KeybindingContribution).toService(MonacoKeybindingContribution); - rebind(StrictEditorTextFocusContext).to(MonacoStrictEditorTextFocusContext).inSingletonScope(); bind(MonacoQuickInputImplementation).toSelf().inSingletonScope(); bind(MonacoQuickInputService).toSelf().inSingletonScope(); diff --git a/packages/monaco/src/browser/monaco-keybinding-contexts.ts b/packages/monaco/src/browser/monaco-keybinding-contexts.ts deleted file mode 100644 index 752ee2cd42573..0000000000000 --- a/packages/monaco/src/browser/monaco-keybinding-contexts.ts +++ /dev/null @@ -1,43 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 TypeFox and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable } from '@theia/core/shared/inversify'; -import { EditorWidget } from '@theia/editor/lib/browser/editor-widget'; -import { StrictEditorTextFocusContext } from '@theia/editor/lib/browser/editor-keybinding-contexts'; -import { MonacoEditor } from './monaco-editor'; - -/** - * Besides checking whether this editor is the currently active one and has the focus, it also checks the followings: - * - the suggest widget is visible - * - the find (and replace) widget is visible. - * - the rename input widget (which we use for refactoring and not find and replace) is visible. - * - * If any of the above-mentioned additional checks evaluates to `true` the `canHandle` will evaluate to `false`. - * - * See: https://github.com/eamodio/vscode-gitlens/blob/57226d54d1e929be04b02ee31ca294c50305481b/package.json#L2857 - */ -@injectable() -export class MonacoStrictEditorTextFocusContext extends StrictEditorTextFocusContext { - - protected override canHandle(widget: EditorWidget): boolean { - const { editor } = widget; - if (editor instanceof MonacoEditor) { - return editor.isFocused({ strict: true }); - } - return super.canHandle(widget); - } - -} diff --git a/packages/navigator/src/browser/navigator-frontend-module.ts b/packages/navigator/src/browser/navigator-frontend-module.ts index 7958560d17515..216265a1a702a 100644 --- a/packages/navigator/src/browser/navigator-frontend-module.ts +++ b/packages/navigator/src/browser/navigator-frontend-module.ts @@ -19,12 +19,11 @@ import '../../src/browser/open-editors-widget/open-editors.css'; import { ContainerModule } from '@theia/core/shared/inversify'; import { - KeybindingContext, bindViewContribution, + bindViewContribution, FrontendApplicationContribution, ApplicationShellLayoutMigration } from '@theia/core/lib/browser'; import { FileNavigatorWidget, FILE_NAVIGATOR_ID } from './navigator-widget'; -import { NavigatorActiveContext } from './navigator-keybinding-context'; import { FileNavigatorContribution } from './navigator-contribution'; import { createFileNavigatorWidget } from './navigator-container'; import { WidgetFactory } from '@theia/core/lib/browser/widget-manager'; @@ -55,8 +54,6 @@ export default new ContainerModule(bind => { bind(FrontendApplicationContribution).toService(FileNavigatorContribution); bind(TabBarToolbarContribution).toService(FileNavigatorContribution); - bind(KeybindingContext).to(NavigatorActiveContext).inSingletonScope(); - bind(FileNavigatorWidget).toDynamicValue(ctx => createFileNavigatorWidget(ctx.container) ); diff --git a/packages/navigator/src/browser/navigator-keybinding-context.ts b/packages/navigator/src/browser/navigator-keybinding-context.ts deleted file mode 100644 index ffd39c1924fb4..0000000000000 --- a/packages/navigator/src/browser/navigator-keybinding-context.ts +++ /dev/null @@ -1,36 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 Ericsson and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable, inject } from '@theia/core/shared/inversify'; -import { KeybindingContext, ApplicationShell } from '@theia/core/lib/browser'; -import { FileNavigatorWidget } from './navigator-widget'; - -export namespace NavigatorKeybindingContexts { - export const navigatorActive = 'navigatorActive'; -} - -@injectable() -export class NavigatorActiveContext implements KeybindingContext { - - readonly id: string = NavigatorKeybindingContexts.navigatorActive; - - @inject(ApplicationShell) - protected readonly applicationShell: ApplicationShell; - - isEnabled(): boolean { - return this.applicationShell.activeWidget instanceof FileNavigatorWidget; - } -} diff --git a/packages/terminal/src/browser/terminal-frontend-module.ts b/packages/terminal/src/browser/terminal-frontend-module.ts index c935e71138471..e5547eb1d64ad 100644 --- a/packages/terminal/src/browser/terminal-frontend-module.ts +++ b/packages/terminal/src/browser/terminal-frontend-module.ts @@ -20,7 +20,7 @@ import 'xterm/css/xterm.css'; import { ContainerModule, Container } from '@theia/core/shared/inversify'; import { CommandContribution, MenuContribution, nls } from '@theia/core/lib/common'; import { bindContributionProvider } from '@theia/core'; -import { KeybindingContribution, WebSocketConnectionProvider, WidgetFactory, KeybindingContext, FrontendApplicationContribution } from '@theia/core/lib/browser'; +import { KeybindingContribution, WebSocketConnectionProvider, WidgetFactory, FrontendApplicationContribution } from '@theia/core/lib/browser'; import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; import { TerminalFrontendContribution } from './terminal-frontend-contribution'; import { TerminalWidgetImpl, TERMINAL_WIDGET_FACTORY_ID } from './terminal-widget-impl'; @@ -28,7 +28,6 @@ import { TerminalWidget, TerminalWidgetOptions } from './base/terminal-widget'; import { ITerminalServer, terminalPath } from '../common/terminal-protocol'; import { TerminalWatcher } from '../common/terminal-watcher'; import { IShellTerminalServer, shellTerminalPath, ShellTerminalServerProxy } from '../common/shell-terminal-protocol'; -import { TerminalActiveContext, TerminalSearchVisibleContext } from './terminal-keybinding-contexts'; import { createCommonBindings } from '../common/terminal-common-module'; import { TerminalService } from './base/terminal-service'; import { bindTerminalPreferences } from './terminal-preferences'; @@ -50,8 +49,6 @@ import { export default new ContainerModule(bind => { bindTerminalPreferences(bind); - bind(KeybindingContext).to(TerminalActiveContext).inSingletonScope(); - bind(KeybindingContext).to(TerminalSearchVisibleContext).inSingletonScope(); bind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope(); bind(TerminalWatcher).toSelf().inSingletonScope(); diff --git a/packages/terminal/src/browser/terminal-keybinding-contexts.ts b/packages/terminal/src/browser/terminal-keybinding-contexts.ts deleted file mode 100644 index 715b1a5371869..0000000000000 --- a/packages/terminal/src/browser/terminal-keybinding-contexts.ts +++ /dev/null @@ -1,52 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 TypeFox and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -import { injectable, inject } from '@theia/core/shared/inversify'; -import { KeybindingContext, ApplicationShell } from '@theia/core/lib/browser'; -import { TerminalWidget } from './base/terminal-widget'; - -export namespace TerminalKeybindingContexts { - export const terminalActive = 'terminalActive'; - export const terminalHideSearch = 'hideSearch'; -} - -@injectable() -export class TerminalActiveContext implements KeybindingContext { - readonly id: string = TerminalKeybindingContexts.terminalActive; - - @inject(ApplicationShell) - protected readonly shell: ApplicationShell; - - isEnabled(): boolean { - return this.shell.activeWidget instanceof TerminalWidget; - } -} - -@injectable() -export class TerminalSearchVisibleContext implements KeybindingContext { - readonly id: string = TerminalKeybindingContexts.terminalHideSearch; - - @inject(ApplicationShell) - protected readonly shell: ApplicationShell; - - isEnabled(): boolean { - if (!(this.shell.activeWidget instanceof TerminalWidget)) { - return false; - } - const searchWidget = this.shell.activeWidget.getSearchBox(); - return searchWidget.isVisible; - } -}