Skip to content

Instantly share code, notes, and snippets.

@Datseris
Last active July 25, 2018 09:58
Show Gist options
  • Save Datseris/6e680d12854d0124c467d7d09316cf59 to your computer and use it in GitHub Desktop.
Save Datseris/6e680d12854d0124c467d7d09316cf59 to your computer and use it in GitHub Desktop.
Give default Juno color in types.
import TreeViews
struct DiffEqMock end
typecolor(x) = "<span class=\"syntax--support syntax--type syntax--julia\">$(x)</span>"
TreeViews.hastreeview(::DiffEqMock) = true
function TreeViews.treelabel(io::IO, ::DiffEqMock, ::MIME"application/juno+inline")
print(io, typecolor("ODEProblem"), " with uType ", typecolor("Array{Float64, 2}"), " and tType ", typecolor("Float64"))
end
# DiffEq Also does
Base.summary(I::DEIntegrator) = string(
TYPE_COLOR, DiffEqBase.parameterless_type(I),
NO_COLOR, " with uType ",
TYPE_COLOR, typeof(I.u),
NO_COLOR, " and tType ",
TYPE_COLOR, typeof(I.t), NO_COLOR)
function Base.show(io::IO, A::DEIntegrator)
println(io,string("t: ",A.t))
print(io,"u: ")
show(io, A.u)
end
function Base.show(io::IO, m::MIME"text/plain", A::DEIntegrator)
println(io,string("t: ",A.t))
print(io,"u: ")
show(io,m,A.u)
end
TreeViews.hastreeview(x::DiffEqBase.DEIntegrator) = true
function TreeViews.treelabel(io::IO,x::DiffEqBase.DEIntegrator,
mime::MIME"text/plain" = MIME"text/plain"())
show(io,mime,Text(Base.summary(x)))
end
# with
const TYPE_COLOR = CSI"36"
const NO_COLOR = CSI"0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment