Comments (9)
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.
Just tried, and I can't reproduce it in fish either.
Xonsh is another shell where this problem comes up.
from libtsm.
I currently have few spare time to investigate this. Pull requests are welcomed.
from libtsm.
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.
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...
I pushed the code to wcwidth
branch, if you want to play with it.
from libtsm.
@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.
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.
Yup, it fixes the original issue. I guess Xonsh works now since Python probably has its own wcwidth.
from libtsm.
Xonsh works with new wcwidth. I've tried that. Fix merged in #8
from libtsm.
Related Issues (16)
- libtsm fails to build with musl libc on Alpine Linux HOT 2
- Folder names in releases not in PV form HOT 5
- Generate doxygen documentation
- Doesn't build with recent harfbuzz HOT 1
- Setting custom color palettes. HOT 3
- pkg-config file is broken when CMAKE_INSTALL_{INCLUDE,LIB}DIR is absolute
- Keycode for backspace
- Make it compile on Windows HOT 1
- DECRQM resets terminal HOT 2
- can't generate Makefile HOT 1
- loose parser
- CMake warning on configuration
- None also a valid CMake BUILD_TYPE
- Proposal: rename to libtsm2 or similar HOT 1
- Don't hardcode color palettes, make them comfigurable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libtsm.