Files
chandra/docs/emoji-picker.md
Claude 27252a97ab
CI / test (push) Canceled after 0s
Emoji picker (Super+.): search, tabs, skin tones, recents, text-input-v3 insertion
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
2026-11-26 07:00:22 +00:00

94 lines
5.2 KiB
Markdown

# Emoji picker (Super+.)
Like Windows' Win+.: **Super+.** opens a panel at the text cursor with a search field, category
tabs, a grid of emoji and a skin tone choice. The emoji you pick goes where you were typing.
![The picker over an app](screenshots/emoji-picker.png)
## Using it
| Key | Does |
|---|---|
| typing | searches every category: names and CLDR keywords ("lol", "yay", "germany"); a leading `:` is skipped |
| arrows, Page Up/Down, Home/End | move the selection |
| Enter | insert the selected emoji and close |
| Shift+Enter | insert it and stay open (for several in a row) |
| Tab / Shift+Tab | next / previous category (clears the search) |
| Ctrl+Right / Ctrl+Left | next / previous skin tone |
| Backspace | delete the last search letter |
| Esc, Super+., a click outside | close |
With the mouse: click an emoji to insert it (Shift+click keeps the picker open), click a tab or
a skin tone, scroll the grid with the wheel.
Tabs: Recent, Smileys, People, Animals, Food, Activities, Travel, Objects, Symbols, Flags. The
picker opens on Recent when you have used emoji before, else on Smileys. The skin tone applies to
every emoji that has skin tone variants; recent emoji keep the tone they were inserted with.
The shortcut is the "Emoji picker" row of Settings > Shortcuts (id `emoji-picker` in state.edn's
`:shortcuts`), so it can be rebound. `chandra-ctl shortcut emoji-picker` opens it from a terminal.
## Where the emoji goes
The app keeps the keyboard focus while the picker is up (the picker takes the keys, as an input
method's popup does), so its text field stays active. Then:
- **The app has a text field active (text-input-v3):** the emoji is typed into it at the cursor
(`zwp_text_input_v3.commit_string`), in any keyboard layout. The picker is placed under the
cursor when the app says where that is.
- **It doesn't:** the emoji is put on the clipboard and a notification says so, with the reason
("Emoji copied: paste it with Ctrl+V"). Chandra doesn't press Ctrl+V for the app: in a terminal
that is a control character, not paste.
Apps that speak text-input-v3, and so get the emoji typed in: GTK 3 and GTK 4 apps (GNOME apps,
gedit, Ghostty), Qt 6 apps (Kate, KWrite, Konsole, Dolphin), Firefox, foot, kitty, Alacritty.
Chrome, Chromium and Electron apps only with `--enable-wayland-ime` on their command line;
without it they get the clipboard. Qt 5 apps speak an older protocol (text-input v2) and get the
clipboard. This was tested with a fake text-input client in the compositor tests (and the
headless host); the app list is what those toolkits document, not checked one by one here.
## The emoji font
The pictures come from Noto Color Emoji, the bitmap (CBDT) edition: Chandra reads the PNG for each
emoji from the font and the font's ligatures for sequences (skin tones, families, flags,
keycaps). This was checked against HarfBuzz on all 3,963 emoji of Emoji 18.0: the same picture for
every one the font has. stb_truetype, which draws Chandra's text, has no colour glyphs.
Chandra uses its own copy, `assets/fonts/NotoColorEmoji.ttf` (v2.051, OFL), not the system's:
distributions ship different editions, and Fedora's is COLRv1 (vector paint graphs), which this
reader doesn't draw. `scripts/fetch-emoji-font.sh` downloads it (pinned by SHA-256); `just
install`, `just run*` and `just test` run it, or run `just emoji-font`. Without it the picker
opens with an error that says what is missing and how to get it. `CHANDRA_EMOJI_FONT=/path` uses
another bitmap emoji font (its errors are shown the same way).
Emoji newer than the font (9 of Emoji 18.0's with v2.051) aren't listed; the log says how many.
## Data
`compositor/emoji/data.mbt` is generated by `scripts/gen-emoji-data.py` from Unicode
`emoji-test.txt` (Emoji 18.0: every emoji in CLDR order with its group and name) and the CLDR 49
English annotations (search keywords): 1,923 emoji, 332 with skin tones. Both sources are under
the Unicode License v3 (`third_party/unicode-emoji/`). Run the script to regenerate it.
## state.edn
:emoji {:recent ["👍🏽" "🍕"] :skin-tone 3}
Recent emoji (newest first, at most 40, as inserted) and the skin tone (0 default, 1 light .. 5
dark). Read at the first Super+. of a session and written when they change.
## Code and cost
- `compositor/emoji/`: the data and search (emoji.mbt), the picker's state and keys without
drawing (picker.mbt), and the font reader (font.mbt: cmap format 12, GSUB ligatures, CBLC/CBDT).
- `compositor/wayland/text_input.mbt`: zwp_text_input_manager_v3 (enter/leave with keyboard focus,
double-buffered enable/disable/cursor rectangle, commit_string + done).
- `compositor/host/emoji_picker.mbt`: drawing, keys, clicks, insertion, the notification.
- `wit/host/raster.wit`: `emoji-font`, `emoji-has`, `emoji-image`. The wasm host reads the font
and decodes the pictures (a native call each); the compositor component only gets image handles.
Each emoji is decoded once per size (28 px in the grid, 20 px on the tabs and tones, 48 px in the
notification) and kept, about 3 KB a picture; a screenful is about 70 of them. Nothing is drawn or
kept running while the picker is closed, and an open picker costs nothing until a key or the
pointer changes it (0% CPU idle, measured on the headless host).