Skip to content

Commit ba29d92

Browse files
committed
Add ClearScreen
ClearScreen clears the screen then redraws the current line at the top of the screen.
1 parent 52e9083 commit ba29d92

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

PSReadLine/PSReadLineResources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSReadLine/PSReadLineResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@
252252
<data name="DisplayAllPossibilities" xml:space="preserve">
253253
<value>Display all {0} possibilities? (y or n)</value>
254254
</data>
255+
<data name="ClearScreenDescription" xml:space="preserve">
256+
<value>Clear the screen and redraw the current line at the top of the screen</value>
257+
</data>
255258
<data name="GotoBraceDescription" xml:space="preserve">
256259
<value>Go to matching brace</value>
257260
</data>

PSReadLine/ReadLine.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ static PSConsoleReadLine()
366366
{ Keys.VolumeUp, MakeKeyHandler(Ignore, "Ignore") },
367367
{ Keys.VolumeMute, MakeKeyHandler(Ignore, "Ignore") },
368368
{ Keys.CtrlC, MakeKeyHandler(CancelLine, "CancelLine") },
369+
{ Keys.CtrlL, MakeKeyHandler(ClearScreen, "ClearScreen") },
369370
{ Keys.CtrlY, MakeKeyHandler(Redo, "Redo") },
370371
{ Keys.CtrlZ, MakeKeyHandler(Undo, "Undo") },
371372
{ Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteLine, "ForwardDeleteLine") },
@@ -396,6 +397,7 @@ static PSConsoleReadLine()
396397
{ Keys.CtrlE, MakeKeyHandler(EndOfLine, "EndOfLine") },
397398
{ Keys.CtrlF, MakeKeyHandler(ForwardChar, "ForwardChar") },
398399
{ Keys.CtrlH, MakeKeyHandler(BackwardDeleteChar, "BackwardDeleteChar") },
400+
{ Keys.CtrlL, MakeKeyHandler(ClearScreen, "ClearScreen") },
399401
{ Keys.CtrlK, MakeKeyHandler(KillLine, "KillLine") },
400402
{ Keys.CtrlM, MakeKeyHandler(AcceptLine, "AcceptLine") },
401403
{ Keys.CtrlU, MakeKeyHandler(BackwardKillLine, "BackwardKillLine") },
@@ -838,6 +840,16 @@ public static void GotoBrace(ConsoleKeyInfo? key = null, object arg = null)
838840
Ding();
839841
}
840842

843+
/// <summary>
844+
/// Clear the screen and draw the current line at the top of the screen.
845+
/// </summary>
846+
public static void ClearScreen(ConsoleKeyInfo? key = null, object arg = null)
847+
{
848+
Console.Clear();
849+
_singleton._initialY = 0;
850+
_singleton.Render();
851+
}
852+
841853
#endregion Movement
842854

843855
#region History

0 commit comments

Comments
 (0)