# Spike 2: composer, IME and chat lines `spike-composer` is a chat view with a composer: - **Lines.** Sample messages in BBCode go through `voelin-ui-vm` (`chat::line`: `bbcode` → `TextBlock`s of `TextRun`s, read only) and are drawn as `StyledText` with one GPUI text run per `TextRun` (its font: Inter, the theme's monospace font for code, Noto Color Emoji for the runs marked as emoji; bold, italic, underline, strike, code background, the author colour `ink_dark`) inside `InteractiveText`, whose clickable ranges are the runs with a link (a click prints the link and whether it is masked, which asks first). Quotes, code blocks, list items and rules are blocks; one to three emoji alone are large (`ChatLine.jumbo`). Emoji are characters drawn by a colour emoji font (`TextRun.emoji`, the Twemoji key, only says that a run is one). - **Emoji probe.** At start the spike lays out three lines of emoji the way the list draws them, once with the emoji runs in Noto Color Emoji and once in Inter with its fallback chain, and prints how many glyphs GPUI draws in colour (`ShapedGlyph::is_emoji`). - **Composer.** gpui-component's `Textarea` (`TextareaState`, auto-grow 1 to 6 rows). The emoji button opens a picker of the first 96 emoji of `voelin_ui_vm::emoji::archive().category(0)` (the names and characters of the client's picker); a click inserts at the caret (`TextareaState::insert`) and gives the focus back. Ctrl+Enter sends (bound to a `Send` action in the `Input` context after gpui-component's own bindings, so its "secondary enter" newline is not inserted first). `Textarea::on_paste` takes pictures (`ClipboardEntry::Image`), files (`ExternalPaths`) and text that is the absolute path of an existing file as attachments; other text is pasted. - **Preedit.** Nothing in the app: GPUI's platform input handler and gpui-component's marked text. The spike reads the marked range ten times a second and prints it. ## Reproducing ```sh spikes/gpui/shell.sh sh -c 'cd spikes/gpui && cargo build --locked --release' # the sample list, the picker, typing, emoji at the caret, Ctrl+Enter, # picture and path paste, a link click: eight checks and the emoji probe's # findings, screenshots in $OUT spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/composer/drive.sh # X11 preedit: fcitx5 + Pinyin as the XIM server (on-the-spot), "nihao", # Space, Ctrl+Enter: three checks, screenshots of the preedit spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/composer/ime.sh ``` `drive.sh` first opens the window once with a font configuration of only Noto Color Emoji, Noto Sans CJK and Cantarell (`FONTCONFIG_FILE`), then with the system's: the two screenshots and the probe's two lines show the colour emoji finding in [docs/design/gpui-spikes.md](../../../docs/design/gpui-spikes.md#spike-2-composer-ime-and-chat-lines).