-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Imstr #683
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
Imstr #683
Conversation
Initial experimental support for API that doesn't require null terminated strings. It compiles but there are bugs, and there's still some char* buffers to deal with.
There are some function signatures which have changed which still work with the old parameters. Might need to keep the old versions around to avoid unexpected issues.
Some user code may be relying on these being around, so keep them for now.
The strlen is now calculated on demand with CalculateEnd() instead of implicitly in the ImStr constructors.
The slice and char* of the same string containing '###' was generating a different hash.
Plots and Menu shortcuts.
String slices can't be used as printf format strings as they aren't null terminated, so for now no formatting functionality is provided for the ImStr text widgets. In the case of FFI it is expected that strings will already be formatted when they're passed to ImGui.
Fixes to cimgui C API builds without modification, to preserve compatibilty with existing API. I haven't tested any of these new code paths yet!
As much as I like the idea, it has has the problem that it breaks all wrapper code for imgui, and I am considering to write a wrapper right now at this moment. |
You'd just need to update the binding to also pass the string length instead of just a pointer to a string |
@krux02 The main motivation for this change was for calling dear imgui from Rust (as Rust strings are not null-terminated). As part of this work I have also branched cimgui (a C imgui wrapper) to support these changes at https://github.com/bitshifter/cimgui/tree/imstr. |
An idea to not create breaking changes is to make #ifdef USE_IM_STR_STRUCT
struct ImStr
[...]
#else
using ImStr = const char*;
#endif |
Closing as moved to #3038 |
Tracking PR for issue #494.