1

I get that this isn't possible to do with normal java, although if there are any libraries out this it would be very useful.

Essentially, I'm designing a console app and running into an issue that when output happens while something is typed in the input line, that input text will move up and appear before the line that just got output. Is it possible to fix this in some form so that the text you are inputting that stays at the bottom?

EX: I'm typing something as input into my commandline app, and then the program prints something WHILE I'm typing - this causes what was originally on the input line to be scrolled up with whatever the output text was. When you are trying to type something in this can obviously be detrimental. I know it's possible to prevent this.. (Other programs have done it... EX: Minecraft Server)

(If I need to be more descriptive I can.)

  • As you say, this isn't really possible with java, as the actual display of the input/output is handled by the operating system/shell. You could solve this there, e.g. by redirecting the output to a file so that it doesn't break your input and switching tasks when you want to look at it. There's probably a better way to handle that -- ask/look on superuser. An alternative is to create a simple instant-messenge style GUI where you have full control over everything. – Adrian Leonhard Feb 20 '15 at 02:43
  • I cant exactly do a gui - it has to be a console app – VoidWhisperer Feb 20 '15 at 02:48
  • I think this is possible... but I don't know how =/ – G Bisconcini Feb 20 '15 at 03:07

1 Answers1

0

You could use the help of threads. One that listens to user input, the other process the actual output. This problem is similar to basic race condition problems when multiple threads attempt to read and write to a shared resource.

Your shared resource is that console. You need to keep the Input/Output operations synchronized. Have a look at race condition.

Community
  • 1
  • 1
Muli Yulzary
  • 2,559
  • 3
  • 21
  • 39