I want the prompt to display at the bottom of the page every time.
I have a GIF of that: The prompt not displaying properly
The code is that for read line:
@Override
public void run()
{
while (((ElytraServer) ElytraAPI.getServer()).isRunning())
{
String cmd;
((ElytraServer) ElytraAPI.getServer()).getReader().getTerminal().writer().flush();
cmd = ((ElytraServer) ElytraAPI.getServer()).getReader().readLine("> ");
if (!cmd.isEmpty())
{
String[] aCMD = cmd.split(" ");
String[] arguments = Arrays.copyOfRange(aCMD, 1, aCMD.length);
ElytraAPI.getCommandRegistry().dispatch(ElytraAPI.getConsole(), aCMD[0], arguments);
}
}
}
It's in a Thread.
And there is the another Thread: With JLine 2, the code keep the prompt at the bottom (But it was buggued !)
public void run()
{
while (((ElytraServer) ElytraAPI.getServer()).isRunning())
{
try
{
if (useJline)
{
/*
JLine 2 / Old:
reader.print(Ansi.ansi().eraseLine(Erase.ALL).toString() + '\n');
reader.flush();
*/
reader.getBuffer().down();
reader.getTerminal().flush();
output.write("".getBytes());
output.flush();
/* // For JLine2
try
{
reader.drawLine();
}
catch (Throwable throwable)
{
reader.getCursorBuffer().clear();
}*/
reader.getTerminal().flush();
}
else
{
output.write("".getBytes());
output.flush();
}
}
catch (IOException ioexception)
{
Logger.getLogger(TerminalConsoleWriterThread.class.getName()).log(Level.SEVERE, null, ioexception);
}
}
}
For the full source: Full source of the program