From 1a8dc5eaa00d8bd6a57f4610e03df6eb92a1ac2f Mon Sep 17 00:00:00 2001 From: Enguerrand de Ribaucourt Date: Fri, 5 Jan 2024 17:32:00 +0100 Subject: [PATCH] wip-bitbake-terminal-profile --- client/package.json | 8 ++++++++ client/src/extension.ts | 4 ++++ client/src/ui/BitbakeTerminalProfile.ts | 27 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 client/src/ui/BitbakeTerminalProfile.ts diff --git a/client/package.json b/client/package.json index 0c1ed5711..d32cd04fb 100644 --- a/client/package.json +++ b/client/package.json @@ -542,6 +542,14 @@ "when": "viewItem == devtoolWorskpaceCtx" } ] + }, + "terminal": { + "profiles": [ + { + "id": "bitbake.terminal", + "title": "bitbake" + } + ] } }, "scripts": { diff --git a/client/src/extension.ts b/client/src/extension.ts index 84eedfa46..2fa98d303 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -19,6 +19,7 @@ import { BitBakeProjectScanner } from './driver/BitBakeProjectScanner' import { BitbakeDocumentLinkProvider } from './documentLinkProvider' import { DevtoolWorkspacesView } from './ui/DevtoolWorkspacesView' import { bitbakeESDKMode, setBitbakeESDKMode } from './driver/BitbakeESDK' +import { BitbakeTerminalProfileProvider } from './ui/BitbakeTerminalProfile' let client: LanguageClient const bitbakeDriver: BitbakeDriver = new BitbakeDriver() @@ -29,6 +30,7 @@ export let bitbakeExtensionContext: vscode.ExtensionContext // eslint-disable-next-line @typescript-eslint/no-unused-vars let bitbakeRecipesView: BitbakeRecipesView | undefined let devtoolWorkspacesView: DevtoolWorkspacesView | undefined +let terminalProvider: BitbakeTerminalProfileProvider | undefined function loadLoggerSettings (): void { logger.level = vscode.workspace.getConfiguration('bitbake').get('loggingLevel') ?? 'info' @@ -84,6 +86,8 @@ export async function activate (context: vscode.ExtensionContext): Promise void vscode.commands.executeCommand('setContext', 'bitbake.active', true) const bitbakeStatusBar = new BitbakeStatusBar(bitBakeProjectScanner) context.subscriptions.push(bitbakeStatusBar.statusBarItem) + terminalProvider = new BitbakeTerminalProfileProvider(bitbakeDriver) + vscode.window.registerTerminalProfileProvider('bitbake.terminal', terminalProvider) const provider = new BitbakeDocumentLinkProvider(client) const selector = { scheme: 'file', language: 'bitbake' } diff --git a/client/src/ui/BitbakeTerminalProfile.ts b/client/src/ui/BitbakeTerminalProfile.ts new file mode 100644 index 000000000..cd8f478c6 --- /dev/null +++ b/client/src/ui/BitbakeTerminalProfile.ts @@ -0,0 +1,27 @@ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) 2023 Savoir-faire Linux. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ + +import type * as vscode from 'vscode' +import { BitbakePseudoTerminal } from './BitbakeTerminal' +import { type BitbakeDriver } from '../driver/BitbakeDriver' + +export class BitbakeTerminalProfileProvider implements vscode.TerminalProfileProvider { + private readonly bitbakeDriver: BitbakeDriver + + constructor (bitbakeDriver: BitbakeDriver) { + this.bitbakeDriver = bitbakeDriver + } + + provideTerminalProfile (token: vscode.CancellationToken): vscode.ProviderResult { + const pty = new BitbakePseudoTerminal(this.bitbakeDriver) + pty.runProcess('bash') // let the fun begin! + return { + options: { + name: 'Bitbake', + pty + } satisfies vscode.ExtensionTerminalOptions + } + } +}