22#ifndef UNDOSTUDIO_UNDOAPP_STOUTPUTFILTER_HPP
23#define UNDOSTUDIO_UNDOAPP_STOUTPUTFILTER_HPP
38 std::string lower = text;
39 for (
char& c : lower) {
40 c =
static_cast<char>(std::tolower(
static_cast<unsigned char>(c)));
46inline bool startsWith(
const std::string& text,
const std::string& prefix)
48 return text.size() >= prefix.size() && text.compare(0, prefix.size(), prefix) == 0;
110 std::vector<OutputLine>
visible(
const std::vector<OutputLine>& lines)
const
112 std::vector<OutputLine> kept;
113 kept.reserve(lines.size());
115 if (
passes(line.severity)) {
116 kept.push_back(line);
131 if (line.severity == severity) {
145inline std::vector<OutputLine>
searchOutput(
const std::vector<OutputLine>& lines,
const std::string& needle)
147 if (needle.empty()) {
150 std::vector<OutputLine> found;
152 if (line.text.find(needle) != std::string::npos) {
153 found.push_back(line);
172 for (
size_t i = 0; i < line.size(); ++i) {
173 if (!std::isdigit(
static_cast<unsigned char>(line[i]))) {
177 while (after < line.size() && std::isdigit(
static_cast<unsigned char>(line[after]))) {
181 while (word < line.size() && line[word] ==
' ') {
214 for (
const char* marker : {
": error",
": warning",
"error:",
"warning:"}) {
215 if (lower.find(marker) != std::string::npos) {
std::string toLowerText(const std::string &text)
A lower-case copy, for matching words without caring about their case.
Definition undoAppSTOutput.hpp:36
bool startsWith(const std::string &text, const std::string &prefix)
Whether a string begins with a prefix.
Definition undoAppSTOutput.hpp:46
std::vector< OutputLine > searchOutput(const std::vector< OutputLine > &lines, const std::string &needle)
The lines matching a substring, for the panel's search box.
Definition undoAppSTOutput.hpp:145
OutSeverity
Severity of a line in the Output panel.
Definition undoAppSTOutput.hpp:57
@ Warning
Reported by the analyzer but not blocking.
@ Info
Debug/detail output, and the generated ST dump.
@ Success
Confirmation that a step succeeded.
@ Error
Blocks code generation.
OutSeverity classifyCompilerLine(const std::string &line)
How a line the transpiler printed should be coloured in the panel.
Definition undoAppSTOutput.hpp:205
bool isCountSummary(const std::string &line)
Whether a line from the transpiler is a tally rather than a diagnostic.
Definition undoAppSTOutput.hpp:170
Definition undoAppCpp.hpp:26
Which severities the Output panel shows.
Definition undoAppSTOutput.hpp:85
bool showInfo
Definition undoAppSTOutput.hpp:89
bool showWarnings
Definition undoAppSTOutput.hpp:87
static size_t count(const std::vector< OutputLine > &lines, OutSeverity severity)
How many lines of a severity the list holds, filtered or not.
Definition undoAppSTOutput.hpp:127
std::vector< OutputLine > visible(const std::vector< OutputLine > &lines) const
The lines to draw, in the order they were added.
Definition undoAppSTOutput.hpp:110
bool showSuccess
Definition undoAppSTOutput.hpp:88
bool showErrors
Definition undoAppSTOutput.hpp:86
bool passes(OutSeverity severity) const
Whether a line of this severity is shown.
Definition undoAppSTOutput.hpp:92
One tagged line in the Output panel.
Definition undoAppSTOutput.hpp:71
std::string text
Definition undoAppSTOutput.hpp:73
OutSeverity severity
Definition undoAppSTOutput.hpp:72