mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-26 16:05:45 +03:00
(Internal) ImGuiTextFilter: renaming ImGuiTextRange->ImGuiTextFilterItem, Filters->Items. (#2435)
This commit is contained in:
parent
a14bebd948
commit
fc98dc4a72
2 changed files with 21 additions and 21 deletions
26
imgui.cpp
26
imgui.cpp
|
|
@ -3094,7 +3094,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|||
ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) //-V1077
|
||||
{
|
||||
InputBuf[0] = 0;
|
||||
CountInclude = 0;
|
||||
_CountInclude = 0;
|
||||
if (default_filter)
|
||||
{
|
||||
ImStrncpy(InputBuf, default_filter, IM_COUNTOF(InputBuf));
|
||||
|
|
@ -3116,7 +3116,7 @@ bool ImGuiTextFilter::DrawWithHint(const char* label, const char* hint)
|
|||
return value_changed;
|
||||
}
|
||||
|
||||
static void ImStrSplit(const char* b, const char* e, char separator, ImVector<ImGuiTextFilter::ImGuiTextRange>* out)
|
||||
static void ImStrSplit(const char* b, const char* e, char separator, ImVector<ImGuiTextFilter::ImGuiTextFilterItem>* out)
|
||||
{
|
||||
out->resize(0);
|
||||
const char* wb = b;
|
||||
|
|
@ -3125,23 +3125,23 @@ static void ImStrSplit(const char* b, const char* e, char separator, ImVector<Im
|
|||
{
|
||||
if (*we == separator)
|
||||
{
|
||||
out->push_back(ImGuiTextFilter::ImGuiTextRange(wb, we));
|
||||
out->push_back(ImGuiTextFilter::ImGuiTextFilterItem(wb, we));
|
||||
wb = we + 1;
|
||||
}
|
||||
we++;
|
||||
}
|
||||
if (wb != we)
|
||||
out->push_back(ImGuiTextFilter::ImGuiTextRange(wb, we));
|
||||
out->push_back(ImGuiTextFilter::ImGuiTextFilterItem(wb, we));
|
||||
}
|
||||
|
||||
void ImGuiTextFilter::Build()
|
||||
{
|
||||
Filters.resize(0);
|
||||
ImGuiTextRange input_range(InputBuf, InputBuf + ImStrlen(InputBuf));
|
||||
ImStrSplit(InputBuf, InputBuf + ImStrlen(InputBuf), ',', &Filters);
|
||||
_Items.resize(0);
|
||||
ImGuiTextFilterItem input_range(InputBuf, InputBuf + ImStrlen(InputBuf));
|
||||
ImStrSplit(InputBuf, InputBuf + ImStrlen(InputBuf), ',', &_Items);
|
||||
|
||||
CountInclude = 0;
|
||||
for (ImGuiTextRange& f : Filters)
|
||||
_CountInclude = 0;
|
||||
for (ImGuiTextFilterItem& f : _Items)
|
||||
{
|
||||
while (f.Begin < f.End && ImCharIsBlankA(f.Begin[0]))
|
||||
f.Begin++;
|
||||
|
|
@ -3150,19 +3150,19 @@ void ImGuiTextFilter::Build()
|
|||
if (f.Begin == f.End)
|
||||
continue;
|
||||
if (f.Begin[0] != '-')
|
||||
CountInclude += 1;
|
||||
_CountInclude += 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
||||
{
|
||||
if (Filters.Size == 0)
|
||||
if (_Items.Size == 0)
|
||||
return true;
|
||||
|
||||
if (text == NULL)
|
||||
text = text_end = "";
|
||||
|
||||
for (const ImGuiTextRange& f : Filters)
|
||||
for (const ImGuiTextFilterItem& f : _Items)
|
||||
{
|
||||
if (f.Begin == f.End)
|
||||
continue;
|
||||
|
|
@ -3181,7 +3181,7 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
|||
}
|
||||
|
||||
// Implicit * grep
|
||||
if (CountInclude == 0)
|
||||
if (_CountInclude == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
|||
16
imgui.h
16
imgui.h
|
|
@ -2792,7 +2792,7 @@ struct ImGuiTextFilter
|
|||
IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const;
|
||||
IMGUI_API void Build(); // Update internal data when filter changes
|
||||
inline void Clear() { InputBuf[0] = 0; Build(); } // Clear filter
|
||||
inline bool IsActive() const { return Filters.Size != 0; } // Useful if you need e.g. an alternative code-path when there are no filters
|
||||
inline bool IsActive() const { return _Items.Size != 0; } // Useful if you need e.g. an alternative code-path when there are no filters
|
||||
|
||||
// Helper to call InputText() + Build() when buffer is changed.
|
||||
IMGUI_API bool Draw(const char* label = "Filter");
|
||||
|
|
@ -2802,17 +2802,17 @@ struct ImGuiTextFilter
|
|||
#endif
|
||||
|
||||
// [Internal] Don't use! Will be replaced with ImStrv.
|
||||
struct ImGuiTextRange
|
||||
struct ImGuiTextFilterItem
|
||||
{
|
||||
const char* Begin;
|
||||
const char* End;
|
||||
ImGuiTextRange(const char* b, const char* e) { Begin = b; End = e; }
|
||||
const char* Begin;
|
||||
const char* End;
|
||||
ImGuiTextFilterItem(const char* b, const char* e) { Begin = b; End = e; }
|
||||
};
|
||||
|
||||
// [Internal] Members
|
||||
char InputBuf[256];
|
||||
ImVector<ImGuiTextRange>Filters;
|
||||
int CountInclude;
|
||||
char InputBuf[256]; // User input buffer
|
||||
int _CountInclude; // >= 0
|
||||
ImVector<ImGuiTextFilterItem> _Items; // Pre-parsed, trimmed items
|
||||
};
|
||||
|
||||
// Helper: Growable text buffer for logging/accumulating text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue