Console text filtering and match highlighting lowercased a full copy of every line, and of every drawn segment, on each pass. - A new alloc-free ASCII case-insensitive substring search folds both sides on the fly, so neither the filter test nor the highlight scan allocates a lowercased copy per line any more. - Both call sites use it; the case-insensitive match behaviour is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.8 KiB
C++
40 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "console_channel.h"
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dragonx {
|
|
namespace ui {
|
|
|
|
struct ConsoleOutputFilter {
|
|
std::string text;
|
|
bool daemonMessagesEnabled = true; // Daemon + Xmrig (node log) channels
|
|
bool errorsOnly = false; // keep only the Error channel
|
|
bool rpcTraceEnabled = false; // Rpc channel
|
|
bool appMessagesEnabled = true; // App channel
|
|
};
|
|
|
|
// Alloc-free ASCII case-insensitive substring search (C-locale fold). Returns the byte
|
|
// offset of the first match at or after `from`, or npos. Needle is folded on the fly.
|
|
size_t FindCaseInsensitive(const char* hay, size_t hayLen, const std::string& needle, size_t from);
|
|
|
|
// Whether a line with the given channel + text passes the active filter.
|
|
bool consoleLinePassesFilter(const std::string& lineText,
|
|
ConsoleChannel channel,
|
|
const ConsoleOutputFilter& filter);
|
|
|
|
// Incrementally maintain a FLAT (filtered, fold-free) visible set across model appends/evictions. `visible` holds
|
|
// ascending raw indices computed for the absolute window [oldFirst, oldEnd); the model now spans
|
|
// [newFirst, newFirst + n). Drops evicted indices, rebases the survivors and appends every new raw index in
|
|
// [oldEnd - newFirst, n) for which passes(i) is true. Returns false (visible untouched) when the windows do not
|
|
// chain; the caller then rescans. Only valid while the filter is unchanged (line text/channel are immutable).
|
|
bool ExtendFlatVisibleIndices(std::vector<int>& visible, std::uint64_t oldFirst, std::uint64_t oldEnd,
|
|
std::uint64_t newFirst, int n, const std::function<bool(int)>& passes);
|
|
|
|
} // namespace ui
|
|
} // namespace dragonx
|