If you let something be printed to the REPL, can you enforce that horizontal space is used to the right side of an existing printout?
For example, you have some variables, a small DataFrame and something else; you have printed out the latter; now you want the small DataFrame printed not below it, but next to it; the prompt still moves down as usual (to just below the lowest point of one of those printouts).
I don’t think there is existing functionality for this.
Also, if I understand the requirement correctly, it is not really something the REPL can easily do: display is called and you get your prompt back, and then you want to go back and align the new output for the next expression horizontally?
If you just want to place text representations next to each other, you could define a function that calls show into an IOBuffer, then arranges the results nicely, but you would have to call this explicitly.
function show_side_by_side(io::IO, xs...; gap = 2)
all_lines = map(x -> split(repr(MIME("text/plain"), x), '\n'), xs)
widths = map(lines -> maximum(length, lines), all_lines)
nrows = maximum(length, all_lines)
nxs = length(all_lines)
for i in 1:nrows
for (j, lines) in enumerate(all_lines)
print(io, rpad(i ≤ length(lines) ? lines[i] : "", widths[j]))
if j == nxs
println(io)
else
print(io, ' '^gap)
end
end
end
end
show_side_by_side(xs...; gap = 2) = show_side_by_side(stdout, xs...; gap = gap)