forked from microsoft/WhackWhackTerminal
-
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.
Add APIs and skeleton ITerminalRenderer
- Loading branch information
Ilya Biryukov
committed
May 30, 2018
1 parent
6cb23f2
commit 7f1ef57
Showing
16 changed files
with
464 additions
and
27 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
64 changes: 64 additions & 0 deletions
64
Microsoft.VisualStudio.Terminal.Embeddable/ITerminalRenderer.cs
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,64 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
/// <summary> | ||
/// Terminal renderer | ||
/// </summary> | ||
[ComImport, Guid("150B7535-03F9-41C0-9515-17ECB8199FFE")] | ||
|
||
public interface ITerminalRenderer : ITerminalWindow | ||
{ | ||
/// <summary> | ||
/// Gets or sets the stream of terminal IO. | ||
/// The terminal will read from the stream to render the output and will write to it | ||
/// when there is user input. | ||
/// If reading returns 0 byte, the terminal is closed. | ||
/// The terminal assumes the data in the stream has UTF-8 encoding. | ||
/// Only sequential access is needed. | ||
/// If there is no stream set (the value is null), | ||
/// the terminal renderer doesn't show any output and ignores user input. | ||
/// </summary> | ||
Stream Stream { get; set; } | ||
|
||
/// <summary> | ||
/// A value indicating whether the render dimensions are fixed (true) | ||
/// or follow the windows size (false, the default). | ||
/// </summary> | ||
bool IsFixedDimensions { get; set; } | ||
|
||
/// <summary> | ||
/// Gets current rows | ||
/// </summary> | ||
int Rows { get; } | ||
|
||
/// <summary> | ||
/// Gets current cols | ||
/// </summary> | ||
int Cols { get; } | ||
|
||
/// <summary> | ||
/// Gets number of rows that can fit terminal window. | ||
/// Setting more rows than this value can cause extra scroll bar to appear. | ||
/// </summary> | ||
int WindowRows { get; } | ||
|
||
/// <summary> | ||
/// Gets number of cols that can fit terminal window. | ||
/// Setting more cols that this value can cause extral scroll bar to appear. | ||
/// </summary> | ||
int WindowCols { get; } | ||
|
||
/// <summary> | ||
/// An event that is fired when the terminal window is resized and either WindowRows or WindowCols have changed. | ||
/// </summary> | ||
event EventHandler WindowResized; | ||
|
||
/// <summary> | ||
/// Resizes the terminal renderer, changing its Rows and Cols dimensions. | ||
/// </summary> | ||
void Resize(int rows, int cols); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Microsoft.VisualStudio.Terminal.Embeddable/ITerminalRendererService.cs
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
[ComImport, Guid("250301DA-0BEA-4C4E-B199-C363C7C164B2")] | ||
public interface ITerminalRendererService | ||
{ | ||
/// <summary> | ||
/// Create a new terminal renderer instance with the given name. | ||
/// </summary> | ||
/// <param name="name">The name that will be displayed as the tool window title.</param> | ||
/// <returns>An instance of ITerminalRenderer</returns> | ||
Task<object> CreateTerminalRendererAsync(string name); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Microsoft.VisualStudio.Terminal.Embeddable/ITerminalWindow.cs
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,37 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
/// <summary> | ||
/// Terminal window | ||
/// </summary> | ||
[ComImport, Guid("4B833FE7-385E-4C2A-B207-1732213035FE")] | ||
public interface ITerminalWindow | ||
{ | ||
/// <summary> | ||
/// Shows the terminal window. | ||
/// </summary> | ||
/// <returns>A <see cref="Task"/> that completes once the tool window has been shown.</returns> | ||
Task ShowAsync(); | ||
|
||
/// <summary> | ||
/// Hides the terminal window. | ||
/// </summary> | ||
/// <returns>A <see cref="Task"/> that completes once the tool window has been hidden.</returns> | ||
Task HideAsync(); | ||
|
||
/// <summary> | ||
/// Closes the terminal window and destroys the underlying terminal instance. | ||
/// It is considered an error to call any methods on this object after close has been called. | ||
/// </summary> | ||
/// <returns>A <see cref="Task"/> that completes once the tool window has been closed.</returns> | ||
Task CloseAsync(); | ||
|
||
/// <summary> | ||
/// An event that is fired when the terminal closes. | ||
/// </summary> | ||
event EventHandler Closed; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Microsoft.VisualStudio.Terminal/BrowserBridge/IRendererScriptingObject.cs
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 @@ | ||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
internal interface IRendererScriptingObject | ||
{ | ||
string GetTheme(); | ||
string GetFontFamily(); | ||
int GetFontSize(); | ||
void InitPty(int cols, int rows, string directory); | ||
void ClosePty(); | ||
void CopyStringToClipboard(string stringToCopy); | ||
string GetClipboard(); | ||
void TermData(string data); | ||
void ResizePty(int cols, int rows); | ||
string GetLinkRegex(); | ||
void HandleLocalLink(string uri); | ||
bool ValidateLocalLink(string link); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
Microsoft.VisualStudio.Terminal/BrowserBridge/RendererScriptingObject.cs
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,88 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Security.Permissions; | ||
using System.Windows; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")] | ||
[ComVisible(true)] | ||
public class RendererScriptingObject : IRendererScriptingObject | ||
{ | ||
private readonly TermWindowPackage package; | ||
|
||
internal RendererScriptingObject(TermWindowPackage package) | ||
{ | ||
this.package = package; | ||
} | ||
|
||
public string GetTheme() | ||
{ | ||
return TerminalThemer.GetTheme(); | ||
} | ||
|
||
public string GetFontFamily() | ||
{ | ||
return this.package.OptionFontFamily; | ||
} | ||
|
||
public int GetFontSize() | ||
{ | ||
return this.package.OptionFontSize; | ||
} | ||
|
||
public void ClosePty() | ||
{ | ||
// Close pty | ||
} | ||
|
||
public void CopyStringToClipboard(string stringToCopy) | ||
{ | ||
Clipboard.SetText(stringToCopy ?? ""); | ||
} | ||
|
||
public string GetClipboard() | ||
{ | ||
return Clipboard.GetText(); | ||
} | ||
|
||
public string GetLinkRegex() | ||
{ | ||
return TerminalRegex.LocalLinkRegex.ToString(); | ||
} | ||
|
||
public void HandleLocalLink(string uri) | ||
{ | ||
TerminalRegex.HandleLocalLink(uri); | ||
} | ||
|
||
public void InitPty(int cols, int rows, string directory) | ||
{ | ||
string configuredShellPath; | ||
if (this.package.OptionTerminal == DefaultTerminal.Other) | ||
{ | ||
configuredShellPath = this.package.OptionShellPath; | ||
} | ||
else | ||
{ | ||
configuredShellPath = this.package.OptionTerminal.ToString(); | ||
} | ||
|
||
// this.ptyService.InvokeAsync("initTerm", this.shellPath ?? configuredShellPath, cols, rows, directory, ((object)this.args) ?? this.package.OptionStartupArgument, env).FileAndForget("WhackWhackTerminal/InitPty"); | ||
} | ||
|
||
public void ResizePty(int cols, int rows) | ||
{ | ||
// this.ptyService.InvokeAsync("resizeTerm", cols, rows).FileAndForget("WhackWhackTerminal/ResizePty"); | ||
} | ||
|
||
public void TermData(string data) | ||
{ | ||
// this.ptyService.InvokeAsync("termData", data).FileAndForget("WhackWhackTerminal/TermData"); | ||
} | ||
|
||
public bool ValidateLocalLink(string link) | ||
{ | ||
return TerminalRegex.ValidateLocalLink(link); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
/// <summary> | ||
/// This class implements the tool window exposed by this package and hosts a user control. | ||
/// </summary> | ||
[Guid(ToolWindowGuid)] | ||
public class RendererToolWindow : ToolWindowPane | ||
{ | ||
public const string ToolWindowGuid = "7f989465-4c63-4820-aa1c-c320682d2c73"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RendererToolWindow"/> class. | ||
/// </summary> | ||
public RendererToolWindow(TermWindowPackage package) : base(null) | ||
{ | ||
this.Content = new RendererToolWindowControl(package); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Microsoft.VisualStudio.Terminal/RendererToolWindowControl.xaml
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,15 @@ | ||
<UserControl | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Microsoft.VisualStudio.Terminal" | ||
xmlns:platformui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0" | ||
x:Class="Microsoft.VisualStudio.Terminal.RendererToolWindowControl" | ||
Background="{DynamicResource VsBrush.Window}" | ||
Foreground="{DynamicResource VsBrush.WindowText}" | ||
x:Name="MyToolWindow"> | ||
<Grid x:Name="mainGrid"> | ||
<local:BetterBrowser x:Name="terminalView" /> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.