From 421bf59653d4cde9ef54bbbfeb012fdd50cb9694 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 24 Oct 2023 15:34:26 +0200 Subject: [PATCH] Fix cr/lf support in dumb terminals (#877) --- .../src/main/java/org/jline/reader/impl/LineReaderImpl.java | 5 ----- .../src/main/java/org/jline/terminal/TerminalBuilder.java | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java b/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java index b7d61f6a6..2a46855cf 100644 --- a/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java +++ b/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java @@ -640,11 +640,6 @@ public String readLine(String prompt, String rightPrompt, MaskingCallback maskin if (isSet(Option.AUTO_FRESH_LINE)) callWidget(FRESH_LINE); if (isSet(Option.MOUSE)) terminal.trackMouse(Terminal.MouseTracking.Normal); if (isSet(Option.BRACKETED_PASTE)) terminal.writer().write(BRACKETED_PASTE_ON); - } else { - // For dumb terminals, we need to make sure that CR are ignored - Attributes attr = new Attributes(originalAttributes); - attr.setInputFlag(Attributes.InputFlag.IGNCR, true); - terminal.setAttributes(attr); } callWidget(CALLBACK_INIT); diff --git a/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java b/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java index ec0f98761..75764dde4 100644 --- a/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java +++ b/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java @@ -459,6 +459,11 @@ private Terminal doBuild() throws IOException { type = getDumbTerminalType(dumb, systemStream); terminal = new DumbTerminalProvider() .sysTerminal(name, type, false, encoding, nativeSignals, signalHandler, paused, systemStream); + if (OSUtils.IS_WINDOWS) { + Attributes attr = terminal.getAttributes(); + attr.setInputFlag(Attributes.InputFlag.IGNCR, true); + terminal.setAttributes(attr); + } } } else { for (TerminalProvider provider : providers) {