Emoji picker (Super+.): search, tabs, skin tones, recents, text-input-v3 insertion
CI / test (push) Canceled after 0s
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:
39 files changed
+4942
-41
No files matched your search
@@ -15,6 +15,15 @@ fn wasmImportThumbnail(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int = "chandra
|
||||
///|
|
||||
fn wasmImportImagePixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) -> Int = "chandra:host/raster@0.1.0" "image-pixels"
|
||||
|
||||
///|
|
||||
fn wasmImportEmojiFont(p0 : Int) = "chandra:host/raster@0.1.0" "emoji-font"
|
||||
|
||||
///|
|
||||
fn wasmImportEmojiHas(p0 : Int, p1 : Int, p2 : Int) = "chandra:host/raster@0.1.0" "emoji-has"
|
||||
|
||||
///|
|
||||
fn wasmImportEmojiImage(p0 : Int, p1 : Int, p2 : Int) -> Int = "chandra:host/raster@0.1.0" "emoji-image"
|
||||
|
||||
///|
|
||||
fn wasmImportSubmit(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int, p9 : Int, p10 : Int, p11 : Int, p12 : Int) = "chandra:host/raster@0.1.0" "submit"
|
||||
|
||||
@@ -37,16 +46,31 @@ fn wasmImportSendRecordingFrame(p0 : Int) -> Int = "chandra:host/raster@0.1.0" "
|
||||
fn wasmImportSnapshotFrame() -> Int = "chandra:host/raster@0.1.0" "snapshot-frame"
|
||||
|
||||
///|
|
||||
fn wasmImportSnapshotPng(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) = "chandra:host/raster@0.1.0" "snapshot-png"
|
||||
fn wasmImportSnapshotPng(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) = "chandra:host/raster@0.1.0" "snapshot-png"
|
||||
|
||||
///|
|
||||
fn wasmImportSnapshotPixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int) = "chandra:host/raster@0.1.0" "snapshot-pixels"
|
||||
fn wasmImportSnapshotPixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int) = "chandra:host/raster@0.1.0" "snapshot-pixels"
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
@@ -55,19 +79,6 @@ extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
@@ -75,6 +86,15 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
|
||||
@@ -26,8 +26,18 @@ fn wasmImportImagePixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) -> In
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
fn wasmImportEmojiFont(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportEmojiHas(p0 : Int, p1 : Int, p2 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportEmojiImage(p0 : Int, p1 : Int, p2 : Int) -> Int {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -76,7 +86,22 @@ fn wasmImportSnapshotPixels(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -90,18 +115,18 @@ fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,83 @@ pub fn image_pixels(w : Int, h : Int, rgba : FixedArray[Byte], reuse : UInt) ->
|
||||
let ptr = mbt_ffi_bytes2ptr(rgba)
|
||||
|
||||
let result : Int = wasmImportImagePixels(w, h, ptr, rgba.length(), (reuse).reinterpret_as_int());
|
||||
mbt_ffi_free(ptr)
|
||||
let ret = (result).reinterpret_as_uint()
|
||||
mbt_ffi_free(ptr)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Open the colour emoji font (Noto Color Emoji from the usual places, or the file
|
||||
/// CHANDRA_EMOJI_FONT names) for the emoji picker: the path it was read from, or a message
|
||||
/// saying why there is none and what to install. Read once; later calls give the same answer.
|
||||
pub fn emoji_font() -> Result[String, String] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(12)
|
||||
wasmImportEmojiFont(return_area);
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((return_area) + 0)) {
|
||||
0 => {
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 4), mbt_ffi_load32((return_area) + 8))
|
||||
|
||||
Result::Ok(result)
|
||||
}
|
||||
1 => {
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 4), mbt_ffi_load32((return_area) + 8))
|
||||
|
||||
Result::Err(result0)
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
let ret = lifted
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// For each emoji in `texts`, whether the font has one picture for it.
|
||||
pub fn emoji_has(texts : Array[String]) -> Array[Bool] {
|
||||
let cleanup_list : Array[Int] = []
|
||||
|
||||
let address = mbt_ffi_malloc((texts).length() * 8);
|
||||
for index = 0; index < (texts).length(); index = index + 1 {
|
||||
let iter_elem : String = (texts)[(index)]
|
||||
let iter_base = address + (index * 8);
|
||||
|
||||
let ptr = mbt_ffi_str2ptr(iter_elem)
|
||||
mbt_ffi_store32((iter_base) + 4, iter_elem.length())
|
||||
mbt_ffi_store32((iter_base) + 0, ptr)
|
||||
cleanup_list.push(ptr)
|
||||
|
||||
}
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportEmojiHas(address, (texts).length(), return_area);
|
||||
|
||||
let array : Array[Bool] = [];
|
||||
for index0 = 0; index0 < (mbt_ffi_load32((return_area) + 4)); index0 = index0 + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index0 * 1)
|
||||
|
||||
array.push((mbt_ffi_load8_u((iter_base) + 0) != 0))
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(address)
|
||||
mbt_ffi_free(return_area)
|
||||
|
||||
cleanup_list.each(mbt_ffi_free)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// The font's picture for emoji `text`, scaled to fit `px` x `px`, as an image for `draw-image`
|
||||
/// (the same text and size give the same handle). 0 when the font has none or isn't open.
|
||||
pub fn emoji_image(text : String, px : Int) -> UInt {
|
||||
|
||||
let ptr = mbt_ffi_str2ptr(text)
|
||||
let result : Int = wasmImportEmojiImage(ptr, text.length(), px);
|
||||
let ret = (result).reinterpret_as_uint()
|
||||
mbt_ffi_free(ptr)
|
||||
return ret
|
||||
|
||||
}
|
||||
@@ -650,7 +725,7 @@ pub fn write_frame_png(path : String) -> Bool {
|
||||
/// the queue is full (the encoder is behind).
|
||||
pub fn grab_recording_frame(x : Int, y : Int, w : Int, h : Int, pointer : Bool, px : Int, py : Int) -> Bool {
|
||||
|
||||
let result : Int = wasmImportGrabRecordingFrame(x, y, w, h, if pointer { 1 } else { 0 }, px, py);
|
||||
let result : Int = wasmImportGrabRecordingFrame(x, y, w, h, (if pointer { 1 } else { 0 }), px, py);
|
||||
let ret = (result != 0)
|
||||
return ret
|
||||
|
||||
@@ -704,3 +779,4 @@ pub fn snapshot_pixels(x : Int, y : Int, w : Int, h : Int, out_w : Int, out_h :
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user