Skip to main content

Module cost

Module cost 

Source
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 n literal backspace bytes.
cbt_cost
Cost of CBT (\x1b[{n?}Z).
cha_cost
Cost of CHA (\x1b[{col+1?}G). The writer drops the parameter when col == 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 than ilog10 on 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 == 0 omits the parameter.
el_cost
Cost of EL (\x1b[{n?}K). n == 0 omits the parameter.
hpa_cost
Cost of HPA (\x1b[{col+1?}` ). The writer drops the parameter when col == 0.
ich_cost
Cost of ICH (\x1b[{n?}@).
il_cost
Cost of IL (\x1b[{n?}L).
lf_cost
Cost of n literal 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 n literal tab bytes.
vpa_cost
Cost of VPA (\x1b[{row+1?}d). The writer drops the parameter when row == 0.