Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a user to change default keybindings #6880

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions packages/core/src/browser/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,11 @@ export namespace KeybindingScope {
export const length = KeybindingScope.END - KeybindingScope.DEFAULT;
}

export namespace Keybinding {

/**
* Returns with the string representation of the binding.
* Any additional properties which are not described on
* the `Keybinding` API will be ignored.
*
* @param binding the binding to stringify.
*/
export function stringify(binding: Keybinding): string {
const copy: Keybinding = {
command: binding.command,
keybinding: binding.keybinding,
context: binding.context
};
return JSON.stringify(copy);
}

/* Determine whether object is a KeyBinding */
// tslint:disable-next-line:no-any
export function is(arg: Keybinding | any): arg is Keybinding {
return !!arg && arg === Object(arg) && 'command' in arg && 'keybinding' in arg;
}
}

/**
* @deprecated import from `@theia/core/lib/common/keybinding` instead
*/
export type Keybinding = common.Keybinding;
export const Keybinding = common.Keybinding;

export interface ResolvedKeybinding extends Keybinding {
/**
Expand Down
26 changes: 26 additions & 0 deletions packages/core/src/common/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,29 @@ export interface Keybinding {
// tslint:disable-next-line no-any
args?: any;
}
export namespace Keybinding {

/**
* Returns with the string representation of the binding.
* Any additional properties which are not described on
* the `Keybinding` API will be ignored.
*
* @param binding the binding to stringify.
*/
export function stringify(binding: Keybinding): string {
const copy: Keybinding = {
command: binding.command,
keybinding: binding.keybinding,
context: binding.context,
when: binding.when,
args: binding.args
};
return JSON.stringify(copy);
}

/* Determine whether object is a KeyBinding */
// tslint:disable-next-line:no-any
export function is(arg: Keybinding | any): arg is Keybinding {
return !!arg && arg === Object(arg) && 'command' in arg && 'keybinding' in arg;
}
}
Loading