Fix ClearScreen, and disable scroll-related functions that don't work in CoreCLR

This commit is contained in:
George Fleming 2016-04-28 16:05:00 -07:00
parent 1d87607bd4
commit 74b5060f6e
5 changed files with 21 additions and 1 deletions

View File

@ -908,6 +908,13 @@ namespace Microsoft.PowerShell.Internal
NativeMethods.ReleaseDC(_hwnd, _hDC);
}
}
#if CORECLR
public void Clear()
{
Console.Clear();
}
#endif
}
#pragma warning restore 1591

View File

@ -181,10 +181,12 @@ namespace Microsoft.PowerShell
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
{ Keys.F8, MakeKeyHandler(HistorySearchBackward, "HistorySearchBackward") },
{ Keys.ShiftF8, MakeKeyHandler(HistorySearchForward, "HistorySearchForward") },
#if !CORECLR
{ Keys.PageUp, MakeKeyHandler(ScrollDisplayUp, "ScrollDisplayUp") },
{ Keys.PageDown, MakeKeyHandler(ScrollDisplayDown, "ScrollDisplayDown") },
{ Keys.CtrlPageUp, MakeKeyHandler(ScrollDisplayUpLine, "ScrollDisplayUpLine") },
{ Keys.CtrlPageDown, MakeKeyHandler(ScrollDisplayDownLine, "ScrollDisplayDownLine") },
#endif
};
_chordDispatchTable = new Dictionary<ConsoleKeyInfo, Dictionary<ConsoleKeyInfo, KeyHandler>>();
@ -267,13 +269,13 @@ namespace Microsoft.PowerShell
{ Keys.VolumeDown, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
#endif
{ Keys.PageUp, MakeKeyHandler(ScrollDisplayUp, "ScrollDisplayUp") },
{ Keys.CtrlPageUp, MakeKeyHandler(ScrollDisplayUpLine, "ScrollDisplayUpLine") },
{ Keys.PageDown, MakeKeyHandler(ScrollDisplayDown, "ScrollDisplayDown") },
{ Keys.CtrlPageDown, MakeKeyHandler(ScrollDisplayDownLine,"ScrollDisplayDownLine") },
{ Keys.CtrlHome, MakeKeyHandler(ScrollDisplayTop, "ScrollDisplayTop") },
{ Keys.CtrlEnd, MakeKeyHandler(ScrollDisplayToCursor,"ScrollDisplayToCursor") },
#endif
};
_chordDispatchTable = new Dictionary<ConsoleKeyInfo, Dictionary<ConsoleKeyInfo, KeyHandler>>();

View File

@ -434,6 +434,11 @@ namespace Microsoft.PowerShell
public static void ClearScreen(ConsoleKeyInfo? key = null, object arg = null)
{
var console = _singleton._console;
#if CORECLR
console.Clear();
_singleton._initialY = 0;
_singleton.Render();
#else
if (_singleton._initialY + console.WindowHeight > console.BufferHeight)
{
var scrollCount = _singleton._initialY - console.WindowTop;
@ -445,6 +450,7 @@ namespace Microsoft.PowerShell
{
console.SetWindowPosition(0, _singleton._initialY);
}
#endif
}
// Try to convert the arg to a char, return 0 for failure

View File

@ -54,6 +54,9 @@ namespace Microsoft.PowerShell
void StartRender();
int LengthInBufferCells(char c);
void EndRender();
#if CORECLR
void Clear();
#endif
}
#pragma warning restore 1591

View File

@ -696,6 +696,7 @@ namespace Microsoft.PowerShell
#region Screen scrolling
#if !CORECLR
/// <summary>
/// Scroll the display up one screen.
/// </summary>
@ -814,6 +815,7 @@ namespace Microsoft.PowerShell
console.SetWindowPosition(0, newTop);
}
#endif
#endregion Screen scrolling
}
}