-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
50 lines (43 loc) · 1.31 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: 0BSD
await OutAsync(
new ControlBuilder()
.SetScreenBuffer(ScreenBuffer.Alternate)
.MoveCursorTo(0, 0)
.SetScrollMargin(2, Terminal.Size.Height));
try
{
await OutAsync(
new ControlBuilder()
.SetDecorations(intense: true)
.PrintLine("The last string entered will be displayed here.")
.ResetAttributes()
.PrintLine(new string('-', Terminal.Size.Width)));
var rng = new Random();
[SuppressMessage("", "CA5394")]
byte PickRandom()
{
return (byte)rng.Next(byte.MinValue, byte.MaxValue + 1);
}
while (true)
{
await OutAsync("Input: ");
if (await ReadLineAsync() is not string str)
break;
await OutAsync(
new ControlBuilder()
.SaveCursorState()
.MoveCursorTo(0, 0)
.ClearLine()
.SetForegroundColor(Color.FromArgb(byte.MaxValue, PickRandom(), PickRandom(), PickRandom()))
.Print(str.ReplaceLineEndings(string.Empty))
.ResetAttributes()
.RestoreCursorState());
}
}
finally
{
await OutAsync(
new ControlBuilder()
.SetScrollMargin(0, Terminal.Size.Height)
.SetScreenBuffer(ScreenBuffer.Main));
}