From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1434a9d2 for ; Thu, 7 Feb 2019 21:07:11 +0000 (UTC) Received: (qmail 21634 invoked by alias); 7 Feb 2019 21:07:01 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44058 Received: (qmail 16440 invoked by uid 1010); 7 Feb 2019 21:07:01 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm1-f67.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(209.85.128.67):SA:0(-2.0/5.0):. Processed in 1.190035 secs); 07 Feb 2019 21:07:01 -0000 X-Envelope-From: tamelingdaniel@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition; bh=7Z2JsrHSuEb4Ku+32ojjF2Yf6lWQcj7xTgVE2vwf+Bw=; b=BLPB+mh9NHnW1OgGrbJiMWy9hA+TwOXKggY1KPkn4CDZFbZuBdQ0lL0UXk+Y3InojQ C8mZTia7/AXen9qhl3QYcxfEY+d65TNP49Xe1t/QFMDsFuyqtXUPqcCUSuiLv3OZkDSw LgJ4iOogLrz/hFYHJFYz9DwIfYgbuIASOIIaEWTZRjpT3XvQJmgRCExTYbxVTsySF1Gw BjWbP5WVQs4OywbExV2GGYwTqW2urHoT7MfVQFfod1snkXKo5rvngMi7mdS4p6KXvnSe Xh+4nhri0mmdLQz0O2IGQja52S0KxIbutGkMAnauxEBW649y/zccfBaVagLSdrVj1/vK NvSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition; bh=7Z2JsrHSuEb4Ku+32ojjF2Yf6lWQcj7xTgVE2vwf+Bw=; b=AgjGgkTRgO1ZQXK94OxHevQw7LJp/YWfoN32Ur4h6aNLFdnGljokk3TP5j0otksZO4 KT9uQX1MmiSITFa7NUCuwOcTowMchzhIgNflAgbtqo7aeTyjtn2TMsHUPZdX1qCOZFh4 gEKYbLMOwyQs+8mUmbO0hrg6ij/lxWfzYi1gAQOPrQ+FosOz1qjMB4Ti/9UjKCy0nUfa mPL2DpeEg6TkN6OrGYi2kDJIBZSgIcMzS7+RoRvwAhCKbxOanMUNTkDiuqfKHdAiWRfw eUTTFOAD5VmyuYw4z88lVpO202puaGBybUrjxRkJeaUYKoSxMVdH5wawDt+I/ufXCdJL zMKg== X-Gm-Message-State: AHQUAuZcNN8QWfiLz4uQrxqf8LPlKtkScKor5Y+qjB7SoY1/6D/cLVYu sJxPBLOZqm/7vI3Au7QenA3GJwU5 X-Google-Smtp-Source: AHgI3IYa37/zsqCYIcP7sKlZc2+UtoEomF7e259DPU7/8wV3riSyB2PbLYmkHdb3rQ2IoRDX8kvYGQ== X-Received: by 2002:a1c:f605:: with SMTP id w5mr9263456wmc.116.1549573615920; Thu, 07 Feb 2019 13:06:55 -0800 (PST) Date: Thu, 7 Feb 2019 22:06:54 +0100 From: Daniel Tameling To: zsh-workers Subject: [PATCH] Improve the X04zlehighlight test Message-ID: <20190207210654.h3re4dhgpdktsuzp@Daniels-MacBook-Air.local> Mail-Followup-To: zsh-workers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Dear all, I have tried to modify the zle highlight test so that the TERM variable isn't set explicitly anymore so people can check with the actual terminal they are using that the features behave as expected. The following things are changed: in REPLY, the enter and exit standout mode sequences are replaced with their xterm equivalents because other terminals (like screen-256color) use different sequences. The old nearcolor tests are now only executed when the terminal has exactly 256 colours because only then they produce meaningful results. In turn, equivalent tests for 88 colour terminals are added. I tested the new X04 successfully with TERM set to various xterms and a few other terminals. The test seems to be surprisingly stable with regards to the number of colours of the terminal. But overall I am not overly optimistic that the test will pass with all terminals/operating systems. The tests feel very brittle. So please try it out. Best regards, Daniel diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst index 000949698..4afdf6c7c 100644 --- a/Test/X04zlehighlight.ztst +++ b/Test/X04zlehighlight.ztst @@ -2,9 +2,8 @@ # Version 0.7 2018-12-06 %prep - export TERM=xterm-256color - if [[ ${+termcap} != 1 || ${termcap[Co]} != <-> || ${termcap[Co]} -lt 256 ]]; then - ZTST_unimplemented="no termcap module OR termcap doesn't support 256 or more colors" + if [[ ${+termcap} != 1 || ${termcap[Co]} != <-> ]]; then + ZTST_unimplemented="no termcap module OR termcap doesn't support colors" elif [[ $OSTYPE == cygwin ]]; then ZTST_unimplemented='the zsh/zpty module does not work on Cygwin' elif zmodload zsh/zpty 2> /dev/null; then @@ -31,6 +30,9 @@ zpty -r zsh REPLY # Normalise me/sgr0 to \e[0m. We also need to strip \e(B in zpty_stop() REPLY=${REPLY//${termcap[me]}/$'\x1b[0m'} + # Replace rmso/se and smso/so with xterm values + REPLY=${REPLY//${termcap[so]}/$'\x1b[7m'} + REPLY=${REPLY//${termcap[se]}/$'\x1b[27m'} # P is for "preserve", and induces keeping some # expected color codes to test region_highlight, # etc. - the color codes are made a regular text. @@ -105,6 +107,9 @@ 0:basic region_highlight with true-color (hex-triplets) >0m27m24m38;2;4;8;16mtrueCDE|39| + if [[ ${termcap[Co]} != 256 ]]; then + ZTST_skip="nearcolor module for 256 color terminals" + fi zpty_start zpty_input 'zmodload zsh/nearcolor' zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#040810" ); }' @@ -117,6 +122,21 @@ 0:basic region_highlight with near-color (hex-triplets at input) >0m27m24mCDE|3232|trueCDE|39| + if [[ ${termcap[Co]} != 88 ]]; then + ZTST_skip="nearcolor module for 88 color terminals" + fi + zpty_start + zpty_input 'zmodload zsh/nearcolor' + zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#040810" ); }' + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' # emits newline, which executes BUFFER="true" command + zpty_line 1 p # the line of interest, preserving escapes ("p") + zpty_stop +0:basic region_highlight with near-color (hex-triplets at input) +>0m27m24mCDE|316|trueCDE|39| + zpty_start zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=green" ); rh2; }' zpty_input 'rh2() { region_highlight+=( "1 2 fg=red" ); }' # `r' in red; the above line would be too long @@ -141,6 +161,9 @@ 0:overlapping region_highlight with true-color >0m27m24m38;2;0;204;0mt38;2;204;0;0mrCDE|39|38;2;0;204;0mueCDE|39| + if [[ ${termcap[Co]} != 256 ]]; then + ZTST_skip="nearcolor module for 256 color terminals" + fi zpty_start zpty_input 'zmodload zsh/nearcolor' zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#00cc00" ); rh2; }' @@ -154,6 +177,22 @@ 0:overlapping region_highlight with near-color (hex-triplets at input) >0m27m24mCDE|340|tCDE|3160|rCDE|39|CDE|340|ueCDE|39| + if [[ ${termcap[Co]} != 88 ]]; then + ZTST_skip="nearcolor module for 88 color terminals" + fi + zpty_start + zpty_input 'zmodload zsh/nearcolor' + zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#00cc00" ); rh2; }' + zpty_input 'rh2() { region_highlight+=( "1 2 fg=#cc0000" ); }' # `r' in red; the above line would be too long + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' # emits newline, which executes BUFFER="true" command + zpty_line 1 p # the line of interest, preserving escapes ("p") + zpty_stop +0:overlapping region_highlight with near-color (hex-triplets at input) +>0m27m24mCDE|324|tCDE|348|rCDE|39|CDE|324|ueCDE|39| + %clean zmodload -ui zsh/zpty