Jline Terminal Writer Outputting Wrong Formatted Output

576 Views Asked by At

We're having some issues with the Jline library terminal when trying to use it's writer. When we try to write a string using the terminal writer's print statement, it's appending characters around the string.

Example: When printing: terminal.writer().print("Username:"); We get the output string as "�[?1l�>�[?1000l�[?2004lUsername:�[?1h�=�[?2004h", where as we want to get only "Username:" as the output.

We've tried the solution from this link https://github.com/jline/jline3/issues/181 by setting the "BRACKETED_PASTE_OFF". But that didn't work.

1

There are 1 best solutions below

0
Alok Nath Saha On

I got it working, I had to use printAbove to remove the string appended when reading a line and set the BRACKETED_PASTE as false to remove the brackets appended during the cleanup phase:

final TerminalBuilder builder = TerminalBuilder.builder(); builder.jansi(false); builder.streams(in, out); terminal = builder.build(); reader = LineReaderBuilder.builder().terminal(terminal).build(); reader.option(BRACKETED_PASTE, false); reader.printAbove(StringToPrint); terminal.writer().print(StringToPrint);