codemp-vscode/src/extension.ts

35 lines
1.4 KiB
TypeScript
Raw Normal View History

import * as vscode from 'vscode';
2024-09-06 14:15:34 +02:00
import * as codemp from 'codemp';
import * as commands from './commands';
2023-12-24 15:04:34 +01:00
export let LOGGER = vscode.window.createOutputChannel("codemp", { log: true });
2024-02-14 15:41:32 +01:00
// extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// start codemp log poller
log_poller_task(new codemp.JsLogger()); // don't await it! run it in background forever
// register commands: the commandId parameter must match the command field in package.json
for (let cmd of [
2024-09-06 14:15:34 +02:00
vscode.commands.registerCommand('codemp.connect', commands.connect),
vscode.commands.registerCommand('codemp.join', commands.join),
vscode.commands.registerCommand('codemp.attach', commands.attach),
vscode.commands.registerCommand('codemp.createWorkspace', commands.createWorkspace),
vscode.commands.registerCommand('codemp.listWorkspaces', commands.listWorkspaces),
vscode.commands.registerCommand('codemp.createBuffer', commands.createBuffer),
vscode.commands.registerCommand('codemp.listBuffers', commands.listBuffers),
vscode.commands.registerCommand('codemp.sync', commands.sync),
]) {
context.subscriptions.push(cmd);
}
}
2024-02-14 15:41:32 +01:00
async function log_poller_task(logger: codemp.JsLogger) {
while (true) {
let message = await logger.message();
if (message === null) break;
2024-02-14 15:41:32 +01:00
LOGGER.info(message);
2024-09-06 14:15:34 +02:00
console.log(message);
}
2024-09-06 14:15:34 +02:00
}