henrik / progress_bar

Command-line progress bars and spinners for Elixir.
MIT License
333 stars 20 forks source link

Hide caret/cursor #11

Closed henrik closed 5 years ago

henrik commented 8 years ago

This seems to work in my OS X terminal: http://stackoverflow.com/a/10995085/6962

PoC:

IO.puts "My progress:"

IO.puts("\e[?25l")

1..100 |> Enum.each fn (i) ->
  IO.write "\r[#{String.duplicate "=", i}] #{i} %"
  :timer.sleep 25
end

IO.puts "\nDone!"
IO.puts("\e[?25h")

Consider that if someone ctrl+C:s before restoring the cursor, that terminal will be without one. Trap exits? Overkill?

henrik commented 8 years ago

Experimented a bit - ctrl+c might be untrappable.

henrik commented 5 years ago

Closing this since I don't think I'll get around to it, but if anyone else wants to, feel free!