Skip to content

Commit

Permalink
Merge pull request #441 from reibitto/graal-support
Browse files Browse the repository at this point in the history
DefaultTerminalFactory Graal native-image support
  • Loading branch information
mabe02 authored Feb 1, 2020
2 parents 2a8042f + 4b07c9a commit 2fa5a0e
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,7 @@ public Terminal createTerminal() throws IOException {
// ("because we can" - unless "rather not")
if (forceTextTerminal || isAwtHeadless() ||
(System.console() != null && !preferTerminalEmulator) ) {
// if tty but have no tty, but do have a port, then go telnet:
if( telnetPort > 0 && System.console() == null) {
return createTelnetTerminal();
}
if(isOperatingSystemWindows()) {
return createWindowsTerminal();
}
else {
return createUnixTerminal(outputStream, inputStream, charset);
}
return createHeadlessTerminal();
}
else {
// while Lanterna's TerminalEmulator lacks mouse support:
Expand All @@ -133,6 +124,25 @@ public Terminal createTerminal() throws IOException {
}
}

/**
* Instantiates a Terminal according to the factory implementation with the exception that
* {@link DefaultTerminalFactory#preferTerminalEmulator} is always ignored. You may want to use this method when
* using tools that rely on AOT compilation such as Graal native-image to ensure AWT/Swing code paths are not hit.
* @return Terminal implementation
* @throws IOException If there was an I/O error with the underlying input/output system
*/
public Terminal createHeadlessTerminal() throws IOException {
// if tty but have no tty, but do have a port, then go telnet:
if( telnetPort > 0 && System.console() == null) {
return createTelnetTerminal();
}
if(isOperatingSystemWindows()) {
return createWindowsTerminal();
}

return createUnixTerminal(outputStream, inputStream, charset);
}

/**
* Creates a new terminal emulator window which will be either Swing-based or AWT-based depending on what is
* available on the system
Expand Down

0 comments on commit 2fa5a0e

Please sign in to comment.