How do I move the cursor up?

I want to print an array on the screen, then wait 1 second and print it again in the exact location (it will have changed) such that I only ever see one copy and the screen does not scroll downwards.

I just need a escape code the moves the cursor up one row? Is that possible>

Cheers, Paul

Here you go

julia> Base.current_terminfo[:cursor_up] # Private API, do not rely on
"\e[A"

Unfortunately this does not work, Does it matter if I am inside Jupyter notebook?

Very much so, my answer was presuming you’d be operating from a terminal emulator (TTY).

That is very relevant. I don’t use Jupyter but took the liberty of googling for you:

  1. For Python the solution seems to be to call clear_output to remove previous output
  2. This function is apparently available in IJulia.jl as well
    Way to programmatically clear last println() statement in Jupyter cell? - #2 by djsegal
  3. However that thread is quite old and apparently it broke some time ago. The comment about it breaking is quite old itself by now. So I suggest you try this and report back if it doesn’t work

Edit: there is an open issue about this. Maybe @MilesCranmer can comment if there is a known workaround. @Paul_Warburton if it still doesn’t work then consider commenting on the issue I linked to draw attention to it.