Fix ClearScreen, and disable scroll-related functions that don't work in CoreCLR
This commit is contained in:
parent
1d87607bd4
commit
74b5060f6e
@ -908,6 +908,13 @@ namespace Microsoft.PowerShell.Internal
|
||||
NativeMethods.ReleaseDC(_hwnd, _hDC);
|
||||
}
|
||||
}
|
||||
|
||||
#if CORECLR
|
||||
public void Clear()
|
||||
{
|
||||
Console.Clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
|
@ -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>>();
|
||||
|
@ -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
|
||||
|
@ -54,6 +54,9 @@ namespace Microsoft.PowerShell
|
||||
void StartRender();
|
||||
int LengthInBufferCells(char c);
|
||||
void EndRender();
|
||||
#if CORECLR
|
||||
void Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user