[PATCH 2/2] less: replace most uses of NORMAL escape with UNHIGHLIGHT

Ishan Bhargava shane.880088.supw at gmail.com
Fri Apr 15 05:50:19 UTC 2022


On Fri, 15 Apr 2022 at 05:49, Kang-Che Sung <explorer09 at gmail.com> wrote:
> What's the difference between the NORMAL escape and the UNHIGHLIGHT escape? Is there a test case to demonstrate th>

The UNHIGHLIGHT escape flips only the HIGHLIGHT (invert, actually) bit back to
off. The normal escape flips ALL special display bits back to off, including
color. We don't want that in case there is a highlighted term (e.g. another
control sequence) in between a colored line.

test case:
printf '\033[33mhello\033\007\013hi\033[m' > ./tmp

Compare how busybox less without this 2nd patch vs. greenwood less (and bbless
with this patch) shows the output. In the former, the colored line is just cut
short because of the highlighted control chars. In the latter, the entire line
is colored, with small highlighted (colored) sections in between.

One thing this cannot deal with is a highlight escape in the input itself,
which would be cut short by any less-emmitted highlight sequence. Avoiding that
would probably require looking at the escapes and keeping state.


More information about the busybox mailing list