Skip to content

Instantly share code, notes, and snippets.

@exceedsystem
Last active November 3, 2024 22:18
Show Gist options
  • Save exceedsystem/c42d93bc635051c0687b8a437212c4b5 to your computer and use it in GitHub Desktop.
Save exceedsystem/c42d93bc635051c0687b8a437212c4b5 to your computer and use it in GitHub Desktop.
An example of 'Output to output window' macro for VSCodeMacros extension
// [VSCode Macros] extension
// https://marketplace.visualstudio.com/items?itemName=EXCEEDSYSTEM.vscode-macros
// License:MIT
const vscode = require('vscode');
// Create an output window for this macro
if (global.phee7Bie === undefined) {
// Store the output channel in the global variable for nodeJS
// ※The variable name 'phee7Bie' just means a unique global variable of this macro in the node JS
global.phee7Bie = {
outputWindow: vscode.window.createOutputChannel('My Output'),
};
}
const outputWindow = global.phee7Bie.outputWindow;
/**
* Macro configuration
*/
module.exports.macroCommands = {
OutputWindowExample: {
no: 1,
func: OutputToOutputWindow,
},
};
/**
* Output to the Output window
*/
function OutputToOutputWindow() {
// Show output window and then clear contents
outputWindow.show(false);
outputWindow.clear();
// Show dummy text to the output window
for (let i = 1; i <= 10; ++i) {
outputWindow.appendLine(`Dummy text ${i}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment