From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28430 invoked by alias); 5 Nov 2016 22:04:39 -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: X-Seq: 39843 Received: (qmail 5876 invoked from network); 5 Nov 2016 22:04:39 -0000 X-Qmail-Scanner-Diagnostics: from hahler.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(188.40.33.212):SA:0(0.0/5.0):. Processed in 0.50643 secs); 05 Nov 2016 22:04:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: genml+zsh-workers@thequod.de X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.hahler.de designates 188.40.33.212 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-type:content-type:mime-version:user-agent:date:date :message-id:subject:subject:from:from:received:received; s= postfix2; t=1478383469; bh=hGg8mGCbJfEDJ+QrJB1hyMIbG8SMInw1CIl7G gu7Ic4=; b=La+RRbcY3Q6JwQGNcPXeGGFvG7g+8tHwgQJJRufn/aMfrnX6k8Hu4 T7u5bq3uzDN4RtF36Wkc5dRrxz9yHupDp0TM6XBuKhQUgr0s5C4KBiRa43CqesFQ Xe1/q9Clpzx4ouTttRfNgqO9Wpb6UpcHn7qQ4swhhEjcd/XSD/DfDU= To: Zsh Hackers' List From: Daniel Hahler Subject: Better handling of wide glyphs (ask the terminal, not wcwidth) Message-ID: <3126f405-b1a0-b29c-df2b-a3376aabb702@thequod.de> Date: Sat, 5 Nov 2016 23:04:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5q28jtqpLs9BOjJ4OqA4atrn4HDu1wEgx" --5q28jtqpLs9BOjJ4OqA4atrn4HDu1wEgx Content-Type: multipart/mixed; boundary="WJAf9hm1rDb9KWn28UnrX6O4H9N4tHeO2"; protected-headers="v1" From: Daniel Hahler To: Zsh Hackers' List Message-ID: <3126f405-b1a0-b29c-df2b-a3376aabb702@thequod.de> Subject: Better handling of wide glyphs (ask the terminal, not wcwidth) --WJAf9hm1rDb9KWn28UnrX6O4H9N4tHeO2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I am working on a patch for rxvt-unicode, which basically asks the (Xft) = font about the glyph's width, instead of using wcwidth(3). This works around the issue that wcwidth is not updated for Unicode 9 on = Linux yet, and is really required after all, since there is a private use= area, and it depends on the font you are using for those glyphs (e.g. Fo= ntAwesome). This method gets provided as a shared object then, which allows to LD_PRE= LOAD it (overwriting wcwidth and wcswidth). In this case Zsh will use the same method, and everything is fine! But this shows that there is a problem between Zsh and the terminal, sinc= e the display gets out of sync, i.e. 1. I insert "=F0=9F=90=8D", it gets two cells in the terminal: % =F0=9F=90=8D 2. I add "a" after it. "=F0=9F=90=8Da" gets displayed (3 cells), but the= offset gets shifted to the right: % =F0=9F=90=8Da This happens also already when only moving the cursor to the left after i= nserting the snake glyph. =20 So I wondered if Zsh could be smarter even without the custom wcwidth(3) = in LD_PRELOAD: there is CSI 6 n ('\e[6n'), which can be used to ask the t= erminal about the current position. This could be used for a certain range of characters, where zle (?) would= query the position before and after displaying it to get the "real" widt= h (as seen by the terminal). What do you think? While looking into the source regarding this, I've found that there is a = useful function already to get some info ("whatcursorposition", bound to = "ga" in Vim mode). Regardless of the idea above, I think it makes sense to include info from= "CSI 6 n" there. I assume there are methods already that query the terminal through ANSI c= ontrol codes? I've found Functions/Misc/promptnl, but that uses shell code. Cheers, Daniel. --WJAf9hm1rDb9KWn28UnrX6O4H9N4tHeO2-- --5q28jtqpLs9BOjJ4OqA4atrn4HDu1wEgx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAlgeV2gACgkQfAK/hT/mPgDM/ACg2/WQwGnFQDH7FeqzvObON1VW ofIAoIFBeXfVUGz8JQcon4yshzfFyFMj =70y6 -----END PGP SIGNATURE----- --5q28jtqpLs9BOjJ4OqA4atrn4HDu1wEgx--