| 711 | } |
| 712 | |
| 713 | std::vector<Highlight> CLogView::GetHighlights(const std::string& text) const |
| 714 | { |
| 715 | std::vector<Highlight> highlights; |
| 716 | |
| 717 | int highlightId = 1; |
| 718 | for (auto& filter : m_filter.messageFilters) |
| 719 | { |
| 720 | if (!filter.enable || filter.filterType != FilterType::Token) |
| 721 | continue; |
| 722 | |
| 723 | std::sregex_iterator begin(text.begin(), text.end(), filter.re), end; |
| 724 | int id = ++highlightId; |
| 725 | for (auto tok = begin; tok != end; ++tok) |
| 726 | { |
| 727 | int first = 0; |
| 728 | int count = 1; |
| 729 | if (tok->size() > 1 && filter.matchType == MatchType::RegexGroups) |
| 730 | { |
| 731 | first = 1; |
| 732 | count = tok->size(); |
| 733 | } |
| 734 | for (int i = first; i < count; ++i) |
| 735 | { |
| 736 | int beginIndex = ExpandedTabOffset(text, tok->position(i)); |
| 737 | int endIndex = ExpandedTabOffset(text, tok->position(i) + tok->length(i)); |
| 738 | |
| 739 | if (filter.bgColor == Colors::Auto) |
| 740 | { |
| 741 | auto itc = m_matchColors.find(tok->str(i)); |
| 742 | if (itc != m_matchColors.end()) |
| 743 | InsertHighlight(highlights, Highlight(id, beginIndex, endIndex, TextColor(itc->second, Colors::Text))); |
| 744 | } |
| 745 | else |
| 746 | { |
| 747 | InsertHighlight(highlights, Highlight(id, beginIndex, endIndex, TextColor(filter.bgColor, filter.fgColor))); |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | InsertHighlight(highlights, text, Str(m_highlightText), TextColor(Colors::Highlight, Colors::Text)); |
| 754 | |
| 755 | return highlights; |
| 756 | } |
| 757 | |
| 758 | void DrawHighlightedText(HDC hdc, const RECT& rect, std::wstring text, std::vector<Highlight> highlights, const Highlight& selection) |
| 759 | { |
nothing calls this directly
no test coverage detected