[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 4 09:56:17 PST 2023


=?utf-8?q?José?= L. Junior <josejunior at 10xengineers.ai>,taalhaataahir0102
 <23100293 at lums.edu.pk>,taalhaataahir0102 <23100293 at lums.edu.pk>,taalhaataahir0102
 <23100293 at lums.edu.pk>,taalhaataahir0102 <23100293 at lums.edu.pk>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/69422 at github.com>


================
@@ -70,6 +72,31 @@ 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}");
----------------
JDevlieghere wrote:

Most (all?) other colors are configurable. I think this one should be too. Some examples of this are the `show-autosuggestion-ansi-prefix` and `show-progress-ansi-prefix`. This pattern should work here as well. 

https://github.com/llvm/llvm-project/pull/69422


More information about the lldb-commits mailing list