Clear IO messages #1407
-
Is there a way to clear IO messages? I'd like to be able to listen for button events, and display some IO.puts message, but clear the log before displaying the message. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Only by reevaluating the cell. Or by having a framing which you can write to and clear from time to time. |
Beta Was this translation helpful? Give feedback.
-
Hey @BrooklinJazz! One of the things you can do is this: for _ <- Kino.Control.stream(button) do
IO.write("\rPRESSED BUTTON! #{DateTime.utc_now()}")
end Note that we use There's also kino frame where you can replace the whole content. Finally, in kino main we have |
Beta Was this translation helpful? Give feedback.
-
Great answers! But I don't think they fit my use case. (trying to clear IO.puts coming from something I don't have control over) I have another workaround for my problem, so I'm going to mark the above as a valid answer to the question as asked. |
Beta Was this translation helpful? Give feedback.
Hey @BrooklinJazz! One of the things you can do is this:
Note that we use
IO.write
so no newline is added, and\r
clears that line next time we print.There's also kino frame where you can replace the whole content.
Finally, in kino main we have
Kino.animate/2
, which could do pretty well here.