enkisoftware / imgui_markdown

Markdown for Dear ImGui
zlib License
1.03k stars 69 forks source link

no userdata for the callback? #2

Closed ratchetfreak closed 5 years ago

ratchetfreak commented 5 years ago

I don't see an option to set a void* userdata pointer for the link callback. This forces use of globals some projects will not accept.

dougbinks commented 5 years ago

Having had a look at ImGui's callbacks I think we will move to the callback data being a struct containing the current link data along with a UserData member similar to https://github.com/ocornut/imgui/blob/master/imgui.h#L1445-L1453

ocornut commented 5 years ago

Note that, this data could also perfectly be returned by Markdown(), aka output/state could be written into a structure without involving a callback at all.

I don’t have a preference. It is easier with the callback to not have to worry about the scope/lifetime of the pointed char*. Just pointing out that possibility.

(As an aside, I think the api there (for markdownconfig etc) will probably need to evolve over time, and that is perfectly fine. I’d suggest it would be better to break api than trying to awkwardly stick to 1.0 api. People will probably wrap this up either way. Maybe just embed a Changelog inside imgui_markdown.h when that happens.)

Great job!

ratchetfreak commented 5 years ago

the char* points to the markdown text passed in so lifetime is not really a worry.

and there is no requirement to have something url-like in the parenthesis, only that it doesn't contain a closing parenthesis. So applications can easily use short identifier strings instead should they need to.

juliettef commented 5 years ago

We've implemented this. Because it's still early days we haven't started a change log yet.