GithubHelp home page GithubHelp logo

Comments (9)

Aetf avatar Aetf commented on August 17, 2024

Hmm, another weird bug with emoji.

I don't have zsh installed, but I'm using fish, which has autocomplete builtin. Anyway, I tested in kmscon, gtktsm, and also in non-libtsm-based konsole, just to see how does it behave.

Despite some font and other cursor placement issues, I can't reproduce the exact issue you described.

Probably due to the way zsh implementing autocomplete is different from fish?

from libtsm.

refi64 avatar refi64 commented on August 17, 2024

Just tried, and I can't reproduce it in fish either.

Xonsh is another shell where this problem comes up.

from libtsm.

Aetf avatar Aetf commented on August 17, 2024

I currently have few spare time to investigate this. Pull requests are welcomed.

from libtsm.

refi64 avatar refi64 commented on August 17, 2024

Hmm, looks like the problem is basically with mk_wcwidth: the library is old, and the Unicode standards it's based on haven't been updated in years. Therefore, is basically thinks that most characters added after 2007 (including emoji) are only 1 column wide, which screws up all the calculations.

Out of curiosity: is there a reason libtsm doesn't just use POSIX's wcwidth? For all practical purposes, on Unix platforms, it's usually UTF-32/UCS4 anyway. There's also a wcwidth implementation that Termux uses...

from libtsm.

Aetf avatar Aetf commented on August 17, 2024

It's on the original author's to-do list for a while...

Anyway, I tried the wcwidth implementation from Termux, which seems to be the most up to date one in C (usually POSIX's wcwidth in libc is several Unicode standards behind).
Now the emoji is displayed full width, but breaking line width calculation in fish. But xonsh is working fine now...

output

I pushed the code to wcwidth branch, if you want to play with it.

from libtsm.

refi64 avatar refi64 commented on August 17, 2024

@Aetf I believe this is this Fish bug, as I can reproduce it in Sakura and URxvt, too.

One of the comments seems to suggest that this happens when the terminal emulator's wcwidth disagrees with Fish's. In this case, Fish thinks the emoji is width 1, but now libtsm is (correctly) seeing it as width 2, which breaks everything.

Maybe there could be a runtime setting for this? Some kind of global function (tsm_set_internal_wcwidth?) that sets whether or not to globally use the internal wcwidth or the system one. That way, when on shells like Fish that glitch out, you could override the setting.

from libtsm.

Aetf avatar Aetf commented on August 17, 2024

Yeah, I saw that bug a while ago when I was messing around with emojis in Konsole.

Having a switch for wcwidth isn't going to help here, as fish also uses its internal copy of wcwidth, unless otherwise compiled.

Another way is to force fish emoji width to 2 using set fish_emoji_width 2. I tried that with gtktsm (using updated wcwidth), and it works, at least the cursor position is correct.

Does the wcwidth branch fixes the original problem you posted? If so I'm going to merge that.

from libtsm.

refi64 avatar refi64 commented on August 17, 2024

Yup, it fixes the original issue. I guess Xonsh works now since Python probably has its own wcwidth.

from libtsm.

Aetf avatar Aetf commented on August 17, 2024

Xonsh works with new wcwidth. I've tried that. Fix merged in #8

from libtsm.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.