Skip to content

Add a one-line Input component - #27

Open
mrnasil wants to merge 1 commit into
kristoferlund:mainfrom
mrnasil:feat/input
Open

mrnasil wants to merge 1 commit into
kristoferlund:mainfrom
mrnasil:feat/input

Conversation

@mrnasil

@mrnasil mrnasil commented Sep 14, 2026

Copy link
Copy Markdown

Closes #26.

What and why

ratcn had twelve components and none of them took typed text. This adds Input: a one-line field whose string lives in app state and whose caret is a transient.

The caret overlays the insertion point as a blinking | and does not take a column, so moving or blinking it never shifts the letters. A left Down is ignored so the runtime can still move focus onto the field (the same press-to-focus path a checkbox uses); the following Click places the caret.

Word-kill is this field's own chord, but hosts disagree on the bytes. Matching only Backspace + Ctrl fails on Windows PowerShell and WSL, where ConPTY reports Ctrl+Backspace as Ctrl+H (0x08). The field therefore treats all of these as the same backward kill:

  • Backspace with Control (kitty, browser)
  • Ctrl+H / 0x08 (Windows ConPTY, xterm, WSL)
  • Backspace with Alt (macOS Option, emacs-style)

Forward kill is Delete with Control (CSI 3;5~) or with Alt. Ctrl+W still bubbles.

Out of scope, on purpose: multi-line, password, selection, undo, max length.

Checks

  • cargo fmt --all
  • cargo test -p ratcn --all-features
  • cargo check -p copy-fixture --examples
  • cargo clippy -p ratcn --all-features --all-targets -- -D warnings
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo clippy --workspace --exclude cargo-ratcn --all-targets --target wasm32-unknown-unknown -- -D warnings

cargo test --workspace was not run to completion on this Windows host: cargo-ratcn has a pre-existing CRLF assertion in renders_the_expected_config, unrelated to this change.

If applicable

  • Added a component? crates/copy-fixture/examples/input.rs added.
  • Changed public API? Input, InputWidget, InputStyle, plus text_width::{grapheme_count, grapheme_byte, graphemes} so a copied module does not depend on unicode_segmentation. Docs page and changelog updated.
  • Added a demo? demos/input/ with Trunk.toml.
  • Added a dependency? No.
  • Needs a newer Rust? No.

The value is app-owned; the caret is a transient. Overlay `|` does not
take a column. Word-kill matches what each host actually reports:
Ctrl+H on Windows ConPTY and WSL, Option+Backspace on macOS.

Closes kristoferlund#26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a one-line Input component

1 participant