Skip to content

Commit 576ae8e

Browse files
committed
[edit] add dark background stripes to search bar and pagination
1 parent 8f81ca9 commit 576ae8e

1 file changed

Lines changed: 36 additions & 10 deletions

File tree

src/EtcdTerminal.App/Screens/KeyBrowseScreen.cs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ public sealed class KeyBrowseScreen(IEtcdClient _etcdClient)
1010
private const int PageSize = 30;
1111
private const int LinePadding = 2;
1212
private const int PrefixWidth = 4;
13-
private const int SearchBarRow = 4;
1413
private const int EditValueMaxLength = 200;
1514

16-
private const string SearchPlaceholder = "[grey]🔍 Type to search keys...[/]";
1715
private const string NoKeysFound = " [grey]No keys found.[/]";
1816
private const string EditAction = "[bold yellow][[E]][/] [white]Edit[/] ";
1917
private const string DeleteAction = "[bold yellow][[D]][/] [white]Delete[/] ";
@@ -37,6 +35,7 @@ public sealed class KeyBrowseScreen(IEtcdClient _etcdClient)
3735
private EtcdKeyValue? _selectedKey;
3836
private EtcdConnectionConfig _config = default!;
3937
private int _searchEndCol;
38+
private int _searchBarRow;
4039

4140
public async Task ShowAsync(EtcdConnectionConfig config)
4241
{
@@ -212,11 +211,8 @@ private void Render()
212211
AnsiConsole.Clear();
213212
Header.Render();
214213

215-
Console.Write(new string(' ', LinePadding));
216214
RenderSearchBar();
217-
_searchEndCol = Console.CursorLeft;
218-
219-
Console.WriteLine();
215+
Console.SetCursorPosition(0, Console.CursorTop + 2);
220216
RenderKeyList();
221217

222218
Console.WriteLine();
@@ -226,16 +222,32 @@ private void Render()
226222

227223
StatusBar.Render(_config);
228224

229-
Console.CursorTop = SearchBarRow;
225+
Console.CursorTop = _searchBarRow;
230226
Console.CursorLeft = _searchEndCol;
231227
}
232228

233229
private void RenderSearchBar()
234230
{
231+
var bgSeq = "\x1b[48;2;27;28;30m";
232+
var resetSeq = "\x1b[0m";
233+
var fill = new string(' ', Console.WindowWidth);
234+
235+
Console.Write(bgSeq + fill + resetSeq);
236+
Console.WriteLine();
237+
238+
Console.Write(bgSeq);
235239
if (_searchQuery.Length == 0)
236-
AnsiConsole.Markup(SearchPlaceholder);
240+
AnsiConsole.Markup("[grey] \U0001f50d Type to search keys...[/]");
237241
else
238-
AnsiConsole.Markup($"[yellow]🔍[/] [white]{Markup.Escape(_searchQuery)}[/]");
242+
AnsiConsole.Markup($" \U0001f50d [white]{Markup.Escape(_searchQuery)}[/]");
243+
_searchEndCol = Console.CursorLeft;
244+
_searchBarRow = Console.CursorTop;
245+
var remaining = Console.WindowWidth - _searchEndCol;
246+
if (remaining > 0)
247+
Console.Write(bgSeq + new string(' ', remaining) + resetSeq);
248+
Console.WriteLine();
249+
250+
Console.Write(bgSeq + fill + resetSeq);
239251
}
240252

241253
private void RenderKeyList()
@@ -271,11 +283,25 @@ private void RenderKeyList()
271283

272284
private void RenderPagination()
273285
{
286+
var bgSeq = "\x1b[48;2;27;28;30m";
287+
var resetSeq = "\x1b[0m";
288+
var fill = new string(' ', Console.WindowWidth);
289+
274290
var totalPages = GetTotalPages();
275291
var totalKeys = _filteredKeys.Count;
276292
var currentPageLabel = _currentPage + 1;
277293

278-
AnsiConsole.MarkupLine($" [grey]Page {currentPageLabel}/{totalPages}{totalKeys} total keys[/]");
294+
Console.Write(bgSeq + fill + resetSeq);
295+
Console.WriteLine();
296+
297+
Console.Write(bgSeq);
298+
AnsiConsole.Markup($"[grey] Page {currentPageLabel}/{totalPages}{totalKeys} total keys[/]");
299+
var remaining = Console.WindowWidth - Console.CursorLeft;
300+
if (remaining > 0)
301+
Console.Write(bgSeq + new string(' ', remaining) + resetSeq);
302+
Console.WriteLine();
303+
304+
Console.Write(bgSeq + fill + resetSeq);
279305
}
280306

281307
private void RenderActionBar()

0 commit comments

Comments
 (0)