Skip to content

Commit cd9090d

Browse files
authored
Merge pull request BalazsJako#32 from pthom/boost_regex_private
Make Boost regex a private dependency
2 parents 8927d95 + 7395b5d commit cd9090d

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

ImGuiDebugPanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void TextEditor::ImGuiDebugPanel(const std::string& panelName)
1919
{
2020
for (int i = 0; i < mLines.size(); i++)
2121
{
22-
ImGui::Text("%d", mLines[i].size());
22+
ImGui::Text("%zu", mLines[i].size());
2323
}
2424
}
2525
if (ImGui::CollapsingHeader("Undo"))

TextEditor.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <algorithm>
22
#include <string>
33
#include <set>
4+
#include <boost/regex.hpp>
45

56
#include "TextEditor.h"
67

@@ -9,10 +10,17 @@
910
#define IMGUI_DEFINE_MATH_OPERATORS
1011
#include "imgui.h" // for imGui::GetCurrentWindow()
1112

13+
14+
struct TextEditor::RegexList {
15+
std::vector<std::pair<boost::regex, TextEditor::PaletteIndex>> mValue;
16+
};
17+
18+
1219
// --------------------------------------- //
1320
// ------------- Exposed API ------------- //
1421

1522
TextEditor::TextEditor()
23+
: mRegexList(std::make_shared<RegexList>())
1624
{
1725
SetPalette(defaultPalette);
1826
mLines.push_back(Line());
@@ -90,9 +98,9 @@ void TextEditor::SetLanguageDefinition(LanguageDefinitionId aValue)
9098
break;
9199
}
92100

93-
mRegexList.clear();
101+
mRegexList->mValue.clear();
94102
for (const auto& r : mLanguageDefinition->mTokenRegexStrings)
95-
mRegexList.push_back(std::make_pair(boost::regex(r.first, boost::regex_constants::optimize), r.second));
103+
mRegexList->mValue.push_back(std::make_pair(boost::regex(r.first, boost::regex_constants::optimize), r.second));
96104

97105
Colorize();
98106
}
@@ -2241,7 +2249,7 @@ void TextEditor::Render(bool aParentIsFocused)
22412249
static char lineNumberBuffer[16];
22422250
if (mShowLineNumbers)
22432251
{
2244-
snprintf(lineNumberBuffer, 16, " %d ", mLines.size());
2252+
snprintf(lineNumberBuffer, 16, " %zu ", mLines.size());
22452253
mTextStart += ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, -1.0f, lineNumberBuffer, nullptr, nullptr).x;
22462254
}
22472255

@@ -2630,7 +2638,7 @@ void TextEditor::ColorizeRange(int aFromLine, int aToLine)
26302638
// todo : remove
26312639
//printf("using regex for %.*s\n", first + 10 < last ? 10 : int(last - first), first);
26322640

2633-
for (const auto& p : mRegexList)
2641+
for (const auto& p : mRegexList->mValue)
26342642
{
26352643
bool regexSearchResult = false;
26362644
try { regexSearchResult = boost::regex_search(first, last, results, p.first, boost::regex_constants::match_continuous); }

TextEditor.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <unordered_set>
1111
#include <unordered_map>
1212
#include <map>
13-
#include <boost/regex.hpp>
1413
#include "imgui.h"
1514

1615
class IMGUI_API TextEditor
@@ -304,7 +303,6 @@ class IMGUI_API TextEditor
304303
UndoOperationType mType;
305304
};
306305

307-
typedef std::vector<std::pair<boost::regex, PaletteIndex>> RegexList;
308306

309307
class UndoRecord
310308
{
@@ -456,7 +454,6 @@ class IMGUI_API TextEditor
456454
Palette mPalette;
457455
LanguageDefinitionId mLanguageDefinitionId;
458456
const LanguageDefinition* mLanguageDefinition = nullptr;
459-
RegexList mRegexList;
460457

461458
inline bool IsHorizontalScrollbarVisible() const { return mCurrentSpaceWidth > mContentWidth; }
462459
inline bool IsVerticalScrollbarVisible() const { return mCurrentSpaceHeight > mContentHeight; }
@@ -469,4 +466,8 @@ class IMGUI_API TextEditor
469466
static const std::unordered_map<char, char> OPEN_TO_CLOSE_CHAR;
470467
static const std::unordered_map<char, char> CLOSE_TO_OPEN_CHAR;
471468
static PaletteId defaultPalette;
469+
470+
private:
471+
struct RegexList;
472+
std::shared_ptr<RegexList> mRegexList;
472473
};

0 commit comments

Comments
 (0)