Skip to content

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

Closed
wants to merge 30 commits into from
Closed

Imstr #683

wants to merge 30 commits into from

Conversation

bitshifter
Copy link

Tracking PR for issue #494.

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!
@krux02
Copy link

krux02 commented Aug 19, 2016

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.

@MrSapps
Copy link

MrSapps commented Aug 20, 2016

You'd just need to update the binding to also pass the string length instead of just a pointer to a string

@bitshifter
Copy link
Author

@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.

@krux02
Copy link

krux02 commented Dec 12, 2017

An idea to not create breaking changes is to make ImStr just an alias of const char* by default. Only when use the ImStr struct when preprocessor flag is set.

#ifdef USE_IM_STR_STRUCT
struct ImStr
[...]
#else
using ImStr = const char*;
#endif

@ocornut
Copy link
Owner

ocornut commented Feb 24, 2020

FYI @rokups has revived this PR as #3038.

@ocornut
Copy link
Owner

ocornut commented Nov 30, 2020

Closing as moved to #3038

@ocornut ocornut closed this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants