1

How can i place input text at the same time text is also being printed out without it effecting what i have placed?

I'm trying to make a server where there is constant debugging information being printed, but at the same time i want to be able to execute commands while still seeing the information being displayed, but have it done without effecting the info that is already typed in the input field. (Minecraft Bukkit is an example)

Example: http://i43.tinypic.com/2e1ufzp.gif

Charles
  • 50,943
  • 13
  • 104
  • 142
  • See my answer [here](http://stackoverflow.com/a/27389903/263801) to a related question "jline keep prompt at the bottom". – Archie Dec 09 '14 at 22:18

1 Answers1

-2

You will need two threads. The main thread (where your application lives) and outputs all the info as it needs, and another one just for input.

EDIT:

You will need to take some special care if your application prints something while you are writing, as there will be characters being printed in the front of what you were writing.

João Henriques
  • 306
  • 1
  • 9
  • I've tried that approach, But the output would always overlap the input, not like the application in the picture. (I even decompiled the source to see, no luck) – Matthew Laskosky Sep 28 '13 at 01:53
  • Have you tried placing a carriage return "\r" in front of every output message being printted? – João Henriques Sep 28 '13 at 01:56
  • If I remember correctly, eclipse doesn't interpret the "\r" properly, I might be wrong. You may need to run your application inside you system console. – João Henriques Sep 28 '13 at 02:01
  • I have, it just clears the line where the input text is placed, but does not move it down to be "displayed". I'm new to this, and i have been trying to do this for quite some time. :/ – Matthew Laskosky Sep 28 '13 at 02:31
  • You need to buffer each character you write and reprint it after every new log output but in java you cant read a character without pressing enter first, so yill need to write a little appication in C/C++ with (Java Native Interface) and use the c function getchar(), which allows you to read a char without pressing enter. There is no easy way to do what you want only from the console. There are some workarounds in the internet using Swing to bind to a keylistener. – João Henriques Sep 28 '13 at 02:42
  • Thank you, but what joao had described worked, i don't need to get the characters before i hit enter, i just needed it to be placed to a new line when a object has been printed out. – Matthew Laskosky Sep 28 '13 at 03:06