|
1 | 1 | #include <algorithm> |
2 | 2 | #include <string> |
3 | 3 | #include <set> |
| 4 | +#include <boost/regex.hpp> |
4 | 5 |
|
5 | 6 | #include "TextEditor.h" |
6 | 7 |
|
|
9 | 10 | #define IMGUI_DEFINE_MATH_OPERATORS |
10 | 11 | #include "imgui.h" // for imGui::GetCurrentWindow() |
11 | 12 |
|
| 13 | + |
| 14 | +struct TextEditor::RegexList { |
| 15 | + std::vector<std::pair<boost::regex, TextEditor::PaletteIndex>> mValue; |
| 16 | +}; |
| 17 | + |
| 18 | + |
12 | 19 | // --------------------------------------- // |
13 | 20 | // ------------- Exposed API ------------- // |
14 | 21 |
|
15 | 22 | TextEditor::TextEditor() |
| 23 | + : mRegexList(std::make_shared<RegexList>()) |
16 | 24 | { |
17 | 25 | SetPalette(defaultPalette); |
18 | 26 | mLines.push_back(Line()); |
@@ -90,9 +98,9 @@ void TextEditor::SetLanguageDefinition(LanguageDefinitionId aValue) |
90 | 98 | break; |
91 | 99 | } |
92 | 100 |
|
93 | | - mRegexList.clear(); |
| 101 | + mRegexList->mValue.clear(); |
94 | 102 | 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)); |
96 | 104 |
|
97 | 105 | Colorize(); |
98 | 106 | } |
@@ -2630,7 +2638,7 @@ void TextEditor::ColorizeRange(int aFromLine, int aToLine) |
2630 | 2638 | // todo : remove |
2631 | 2639 | //printf("using regex for %.*s\n", first + 10 < last ? 10 : int(last - first), first); |
2632 | 2640 |
|
2633 | | - for (const auto& p : mRegexList) |
| 2641 | + for (const auto& p : mRegexList->mValue) |
2634 | 2642 | { |
2635 | 2643 | bool regexSearchResult = false; |
2636 | 2644 | try { regexSearchResult = boost::regex_search(first, last, results, p.first, boost::regex_constants::match_continuous); } |
|
0 commit comments