Re: ZWJ paste from clipboard problem (unicode)
Mikael Magnusson <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAHYJk3TF4g4x9vz6OF9imP=hLpCKDcrPH-kRp5JHkwAvGny5Gg@mail.gmail.com> |
On Tue, Apr 1, 2025 at 10:08 AM Daniil Rozanov <[email protected]> wrote: > > On Tue Apr 1, 2025 at 5:07 AM +04, Mikael Magnusson wrote: > > On Mon, Mar 31, 2025 at 11:23 PM Daniil Rozanov <[email protected]> wrote: > >> > >> On Mon Mar 31, 2025 at 11:31 PM +04, Bart Schaefer wrote: > >> > On Mon, Mar 31, 2025 at 12:13 PM Daniil Rozanov <[email protected]> wrote: > >> >> > >> >> When trying to paste "👩" (U+1F469 U+1F3FB U+200D U+1F9B0) emoji, zsh > >> >> prints two emojis and "<200d>" in between. > >> > > >> > Try "setopt combining_chars" > >> > > >> > Additional tweaks may be needed if your terminal is using bracketed paste mode. > >> > >> Thanks! Now it pastes pretty emoji. But now there is another problem, > >> which is character's width is more than expected. And with some special > >> emojis it works wrong: duplicated display on paste, backspase erases > >> kinda parts of emoji instead of remove it all at once. Btw this > >> behaviour now is similar to bash. > >> > >> Maybe zsh has some group of settings which handle unicode? > > > > What you want is not theoretically possible as far as I know. > > Combining emojis is optional according to the specs, and zsh has no > > way of knowing if a terminal will combine two particular emoji in a > > zwj sequence, and thus has no idea how wide the sequence of characters > > will be or when the terminal will start drawing on a new line. > > > As far as I know it is possible on some bunch of terminals. This > possibility called "mode 2027", briefly described here: > > https://mitchellh.com/writing/grapheme-clusters-in-terminals > > So at least zsh can test terminal to know does it support grapheme > clustering or not and work around this. This requires querying the cursor position from the terminal though, see the thread starting at https://www.zsh.org/mla/workers/2016/msg02326.html for why this is unlikely to happen. (We need to know the width before printing the text in many cases). -- Mikael Magnusson