mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Update files from Source Depot changeset [SD:706766]
Corresponds to e2ce37c87c0ab9795bfac2389edc1aff934bdb9e in psl-monad.
This commit is contained in:
1 parent
dd950e4837
commit
b8dced8e80
21 files changed
+621
-538
No files matched your search
@@ -100,14 +100,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ShowInitialPrompt
|
||||
{
|
||||
get
|
||||
{
|
||||
return showInitialPrompt;
|
||||
}
|
||||
}
|
||||
|
||||
internal uint ExitCode
|
||||
{
|
||||
get
|
||||
@@ -240,15 +232,11 @@ namespace Microsoft.PowerShell
|
||||
|
||||
private void DisplayBanner()
|
||||
{
|
||||
// We need to show the banner only if it has not been already shown in native layer
|
||||
if (!showInitialPrompt)
|
||||
// If banner text is not supplied do nothing.
|
||||
if (!String.IsNullOrEmpty(bannerText))
|
||||
{
|
||||
// If banner text is not supplied do nothing.
|
||||
if (!String.IsNullOrEmpty(bannerText))
|
||||
{
|
||||
ui.WriteLine(bannerText);
|
||||
ui.WriteLine();
|
||||
}
|
||||
ui.WriteLine(bannerText);
|
||||
ui.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,10 +373,6 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
importSystemModules = true;
|
||||
}
|
||||
else if (MatchSwitch(switchKey, "showinitialprompt", "show"))
|
||||
{
|
||||
showInitialPrompt = true;
|
||||
}
|
||||
else if (MatchSwitch(switchKey, "noprofile", "nop"))
|
||||
{
|
||||
skipUserInit = true;
|
||||
@@ -960,7 +944,6 @@ namespace Microsoft.PowerShell
|
||||
private ConsoleHostUserInterface ui;
|
||||
private bool showHelp;
|
||||
private bool showBanner = true;
|
||||
private bool showInitialPrompt;
|
||||
private bool noInteractive;
|
||||
private string bannerText;
|
||||
private string helpText;
|
||||
|
||||
@@ -513,7 +513,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleCtrlHandler fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void AddBreakHandler(BreakHandler handlerDelegate)
|
||||
{
|
||||
bool result = NativeMethods.SetConsoleCtrlHandler(handlerDelegate, true);
|
||||
@@ -553,7 +552,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
#region Win32Handles
|
||||
|
||||
static readonly Lazy<ConsoleHandle> _inputHandle = new Lazy<SafeFileHandle>(() =>
|
||||
static readonly Lazy<ConsoleHandle> _keyboardInputHandle = new Lazy<SafeFileHandle>(() =>
|
||||
{
|
||||
var handle = NativeMethods.CreateFile(
|
||||
"CONIN$",
|
||||
@@ -580,19 +579,11 @@ namespace Microsoft.PowerShell
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a ConsoleHandle to the console input device, even if stdin has been redirected.
|
||||
///
|
||||
/// Returns a ConsoleHandle to the console (keyboard device)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's CreateFile fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static ConsoleHandle GetInputHandle()
|
||||
internal static ConsoleHandle GetConioDeviceHandle()
|
||||
{
|
||||
return _inputHandle.Value;
|
||||
return _keyboardInputHandle.Value;
|
||||
}
|
||||
|
||||
static readonly Lazy<ConsoleHandle> _outputHandle = new Lazy<SafeFileHandle>(() =>
|
||||
@@ -627,7 +618,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's CreateFile fails
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static ConsoleHandle GetActiveScreenBufferHandle()
|
||||
{
|
||||
return _outputHandle.Value;
|
||||
@@ -645,7 +635,6 @@ namespace Microsoft.PowerShell
|
||||
Error = 0xFFFFFFF4
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static NakedWin32Handle GetStdHandle(StandardHandleId handleId)
|
||||
{
|
||||
unchecked
|
||||
@@ -657,8 +646,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mode
|
||||
@@ -697,7 +684,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's GetConsoleMode fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static ConsoleModes GetMode(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "consoleHandle is not valid");
|
||||
@@ -739,7 +725,6 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetMode(ConsoleHandle consoleHandle, ConsoleModes mode)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "consoleHandle is not valid");
|
||||
@@ -800,7 +785,6 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static string ReadConsole(ConsoleHandle consoleHandle, string initialContent,
|
||||
int charactersToRead, bool endOnTab, out uint keyState)
|
||||
{
|
||||
@@ -867,7 +851,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's ReadConsoleInput fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static int ReadConsoleInput(ConsoleHandle consoleHandle, ref INPUT_RECORD[] buffer)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -913,7 +896,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's PeekConsoleInput fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static int PeekConsoleInput
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -960,7 +942,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's GetNumberOfConsoleInputEvents fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static int GetNumberOfConsoleInputEvents(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -992,7 +973,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's FlushConsoleInputBuffer fails
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static void FlushConsoleInputBuffer(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -1033,7 +1013,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's GetConsoleScreenBufferInfo fails
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static CONSOLE_SCREEN_BUFFER_INFO GetConsoleScreenBufferInfo(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -1063,7 +1042,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleScreenBufferSize fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleScreenBufferSize(ConsoleHandle consoleHandle, Size newSize)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -1086,7 +1064,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static bool IsConsoleColor(ConsoleColor c)
|
||||
{
|
||||
switch (c)
|
||||
@@ -1112,7 +1089,6 @@ namespace Microsoft.PowerShell
|
||||
return false;
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void WORDToColor(WORD attribute, out ConsoleColor foreground, out ConsoleColor background)
|
||||
{
|
||||
// foreground color is the low-byte in the word, background color is the hi-byte.
|
||||
@@ -1122,7 +1098,6 @@ namespace Microsoft.PowerShell
|
||||
Dbg.Assert(IsConsoleColor(background), "unknown color");
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static WORD ColorToWORD(ConsoleColor foreground, ConsoleColor background)
|
||||
{
|
||||
WORD result = (WORD)(((int)background << 4) | (int)foreground);
|
||||
@@ -1161,7 +1136,6 @@ namespace Microsoft.PowerShell
|
||||
/// If it is illegal to write <paramref name="contents"/> to the output buffer
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void WriteConsoleOutput(ConsoleHandle consoleHandle, Coordinates origin, BufferCell[,] contents)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -1235,7 +1209,6 @@ namespace Microsoft.PowerShell
|
||||
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static void BuildEdgeTypeInfo(
|
||||
Rectangle contentsRegion,
|
||||
BufferCell[,] contents,
|
||||
@@ -1281,7 +1254,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static BufferCellArrayRowType GetEdgeType(BufferCell left, BufferCell right)
|
||||
{
|
||||
BufferCellArrayRowType edgeType = 0;
|
||||
@@ -1327,7 +1299,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If there is not enough memory to complete calls to Win32's ReadConsoleOutput
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called in CHK builds")]
|
||||
internal static void CheckWriteEdges(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -1393,7 +1364,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
|
||||
|
||||
[ArchitectureSensitive]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called in CHK builds")]
|
||||
private static void CheckWriteConsoleOutputContents(BufferCell[,] contents, Rectangle contentsRegion)
|
||||
{
|
||||
@@ -1429,7 +1399,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static void WriteConsoleOutputCJK(ConsoleHandle consoleHandle, Coordinates origin, Rectangle contentsRegion, BufferCell[,] contents, BufferCellArrayRowType rowType)
|
||||
{
|
||||
Dbg.Assert(origin.X >= 0 && origin.Y >= 0,
|
||||
@@ -1635,7 +1604,6 @@ namespace Microsoft.PowerShell
|
||||
} // row iteration
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static void WriteConsoleOutputPlain(ConsoleHandle consoleHandle, Coordinates origin, BufferCell[,] contents)
|
||||
{
|
||||
int rows = contents.GetLength(0);
|
||||
@@ -1792,7 +1760,6 @@ namespace Microsoft.PowerShell
|
||||
/// If there is not enough memory to complete calls to Win32's ReadConsoleOutput
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void ReadConsoleOutput
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -1877,7 +1844,6 @@ namespace Microsoft.PowerShell
|
||||
return false;
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static bool ReadConsoleOutputCJKSmall
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -1979,7 +1945,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If there is not enough memory to complete calls to Win32's ReadConsoleOutput
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static void ReadConsoleOutputCJK
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -2153,7 +2118,6 @@ namespace Microsoft.PowerShell
|
||||
#endregion ReadConsoleOutput CJK
|
||||
|
||||
|
||||
[ArchitectureSensitive]
|
||||
private static void ReadConsoleOutputPlain
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -2360,7 +2324,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's FillConsoleOutputCharacter fails
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static void FillConsoleOutputCharacter
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -2423,7 +2386,6 @@ namespace Microsoft.PowerShell
|
||||
/// <exception cref="HostException">
|
||||
/// If Win32's FillConsoleOutputAttribute fails
|
||||
/// </exception>
|
||||
[ArchitectureSensitive]
|
||||
internal static void FillConsoleOutputAttribute
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -2491,7 +2453,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's ScrollConsoleScreenBuffer fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void ScrollConsoleScreenBuffer
|
||||
(
|
||||
ConsoleHandle consoleHandle,
|
||||
@@ -2549,7 +2510,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleWindowInfo fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleWindowInfo(ConsoleHandle consoleHandle, bool absolute, SMALL_RECT windowInfo)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -2584,7 +2544,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's GetLargestConsoleWindowSize fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static Size GetLargestConsoleWindowSize(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -2619,7 +2578,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's GetConsoleTitle fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static string GetConsoleWindowTitle()
|
||||
{
|
||||
const int MaxWindowTitleLength = 1024;
|
||||
@@ -2654,7 +2612,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleTitle fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleWindowTitle(string consoleTitle)
|
||||
{
|
||||
bool result = NativeMethods.SetConsoleTitle(consoleTitle);
|
||||
@@ -2795,7 +2752,6 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void WriteConsole(ConsoleHandle consoleHandle, string output)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -2864,7 +2820,6 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleTextAttribute(ConsoleHandle consoleHandle, WORD attribute)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -3080,7 +3035,6 @@ namespace Microsoft.PowerShell
|
||||
/// <param name="c"></param>
|
||||
/// <param name="codePage"></param>
|
||||
/// <returns></returns>
|
||||
[ArchitectureSensitive]
|
||||
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults",
|
||||
MessageId = "Microsoft.PowerShell.ConsoleControl+NativeMethods.ReleaseDC(System.IntPtr,System.IntPtr)")]
|
||||
private static int LengthInBufferCells(char c, uint codePage)
|
||||
@@ -3148,7 +3102,6 @@ namespace Microsoft.PowerShell
|
||||
/// From IsConsoleFullWidth in \windows\core\ntcon\server\dbcs.c
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[ArchitectureSensitive]
|
||||
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults",
|
||||
MessageId = "Microsoft.PowerShell.ConsoleControl+NativeMethods.ReleaseDC(System.IntPtr,System.IntPtr)")]
|
||||
internal static int LengthInBufferCells(string str, int offset, bool checkEscapeSequences)
|
||||
@@ -3209,7 +3162,6 @@ namespace Microsoft.PowerShell
|
||||
/// </summary>
|
||||
/// <param name="codePage"></param>
|
||||
/// <returns></returns>
|
||||
[ArchitectureSensitive]
|
||||
internal static bool IsCJKOutputCodePage(out uint codePage)
|
||||
{
|
||||
codePage = NativeMethods.GetConsoleOutputCP();
|
||||
@@ -3241,7 +3193,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleCursorPosition fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleCursorPosition(ConsoleHandle consoleHandle, Coordinates cursorPosition)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -3283,7 +3234,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's GetConsoleCursorInfo fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static CONSOLE_CURSOR_INFO GetConsoleCursorInfo(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -3304,7 +3254,6 @@ namespace Microsoft.PowerShell
|
||||
return cursorInfo;
|
||||
}
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static CONSOLE_FONT_INFO_EX GetConsoleFontInfo(ConsoleHandle consoleHandle)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
@@ -3342,7 +3291,6 @@ namespace Microsoft.PowerShell
|
||||
/// If Win32's SetConsoleCursorInfo fails
|
||||
/// </exception>
|
||||
|
||||
[ArchitectureSensitive]
|
||||
internal static void SetConsoleCursorInfo(ConsoleHandle consoleHandle, CONSOLE_CURSOR_INFO cursorInfo)
|
||||
{
|
||||
Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
|
||||
|
||||
@@ -168,6 +168,16 @@ namespace Microsoft.PowerShell
|
||||
string preStartWarning,
|
||||
string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
if (Environment.GetEnvironmentVariable("POWERSHELL_DEBUG_STARTUP") != null)
|
||||
{
|
||||
while (!System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
string profileDir;
|
||||
@@ -437,7 +447,7 @@ namespace Microsoft.PowerShell
|
||||
// already if this thread is lagging behind the main thread.
|
||||
|
||||
#if !PORTABLE
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
ConsoleControl.FlushConsoleInputBuffer(handle);
|
||||
#endif
|
||||
|
||||
@@ -1348,7 +1358,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
// NTRAID#Windows Out Of Band Releases-915506-2005/09/09
|
||||
// Removed HandleUnexpectedExceptions infrastructure
|
||||
exitCode = DoRunspaceLoop(cpp.InitialCommand, cpp.SkipProfiles, cpp.Args, cpp.StaMode, cpp.ImportSystemModules, cpp.ShowInitialPrompt, cpp.ConfigurationName);
|
||||
exitCode = DoRunspaceLoop(cpp.InitialCommand, cpp.SkipProfiles, cpp.Args, cpp.StaMode, cpp.ImportSystemModules, cpp.ConfigurationName);
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -1383,14 +1393,12 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// </returns>
|
||||
private uint DoRunspaceLoop(string initialCommand, bool skipProfiles, Collection<CommandParameter> initialCommandArgs, bool staMode,
|
||||
bool importSystemModules, bool showInitialPrompt, string configurationName)
|
||||
bool importSystemModules, string configurationName)
|
||||
{
|
||||
ExitCode = ExitCodeSuccess;
|
||||
|
||||
while (!ShouldEndSession)
|
||||
{
|
||||
this.promptDisplayedInNativeCode = showInitialPrompt;
|
||||
|
||||
RunspaceCreationEventArgs args = new RunspaceCreationEventArgs(initialCommand, skipProfiles, staMode, importSystemModules, configurationName, initialCommandArgs);
|
||||
CreateRunspace(args);
|
||||
|
||||
@@ -2154,8 +2162,6 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
internal bool promptDisplayedInNativeCode = false;
|
||||
|
||||
/// <summary>
|
||||
/// True when debugger command is user and available
|
||||
/// for stopping.
|
||||
@@ -2372,6 +2378,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
string prompt = null;
|
||||
string line = null;
|
||||
|
||||
if (!ui.NoPrompt)
|
||||
{
|
||||
if (inBlockMode)
|
||||
|
||||
@@ -720,7 +720,7 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
ConsoleControl.INPUT_RECORD[] inputRecords = new ConsoleControl.INPUT_RECORD[1];
|
||||
ConsoleControl.ConsoleModes originalMode = ConsoleControl.GetMode(handle);
|
||||
|
||||
@@ -826,7 +826,7 @@ namespace Microsoft.PowerShell
|
||||
void
|
||||
FlushInputBuffer()
|
||||
{
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
ConsoleControl.FlushConsoleInputBuffer(handle);
|
||||
|
||||
cachedKeyEvent.RepeatCount = 0;
|
||||
@@ -861,7 +861,7 @@ namespace Microsoft.PowerShell
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
ConsoleControl.INPUT_RECORD[] inputRecords =
|
||||
new ConsoleControl.INPUT_RECORD[ConsoleControl.GetNumberOfConsoleInputEvents(handle)];
|
||||
|
||||
|
||||
@@ -60,24 +60,31 @@ namespace Microsoft.PowerShell
|
||||
|
||||
this.parent = parent;
|
||||
this.rawui = new ConsoleHostRawUserInterface(this);
|
||||
isInteractiveTestToolListening = false;
|
||||
|
||||
#if PORTABLE
|
||||
this._supportsVirtualTerminal = true;
|
||||
#else
|
||||
// Turn on virtual terminal if possible.
|
||||
var handle = ConsoleControl.GetActiveScreenBufferHandle();
|
||||
var m = ConsoleControl.GetMode(handle);
|
||||
try
|
||||
{
|
||||
// Turn on virtual terminal if possible.
|
||||
|
||||
// We don't call ConsoleControl.SetMode because we want to ignore the return value as it doesn't tell us reliably if conhost
|
||||
// supports a virtual terminal.
|
||||
ConsoleControl.NativeMethods.SetConsoleMode(handle.DangerousGetHandle(), (uint)(m | ConsoleControl.ConsoleModes.VirtualTerminal));
|
||||
|
||||
// We only know if vt100 is supported if the previous call actually set the new flag, older
|
||||
// systems ignore the setting.
|
||||
m = ConsoleControl.GetMode(handle);
|
||||
this._supportsVirtualTerminal = (m & ConsoleControl.ConsoleModes.VirtualTerminal) != 0;
|
||||
// This might throw - not sure how exactly (no console), but if it does, we shouldn't fail to start.
|
||||
var handle = ConsoleControl.GetActiveScreenBufferHandle();
|
||||
var m = ConsoleControl.GetMode(handle);
|
||||
if (ConsoleControl.NativeMethods.SetConsoleMode(handle.DangerousGetHandle(), (uint) (m | ConsoleControl.ConsoleModes.VirtualTerminal)))
|
||||
{
|
||||
// We only know if vt100 is supported if the previous call actually set the new flag, older
|
||||
// systems ignore the setting.
|
||||
m = ConsoleControl.GetMode(handle);
|
||||
this._supportsVirtualTerminal = (m & ConsoleControl.ConsoleModes.VirtualTerminal) != 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
isInteractiveTestToolListening = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -289,7 +296,7 @@ namespace Microsoft.PowerShell
|
||||
null;
|
||||
SecureString secureResult = new SecureString();
|
||||
StringBuilder result = new StringBuilder();
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
ConsoleControl.ConsoleModes originalMode = ConsoleControl.GetMode(handle);
|
||||
bool isModeChanged = true; // assume ConsoleMode is changed so that if ReadLineSetMode
|
||||
// fails to return the value correctly, the original mode is
|
||||
@@ -1364,8 +1371,7 @@ namespace Microsoft.PowerShell
|
||||
return;
|
||||
}
|
||||
|
||||
TextWriter writer =
|
||||
(!Console.IsErrorRedirected || parent.IsInteractive)
|
||||
TextWriter writer = (!Console.IsErrorRedirected || parent.IsInteractive)
|
||||
? parent.ConsoleTextWriter
|
||||
: Console.Error;
|
||||
|
||||
@@ -1380,7 +1386,6 @@ namespace Microsoft.PowerShell
|
||||
if (writer == parent.ConsoleTextWriter)
|
||||
WriteLine(errorForegroundColor, errorBackgroundColor, value);
|
||||
else
|
||||
|
||||
Console.Error.Write(value + Crlf);
|
||||
}
|
||||
}
|
||||
@@ -1611,7 +1616,15 @@ namespace Microsoft.PowerShell
|
||||
break;
|
||||
}
|
||||
|
||||
sb.Append(c);
|
||||
if (c == '\b')
|
||||
{
|
||||
sb.Remove(sb.Length - 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(c);
|
||||
}
|
||||
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
@@ -1627,8 +1640,7 @@ namespace Microsoft.PowerShell
|
||||
#if PORTABLE
|
||||
return ReadLineFromFile(initialContent);
|
||||
#else
|
||||
|
||||
ConsoleHandle handle = ConsoleControl.GetInputHandle();
|
||||
ConsoleHandle handle = ConsoleControl.GetConioDeviceHandle();
|
||||
PreRead();
|
||||
// Ensure that we're in the proper line-input mode.
|
||||
|
||||
@@ -1813,6 +1825,8 @@ namespace Microsoft.PowerShell
|
||||
///
|
||||
/// The Executor instance on which to run any pipelines that are needed to find matches
|
||||
///
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>
|
||||
///
|
||||
/// null on a break event
|
||||
@@ -1843,7 +1857,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
do
|
||||
{
|
||||
if (!ReadFromStdin && TryInvokeUserDefinedReadLine(out input))
|
||||
if (TryInvokeUserDefinedReadLine(out input))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2065,9 +2079,8 @@ namespace Microsoft.PowerShell
|
||||
|
||||
var runspace = this.parent.LocalRunspace;
|
||||
if (runspace != null &&
|
||||
runspace.Engine.Context.EngineIntrinsics.InvokeCommand.
|
||||
GetCommands(CustomReadlineCommand,
|
||||
CommandTypes.Function | CommandTypes.Cmdlet, nameIsPattern: false).Any())
|
||||
runspace.Engine.Context.EngineIntrinsics.InvokeCommand.GetCommands(CustomReadlineCommand,
|
||||
CommandTypes.Function | CommandTypes.Cmdlet, nameIsPattern: false).Any())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user