Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: region_highlight converts `fg=default` to `none`, which is not the same



On Fri, Oct 23, 2020 at 12:40 PM Marlon Richert
<marlon.richert@xxxxxxxxx> wrote:
>
> On Fri, 23 Oct 2020 at 12:35, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
>>
>> The only way to know whether the terminal supports some capability
>> (e.g., moving the cursor to the specified location on the screen, or
>> highlighting text with 256 colors) and to use the said capability is
>> through terminfo. There is no way around it.
>
> Sure, but that is not necessary for this particular problem.

Which problem? As I mentioned, it's definitely possible to add support
for italicized text to zsh and to make it consistent with the existing
highlighting API.

The fact that region_highlight and zle_highlight support "standout" is
not a problem but a feature. Standout is a part of the curses standard
and zsh interprets it within region_highlight and zle_highlight in a
manner consistent with the standard. ("standout" within "colors" is a
different matter. That one is incorrect in my opinion.)

> If the user wants to pass something to their own terminal, then
> just let them. Zsh already lets the user pass in ECMA-48 SGR
> parameter values directly in [...] prompt expansions.

Do you mean %{...%}? It's indeed useful and allows the user to insert
any byte sequence into their prompt. I don't think there is anything
specific to ECMA-48 SGR in prompt expansions, or am I missing it?

region_highlight doesn't need the equivalent of %{...%} because it's
implied. So something like this could work:

  region_highlight=($'1 2 raw=\e[4m')

The value of `raw=` spans until the end of the string, so if you want
to combine it with `fg=42`, you'll need to use `fg=42,raw=\e[4m`
rather than `raw=\e[4m,fg=42`. That's one way to do it -- I'm not
particularly attached to it, just thinking out loud.

One tricky part about this is that it doesn't allow you to specify the
sequence that undoes the effect of `raw` but this is probably OK
because zle inserts SGR0 before every that may have different
highlighting. There is something in the code that suggests this isn't
always the case but I don't know where this code actually triggers.

From the implementation's point of view this will require quite a bit
of work because this doesn't fit the existing framework around zattr.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author