forked from eclipse-theia/theia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial contribution of external terminal
Signed-off-by: Duc Nguyen <[email protected]>
- Loading branch information
Showing
14 changed files
with
427 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/terminal-external/src/browser/terminal-external-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/terminal-external/src/browser/terminal-external-frontend-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
77 changes: 77 additions & 0 deletions
77
packages/terminal-external/src/browser/terminal-external-preference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
47
packages/terminal-external/src/common/terminal-external.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/terminal-external/src/node/terminal-external-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
Oops, something went wrong.