2023-09-14 23:22:19 +02:00
|
|
|
import * as vscode from 'vscode';
|
2024-09-06 14:15:34 +02:00
|
|
|
import * as codemp from 'codemp';
|
|
|
|
import * as commands from './commands';
|
2024-09-06 18:45:25 +02:00
|
|
|
import { CodempTreeProvider } from './tree';
|
|
|
|
|
|
|
|
export let provider = new CodempTreeProvider();
|
2023-12-24 15:04:34 +01:00
|
|
|
|
2024-08-29 00:04:58 +02:00
|
|
|
export let LOGGER = vscode.window.createOutputChannel("codemp", { log: true });
|
2024-02-14 15:41:32 +01:00
|
|
|
|
2024-02-12 19:22:50 +01:00
|
|
|
// extension is activated the very first time the command is executed
|
2023-09-14 23:22:19 +02:00
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
2024-02-12 19:22:50 +01:00
|
|
|
// start codemp log poller
|
2024-08-24 20:38:07 +02:00
|
|
|
log_poller_task(new codemp.JsLogger()); // don't await it! run it in background forever
|
2024-09-06 18:45:25 +02:00
|
|
|
let sub = vscode.window.registerTreeDataProvider('codemp-tree-view', provider);
|
|
|
|
context.subscriptions.push(sub);
|
2024-02-12 19:22:50 +01:00
|
|
|
|
|
|
|
// 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),
|
2024-09-15 03:11:13 +02:00
|
|
|
vscode.commands.registerCommand('codemp.share', commands.share),
|
2024-09-06 14:15:34 +02:00
|
|
|
vscode.commands.registerCommand('codemp.createWorkspace', commands.createWorkspace),
|
2024-09-09 15:59:41 +02:00
|
|
|
vscode.commands.registerCommand('codemp.inviteWorkspace', commands.inviteToWorkspace),
|
2024-09-06 14:15:34 +02:00
|
|
|
vscode.commands.registerCommand('codemp.listWorkspaces', commands.listWorkspaces),
|
2024-09-09 15:59:41 +02:00
|
|
|
vscode.commands.registerCommand('codemp.activeWorkspaces', commands.activeWorkspaces),
|
|
|
|
vscode.commands.registerCommand('codemp.leaveWorkspace', commands.leaveWorkspace),
|
2024-09-06 14:15:34 +02:00
|
|
|
vscode.commands.registerCommand('codemp.createBuffer', commands.createBuffer),
|
|
|
|
vscode.commands.registerCommand('codemp.listBuffers', commands.listBuffers),
|
|
|
|
vscode.commands.registerCommand('codemp.sync', commands.sync),
|
2024-09-09 15:59:41 +02:00
|
|
|
vscode.commands.registerCommand('codemp.refresh', commands.refresh),
|
2024-02-12 19:22:50 +01:00
|
|
|
]) {
|
|
|
|
context.subscriptions.push(cmd);
|
|
|
|
}
|
2023-10-01 10:47:53 +02:00
|
|
|
}
|
2023-09-14 23:22:19 +02:00
|
|
|
|
2024-02-14 15:41:32 +01:00
|
|
|
async function log_poller_task(logger: codemp.JsLogger) {
|
2024-02-12 19:22:50 +01:00
|
|
|
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-02-12 19:22:50 +01:00
|
|
|
}
|
2024-09-06 14:15:34 +02:00
|
|
|
}
|