[#1223] lens/tui: Add cursor to search bar

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-08-12 22:51:16 +03:00
parent a248b4233d
commit 8dd398914e
No known key found for this signature in database

View file

@ -96,6 +96,8 @@ func NewUI(ctx context.Context, app *tview.Application, db *bbolt.DB) *UI {
ui.searchBar.SetFieldBackgroundColor(barTextColor)
ui.searchBar.SetFieldTextColor(barBackgroundColor)
ui.searchBar.SetLabelColor(barBackgroundColor)
ui.searchBar.Focus(func(tview.Primitive) {})
// ui.searchBar.Blur()
ui.infoBar.SetBackgroundColor(barBackgroundColor)
ui.infoBar.SetTextColor(barTextColor)
@ -256,6 +258,10 @@ func (ui *UI) draw(screen tcell.Screen) {
pageToDraw.SetRect(x, y, width, height-1)
pageToDraw.Draw(screen)
// Search bar uses cursor and we want
// to hide it when another bar is drawn.
screen.HideCursor()
switch {
case ui.isLoading.Load():
barToDraw = ui.loadingBar
@ -451,7 +457,6 @@ func (ui *UI) handleInputOnSearching(event *tcell.EventKey) {
ui.isSearching = false
case k == tcell.KeyEsc:
ui.isSearching = false
// ui.searchBar.SetText("")
case (k == tcell.KeyBackspace2 || m&tcell.ModCtrl != 0 && k == tcell.KeyETB) && len(ui.searchBar.GetText()) == 0:
ui.isSearching = false
default: