Emoji picker (Super+.): search, tabs, skin tones, recents, text-input-v3 insertion
CI / test (push) Canceled after 0s

Compositor-drawn Win+. style picker. The focused app keeps keyboard focus so
its text-input-v3 field stays enabled; the emoji goes in with commit_string,
or onto the clipboard with a visible notice when the app has no text field.
Shortcut lives in the shortcut table (rebindable in Settings > Shortcuts).

- compositor/wayland/text_input.mbt: zwp_text_input_manager_v3 (global 12)
- compositor/emoji: Emoji 18.0 + CLDR 49 data (Unicode License), search,
  picker model, CBDT/CBLC + GSUB reader for Noto Color Emoji
- Chandra's own pinned bitmap Noto Color Emoji (scripts/fetch-emoji-font.sh,
  just emoji-font); Fedora's COLRv1 copy can't be drawn. Missing font shows
  an error panel.
- raster WIT: emoji-font, emoji-has, emoji-image; served by wasmhost
- state.edn :emoji {:recent [...] :skin-tone n}
- tests incl. a fake text-input client; docs/emoji-picker.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkABDGJixotaqFv2X2
This commit is contained in:
Claude committed 2026-11-26 07:00:22 +00:00
1 parent 738928352e
commit 27252a97ab
39 files changed
+4942 -41

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
///|
fn type_text(p : @emoji.Picker, s : String) -> Unit {
for c in s {
ignore(p.key(Type(c)))
}
}
///|
test "opens on Smileys without recents, on Recent with them" {
let p = @emoji.Picker::new([], 0)
assert_eq(p.tab, 1)
assert_eq(p.items()[0].text, "😀")
let q = @emoji.Picker::new(["🍕", "not an emoji", "👍🏽", "🍕"], 0)
assert_eq(q.tab, 0)
// Unknown text and repeats are dropped.
assert_eq(q.items().map(i => i.text), ["🍕", "👍🏽"])
}
///|
test "arrows move over the grid, rows scroll into view" {
let p = @emoji.Picker::new([], 0, cols=4, rows=2)
ignore(p.key(Right))
assert_eq(p.sel, 1)
ignore(p.key(Down))
assert_eq(p.sel, 5)
ignore(p.key(Down))
assert_eq(p.sel, 9)
assert_eq(p.scroll, 1) // row 2 shown in a 2-row grid starting at row 1
ignore(p.key(Up))
ignore(p.key(Up))
assert_eq(p.sel, 1)
assert_eq(p.scroll, 0)
ignore(p.key(Up)) // on the first row: stays
assert_eq(p.sel, 1)
ignore(p.key(Left))
ignore(p.key(Left))
assert_eq(p.sel, 0)
ignore(p.key(End))
assert_eq(p.sel, p.items().length() - 1)
ignore(p.key(Home))
assert_eq((p.sel, p.scroll), (0, 0))
ignore(p.key(PageDown))
assert_eq(p.sel, 8)
}
///|
test "Down on the row above a short last row goes to the last item" {
let p = @emoji.Picker::new([], 0, cols=4, rows=2)
type_text(p, "pizza") // a few results
let n = p.items().length()
assert_true(n >= 1)
p.select(0)
for _ in 0..<10 {
ignore(p.key(Down))
}
assert_eq(p.sel / 4, (n - 1) / 4)
}
///|
test "typing searches across every tab; Backspace and Tab clear it" {
let p = @emoji.Picker::new([], 0)
type_text(p, "pizz")
assert_eq(p.items()[0].text, "🍕")
assert_eq(p.key(Choose), Some("🍕"))
assert_eq(p.recents, ["🍕"])
for _ in 0..<4 {
ignore(p.key(Backspace))
}
assert_eq(p.query, "")
ignore(p.key(Backspace)) // nothing left: no harm
type_text(p, "zzzzqq")
assert_eq(p.items().length(), 0)
assert_eq(p.key(Choose), None)
ignore(p.key(NextTab))
assert_eq(p.query, "")
assert_eq(p.tab, 2)
ignore(p.key(PrevTab))
ignore(p.key(PrevTab))
assert_eq(p.tab, 0)
ignore(p.key(PrevTab)) // wraps to Flags
assert_eq(p.tab, 9)
assert_eq(p.items()[0].text, "🏁")
}
///|
test "skin tone applies to emoji that take one, and recents keep the tone they were used with" {
let p = @emoji.Picker::new([], 0)
type_text(p, "thumbs up")
assert_eq(p.selected().unwrap().text, "👍")
ignore(p.key(NextTone))
ignore(p.key(NextTone))
assert_eq(p.tone, 2)
assert_eq(p.selected().unwrap().text, "👍🏼")
assert_eq(p.key(Choose), Some("👍🏼"))
ignore(p.key(PrevTone))
ignore(p.key(PrevTone))
ignore(p.key(PrevTone)) // wraps to dark
assert_eq(p.tone, 5)
p.set_tab(0)
assert_eq(p.items().map(i => i.text), ["👍🏼"])
}
///|
test "recents: newest first, no repeats, at most max_recent" {
let p = @emoji.Picker::new([], 0)
let es = @emoji.all()
for i = 0; i < @emoji.max_recent + 5; i = i + 1 {
p.used(es[i].text)
}
p.used(es[3].text)
assert_eq(p.recents.length(), @emoji.max_recent)
assert_eq(p.recents[0], es[3].text)
assert_eq(p.recents.filter(r => r == es[3].text).length(), 1)
}
///|
test "emoji the font can't draw are not shown" {
let es = @emoji.all()
let p = @emoji.Picker::new([], 0, has=i => es[i].text != "😀")
assert_eq(p.items()[0].text, "😃")
type_text(p, "grinning face")
assert_false(p.items().map(i => i.text).contains("😀"))
}