This commit is contained in:
Andrew Schwartzmeyer
2015-11-04 15:09:29 -08:00
parent 391371e753
commit f8bd1243b6
3 changed files with 36 additions and 42 deletions
+5 -10
View File
@@ -87,8 +87,8 @@ namespace Microsoft.Samples.PowerShell.Host
for (int i = 0; i < args.Length; ++i)
{
string arg = args[i];
bool hasNext = (i+1)<args.Length;
string nextArg = hasNext ? args[i+1] : "";
bool hasNext = (i+1) < args.Length;
string nextArg = hasNext ? args[i+1] : string.Empty;
if (hasNext && arg == "--file")
{
@@ -173,7 +173,7 @@ namespace Microsoft.Samples.PowerShell.Host
// run the initial script
if (initialScript != null)
{
executeHelper(initialScript,null);
executeHelper(initialScript, null);
}
}
@@ -234,9 +234,6 @@ namespace Microsoft.Samples.PowerShell.Host
{
this.currentPowerShell.Runspace = this.myRunSpace;
// TODO: Find out where this is set in the Monad host code and set all defaults that way
// note that this breaks exception reporting for unknown reasons
// this.currentPowerShell.AddScript(string.Format("(Get-PSProvider 'FileSystem').Home = '{0}'",Environment.GetEnvironmentVariable("HOME")));
this.currentPowerShell.AddScript(cmd);
// Add the default outputter to the end of the pipe and then call the
@@ -399,12 +396,10 @@ namespace Microsoft.Samples.PowerShell.Host
// the user calling "exit".
while (!this.ShouldExit)
{
string prompt;
prompt = Prompt(this.myHost.Runspace);
string prompt = Prompt(this.myHost.Runspace);
this.myHost.UI.Write(ConsoleColor.White, ConsoleColor.Black, prompt);
// string cmd = this.consoleReadLine.Read();
string cmd = Console.ReadLine();
string cmd = this.myHost.UI.ReadLine();
this.Execute(cmd);
}
+21 -22
View File
@@ -14,13 +14,14 @@ namespace Microsoft.Samples.PowerShell.Host
{
// this is all from https://msdn.microsoft.com/en-us/library/ee706570%28v=vs.85%29.aspx
internal class MyRawUserInterface : PSHostRawUserInterface
internal class MyRawUserInterface : PSHostRawUserInterface
{
// this class provides features otherwise not available through .net
internal class Native
{
[DllImport("libpsnative")]
internal static extern int GetTerminalWidth();
[DllImport("libpsnative")]
internal static extern int GetTerminalHeight();
}
@@ -55,9 +56,9 @@ namespace Microsoft.Samples.PowerShell.Host
public override Coordinates CursorPosition
{
get { throw new NotImplementedException(
"The method or operation is not implemented."); }
"The method or operation is not implemented."); }
set { throw new NotImplementedException(
"The method or operation is not implemented."); }
"The method or operation is not implemented."); }
}
/// <summary>
@@ -89,8 +90,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override bool KeyAvailable
{
get { return false; }
// get { return Console.KeyAvailable; }
get { return false; }
// get { return Console.KeyAvailable; }
}
/// <summary>
@@ -102,8 +103,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override Size MaxPhysicalWindowSize
{
// get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); }
get { return new Size(1024,768); }
// get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); }
get { return new Size(1024,768); }
}
/// <summary>
@@ -114,8 +115,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override Size MaxWindowSize
{
// get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); }
get { return new Size(1024,768); }
// get { return new Size(Console.LargestWindowWidth, Console.LargestWindowHeight); }
get { return new Size(1024,768); }
}
/// <summary>
@@ -125,8 +126,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override Coordinates WindowPosition
{
// get { return new Coordinates(Console.WindowLeft, Console.WindowTop); }
// set { Console.SetWindowPosition(value.X, value.Y); }
// get { return new Coordinates(Console.WindowLeft, Console.WindowTop); }
// set { Console.SetWindowPosition(value.X, value.Y); }
get { return new Coordinates(0,0); }
set { }
}
@@ -138,8 +139,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override Size WindowSize
{
// get { return new Size(Console.WindowWidth, Console.WindowHeight); }
// set { Console.SetWindowSize(value.Width, value.Height); }
// get { return new Size(Console.WindowWidth, Console.WindowHeight); }
// set { Console.SetWindowSize(value.Width, value.Height); }
get { return new Size(1024,768); }
set { }
}
@@ -150,8 +151,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override string WindowTitle
{
// get { return Console.Title; }
// set { Console.Title = value; }
// get { return Console.Title; }
// set { Console.Title = value; }
get { return "window title"; }
set { }
}
@@ -174,7 +175,7 @@ namespace Microsoft.Samples.PowerShell.Host
public override BufferCell[,] GetBufferContents(Rectangle rectangle)
{
throw new NotImplementedException(
"The method or operation is not implemented.");
"The method or operation is not implemented.");
}
/// <summary>
@@ -190,7 +191,7 @@ namespace Microsoft.Samples.PowerShell.Host
public override KeyInfo ReadKey(ReadKeyOptions options)
{
throw new NotImplementedException(
"The method or operation is not implemented.");
"The method or operation is not implemented.");
}
/// <summary>
@@ -206,7 +207,7 @@ namespace Microsoft.Samples.PowerShell.Host
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
{
throw new NotImplementedException(
"The method or operation is not implemented.");
"The method or operation is not implemented.");
}
/// <summary>
@@ -220,7 +221,7 @@ namespace Microsoft.Samples.PowerShell.Host
BufferCell[,] contents)
{
throw new NotImplementedException(
"The method or operation is not implemented.");
"The method or operation is not implemented.");
}
/// <summary>
@@ -233,9 +234,7 @@ namespace Microsoft.Samples.PowerShell.Host
public override void SetBufferContents(Rectangle rectangle, BufferCell fill)
{
throw new NotImplementedException(
"The method or operation is not implemented.");
"The method or operation is not implemented.");
}
}
}
+10 -10
View File
@@ -49,28 +49,28 @@ namespace Microsoft.Samples.PowerShell.Host
public ConsoleReadLine()
{
this.tokenColors = new ConsoleColor[]
{
this.defaultColor, // Unknown
{
this.defaultColor, // Unknown
ConsoleColor.Yellow, // Command
ConsoleColor.Green, // CommandParameter
ConsoleColor.Cyan, // CommandArgument
ConsoleColor.Cyan, // Number
ConsoleColor.Cyan, // String
ConsoleColor.Green, // Variable
this.defaultColor, // Member
this.defaultColor, // LoopLabel
this.defaultColor, // Member
this.defaultColor, // LoopLabel
ConsoleColor.DarkYellow, // Attribute
ConsoleColor.DarkYellow, // Type
ConsoleColor.DarkCyan, // Operator
this.defaultColor, // GroupStart
this.defaultColor, // GroupEnd
this.defaultColor, // GroupStart
this.defaultColor, // GroupEnd
ConsoleColor.Magenta, // Keyword
ConsoleColor.Red, // Comment
ConsoleColor.DarkCyan, // StatementSeparator
this.defaultColor, // NewLine
this.defaultColor, // LineContinuation
this.defaultColor, // Position
};
this.defaultColor, // NewLine
this.defaultColor, // LineContinuation
this.defaultColor, // Position
};
}
/// <summary>