This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Ilya Biryukov
committed
Jun 12, 2018
1 parent
6cb23f2
commit fccd3c0
Showing
21 changed files
with
635 additions
and
182 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
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,56 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
public delegate void TerminalDataRecievedEventHandler(object sender, string data); | ||
|
||
/// <summary> | ||
/// Terminal renderer. | ||
/// The terminal starts in auto-fit mode where terminal size always matches the window size when window resizes. | ||
/// After a first call to <c>ResizeAsyc()</c>, the terminal switches to fixed size mode where the terminal size stays | ||
/// fixed and doesn't change when the window size changes. In this mode the terminal size can only be changed | ||
/// with <c>ResizeAsync()</c>. To show the terminal inside the window, a dotted border will be displayed | ||
/// on the bottom and right sides of it. | ||
/// If the terminal window gets smaller than the terminal, some parts of the terminal may get clipped from view. | ||
/// </summary> | ||
[ComImport, Guid("150B7535-03F9-41C0-9515-17ECB8199FFE")] | ||
public interface ITerminalRenderer : ITerminal | ||
{ | ||
/// <summary> | ||
/// Gets current cols of the terminal window. | ||
/// </summary> | ||
int Cols { get; } | ||
|
||
/// <summary> | ||
/// Gets current rows of the terminal window. | ||
/// </summary> | ||
int Rows { get; } | ||
|
||
/// <summary> | ||
/// Changes the size of the terminal. | ||
/// After that the terminal size may not match the terminal window size. | ||
/// <c>Rows</c> and <c>Cols</c> always match the terminal window, and may differ from the terminal size | ||
/// after <c>ResizeAsync</c> is called. | ||
/// Calling<c>ResizeAsync</c> doesn't cause <c>TerminalResized</c> event. | ||
/// </summary> | ||
Task ResizeAsync(int cols, int rows, CancellationToken cancellationToken); | ||
|
||
/// <summary> | ||
/// An event that is fired when the terminal window is resized and either Rows or Cols have changed. | ||
/// </summary> | ||
event EventHandler TerminalResized; | ||
|
||
/// <summary> | ||
/// An event that is fired when user input is recieved. | ||
/// </summary> | ||
event TerminalDataRecievedEventHandler TerminalDataRecieved; | ||
|
||
/// <summary> | ||
/// Sends data to the terminal making it render the data. | ||
/// </summary> | ||
Task PtyDataAsync(string data, CancellationToken cancellationToken); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
using System; | ||
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 that fits the window. | ||
/// </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); | ||
|
||
/// <summary> | ||
/// Create a new terminal renderer instance with the given name and dimensions. | ||
/// The terminal size won't change when user resizes the window. | ||
/// </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, int cols, int rows); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Security.Permissions; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")] | ||
[ComVisible(true)] | ||
public class RendererScriptingObject : TerminalScriptingObjectBase | ||
{ | ||
internal RendererScriptingObject(TermWindowPackage package) : base(package) | ||
{ | ||
} | ||
|
||
internal EventHandler<string> TermDataRecieved { get; set; } | ||
|
||
internal EventHandler TermInit { get; set; } | ||
|
||
internal EventHandler<ResizeEventArgs> TermResized { get; set; } | ||
|
||
|
||
public override void ClosePty() | ||
{ | ||
// There is already Closed event that is fired by the TerminalWindow | ||
} | ||
|
||
public override void InitPty(int cols, int rows, string directory) => TermInit?.Invoke(this, EventArgs.Empty); | ||
|
||
public override void ResizePty(int cols, int rows) => TermResized?.Invoke(this, new ResizeEventArgs(cols, rows)); | ||
|
||
public override void TermData(string data) => TermDataRecieved?.Invoke(this, data); | ||
|
||
public override string GetSolutionDir() => null; | ||
} | ||
|
||
[DebuggerStepThrough] | ||
public class ResizeEventArgs : EventArgs | ||
{ | ||
public ResizeEventArgs(int cols, int rows) | ||
{ | ||
Cols = cols; | ||
Rows = rows; | ||
} | ||
|
||
public int Cols { get; } | ||
public int Rows { get; } | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
Microsoft.VisualStudio.Terminal/BrowserBridge/TerminalScriptingObjectBase.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,43 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Security.Permissions; | ||
using System.Windows; | ||
|
||
namespace Microsoft.VisualStudio.Terminal | ||
{ | ||
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")] | ||
[ComVisible(true)] | ||
public abstract class TerminalScriptingObjectBase : ITerminalScriptingObject | ||
{ | ||
protected readonly TermWindowPackage package; | ||
|
||
internal TerminalScriptingObjectBase(TermWindowPackage package) | ||
{ | ||
this.package = package; | ||
} | ||
|
||
public string GetTheme() => TerminalThemer.GetTheme(); | ||
|
||
public string GetFontFamily() => this.package.OptionFontFamily; | ||
|
||
public int GetFontSize() => this.package.OptionFontSize; | ||
|
||
public abstract string GetSolutionDir(); | ||
public abstract void ClosePty(); | ||
|
||
public void CopyStringToClipboard(string stringToCopy) => Clipboard.SetText(stringToCopy ?? ""); | ||
|
||
public string GetClipboard() => Clipboard.GetText(); | ||
|
||
public string GetLinkRegex() => TerminalRegex.LocalLinkRegex.ToString(); | ||
|
||
public void HandleLocalLink(string uri) => TerminalRegex.HandleLocalLink(uri); | ||
|
||
public abstract void InitPty(int cols, int rows, string directory); | ||
|
||
public abstract void ResizePty(int cols, int rows); | ||
|
||
public abstract void TermData(string data); | ||
|
||
public bool ValidateLocalLink(string link) => 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,5 +137,12 @@ public string BrightWhite | |
get; | ||
set; | ||
} | ||
|
||
[DataMember(Name = "border")] | ||
public string Border | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.