Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour surrounding clear screen and ConsoleReader.clearScreen() #224

Open
JDurston opened this issue Nov 14, 2015 · 0 comments
Open

Comments

@JDurston
Copy link

Linux x86-64; Ubuntu; Terminal; zsh

I noticed some strange behaviour when trying to clear the screen.
Attempts to clear the screen do not work with usual method of System.out.print("\u001b[2J").
Furthermore, when ConsoleReader.clearScreen is used, the screen WILL clear, BUT a double command prompt (--+--> --+-->) appears!

Example (swap con.clearScreen and System.out... to see both 'features'):

class TestJline {
    private static final String ERASE_DISPLAY = "\u001b[2J";
    public static void main (String argv[]) {
        try {
            ConsoleReader con = new ConsoleReader();
            con.setPrompt("--+--> ");

            System.out.print(ERASE_DISPLAY);
            System.out.println("Press any key to continue...");
            con.readCharacter();
            //con.clearScreen();
            System.out.print(ERASE_DISPLAY);

            System.out.println("Here is a prompt. Do something and press enter to continue...");
            String line = con.readLine();
            //con.clearScreen();
            System.out.print(ERASE_DISPLAY);

            System.out.println("You typed: ");
            System.out.println(line);
            System.out.println("Press any key to exit. ");
            con.readCharacter();
            //con.clearScreen();
            System.out.print(ERASE_DISPLAY);

            System.out.println("Thank You. Goodbye.");
            System.out.println("");
        } catch(IOException e) {
            //What to do in the event of an IOException:
            e.printStackTrace();
        } finally {
            try {
                TerminalFactory.get().restore();
            } catch(Exception e) {
                e.printStackTrace();
            }   
        }   
    }   
@JDurston JDurston changed the title Strange behaviour surrounding clear screen and ConsoleReader.clearScreen Strange behaviour surrounding clear screen and ConsoleReader.clearScreen() Nov 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant