Skip to content

Commit 060dfba

Browse files
authored
simplify screencast keyboard options (microsoft#187469)
fixes microsoft#179541
1 parent 2ff3c9a commit 060dfba

File tree

1 file changed

+48
-32
lines changed

1 file changed

+48
-32
lines changed

src/vs/workbench/browser/actions/developerActions.ts

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ class InspectContextKeysAction extends Action2 {
9292
}
9393
}
9494

95+
interface IScreencastKeyboardOptions {
96+
readonly showKeys?: boolean;
97+
readonly showCommands?: boolean;
98+
readonly showCommandGroups?: boolean;
99+
readonly showSingleEditorCursorMoves?: boolean;
100+
}
101+
95102
class ToggleScreencastModeAction extends Action2 {
96103

97104
static disposable: IDisposable | undefined;
@@ -259,11 +266,12 @@ class ToggleScreencastModeAction extends Action2 {
259266
return;
260267
}
261268

269+
const options = configurationService.getValue<IScreencastKeyboardOptions>('screencastMode.keyboardOptions');
262270
const event = new StandardKeyboardEvent(e);
263271
const shortcut = keybindingService.softDispatch(event, event.target);
264272

265273
// Hide the single arrow key pressed
266-
if (shortcut.kind === ResultKind.KbFound && shortcut.commandId && configurationService.getValue('screencastMode.hideSingleEditorCursorMoves') && (
274+
if (shortcut.kind === ResultKind.KbFound && shortcut.commandId && !(options.showSingleEditorCursorMoves ?? true) && (
267275
['cursorLeft', 'cursorRight', 'cursorUp', 'cursorDown'].includes(shortcut.commandId))
268276
) {
269277
return;
@@ -280,18 +288,17 @@ class ToggleScreencastModeAction extends Action2 {
280288
length = 0;
281289
}
282290

283-
const format = configurationService.getValue<'keys' | 'command' | 'commandWithGroup' | 'commandAndKeys' | 'commandWithGroupAndKeys'>('screencastMode.keyboardShortcutsFormat');
284291
const keybinding = keybindingService.resolveKeyboardEvent(event);
285292
const command = (this._isKbFound(shortcut) && shortcut.commandId) ? MenuRegistry.getCommand(shortcut.commandId) : null;
286293

287-
let titleLabel = '';
294+
let commandAndGroupLabel = '';
288295
let keyLabel: string | undefined | null = keybinding.getLabel();
289296

290297
if (command) {
291-
titleLabel = typeof command.title === 'string' ? command.title : command.title.value;
298+
commandAndGroupLabel = typeof command.title === 'string' ? command.title : command.title.value;
292299

293-
if ((format === 'commandWithGroup' || format === 'commandWithGroupAndKeys') && command.category) {
294-
titleLabel = `${typeof command.category === 'string' ? command.category : command.category.value}: ${titleLabel} `;
300+
if ((options.showCommandGroups ?? false) && command.category) {
301+
commandAndGroupLabel = `${typeof command.category === 'string' ? command.category : command.category.value}: ${commandAndGroupLabel} `;
295302
}
296303

297304
if (this._isKbFound(shortcut) && shortcut.commandId) {
@@ -304,13 +311,11 @@ class ToggleScreencastModeAction extends Action2 {
304311
}
305312
}
306313

307-
const onlyKeyboardShortcuts = configurationService.getValue('screencastMode.onlyKeyboardShortcuts');
308-
309-
if (format !== 'keys' && titleLabel && !onlyKeyboardShortcuts) {
310-
append(keyboardMarker, $('span.title', {}, `${titleLabel} `));
314+
if ((options.showCommands ?? true) && commandAndGroupLabel) {
315+
append(keyboardMarker, $('span.title', {}, `${commandAndGroupLabel} `));
311316
}
312317

313-
if (onlyKeyboardShortcuts || !titleLabel || (this._isKbFound(shortcut) && shortcut.commandId) && (format === 'keys' || format === 'commandAndKeys' || format === 'commandWithGroupAndKeys')) {
318+
if (options.showKeys ?? true) {
314319
// Fix label for arrow keys
315320
keyLabel = keyLabel?.replace('UpArrow', '↑')
316321
?.replace('DownArrow', '↓')
@@ -421,27 +426,38 @@ configurationRegistry.registerConfiguration({
421426
maximum: 100,
422427
description: localize('screencastMode.fontSize', "Controls the font size (in pixels) of the screencast mode keyboard.")
423428
},
424-
'screencastMode.keyboardShortcutsFormat': {
425-
enum: ['keys', 'command', 'commandWithGroup', 'commandAndKeys', 'commandWithGroupAndKeys'],
426-
enumDescriptions: [
427-
localize('keyboardShortcutsFormat.keys', "Keys."),
428-
localize('keyboardShortcutsFormat.command', "Command title."),
429-
localize('keyboardShortcutsFormat.commandWithGroup', "Command title prefixed by its group."),
430-
localize('keyboardShortcutsFormat.commandAndKeys', "Command title and keys."),
431-
localize('keyboardShortcutsFormat.commandWithGroupAndKeys', "Command title and keys, with the command prefixed by its group.")
432-
],
433-
description: localize('screencastMode.keyboardShortcutsFormat', "Controls what is displayed in the keyboard overlay when showing shortcuts."),
434-
default: 'commandAndKeys'
435-
},
436-
'screencastMode.onlyKeyboardShortcuts': {
437-
type: 'boolean',
438-
description: localize('screencastMode.onlyKeyboardShortcuts', "Show only keyboard shortcuts in screencast mode (do not include action names)."),
439-
default: false
440-
},
441-
'screencastMode.hideSingleEditorCursorMoves': {
442-
type: 'boolean',
443-
description: localize('screencastMode.hideSingleEditorCursorMoves', "Hide the single editor cursor move commands in screencast mode."),
444-
default: false
429+
'screencastMode.keyboardOptions': {
430+
type: 'object',
431+
description: localize('screencastMode.keyboardOptions.description', "Options for customizing the keyboard overlay in screencast mode."),
432+
properties: {
433+
'showKeys': {
434+
type: 'boolean',
435+
default: true,
436+
description: localize('screencastMode.keyboardOptions.showKeys', "Show raw keys.")
437+
},
438+
'showCommands': {
439+
type: 'boolean',
440+
default: true,
441+
description: localize('screencastMode.keyboardOptions.showCommands', "Show command names.")
442+
},
443+
'showCommandGroups': {
444+
type: 'boolean',
445+
default: false,
446+
description: localize('screencastMode.keyboardOptions.showCommandGroups', "Show command group names, when commands are also shown.")
447+
},
448+
'showSingleEditorCursorMoves': {
449+
type: 'boolean',
450+
default: true,
451+
description: localize('screencastMode.keyboardOptions.showSingleEditorCursorMoves', "Show single editor cursor move commands.")
452+
}
453+
},
454+
default: {
455+
'showKeys': true,
456+
'showCommands': true,
457+
'showCommandGroups': false,
458+
'showSingleEditorCursorMoves': true
459+
},
460+
additionalProperties: false
445461
},
446462
'screencastMode.keyboardOverlayTimeout': {
447463
type: 'number',

0 commit comments

Comments
 (0)