From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id A610F267F8 for ; Tue, 13 Feb 2024 01:31:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=9oLjAtODNfDBPhL1t23FkD+8PS1JBM7+buyIlqktL6E=; b=qq42MHbYev/WFpMAed2d8vWANx J6cqMqxQQXv3BK5FRRSRj3DoMVzOtYlKMAZCgKXB2nG362XKxhrfyqBP8JKtVEVQvFaBObUr0QcrR eBzlEbOo09mzz3Gdq6RwZ6PM6gMR4rF3e1VlfhxngC4jnR3tjQicIflSG7pYg+VeMYz60WqnZqWY6 Mr+TyqY2uf4skRsV9y0GrdMefs2UpAmHqf0UOBlFZP5au0t0m9Bu0rx+sQecflyy+0cfzfRqrFVRN F4Zd0CcevU7eWy8spk57Qf6+d0vIE8wkwKNQSqeQ9H++UDvU41/PDYTbirg0otFm9oMlaDXejSRFe d7EtzFVw==; Received: by zero.zsh.org with local id 1rZgho-0006ix-Nw; Tue, 13 Feb 2024 00:31:24 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rZghH-0006OC-Fg; Tue, 13 Feb 2024 00:30:51 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.97.1) (envelope-from ) id 1rZghG-000000007c1-0NS5; Tue, 13 Feb 2024 01:30:50 +0100 cc: Zsh workers In-reply-to: From: Oliver Kiddle References: <84864-1707708370.319024@8kOf.oEra.sYsr> To: Bart Schaefer Subject: Re: PATCH: alternate views on .zle.hlgroups MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29263.1707784250.1@hydra> Date: Tue, 13 Feb 2024 01:30:50 +0100 Message-ID: <29264-1707784250.086672@DYTv.CIRB.22cb> X-Seq: 52535 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Bart Schaefer wrote: > I don't do much with zle_highlight so I have only general comments ... Thanks. That gave me a few more ideas of things to test, none of which triggered outcomes that appeared iffy. I've attached a doc patch though some things remain that may need addressing in the code. In particular resetting attributes after %H in a prompt and whether the layers and rules for merging attributes are sufficient for the needs of plugins like zsh-syntax-highlighting. Probing the tty for background colour is something that'll probably need testing privately for a while first. Oliver diff --git a/Doc/Makefile.in b/Doc/Makefile.in index dabe11fe3..d9be182e9 100644 --- a/Doc/Makefile.in +++ b/Doc/Makefile.in @@ -63,7 +63,8 @@ Zsh/mod_attr.yo Zsh/mod_cap.yo Zsh/mod_clone.yo \ Zsh/mod_compctl.yo Zsh/mod_complete.yo Zsh/mod_complist.yo \ Zsh/mod_computil.yo Zsh/mod_curses.yo \ Zsh/mod_datetime.yo Zsh/mod_db_gdbm.yo Zsh/mod_deltochar.yo \ -Zsh/mod_example.yo Zsh/mod_files.yo Zsh/mod_langinfo.yo \ +Zsh/mod_example.yo Zsh/mod_files.yo \ +Zsh/mod_hlgroup.yo Zsh/mod_langinfo.yo \ Zsh/mod_ksh93.yo Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo \ Zsh/mod_nearcolor.yo Zsh/mod_newuser.yo \ Zsh/mod_parameter.yo Zsh/mod_pcre.yo Zsh/mod_private.yo \ diff --git a/Doc/Zsh/mod_hlgroup.yo b/Doc/Zsh/mod_hlgroup.yo new file mode 100644 index 000000000..efe8934a1 --- /dev/null +++ b/Doc/Zsh/mod_hlgroup.yo @@ -0,0 +1,25 @@ +COMMENT(!MOD!zsh/hlgroup +Alternative views of highlighting groups +!MOD!) +The tt(zsh/hlgroup) module defines special parameters that represent +highlighting groups in different forms to ease the use of the groups when +configuring other tools. + +In each case, these are readonly associative arrays where accessing elements +uses values from the underlying tt(.zle.hlgroups) variable. + +startitem() +vindex(.zle.esc) +item(tt(.zle.esc))( +This associative array contains the literal escape sequences used to apply the +highlighting for each group. An example use would be when setting the +tt(LESS_TERMCAP_xx) environment variables for the tt(less) pager. +) +vindex(.zle.sgr) +item(tt(.zle.sgr))( +Where highlighting makes use of CSI escape sequences, this parameter contains +the "Select Graphic Rendition" number sequence. This is useful with, for +example the tt(GREP_COLORS) and tt(LSCOLORS) environment variables and the +tt(list-colors) style. +) +enditem() diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 909012c8e..de988ab7c 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -246,6 +246,14 @@ item(tt(%K) LPAR()tt(%k)RPAR())( Start (stop) using a different bacKground colour. The syntax is identical to that for tt(%F) and tt(%f). ) +item(tt(%H))( +Change all character visual attributes using a highlighting specification from +the tt(.zle.hlgroups) associative array. The key is specified in following +braces so, for example tt(%H{error}) will use the highlighting specification +for the `error' group. If the key is not found in the associative array then +it has no effect. Highlighting specifications are in the same format as for +the tt(zle_highlight) parameter. +) item(tt(%{)...tt(%}))( Include a string as a literal escape sequence. The string within the braces should not change the cursor diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index 495bd86a8..31eb3f3ba 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -2807,6 +2807,17 @@ item(tt(italic))( The characters in the given context are shown in a italic font. Not all terminals support italic fonts. ) +item(tt(hl=)var(group))( +Use the specified highlighting group. The var(group) is used as a key into +the associative array tt(.zle.hlgroups) to determine the actual highlighting. +) +item(tt(layer=)var(layer))( +The layer is used to determine precedence when multiple highlighting regions +overlap. The var(layer) is a decimal integer, with higher numbers taking +precedence over lower numbers. The default layer is 10 with 30 used as the +default for tt(special), 20 for tt(region) and tt(isearch) and 15 for +tt(paste). +) enditem() The characters described above as `special' are as follows. The diff --git a/NEWS b/NEWS index 4d4699f7e..d0a8584e2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,12 @@ Changes since 5.9 In region_highlight and zle_highlight, italic and faint can be specified as font attributes for terminals that support them. +Highlighting groups can be referenced in region_highlight and +zle_highlight for common attribute combinations and a layer can be +specified to indicate precedence where highlighted regions overlap. +Highlighting groups are also supported in the prompt via a new %H +prompt escape. + Ellipsis markers shown by the line editor to indicate where the line doesn't fit in the terminal can be highlighted.