New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shifting characters #515
Comments
@rivo here you've said:
Shouldn't the last character be at position 4? |
This line in the code above puts the dollar sign in position screen.SetContent(2, 1, str[3], nil, tcell.StyleDefault) // Third character (dollar sign). But as you can see in the screenshot, it appears in position |
Terminals can do unwanted things when you try to overlap wide and narrow characters. It's poor form really to even attempt this. Tcell issues the request, but because of the way we draw, we might wind up thinking that the characters are adjacent or not depending on the flow. And what happens when you issue those characters in a single stream (without a position reset first) is likely what you see. One thing we can explore in tcell is to detect this case and reset the position in the case of an attempt to overlap. This probably has a better (but not guaranteed) chance of working reasonably (overlapping characters). But really, its kind of an error on the part of the caller to expect anything reasonable when using overlapping characters like this. Unicode (and emoticons especially) make this a lot messier because there isn't yet universal agreement about how many cells such characters should occupy, and it can often depend on the specific font being used for display. |
The other thing is that whatever we do we are going to be very dependent on the width of the glyph on screen matching what we think (per the runewidth library) the width should be. Discrepancies are not entirely uncommon here, but there isn't really anything I can do about it. |
Yeah, I guessed so. The problem is, currently, the I guess you can close this issue then. I'll follow up on the |
It looks like some Unicode characters will cause the output to shift. Below is an example program that writes three characters in the first three positions (0, 1, and 2) but the last character (a normal dollar sign) is actually output in position 3 instead of 2.
I don't know if this is an actual error on
tcell
's end because when I output the same string to the console, the first character will actually occupy two cells instead of one, so I'm actually forcingtcell
to do something that's probably not right. Still, I would expect a character to be put in a specific position to be output at that position. Maybe you can comment.(This is macOS with iTerm2.)
The text was updated successfully, but these errors were encountered: