Skip to content

Commit 8cc137b

Browse files
committed
[edit] restyle StatusBar colors, icons, and padding calculation
1 parent 6d099a4 commit 8cc137b

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

src/EtcdTerminal.App/Components/StatusBar.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,42 @@ public static class StatusBar
88
public static void Render(EtcdConnectionConfig? config = null)
99
{
1010
var bgSeq = "\x1b[48;2;27;28;30m";
11-
var fgSeq = "\x1b[38;2;210;210;210m";
11+
var fgSeq = "\x1b[38;2;128;128;128m";
1212
var greenSeq = "\x1b[38;2;0;200;0m";
13+
var whiteSeq = "\x1b[38;2;255;255;255m";
14+
var tealSeq = "\x1b[38;2;0;180;180m";
15+
var yellowSeq = "\x1b[38;2;255;200;0m";
16+
var dimSeq = "\x1b[38;2;80;80;80m";
1317
var resetSeq = "\x1b[0m";
1418
var fill = new string(' ', Console.WindowWidth);
1519

16-
var left = " (\u2191/\u2193 navigate, Enter confirm, Esc back) ";
20+
var left = $"{fgSeq} {whiteSeq}\u2191/\u2193{fgSeq} navigate \u00b7 {whiteSeq}Enter{fgSeq} confirm/select \u00b7 {whiteSeq}Esc{fgSeq} back ";
1721
var version = GetVersion();
1822

23+
var rightPadding = " ";
24+
1925
string content;
2026
if (config is not null)
2127
{
2228
var connStr = config.ConnectionString.Length > 50
2329
? config.ConnectionString[..50] + "..."
2430
: config.ConnectionString;
25-
var auth = config.IsAuthenticationEnabled
26-
? $" \x1b[38;2;128;128;128m│\x1b[38;2;210;210;210m {config.Username}"
27-
: "";
28-
var right = $"{greenSeq}\u25cf{fgSeq} {config.Name} \x1b[38;2;128;128;128m│\x1b[38;2;210;210;210m {connStr}{auth} v{version} ";
29-
var pad = Console.WindowWidth - left.Length - GetVisibleLength(right);
30-
if (pad < 1) pad = 1;
31-
content = bgSeq + fgSeq + left + new string(' ', pad) + right + resetSeq;
31+
var right = $"{greenSeq}\u2022{tealSeq} {config.Name} {dimSeq}\u2502{fgSeq} {connStr}";
32+
if (config.IsAuthenticationEnabled)
33+
right += $" {dimSeq}\u2502{yellowSeq} {config.Username}";
34+
right += $" {fgSeq}v{whiteSeq}{version}";
35+
var visibleWidth = GetVisibleLength(left) + GetVisibleLength(right) + rightPadding.Length;
36+
var pad = Console.WindowWidth - visibleWidth;
37+
if (pad < 0) pad = 0;
38+
content = bgSeq + fgSeq + left + new string(' ', pad) + right + fgSeq + rightPadding + resetSeq;
3239
}
3340
else
3441
{
35-
var right = $"v{version} ";
36-
var pad = Console.WindowWidth - left.Length - right.Length;
37-
if (pad < 1) pad = 1;
38-
content = bgSeq + fgSeq + left + new string(' ', pad) + right + resetSeq;
42+
var right = $"{fgSeq}v{whiteSeq}{version}";
43+
var visibleWidth = GetVisibleLength(left) + GetVisibleLength(right) + rightPadding.Length;
44+
var pad = Console.WindowWidth - visibleWidth;
45+
if (pad < 0) pad = 0;
46+
content = bgSeq + fgSeq + left + new string(' ', pad) + right + fgSeq + rightPadding + resetSeq;
3947
}
4048

4149
Console.CursorTop = Console.WindowHeight - 3;

0 commit comments

Comments
 (0)