Skip to content

Phase 1.x: UTF-8 / multibyte input in boxen UI bridge modals #796

Description

@jsavin

Problem

frontier-cli/boxen_ui.c:291 only accepts printable ASCII:

if (ev->key.key == BOXEN_KEY_NONE && ev->key.ch >= 0x20 && ev->key.ch < 0x7F) {
    insert_char(ctx, (char)ev->key.ch);
}

boxen delivers Unicode codepoints in key.ch. The legacy read_line_with_editing stored the single byte without any range check. UTF-8 paste / IME input is silently rejected by the bridge but accepted by the legacy reader.

Fix

Widen the accept range to include codepoints > 0x7F. Encode each codepoint as UTF-8 (1-4 bytes) into the buffer. The render path at boxen_ui.c:170-171 treats buf[i] as a single byte cell — needs to be updated to advance by codepoint width, not byte width, for correct cursor positioning. The > prefix and field width math stay the same.

Caveats:

  • East-Asian wide characters take 2 cells per codepoint — boxen_window_content_width plus a wcwidth-style helper needed
  • Backspace should delete one codepoint, not one byte
  • dialog_get_int should still reject non-digit codepoints (keep the existing ch_is_acceptable_int check on the input filter)

This compounds with #795 (buffer growth) — both touch the input buffer representation.

Context

Acceptance

  • Typing non-ASCII characters into a bridge modal stores and displays them correctly
  • Cursor advances by codepoint width on insert / retreats on backspace
  • Test in test_06_ui_bridge.py paste/insert a multibyte character and assert it round-trips through dialog.getString

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2Medium priority - nice to havescope/medium1-2 weeks, requires design worktype/featureNew feature or requestworkstream/verb-portingKernel verb implementation and bindings

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions