Make ConsoleChannel the canonical semantic classification of every console
line. Producers (command executor, app log forwarders, result formatter) tag
each line with a channel; the UI derives both the text color and the left
accent-bar color from it at draw time, and the output filter keys off it.
This replaces the prior scheme of storing an ImU32 color per line and then
reverse-engineering the source from color-equality plus a "[daemon] "/"[xmrig] "
/"[app] "/"[rpc] " text prefix. Consequences:
- ConsoleLine now stores {text, ConsoleChannel} — no per-line color.
- addLine()/addRpcTraceLine() take a channel; the redundant text prefixes are
gone (the accent bar carries the origin).
- The executor's ConsoleAddLineFn hands a channel, not an ImU32, so the backend
no longer depends on ConsoleTab::COLOR_* — FullNode/Lite executors emit clean
text + channel.
- The theme-remap loop that rewrote stored colors on light/dark flip is deleted;
colors are resolved per-channel each frame (refreshColors on flip only).
- ConsoleOutputFilter drops its color fields; consoleLinePassesFilter() keys off
the channel. Test updated to the channel-based API.
- Added a Warning channel (amber severity peer of Error/Success) so the
notification + logger warning forwarders keep their color.
Full-node + lite build clean; ctest green; source hygiene clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#include "console_output_model.h"
|
|
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
|
|
namespace dragonx {
|
|
namespace ui {
|
|
|
|
namespace {
|
|
std::string lowerCopy(std::string value)
|
|
{
|
|
std::transform(value.begin(), value.end(), value.begin(),
|
|
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
|
return value;
|
|
}
|
|
}
|
|
|
|
bool consoleLinePassesFilter(const std::string& lineText,
|
|
ConsoleChannel channel,
|
|
const ConsoleOutputFilter& filter)
|
|
{
|
|
if (!filter.daemonMessagesEnabled &&
|
|
(channel == ConsoleChannel::Daemon || channel == ConsoleChannel::Xmrig)) return false;
|
|
if (!filter.rpcTraceEnabled && channel == ConsoleChannel::Rpc) return false;
|
|
if (!filter.appMessagesEnabled && channel == ConsoleChannel::App) return false;
|
|
if (filter.errorsOnly && channel != ConsoleChannel::Error) return false;
|
|
if (!filter.text.empty()) {
|
|
std::string needle = lowerCopy(filter.text);
|
|
std::string haystack = lowerCopy(lineText);
|
|
if (haystack.find(needle) == std::string::npos) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace ui
|
|
} // namespace dragonx
|