troglobit / editline

A small replacement for GNU readline() for UNIX
https://troglobit.com/projects/editline/
Other
279 stars 58 forks source link

Request for \1 and \2 (RL_PROMPT_START_IGNORE, RL_PROMPT_END_IGNORE) support #48

Open Artoria2e5 opened 3 years ago

Artoria2e5 commented 3 years ago

Editline currently uses a "one byte per column" heuristic, and one way that breaks down is when it encounters colored prompts. The way readline (and libedit) handles this issue is by having the program tell it what parts of the prompt don't count into the width calculation: \1 (RL_PROMPT_START_IGNORE) starts the width-ignore area and \2 (RL_PROMPT_END_IGNORE) ends it.

See https://github.com/cdesjardins/libedit/search?q=RL_PROMPT_START_IGNORE for how it works in NetBSD libedit.

troglobit commented 3 years ago

Pull requests are welcome.