blob: 39b4a0b648a127d0ab489f426bf50274815aee5f (
plain)
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
|
/***************************************************************************************************
Copyright (C) 2025 The Qt Company Ltd.
SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/
namespace UserViewCli
{
internal static class ConsoleExt
{
public static void WriteLine(string text)
{
Console.Write(text);
var pos = Console.GetCursorPosition();
Console.WriteLine(new string(' ', Console.WindowWidth - pos.Left));
}
public static bool EscapePressed
=> Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape;
public static void ClearScreen(bool keepContent = true)
{
Console.CursorVisible = false;
if (!keepContent)
Console.SetCursorPosition(0, 0);
var pos = Console.GetCursorPosition();
Console.WriteLine(new string(' ', Console.WindowWidth - pos.Left));
for (int i = 0; i < Console.WindowHeight - pos.Top - 1; i++)
Console.WriteLine(new string(' ', Console.WindowWidth));
Console.SetCursorPosition(0, 0);
}
}
}
|