-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update to work with text >= 2.0.1 #16
Conversation
src/SDL/Font.hs
Outdated
@@ -244,14 +244,14 @@ blended (Font font) (V4 r g b a) text = | |||
|
|||
-- Analogous to Data.Text.Foreign.useAsPtr, just appends a null-byte. | |||
-- FIXME: Is this even necessary? | |||
withText :: Text -> (Ptr Word16 -> IO a) -> IO a | |||
withText :: Text -> (Ptr Word8 -> IO a) -> IO a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be CString
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the tips. Do you think we could just use Data.Text.Foreign.useAsPtr
or something similar instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a similar issue with text-2 in dear-imgui
. But I know from the code I need to append NUL in a few places here and there.
We need Data.Text.Foreign.useAsCString
and there's haskell/text#254 already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haskell/text#431 - it's on the books now.
Would it be reasonable to request text <2 || >= 2.1
and don't ship an own copy? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Yes, procrastination works. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's reasonable to request text <2 || >= 2.1. I will do that myself. In dear-imgui
, would that permit to change the condition in https://github.com/haskell-game/dear-imgui.hs/blob/main/src/DearImGui/Internal/Text.hs#L29-L50 to MIN_VERSION_text(2,0,1)
and the first branch of the conditional to withCString = Data.Text.Foreign.withCString
and then the second branch stays untouched?
src/SDL/Font.hs
Outdated
withText text act = | ||
allocaBytes len $ \ptr -> do | ||
unsafeCopyToPtr text ptr | ||
pokeByteOff ptr (len - 2) (0 :: CUShort) | ||
pokeByteOff ptr (len - 2) (0 :: CChar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len - 1
Also, you need to switch from |
5dd66ac
to
09c6889
Compare
Good catch. Actually cbits are fine, because they already include UTF8 as well. |
… GHC 9.4.*" This reverts commit d42d654. We don't depend on text 2.1 in the end, 2.0.1 is enough and, while not included in GHC 9.4 RC1, 2.0.1 can be taken from Hackage just fine, to satisfy the constraint in .cabal.
No reviews with change requests, so I'm merging, :) |
This updates the package to compile with text-2.0, but with HEAD ghc-9.3.20220316 my test program (LambdaHack) segfaults, so I wasn't able to verify if it also works. If you do verify, please let me know.
Edit: of course this needs to be CPPd vs text-2.0.