Launcher: draw the search field focused, with a caret
CI / test (push) Canceled after 0s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-29 00:28:57 -08:00
1 parent 68baf1a467
commit 2f404ced5c
1 file changed
+37 -5
+37 -5
View File
@@ -366,15 +366,18 @@ pub fn render_popup(
let ops = [
@ui.fill_rect(@ui.rect(0, 0, w, h), p.surface_popup, radius=r + 4),
@ui.stroke_rect(@ui.rect(0, 0, w, h), p.border, radius=r + 4),
// search field
// The search field. It has the keyboard as long as the menu is open, so it is always drawn
// focused: an accent outline and a caret.
@ui.fill_rect(@ui.rect(10, 10, w - 20, 32), p.surface, radius=r),
@ui.stroke_rect(@ui.rect(10, 10, w - 20, 32), p.accent, width=2, radius=r),
]
let q = if st.query.length() == 0 {
@ui.text(20, 26, "Type to search applications...", fs - 1, p.foreground_muted)
if st.query.length() == 0 {
ops.push(@ui.fill_rect(@ui.rect(20, 18, 2, 16), p.accent))
ops.push(@ui.text(26, 26, "Type to search applications...", fs - 1, p.foreground_muted))
} else {
@ui.text(20, 26, st.query + "_", fs, p.foreground)
// The caret is a glyph: it has to follow text whose width only the renderer knows.
ops.push(@ui.text(20, 26, st.query + "|", fs, p.foreground))
}
ops.push(q)
// The category column. A search looks through everything, so it shows as "All".
let cats = categories(apps)
let lx = list_x(apps)
@@ -861,6 +864,35 @@ test "a catalog too long for the popup gets a category column" {
assert_eq((st.open, st.category), (false, ""))
}
///|
test "the open menu's search field looks focused, empty or not" {
let st = State::new()
st.open = true
let t = test_tokens()
let outlined = fn() {
render_popup(sample_apps(), t, st).iter().any(op => match op {
StrokeRect(s) => s.rect.y == 10 && s.color.b == t.palette.accent.b
_ => false
})
}
assert_true(outlined())
// Empty: the caret before the hint.
assert_true(
render_popup(sample_apps(), t, st).iter().any(op => match op {
FillRect(f) => f.rect.x == 20 && f.rect.w == 2U && f.color.b == t.palette.accent.b
_ => false
}),
)
st.query = "ma"
assert_true(outlined())
assert_true(
render_popup(sample_apps(), t, st).iter().any(op => match op {
Text(x) => x.text == "ma|"
_ => false
}),
)
}
///|
test "the list scrolls with the wheel and the scrollbar" {
let apps = long_catalog()