1

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.

Alok Nath Saha
  • 297
  • 1
  • 4
  • 20
  • maybe it would help to see the code, at least how `terminal` comes to live. the codes resemble ANSI escape codes, try setting `jansi` to `false`. (e.g. `...2004...` is BRACKETED_PASTE mode command) – user85421 Dec 06 '18 at 23:25
  • So setting jansi to false in the terminal builder didn't work. However setting the option (BRACKETED_PASTE, false) on the linereader did get rid of the 2004 strings. But I'm still getting some more stuff attached to the user name field "[?1l>[?1000lUsername:[?1h=". Looking if any other option needs to be disabled/ enabled. – Alok Nath Saha Dec 06 '18 at 23:50

1 Answers1

0

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);

Alok Nath Saha
  • 297
  • 1
  • 4
  • 20