--- a/src/jdk.internal.le/share/classes/jdk/internal/jline/WindowsTerminal.java Fri Jun 01 11:34:13 2018 +0200
+++ b/src/jdk.internal.le/share/classes/jdk/internal/jline/WindowsTerminal.java Fri Jun 01 13:04:30 2018 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002-2012, the original author or authors.
+ * Copyright (c) 2002-2016, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -12,7 +12,11 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import jdk.internal.jline.extra.AnsiInterpretingOutputStream;
+import jdk.internal.jline.extra.AnsiInterpretingOutputStream.BufferState;
+import jdk.internal.jline.extra.AnsiInterpretingOutputStream.Performer;
import jdk.internal.jline.internal.Configuration;
import jdk.internal.jline.internal.Log;
//import org.fusesource.jansi.internal.WindowsSupport;
@@ -71,7 +75,7 @@
super.init();
// setAnsiSupported(Configuration.getBoolean(ANSI, true));
- setAnsiSupported(false);
+ setAnsiSupported(true);
//
// FIXME: Need a way to disable direct console and sysin detection muck
@@ -115,19 +119,27 @@
setConsoleMode(getConsoleMode() |
ENABLE_ECHO_INPUT.code |
ENABLE_LINE_INPUT.code |
- ENABLE_PROCESSED_INPUT.code |
ENABLE_WINDOW_INPUT.code);
}
else {
setConsoleMode(getConsoleMode() &
~(ENABLE_LINE_INPUT.code |
ENABLE_ECHO_INPUT.code |
- ENABLE_PROCESSED_INPUT.code |
ENABLE_WINDOW_INPUT.code));
}
super.setEchoEnabled(enabled);
}
+ public void disableInterruptCharacter() {
+ setConsoleMode(getConsoleMode() &
+ ~(ENABLE_PROCESSED_INPUT.code));
+ }
+
+ public void enableInterruptCharacter() {
+ setConsoleMode(getConsoleMode() |
+ ENABLE_PROCESSED_INPUT.code);
+ }
+
/**
* Whether or not to allow the use of the JNI console interaction.
*/
@@ -182,6 +194,22 @@
}
@Override
+ public OutputStream wrapOutIfNeeded(OutputStream out) {
+ return new AnsiInterpretingOutputStream(getOutputEncoding(), out, new Performer() {
+ @Override
+ public BufferState getBufferState() throws IOException {
+ out.flush();
+ return WindowsTerminal.this.getBufferState();
+ }
+ @Override
+ public void setCursorPosition(int cursorX, int cursorY) throws IOException {
+ out.flush();
+ WindowsTerminal.this.setCursorPosition(cursorX, cursorY);
+ }
+ });
+ }
+
+ @Override
public String getOutputEncoding() {
int codepage = getConsoleOutputCodepage();
//http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html
@@ -511,6 +539,10 @@
private native int getWindowsTerminalHeight();
+ private native BufferState getBufferState();
+
+ private native void setCursorPosition(int x, int y);
+
/**
* Console mode
* <p/>