santaclose / ImGuiColorTextEdit

Colorizing text editor for ImGui
MIT License
67 stars 18 forks source link

Easy way to make boost::regex Optional #13

Open goossens opened 1 year ago

goossens commented 1 year ago

In issue #6, there was a discussion on making the use of the boost::regex library optional. I have two project where I’m using ImGuiColorTextEdit. In the first one, I’m using regex-based syntax highlighting and using boost is not an issue. I’m doing another project with someone who is very allergic to anything boost and we’re not using regex based syntax coloring.

To support both scenarios, we changed one line in TextEditor.h to six lines and now everybody can be happy.

Change:

#include <boost/regex.hpp>

to:

#ifdef IMGUI_EDITOR_NO_BOOST
    #include <regex>
    namespace boost = std;
#else
    #include <boost/regex.hpp>
#endif

Those that want to use boost don’t have to do anything. Those that are allergic to boost or don’t care for another dependency, can define IMGUI_EDITOR_NO_BOOST in their Makefile or whatever IDE that are using.

You can see my implementation at https://github.com/goossens/ImGuiColorTextEdit/commit/956668814499b2492665f60c12f3e9c5e9d0dcfa. Let me know if you want a pull request.

santaclose commented 1 year ago

I switched to boost because Microsoft STL was crashing. I understand being allergic to boost. but this is just a header file, not boost fatness. What exactly would be the benefit of not using boost regex?

sphaero commented 1 year ago

I agree to this issue. Not having dependencies is always best. Any reference to the issue with MS std::regex?

goossens commented 1 year ago

What exactly would be the benefit of not using boost regex?

As I mentioned in issue #11, you are on your way to become the "goto" fork of this library. You are putting a lot of effort into this and the fact that you have made it open source, tells me you want as many people as possible to use your work. This is why I believe that "maximum reuse" is a key design characteristic.

When people look at things to reuse, they all have their criteria but certain things keep popping up. Not having extra dependencies (as also pointed out by @sphere above) is always a strong selling point. Some people frown upon extra dependencies and you might scare them away. The same is true for Boost. Some people see or hear the word and they run in a different direction even if in this case, the integration is not too difficult.

Also think of the following examples:

With 5 more lines in the include file that don't affect you, you please more people and therefore improve the library's reusability. Just some friendly advice.

jsandham commented 1 year ago

I highly agree with what @goossens has said. Just to add one more point, requiring boost (in any amount) is I think a divergence in philosophy set out by the original Dear imgui (minimal dependences). Of course you do not have to follow this, but I think it was a major selling feature of that library and it is really nice when extensions to that library follow suit. Using std is one thing, but requiring boost I think for many is a bridge too far.