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

Re: Feature request: italic style in region_highlight



On Mon, Dec 30, 2019 at 2:30 AM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> Hi,
> it would be nice if the italic escape (\e[3m) would have been
> supported in the region_highlight array. Currently supported are only
> bold, standout and underline. The escape is widely supported, e.g.: it
> works on urxvt out of the box.

Zsh sort of supports italicized text through "standout" attribute in
ncurses. ncurses translates standout to italicized on some terminals
and to negative image on others.

    % zle_highlight=(default:standout)
    % export TERM=screen-256color
    % print -P '%Shello%s'
    hello
    % export TERM=xterm-256color
    % print -P '%Shello%s'
    hello

With TERM=screen-256color standout is italicized while with
TERM=xterm-256color it's negative image.

The terms "italicized" and "negative image" come from ECMA-48. Note
that it doesn't define "standout".

When printing text, you can use `colors` from contrib to bypass
ncurses. Confusingly enough, in `color` associative array the key for
italicized text is "standout" (negative image goes by "reverse").

    % autoload -Uz colors
    % colors
    % echo "\e[$color[standout]mhello$reset_color"

The only difference between $color[standout] and plain `3` is
readability. I know which version I prefer.

As far as I can tell, there is no way to specify italicized attribute
through zle_highlight or region_highlight. zle_highlight allows you to
override the default escape sequences used by fg and bg attributes. It
seems natural to extend this API to also allow overriding escape
sequences used by standout style. Then you would be able to do this:

    zle_highlight=(default:standout standout_begin_code:'\e[3m'
standout_stop_code:'\e[23m')

fg_start_code and fg_end_code specify the prefix and the suffix of a
single escape sequence. To avoid confusion, I've used begin/stop with
standout. It's awkward, as the natural pairing would be start/stop and
begin/end. Oh well.

Roman.



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