Merge branch 'master' into sophiabranch

This commit is contained in:
sophiadrewfs 2021-11-02 11:51:35 -05:00
commit f5dfb2397b
2 changed files with 89 additions and 48 deletions

79
src/commands.ts Normal file
View File

@ -0,0 +1,79 @@
import * as vscode from 'vscode';
/**
* @type {Object} Command // Command to register with the VS Code Extension API
* @prop {string} command // Name of the command; e.g., 'mind-reader.selectTheme'
* @prop {callback} callback // Callback to register when `command` is invoked
*/
type Command = {
name: string,
callback: () => void
};
// The list of commands to register in the extension
const commands: Command[] = [
{
name: 'mind-reader.selectTheme',
// callbacks can be inlined...
callback: () => vscode.commands.executeCommand('workbench.action.selectTheme'),
},
{
name: 'mind-reader.increaseFontScale',
callback: increaseFontScale, // ...or factored out into separate functions below
},
{
name: 'mind-reader.decreaseFontScale',
callback: decreaseFontScale,
},
{
name: 'mind-reader.resetFontScale',
callback: resetFontScale,
},
{
name: 'mind-reader.increaseEditorScale',
callback: increaseEditorScale,
},
{
name: 'mind-reader.decreaseEditorScale',
callback: decreaseEditorScale,
},
{
name: 'mind-reader.resetEditorScale',
callback: resetEditorScale,
},
];
// COMMAND CALLBACK IMPLEMENTATIONS
function increaseFontScale(): void {
vscode.commands.executeCommand('editor.action.fontZoomIn');
}
function decreaseFontScale(): void {
vscode.commands.executeCommand('editor.action.fontZoomOut');
}
function resetFontScale(): void {
vscode.commands.executeCommand('editor.action.fontZoomReset');
}
function increaseEditorScale(): void {
vscode.commands.executeCommand('workbench.action.zoomIn');
}
function decreaseEditorScale(): void {
vscode.commands.executeCommand('workbench.action.zoomOut');
}
function resetEditorScale(): void {
vscode.commands.executeCommand('workbench.action.zoomReset');
}
export default commands;

View File

@ -1,5 +1,7 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as pl from './pylex'; import * as pl from './pylex';
import commands from './commands';
let parser: pl.Parser = new pl.Parser(); let parser: pl.Parser = new pl.Parser();
@ -9,54 +11,14 @@ export function activate(context: vscode.ExtensionContext) {
parser.parse('Beep Boop'); parser.parse('Beep Boop');
// Increase Font Scale // Register Commands
context.subscriptions.push( commands.forEach(command => {
vscode.commands.registerCommand('mind-reader.increaseFontScale', () => { let disposable = vscode.commands.registerCommand(
vscode.commands.executeCommand('editor.action.fontZoomIn'); command.name,
}) command.callback
); );
context.subscriptions.push(disposable);
// Decrease Font Scale });
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.decreaseFontScale', () => {
vscode.commands.executeCommand('editor.action.fontZoomOut');
})
);
// Reset Font Scale
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.resetFontScale', () => {
vscode.commands.executeCommand('editor.action.fontZoomReset');
})
);
// Increase Editor Scale
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.increaseEditorScale', () => {
vscode.commands.executeCommand('workbench.action.zoomIn');
})
);
// Decrease Editor Scale
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.decreaseEditorScale', () => {
vscode.commands.executeCommand('workbench.action.zoomOut');
})
);
// Reset Editor Scale
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.resetEditorScale', () => {
vscode.commands.executeCommand('workbench.action.zoomReset');
})
);
// Select Theme
context.subscriptions.push(
vscode.commands.registerCommand('mind-reader.selectTheme', () => {
vscode.commands.executeCommand('workbench.action.selectTheme');
})
);
} }
export function deactivate() {} export function deactivate() {}