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

Jansi 2.4 #62

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<packaging>pom</packaging>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
<name>Æsh Readline and terminal</name>
<description>Æsh (Another Extendable SHell) Readline and Terminal API</description>
<scm>
Expand Down Expand Up @@ -61,7 +61,7 @@
<version.org.slf4j>1.7.12</version.org.slf4j>
<netty.version>4.1.36.Final</netty.version>
<jackson.version>2.6.1</jackson.version>
<jansi.version>1.18</jansi.version>
<jansi.version>2.4.0</jansi.version>
<junit.version>4.12</junit.version>

<!-- maven-compiler-plugin -->
Expand Down
2 changes: 1 addition & 1 deletion readline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
import static org.fusesource.jansi.internal.Kernel32.GetStdHandle;
import static org.fusesource.jansi.internal.Kernel32.STD_OUTPUT_HANDLE;
import static org.fusesource.jansi.internal.Kernel32.WriteConsoleW;
import org.fusesource.jansi.internal.WindowsSupport;

import org.fusesource.jansi.WindowsSupport;

abstract class AbstractWindowsTerminal extends AbstractTerminal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@
*/
package org.aesh.readline.terminal.impl;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;

import org.aesh.terminal.tty.Capability;
import org.aesh.terminal.tty.Size;
import org.fusesource.jansi.WindowsAnsiOutputStream;
import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.Kernel32;
import static org.fusesource.jansi.internal.Kernel32.GetStdHandle;
import org.fusesource.jansi.internal.Kernel32.INPUT_RECORD;
import org.fusesource.jansi.internal.Kernel32.KEY_EVENT_RECORD;

import static org.fusesource.jansi.internal.Kernel32.STD_OUTPUT_HANDLE;
import org.fusesource.jansi.internal.WindowsSupport;

public class WinSysTerminal extends AbstractWindowsTerminal {

Expand All @@ -43,7 +41,7 @@ public WinSysTerminal(String name, boolean nativeSignals) throws IOException {
}

public WinSysTerminal(String name, boolean nativeSignals, SignalHandler signalHandler) throws IOException {
super(setVTMode(), new WindowsAnsiOutputStream(new FileOutputStream(FileDescriptor.out)), name, nativeSignals, signalHandler);
super(setVTMode(), AnsiConsole.out(), name, nativeSignals, signalHandler);
}

protected int getConsoleOutputCP() {
Expand All @@ -52,25 +50,37 @@ protected int getConsoleOutputCP() {

@Override
protected int getConsoleMode() {
return WindowsSupport.getConsoleMode();
long hConsole = Kernel32.GetStdHandle(Kernel32.STD_INPUT_HANDLE);
if (hConsole == (long)Kernel32.INVALID_HANDLE_VALUE) {
return -1;
} else {
int[] mode = new int[1];
return Kernel32.GetConsoleMode(hConsole, mode) == 0 ? -1 : mode[0];
}
}

@Override
protected void setConsoleMode(int mode) {
WindowsSupport.setConsoleMode(mode);
long hConsole = Kernel32.GetStdHandle(Kernel32.STD_INPUT_HANDLE);
if (hConsole != (long)Kernel32.INVALID_HANDLE_VALUE) {
Kernel32.SetConsoleMode(hConsole, mode);
}
}

public Size getSize() {
Size size = new Size(WindowsSupport.getWindowsTerminalWidth(),
WindowsSupport.getWindowsTerminalHeight());
long outputHandle = Kernel32.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE);
Kernel32.CONSOLE_SCREEN_BUFFER_INFO info = new Kernel32.CONSOLE_SCREEN_BUFFER_INFO();
Kernel32.GetConsoleScreenBufferInfo(outputHandle, info);
Size size = new Size(info.windowWidth(), info.windowHeight());
return size;
}

protected byte[] readConsoleInput() {
// XXX does how many events to read in one call matter?
INPUT_RECORD[] events = null;
long hConsole = Kernel32.GetStdHandle(Kernel32.STD_INPUT_HANDLE);
try {
events = WindowsSupport.readConsoleInput(1);
events = hConsole == (long)Kernel32.INVALID_HANDLE_VALUE ? null : Kernel32.readConsoleInputHelper(hConsole, 1, false);
} catch (IOException e) {
LOGGER.log(Level.INFO, "read Windows terminal input error: ", e);
}
Expand Down
2 changes: 1 addition & 1 deletion terminal-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion terminal-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion terminal-ssh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion terminal-telnet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.aesh</groupId>
<artifactId>readline-all</artifactId>
<version>2.3</version>
<version>2.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down