Created
February 7, 2020 16:50
-
-
Save jkrumbiegel/e69f832d0ec0c0bdd1af9e587ad74750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using PrettyTables | |
st = try | |
pretty_table(1) | |
catch e | |
stacktrace(catch_backtrace()) | |
end | |
getmodule(frame) = try; string(frame.linfo.def.module) catch; "" end | |
function maxlastn(str, n; ellipsis = "\u2026") | |
length(str) < (n - 1) ? str : ellipsis * chop(str, head = length(str)-n+1, tail = 0) | |
end | |
function expandbasepath(str) | |
if !isnothing(match(r"^\./\w+\.jl$", str)) | |
sourcestring = Base.find_source_file(str[3:end]) # cut off ./ | |
replace(sourcestring, raw"\\" => '/') | |
else | |
str | |
end | |
end | |
rows = [ | |
( | |
i = i, | |
func = s.func, | |
modul = getmodule(s), | |
location = (string(s.file) |> | |
x->replace(x, homedir() => "~") |> | |
x->replace(x, lowercasefirst(homedir()) => "~") |> | |
x -> replace(x, raw"\\" => '/') |> | |
expandbasepath) * | |
":$(s.line)" | |
# x -> maxlastn(x, 60), | |
) | |
for (i, s) in enumerate(st) | |
]; | |
unimods = setdiff(unique(getmodule.(st)), ["Base", ""]) | |
modhighlighter_funcs = [ | |
(data, i, j) -> begin | |
(j == 3 && data[i, j] == mo) | |
end | |
for mo in unimods | |
] | |
highlighters = tuple((Highlighter(f, foreground = color) | |
for (f, color) in Iterators.zip(modhighlighter_funcs, [:red, :blue, :green, :yellow]))...); | |
filelowlighter = Highlighter((d, i, j) -> j == 4, foreground = :dark_gray) | |
pretty_table(rows, | |
alignment = :l, | |
columns_width = [2, 0, 0, 0], | |
# linebreaks = true, | |
# autowrap = true, | |
nosubheader = true, | |
highlighters = (highlighters..., filelowlighter), | |
crop = :none, | |
tf = borderless | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment