Skip to content
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

Emoji Support? #3

Open
arnemileswinter opened this issue Dec 1, 2022 · 6 comments
Open

Emoji Support? #3

arnemileswinter opened this issue Dec 1, 2022 · 6 comments

Comments

@arnemileswinter
Copy link

Hello, it's me again :)

Sorry again for confusing your API last time, cool new Repository layout however!

I was testing Emoji support, because i wanted to build a Tui-enabled version of my other project: https://github.com/arnemileswinter/jungle-chess

However, using, for example, '⭕' for a termbox cell resulted in this cell being empty - also my bg color property is ignored, the cell just turns invisible. Classic ascii works.
I've used TB.cell ... (TB.Char ...) for this.

I didn't open the issue on the mother-project because i didn't get to test it on frontends other than haskell yet.

Thanks in advance!

@mitchellwrosen
Copy link
Member

mitchellwrosen commented Dec 1, 2022

Hello User! :) I was hoping you would turn up some time, but I archived the old repo and could not comment again on mitchellwrosen/termbox-banana#3

I believe the behavior you are seeing is documented on Cell:

If the character is not 1 character wide, it will not be displayed.

We just call wcwidth from <wchar.h> on the given character, and if it's not 1, we throw that input away (rather than throw an error, or something).

The rationale for this was essentially just to simplify the model of a scene, which is a 2d grid of 1x1 cells. It's much easier to make a function that "draws a string" in user-space by getting the column arguments from zip [col..], e.g.:

string :: Int -> [Char] -> Termbox.Scene
string row cs =
  let f (col, c) = Termbox.cell Termbox.Pos{row,col} (Termbox.char c)
  in foldMap f (zip [0..] cs)

That said, it'd probably be better to replace wide characters with ' ' so that at least setting their background works, and perhaps it'd be better still to go back on that decision; certainly a "power-user" trying to draw wide characters ought to be able to, no? :)

@arnemileswinter
Copy link
Author

Thanks for the explanation!

Ah, character width issue makes sense. I just tried with more classic symbols:

image

works like a charm.

ty!

@mitchellwrosen
Copy link
Member

Oh, sweet! I think I'll reopen this issue just to mull over whether we should actually support wide characters after all. I'm leaning towards yes.

@mitchellwrosen mitchellwrosen reopened this Dec 1, 2022
@mitchellwrosen
Copy link
Member

(Is that yellow thing in the bottom right of your screenshot intentional?)

@arnemileswinter
Copy link
Author

It's the keyboard controlled cursor :)

@mitchellwrosen
Copy link
Member

I've begun work on termbox2 bindings, which support emojis out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants