开发者

Overwriting text on terminal with Java, issue with Console.read*

I know there are hundreds of questions asking how to update already written text on console and I know I can do it printing the \r c开发者_如何学Goharacter.

My issue comes when I use Console.readPassword or Console.readLine which creates a new line and later I can't overwrite it.

I think that my issue isn't related to something special about the Console.read* methods but to new lines. \r goes to the start of the current line, I need to be able to go to the start of the previous N line and start overwriting from there. Or just clear the entire screen.

Any ideas how can I do this?

Thanks.


In principle, this is terminal dependent, and with simple Java means there is no way to do this for all consoles.

Many terminals (at least in unixoid systems) support ANSI-escape sequences, so you can there write something like "\u001B[1;5H" to move the cursor to line 1, columnn 5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜