Skip to content

Make it more clear which line in snippets is the current, even without colors #273

@RedBeard0531

Description

@RedBeard0531

Consider the output from https://godbolt.org/z/bfj789dbf:

Stack trace (most recent call first):
#0 0x000060e80ede8a4e in void recurse<0>() requires (0)<=(0)
                      at /app/example.cpp:19:16
      17:         //.addresses(addrs::object)
      18:         .colors(colors::always)
      19:         .print(cpptrace::generate_trace());
      20: }
      21: template <int i>
#1 0x000060e80ede89d8 in void recurse<1>() requires (((1)>(0)))&&(((1)%(2))==(1))
                      at /app/example.cpp:23:5
      21: template <int i>
      22: void recurse() requires (i > 0 && (i % 2) == 1) {
      23:     recurse<i-1>();
      24: }
      25: template <int i>
#2 (inlined)          in void recurse<2>()
                      at /app/example.cpp:27:5
      25: template <int i>
      26: [[clang::always_inline]] void recurse() {
      27:     recurse<i-1>();
      28: }

Without colors, it is hard to see which line is current in each frame. I think backward-cpp does a pretty good job here:
backward image

Not only does it make the whole line rather than just the line number colored, it also puts a > indicator which both draws the eye, and works without colors. (I wouldn't bother with the separate colors and | for inlined functions.)

Also, since you have column info, it might also be nice to put a ^ under the interesting char, at least if it isn't the first non-whitespace character on the line. It is perhaps tricky if the code has tabs and/or non-ascii codepoints, but the simple thing may be good enough and still useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions