=?utf-8?q?José?= L. Junior <[email protected]>,taalhaataahir0102
<[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) {
return bytes_written;
}
+void Stream::PutCStringColorHighlighted(llvm::StringRef text,
+ const char *pattern) {
+ if (!pattern) {
+ PutCString(text);
+ return;
+ }
+
+ // If pattern is not nullptr, we should use color
+ llvm::Regex reg_pattern(pattern);
+ llvm::SmallVector<llvm::StringRef, 1> matches;
+ llvm::StringRef remaining = text;
+ std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes(
+ "${ansi.fg.red}%s${ansi.normal}");
+ while (reg_pattern.match(remaining, &matches)) {
+ llvm::StringRef match = matches[0];
+ size_t match_start_pos = match.data() - remaining.data();
+ Write(remaining.data(), match_start_pos);
----------------
DavidSpickett wrote:
Here you could say:
```
PutCString(remaining.take_front(match_start_pos);
```
Just so that you're always using `PutCString`, intead of 1 `Write` and 1
`PutCString`.
https://github.com/llvm/llvm-project/pull/69422
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits