|
1 | | -using EtcdTerminal; |
2 | | -using EtcdTerminal.Models; |
3 | | -using Spectre.Console; |
4 | | - |
5 | 1 | namespace EtcdTerminal.App.Modules; |
6 | 2 |
|
7 | 3 | public static class StatusBar |
8 | 4 | { |
9 | | - public static void Render(EtcdConnectionConfig config) |
| 5 | + public static void Render() |
10 | 6 | { |
11 | | - var dot = "[green]●[/]"; |
12 | | - var connStr = config.ConnectionString.Length > 50 |
13 | | - ? config.ConnectionString[..50] + "..." |
14 | | - : config.ConnectionString; |
15 | | - var auth = config.IsAuthenticationEnabled |
16 | | - ? $" [grey]│[/] [yellow]{config.Username}[/]" |
17 | | - : ""; |
18 | | - var bg = new Style(background: Color.FromHex("1b1c1e")); |
| 7 | + var bgSeq = "\x1b[48;2;27;28;30m"; |
| 8 | + var fgSeq = "\x1b[38;2;210;210;210m"; |
| 9 | + var resetSeq = "\x1b[0m"; |
| 10 | + var fill = new string(' ', Console.WindowWidth); |
| 11 | + var hintText = " (\u2191/\u2193 navigate, Enter confirm, Esc back) "; |
| 12 | + var hintLine = (hintText + fill)[..Console.WindowWidth]; |
| 13 | + |
| 14 | + Console.CursorTop = Console.WindowHeight - 3; |
| 15 | + Console.CursorLeft = 0; |
| 16 | + Console.Write(bgSeq + fill + resetSeq); |
| 17 | + |
| 18 | + Console.CursorTop = Console.WindowHeight - 2; |
| 19 | + Console.CursorLeft = 0; |
| 20 | + Console.Write(bgSeq + fgSeq + hintLine + resetSeq); |
19 | 21 |
|
20 | | - AnsiConsole.Write(new Rule(" ") { Style = bg, Border = BoxBorder.None }); |
21 | | - AnsiConsole.Write(new Rule($" {dot} [bold cyan]{config.Name}[/] [grey]│[/] [grey]{connStr}[/]{auth} ") |
22 | | - { |
23 | | - Style = bg, |
24 | | - Border = BoxBorder.None |
25 | | - }); |
26 | | - AnsiConsole.Write(new Rule(" ") { Style = bg, Border = BoxBorder.None }); |
27 | | - AnsiConsole.WriteLine(); |
| 22 | + Console.CursorTop = Console.WindowHeight - 1; |
| 23 | + Console.CursorLeft = 0; |
| 24 | + Console.Write(bgSeq + fill + resetSeq); |
28 | 25 | } |
29 | 26 | } |
0 commit comments