-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8440af2
commit 31bcda4
Showing
6 changed files
with
166 additions
and
8 deletions.
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
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
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
78 changes: 78 additions & 0 deletions
78
src/vs/workbench/contrib/terminal/browser/terminalEditor.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,78 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Dimension } from 'vs/base/browser/dom'; | ||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; | ||
import { IStorageService } from 'vs/platform/storage/common/storage'; | ||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; | ||
import { IThemeService } from 'vs/platform/theme/common/themeService'; | ||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane'; | ||
import { IEditorInputSerializer } from 'vs/workbench/common/editor'; | ||
import { ITerminalInstance, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal'; | ||
import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput'; | ||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; | ||
|
||
|
||
export class TerminalEditor extends EditorPane { | ||
|
||
public static readonly ID = 'terminalEditor'; | ||
|
||
private _instance: ITerminalInstance | undefined; | ||
private _parentElement: HTMLElement | undefined; | ||
private _isAttached: boolean = false; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
protected createEditor(parent: HTMLElement): void { | ||
this._parentElement = parent; | ||
this._instance = this._terminalService.createInstance({}); | ||
} | ||
|
||
layout(dimension: Dimension): void { | ||
if (this._instance) { | ||
this._instance.layout(dimension); | ||
} | ||
} | ||
|
||
override setVisible(visible: boolean, group?: IEditorGroup): void { | ||
super.setVisible(visible, group); | ||
|
||
if (!this._instance) { | ||
return; | ||
} | ||
|
||
if (!this._isAttached) { | ||
this._instance.attachToElement(this._parentElement!); | ||
this._isAttached = true; | ||
} | ||
this._instance.setVisible(visible); | ||
} | ||
|
||
constructor( | ||
@ITelemetryService telemetryService: ITelemetryService, | ||
@IThemeService themeService: IThemeService, | ||
@IStorageService storageService: IStorageService, | ||
@ITerminalService private readonly _terminalService: ITerminalService | ||
) { | ||
|
||
super(TerminalEditor.ID, telemetryService, themeService, storageService); | ||
} | ||
} | ||
|
||
export class TerminalInputSerializer implements IEditorInputSerializer { | ||
public canSerialize(editorInput: TerminalEditorInput): boolean { | ||
return true; | ||
} | ||
|
||
public serialize(editorInput: TerminalEditorInput): string { | ||
return ''; | ||
} | ||
|
||
public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): TerminalEditorInput { | ||
try { | ||
return new TerminalEditorInput(); | ||
} catch { } | ||
return new TerminalEditorInput(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/vs/workbench/contrib/terminal/browser/terminalEditorInput.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,33 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Schemas } from 'vs/base/common/network'; | ||
import { URI } from 'vs/base/common/uri'; | ||
import { localize } from 'vs/nls'; | ||
import { EditorInput } from 'vs/workbench/common/editor/editorInput'; | ||
|
||
export const terminalInputId = 'workbench.editors.terminal'; | ||
export class TerminalEditorInput extends EditorInput { | ||
|
||
static readonly ID = terminalInputId; | ||
static readonly RESOURCE = URI.from({ scheme: Schemas.vscodeTerminal, authority: 'vscode_editor_terminal' }); | ||
|
||
override get typeId(): string { | ||
return TerminalEditorInput.ID; | ||
} | ||
|
||
get resource(): URI | undefined { | ||
return TerminalEditorInput.RESOURCE; | ||
} | ||
|
||
constructor( | ||
) { | ||
super(); | ||
} | ||
|
||
override getName() { | ||
return localize('terminal.editor.input', "Terminal"); | ||
} | ||
} |
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