Skip to content

Commit

Permalink
Initial contribution of external terminal
Browse files Browse the repository at this point in the history
Signed-off-by: Duc Nguyen <[email protected]>
  • Loading branch information
DucNgn committed Dec 9, 2020
1 parent 4641a29 commit 36c2b8c
Show file tree
Hide file tree
Showing 14 changed files with 427 additions and 1 deletion.
3 changes: 3 additions & 0 deletions configs/root-compilation.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
},
{
"path": "../packages/timeline/compile.tsconfig.json"
},
{
"path": "../packages/terminal-external/compile.tsconfig.json"
}
]
}
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions packages/terminal-external/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div align='center'>

<br />

<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />

<h2>ECLIPSE THEIA - TERMINAL-EXTERNAL EXTENSION</h2>

<hr />

</div>

## Description

## Additional Information

## License

- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)

## Trademark

"Theia" is a trademark of the Eclipse Foundation
https://www.eclipse.org/theia
16 changes: 16 additions & 0 deletions packages/terminal-external/compile.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../configs/base.tsconfig",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
],
"references": [
{
"path": "../core/compile.tsconfig.json"
}
]
}
32 changes: 32 additions & 0 deletions packages/terminal-external/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "terminal-external",
"version": "1.7.0",
"description": "Theia - External Terminal Extension",
"keywords": [
"theia-extension"
],
"files": [
"lib",
"src",
"AppleScripts"
],
"dependencies": {
"@theia/core": "^1.7.0"
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest"
},
"scripts": {
"lint": "theiaext lint",
"build": "theiaext build",
"watch": "theiaext watch",
"clean": "theiaext clean",
"test": "theiaext test"
},
"theiaExtensions": [
{
"frontend": "lib/browser/terminal-external-frontend-module"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from 'inversify';
import {
CommandContribution,
CommandRegistry,
MessageService,
Command
} from '@theia/core/lib/common';
import { KeybindingRegistry } from '@theia/core/lib/browser';

export namespace TerminalExternalCommands {
export const OPEN: Command = {
id: 'terminal:external:open:native:console:command',
label: 'Open New External Terminal'
};
}

@injectable()
export class TerminalExternalCommandContribution implements CommandContribution {

@inject(MessageService)
private readonly messageService: MessageService;

registerCommands(registry: CommandRegistry): void {
registry.registerCommand(TerminalExternalCommands.OPEN, {
execute: () => this.openExternalTerminal()
});
}

registerKeybindings(keybindings: KeybindingRegistry): void {
keybindings.registerKeybinding({
command: TerminalExternalCommands.OPEN.id,
keybinding: 'shift+ctrlcmd+c'
});
}

protected openExternalTerminal(): void {
this.messageService.info('Trigger the command');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { CommandContribution } from '@theia/core/lib/common';
import { TerminalExternalCommandContribution } from './terminal-external-contribution';
import { bindTerminalExternalPreferences } from './terminal-external-preference';
import { ContainerModule } from 'inversify';

export default new ContainerModule(bind => {
bindTerminalExternalPreferences(bind);
bind(CommandContribution).to(TerminalExternalCommandContribution);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import {
createPreferenceProxy,
PreferenceProxy,
PreferenceSchema,
PreferenceService,
PreferenceContribution
} from '@theia/core/lib/browser';
import { DEFAULT_TERMINAL_APP_OSX } from '../node/terminal-external-service';
import { interfaces } from 'inversify';

export const TerminalExternalConfigSchema: PreferenceSchema = {
type: 'object',
properties: {
'terminal.explorerKind': {
type: 'string',
enum: [
'integrated',
'external'
],
description: 'Customizes what kind of terminal to launch',
default: 'integrated'
},
'terminal.external.windowsExec': {
type: 'string',
description: 'Customizes which terminal to run on Windows.',
default: ''
},
'terminal.external.osxExec': {
type: 'string',
description: 'Cuztomizes which terminal application to run on macOS.',
default: DEFAULT_TERMINAL_APP_OSX
},
'terminal.external.linuxExec': {
type: 'string',
description: 'Customizes which terminal to run on Linux.',
default: ''
}
}
};

export interface TerminalExternalConfiguration {
'terminal.explorerKind': string
'terminal.external.windowsExec': string
'terminal.external.osxExec': string
'terminal.external.linuxExec': string
}

export const TerminalExternalPreferences = Symbol('TerminalExternalPreferences');
export type TerminalExternalPreferences = PreferenceProxy<TerminalExternalConfiguration>;

export function createTerminalExternalPreferences(preferences: PreferenceService): TerminalExternalPreferences {
return createPreferenceProxy(preferences, TerminalExternalConfigSchema);
}

export function bindTerminalExternalPreferences(bind: interfaces.Bind): void {
bind(TerminalExternalPreferences).toDynamicValue(ctx => {
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
return createTerminalExternalPreferences(preferences);
});
bind(PreferenceContribution).toConstantValue({ schema: TerminalExternalConfigSchema });
}
47 changes: 47 additions & 0 deletions packages/terminal-external/src/common/terminal-external.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

/**
* TODO: Heavily inspired from vscode:
* https://github.com/microsoft/vscode/blob/cadabab73fef89fe0c4bfe23b5a33cd58e39ea9c/src%2Fvs%2Fworkbench%2Fcontrib%2FexternalTerminal%2Fcommon%2FexternalTerminal.ts
*/

export const ExternalTerminalServiceSymbol = Symbol('ExternalTerminalService');

export interface ExternalTerminalSettings {
linuxExec?: string;
osxExec?: string;
windowsExec?: string;
}

export interface ExternalTerminalService {
getDefaultTerminalName(): string;
openTerminal(cwd: string): void;
runInTerminal(
title: string,
cwd: string,
args: string[],
env: { [key: string]: string | null; },
settings: ExternalTerminalSettings
): Promise<number | undefined>;
}

export interface ExternalTerminalConfiguration {
terminal: {
explorerKind: 'intergrated' | 'external';
external: ExternalTerminalSettings;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/********************************************************************************
* Copyright (C) 2020 Ericsson and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

// import { isWindows, isOSX } from '@theia/core/lib/common/os';

Loading

0 comments on commit 36c2b8c

Please sign in to comment.