Expand description
Byte-length predictors for emitted ANSI sequences.
§Category
Cost functions mirror writer functions in crate::ansi::cursor and
crate::ansi::screen. They let render planning compare equivalent cursor,
erase, scroll, and overwrite strategies without allocating formatted strings.
§Conventions
Costs are byte counts for the exact 7-bit sequences emitted by this crate,
including omitted default parameters such as ESC [ A for CUU 1 and
ESC [ H for home.
§Mode interaction
The predictors do not change terminal modes. For mode-sensitive sequences,
such as left/right margins requiring Mode::LEFT_RIGHT_MARGIN, the cost still describes only the bytes emitted.
Constants§
- CR_COST
- Cost of a carriage return (
\r). - DECSTBM_
RESET_ COST - Cost of resetting DECSTBM to the full screen (
\x1b[r). - HOME_
COST - Cost of an absolute home jump (
\x1b[H). - RI_COST
- Cost of Reverse Index (
\x1bM).
Functions§
- bs_cost
- Cost of
nliteral backspace bytes. - cbt_
cost - Cost of CBT (
\x1b[{n?}Z). - cha_
cost - Cost of CHA (
\x1b[{col+1?}G). The writer drops the parameter whencol == 0. - cht_
cost - Cost of CHT (
\x1b[{n?}I). - cub_
cost - Cost of CUB (
\x1b[{n?}D). - cud_
cost - Cost of CUD (
\x1b[{n?}B). - cuf_
cost - Cost of CUF (
\x1b[{n?}C). - cup_
cost - Cost of a CUP sequence for the given 0-based position. The writer
drops the column when it is
0, and drops both parameters when the destination is the origin. - cuu_
cost - Cost of CUU (
\x1b[{n?}A). - dch_
cost - Cost of DCH (
\x1b[{n?}P). - decstbm_
cost - Cost of DECSTBM (
\x1b[{top+1};{bottom+1}r). - digit_
count - Number of decimal digits in a
u16. Branchy table — faster thanilog10on the small range we feed it (cursor coordinates, repeat counts). - dl_cost
- Cost of DL (
\x1b[{n?}M). - ech_
cost - Cost of ECH (
\x1b[{n?}X). - ed_cost
- Cost of ED (
\x1b[{n?}J).n == 0omits the parameter. - el_cost
- Cost of EL (
\x1b[{n?}K).n == 0omits the parameter. - hpa_
cost - Cost of HPA (
\x1b[{col+1?}`). The writer drops the parameter whencol == 0. - ich_
cost - Cost of ICH (
\x1b[{n?}@). - il_cost
- Cost of IL (
\x1b[{n?}L). - lf_cost
- Cost of
nliteral line-feed bytes. - overwrite_
cost - Approximate byte cost of re-emitting the cells in
line[from..to]as a forward-move candidate. - rep_
cost - Cost of REP (
\x1b[{n?}b). - sd_cost
- Cost of SD (
\x1b[{n?}T). - su_cost
- Cost of SU (
\x1b[{n?}S). - tab_
cost - Cost of
nliteral tab bytes. - vpa_
cost - Cost of VPA (
\x1b[{row+1?}d). The writer drops the parameter whenrow == 0.