Andy
Andy

Reputation: 3522

How do I set the console cursor position in scala?

I'm trying to put a simple console spinner into my scala application, but I'm not sure how to set the cursor position?

If it's not possible, is there another way of achieving this?

Upvotes: 1

Views: 392

Answers (1)

vvg
vvg

Reputation: 6385

val chars = List("/", "-", "\\", "|")
(0 to 30).foreach { _ => chars.foreach { cc =>
        print(s"\u0008$cc")
        Thread.sleep(150)
    }
}

Idea taken from that answer: Write to same location in a console window with java

Upvotes: 1

Related Questions