Expand description
Prompt cursor coordinate calculation.
Given prompt text, a grapheme-cluster cursor position, the body width
(columns available for text), and an optional prompt indent, compute the
(row, col) coordinate of the cursor within the prompt’s visual rows.
Uses unicode_width for display-width measurement so that wide
characters (CJK), zero-width characters (combining marks), and emoji are
handled correctly. Cursor position is expressed as a grapheme-cluster index
(matching crate::input::PromptInput).
Handles:
- single-line input;
- word/char wrapping at
body_widthusing display width, not char count; - explicit
\nnewlines; - a leading prompt indent applied to every visual row;
- multibyte and grapheme clusters.
Functions§
- prompt_
cursor - Compute the
(row, col)coordinate of the cursor in the prompt’s visual rows. - prompt_
rows - Decompose prompt text into visual rows of text (without the indent) for rendering. Uses display width for wrapping so wide characters occupy the correct number of columns.