mirror of
https://github.com/Microsoft/vscode
synced 2024-09-20 19:18:03 +00:00
parent
5b0d712fa1
commit
31bcb5ad38
|
@ -28,16 +28,40 @@ configurationRegistry.registerConfiguration({
|
|||
'type': 'string',
|
||||
'default': TERMINAL_DEFAULT_SHELL_LINUX
|
||||
},
|
||||
'terminal.integrated.shellArgs.linux': {
|
||||
'description': nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal."),
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'string'
|
||||
},
|
||||
'default': []
|
||||
},
|
||||
'terminal.integrated.shell.osx': {
|
||||
'description': nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on OS X."),
|
||||
'type': 'string',
|
||||
'default': TERMINAL_DEFAULT_SHELL_OSX
|
||||
},
|
||||
'terminal.integrated.shellArgs.osx': {
|
||||
'description': nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the OS X terminal."),
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'string'
|
||||
},
|
||||
'default': []
|
||||
},
|
||||
'terminal.integrated.shell.windows': {
|
||||
'description': nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows."),
|
||||
'type': 'string',
|
||||
'default': TERMINAL_DEFAULT_SHELL_WINDOWS
|
||||
},
|
||||
'terminal.integrated.shellArgs.windows': {
|
||||
'description': nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."),
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'string'
|
||||
},
|
||||
'default': []
|
||||
},
|
||||
'terminal.integrated.fontFamily': {
|
||||
'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."),
|
||||
'type': 'string'
|
||||
|
|
|
@ -27,6 +27,11 @@ export interface ITerminalConfiguration {
|
|||
osx: string,
|
||||
windows: string
|
||||
},
|
||||
shellArgs: {
|
||||
linux: string[],
|
||||
osx: string[],
|
||||
windows: string[]
|
||||
},
|
||||
fontFamily: string,
|
||||
fontSize: number,
|
||||
lineHeight: number
|
||||
|
|
|
@ -76,6 +76,11 @@ export interface ITerminalFont {
|
|||
charHeight: number;
|
||||
}
|
||||
|
||||
export interface IShell {
|
||||
executable: string;
|
||||
args: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates terminal configuration logic, the primary purpose of this file is so that platform
|
||||
* specific test cases can be written.
|
||||
|
@ -137,15 +142,23 @@ export class TerminalConfigHelper {
|
|||
return this.measureFont(fontFamily, fontSize, lineHeight);
|
||||
}
|
||||
|
||||
public getShell(): string {
|
||||
public getShell(): IShell {
|
||||
let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
|
||||
let shell: IShell = {
|
||||
executable: '',
|
||||
args: []
|
||||
};
|
||||
if (this.platform === Platform.Windows) {
|
||||
return config.terminal.integrated.shell.windows;
|
||||
shell.executable = config.terminal.integrated.shell.windows;
|
||||
shell.args = config.terminal.integrated.shellArgs.windows;
|
||||
} else if (this.platform === Platform.Mac) {
|
||||
shell.executable = config.terminal.integrated.shell.osx;
|
||||
shell.args = config.terminal.integrated.shellArgs.osx;
|
||||
} else if (this.platform === Platform.Linux) {
|
||||
shell.executable = config.terminal.integrated.shell.linux;
|
||||
shell.args = config.terminal.integrated.shellArgs.linux;
|
||||
}
|
||||
if (this.platform === Platform.Mac) {
|
||||
return config.terminal.integrated.shell.osx;
|
||||
}
|
||||
return config.terminal.integrated.shell.linux;
|
||||
return shell;
|
||||
}
|
||||
|
||||
private toInteger(source: any, minimum?: number): number {
|
||||
|
|
|
@ -17,7 +17,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
|||
import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal';
|
||||
import {DomScrollableElement} from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
|
||||
import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
|
||||
import {IShell, ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
|
||||
|
||||
export class TerminalInstance {
|
||||
|
||||
|
@ -28,7 +28,7 @@ export class TerminalInstance {
|
|||
private font: ITerminalFont;
|
||||
|
||||
public constructor(
|
||||
private shell: string,
|
||||
private shell: IShell,
|
||||
private parentDomElement: HTMLElement,
|
||||
private contextService: IWorkspaceContextService,
|
||||
private terminalService: ITerminalService,
|
||||
|
@ -120,7 +120,10 @@ export class TerminalInstance {
|
|||
|
||||
private createTerminalProcess(): cp.ChildProcess {
|
||||
let env = this.cloneEnv();
|
||||
env['PTYSHELL'] = this.shell;
|
||||
env['PTYSHELL'] = this.shell.executable;
|
||||
this.shell.args.forEach((arg, i) => {
|
||||
env[`PTYSHELLARG${i}`] = arg;
|
||||
});
|
||||
env['PTYCWD'] = this.contextService.getWorkspace() ? this.contextService.getWorkspace().resource.fsPath : os.homedir();
|
||||
return cp.fork('./terminalProcess', [], {
|
||||
env: env,
|
||||
|
|
|
@ -8,7 +8,8 @@ var ptyJs = require('pty.js');
|
|||
|
||||
// The pty process needs to be run in its own child process to get around maxing out CPU on Mac,
|
||||
// see https://github.com/electron/electron/issues/38
|
||||
var ptyProcess = ptyJs.fork(process.env.PTYSHELL, [], {
|
||||
|
||||
var ptyProcess = ptyJs.fork(process.env.PTYSHELL, getArgs(), {
|
||||
name: fs.existsSync('/usr/share/terminfo/x/xterm-256color') ? 'xterm-256color' : 'xterm',
|
||||
cwd: process.env.PTYCWD
|
||||
});
|
||||
|
@ -27,4 +28,14 @@ process.on('message', function (message) {
|
|||
} else if (message.event === 'resize') {
|
||||
ptyProcess.resize(message.cols, message.rows);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getArgs() {
|
||||
var args = [];
|
||||
var i = 0;
|
||||
while (process.env['PTYSHELLARG' + i]) {
|
||||
args.push(process.env['PTYSHELLARG' + i]);
|
||||
i++;
|
||||
}
|
||||
return args;
|
||||
}
|
Loading…
Reference in a new issue