I am writing a console application in Java. It looks like a chat client: input and output are asynchronously done. The problem is that if some kind of output is executed when the user is in the middle of the set, the lines will be mixed on the screen.
I am looking for a solution that allows me to have an input area separate from the output area. I am currently using an additional thread that polls BufferedReader on System.in.
The program must run on a Linux server and access through an ssh session. Therefore, any tips that work only in this environment are wonderful.
Are there high-level libraries that can do this? Or is there a trick using terminal / ANSI codes? The ANSI s (save cursor) and r (restore cursor) codes can be useful, but how do you know where to get to the output and how to handle scrolling?
source share