What function (display?) does IJulia call at the end of each cell?

IJulia calls display, but with its own AbstractDisplay type, so your method isn’t being called.

The problem is that you shouldn’t be overriding display in the first place. You should override show, as is explained in the manual. For example:

Base.show(io::IO, s::SqrV) = print(io, "SV1 count=$(s.count)")
Base.show(io::IO, m::MIME"text/plain", s::SqrV) = print(io, "SV2 $(s.count)")

Then if you do print(s) it will use the first method, whereas REPL display and IJulia will use the second method, as is explained in the manual.

Note that you want to call print(io, ...) in show, not println(....). First, show output does not typically include a trailing newline (that is added when show is called, e.g. by println). Second, you want to output to the supplied io stream — that way your custom show method can work with streams besides stdout (e.g. output to a file or buffer).

5 Likes