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 ad3f2448 for ; Thu, 17 Oct 2019 10:53:07 +0000 (UTC) Received: (qmail 153 invoked by alias); 17 Oct 2019 10:52:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24352 Received: (qmail 569 invoked by uid 1010); 17 Oct 2019 10:52:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm1-f68.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25601. spamassassin: 3.4.2. Clear:RC:0(209.85.128.68):SA:0(-1.0/5.0):. Processed in 3.510096 secs); 17 Oct 2019 10:52:57 -0000 X-Envelope-From: doron.behar@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.68 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ush2zw76wCphGmUJk2pZVpTrYgE3Fjs1wNY6MFuZj4M=; b=N3/Wez8GWVYNoirOCMmq5GvGHiesjaWox6+LiHdEs8MAFZ5MB2KWpHZdIQ9Ac+OGab VgZxn0JdH3ioRCq3PlzHIlkmtrTuW6+mxnX84Oa0aG5EKpolB7nWgImc7CPo8wxxSbTy NukxjxUxb2R8MZrXr2lwmPS4xR3A0MuHKzFG/S2PnHW1ITwvsA8JpEFtZw8qwvvqeU1U 5rTaUXBTImwW8FcUA3QTkqpFDFsC0mjGzX+e4zMIvkCf9NKMUiBTxkSx9SmiSkBMMk41 AOlEwJpbH573OUqeflzFw7NXX2NQkyELv5Fphn9QeIz80K8v/fqjvxLewo+/UJQ3K4nr JotA== 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:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Ush2zw76wCphGmUJk2pZVpTrYgE3Fjs1wNY6MFuZj4M=; b=n7fXzoJ2W0AofyNhGKGFEfLXpwAKcRr+m9ewWwvJ/DDV8Ijy2owrYXVTwo1+oldlh0 KdmQZeJvGR0C3E5MJ6Ttcab4FwCfza56gkA02UaTrvfj3ownjF0kJ8bJxyv2SfD+jkeN mPlJqit3gnHb3pJbqkqv+Hfj4AZDklF2OELJmwmi1p1tqbBfh1gYbtAMu5NC93pUi6z/ gPH07aeB22beM1iVwdWyOgWN50SbVI4thaiErt9ahDQGYIr0j87LPERcKsG0R0nMZYtd DnXGgTXzZ8iqLgYu9yAt2/K13967ezKiDVw4XMH0AXb1SKNfizm89KkGRBVXidgJjHL0 YvMw== X-Gm-Message-State: APjAAAWVAg1wHVf19BKzuutgtbSyXxGlOZNfHIy+dS74GivDRu8kRXya qqM2wpJn09KZvzR8XNeb/IpfBleuNgY= X-Google-Smtp-Source: APXvYqwkEokFs6ecdgGAng1VmhvadI5UQYmauosibxXWyebJ7elDVBpE6URaj7b/7ok3AtioymOMgg== X-Received: by 2002:a1c:1bd8:: with SMTP id b207mr2284632wmb.62.1571309537432; Thu, 17 Oct 2019 03:52:17 -0700 (PDT) Date: Thu, 17 Oct 2019 13:51:55 +0300 From: Doron Behar To: zsh-users@zsh.org Subject: Re: ZLE Vi-mode: visual mode selection doesn't match the characters highlighted Message-ID: <20191017105155.tshgdwg2m5wwoinm@NUX> Reply-To: Oliver Kiddle References: <20191012150611.rwjwhbiqpvwla656@NUX> <11565-1570953731.113937@7Hja.mAXg.cCYH> <20191013110016.pdkjrobevpxkqx6e@NUX> <68873-1571254670.273502@yOop.8xvF.viEb> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <68873-1571254670.273502@yOop.8xvF.viEb> User-Agent: NeoMutt/20180716 On Wed, Oct 16, 2019 at 09:37:50PM +0200, Oliver Kiddle wrote: > On 13 Oct, Doron Behar wrote: > > Thanks for suggesting that. Indeed this is a combination of terminal > > emulators' settings / differences in behaviour along with a certain > > plugin I use: https://github.com/zsh-users/zsh-syntax-highlighting > > If I run zsh -df and then enable just that plugin by doing > . zsh-syntax-highlighting.zsh > then I still can't reproduce the problem with highlighting of the t. > > It doesn't appear to create any new keymaps so I'm unsure why you > don't get the `t' highlighted. Are you loading it with a plugin > manager? It'd be useful to isolate just the minimum required to > cause the problem. I'm glad Oliver that you are attending _this_ issue as well but I'd like to deal with it at that GitHub thread (https://github.com/zsh-users/zsh-syntax-highlighting/issues/637), as I don't feel it's related and focus here on the _cursor's_ character's highlighting. Never the less, I'll emphasize that this issue appears only when the syntax highlighter colors the text of `t` in a certain foreground color. If normal foreground color is used, `t` is highlighted properly. > Zsh does highlight the cursor position. It is down to the terminal > emulator how that appears. What terminal emulator do you use? What is > $TERM set to and what OS are you on? I use a green solid block as my > cursor and I know that the cursor position is included in the > selection. It appears much the same in vim and gvim. I'm using NixOS and our `urxvt` is compiled according to this "recipe": https://github.com/NixOS/nixpkgs/blob/7885eeaffdbd02ff6ce5483239fba1a063b314a9/pkgs/applications/misc/rxvt_unicode/default.nix My `$TERM` is `rxvt-unicode-256color`. I've tested as well: - Urxvt with an empty `.Xresources` (I ran `xrdb merge .Xresources`) - Gnome-Terminal - Konsole I've demonstrated the problematic behaviour with `zsh -df` (without syntax highlighting) here: https://gist.github.com/doronbehar/cba65dbac52b5859e8e967a6bc71ea91#gistcomment-3057815 As you can see, if the cursor's color is not blinking, **all** tested terminal emulators don't highlight the cursor's character. I dearly hope the issue is clear now. > You may be able to configure the cursor with escape sequences. For > example, for a vertical bar (good for vi insert mode): > print -n $'\e[5 q' I tried using an underline cursor, and it somewhat improved my situation: The letter the cursor is standing at is highlighted so it's a good-enough workaround but I hope this won't be considered as a solution because in general, I prefer the block cursor. > We could perhaps use some hooks for when visual mode is invoked and > finished. Yea I can use `zle-keymap-select` in the meantime... > > Oliver, do you think perhaps ZSH could 'double reverse' the cursor > > in visual mode? I think this will emulate Vim's behaviour better > > because this way, with a non blinking cursor in visual mode, the > > character the cursor stands upon will standout as well. > > That could make it hard to see which end of the selection the cursor > is at. I can imagine, but if the cursor is a block and it's not blinking, no sane user would expect to see on which end of the selection the cursor's located since the cursor is a block. Vim can't help you distinguish this as well. With the current behaviour and a non blinking, block cursor, it's even more confusing if the character the cursor is located at is not highlighted at all but it _is_ selected! > Whatever highlighting is chosen, there will be some terminal > setup for which it is not ideal and somebody who complains. I hope I've demonstrated good enough that this is not a terminal emulator issue, it's an issue of a non blinking cursor. Hence, I think my complain is legitimate. > Vim's defaults result in a barely visible selection if you chose a > near-white default background colour. I'm not sure I agree. I tested Vim in Konsole and Gnome terminal and the cursor was surely visible - a black block on a white or whitish background instead of the other way around. > Copying Vim might be tempting but Vim is not the only editor - zsh > uses the term region for the selection in many cases because the > feature first appeared in an Emacs form. I'm not sure how emacs feels in that sense, nor ZSH's region selection when it's emulating Emacs. Anyhow, since there are only 2 editors we emulate, I think Vim should be emulated if `bindkey -v` is set, else Emacs should be emulated. > Feel free to lobby on zsh-workers if you want the defaults changed. > Personally I was happy to just tweak zle_highlight and the terminal > emulator. I'd love to lobby there but I'm not sure what defaults can I change. Given the GIF demonstrations I've made. It seems to me the underlying code needs a change, and that the defaults are OK. I'd thank you a lot Oliver if you'll at least verify that with your version of ZSH and the terminals I tested you get the same behaviour with a non blinking cursor. Thanks, Doron.