Some renames and javadoc.
This commit is contained in:
@@ -18,13 +18,13 @@ public class Main {
|
||||
System.out.println(" * " + fileSystem.getMountPoint() + ' ' + fileSystem.getFileSystemType() + ' ' + fileSystem.getDeviceName() + (fileSystem.isRemote() ? " remote" : " local"));
|
||||
}
|
||||
|
||||
TerminalAccess terminalAccess = Native.get(TerminalAccess.class);
|
||||
boolean stdoutIsTerminal = terminalAccess.isTerminal(TerminalAccess.Output.Stdout);
|
||||
boolean stderrIsTerminal = terminalAccess.isTerminal(TerminalAccess.Output.Stderr);
|
||||
Terminals terminals = Native.get(Terminals.class);
|
||||
boolean stdoutIsTerminal = terminals.isTerminal(Terminals.Output.Stdout);
|
||||
boolean stderrIsTerminal = terminals.isTerminal(Terminals.Output.Stderr);
|
||||
System.out.println("* stdout: " + (stdoutIsTerminal ? "terminal" : "not a terminal"));
|
||||
System.out.println("* stderr: " + (stderrIsTerminal ? "terminal" : "not a terminal"));
|
||||
if (stdoutIsTerminal) {
|
||||
Terminal terminal = terminalAccess.getTerminal(TerminalAccess.Output.Stdout);
|
||||
Terminal terminal = terminals.getTerminal(Terminals.Output.Stdout);
|
||||
TerminalSize terminalSize = terminal.getTerminalSize();
|
||||
System.out.println("* terminal size: " + terminalSize.getCols() + " cols x " + terminalSize.getRows() + " rows");
|
||||
System.out.println("* text attributes: " + (terminal.supportsTextAttributes() ? "yes" : "no"));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.rubygrapefruit.platform;
|
||||
|
||||
/**
|
||||
* Functions to query and modify a process' meta-data
|
||||
* Functions to query and modify a process' state.
|
||||
*
|
||||
* Supported on Linux, OS X, Windows.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
package net.rubygrapefruit.platform;
|
||||
|
||||
/**
|
||||
* Provides access to some system information.
|
||||
*/
|
||||
public interface SystemInfo extends NativeIntegration {
|
||||
String getKernelName();
|
||||
/**
|
||||
* Returns the name of the kernel for the current operating system.
|
||||
*
|
||||
* @throws NativeException on failure.
|
||||
*/
|
||||
String getKernelName() throws NativeException;
|
||||
|
||||
String getKernelVersion();
|
||||
/**
|
||||
* Returns the version of the kernel for the current operating system.
|
||||
*
|
||||
* @throws NativeException on failure.
|
||||
*/
|
||||
String getKernelVersion() throws NativeException;
|
||||
|
||||
String getMachineArchitecture();
|
||||
/**
|
||||
* Returns the machine architecture, as reported by the operating system.
|
||||
*
|
||||
* @throws NativeException on failure.
|
||||
*/
|
||||
String getMachineArchitecture() throws NativeException;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package net.rubygrapefruit.platform;
|
||||
*
|
||||
* Supported on Linux, OS X, Windows.
|
||||
*/
|
||||
public interface TerminalAccess extends NativeIntegration {
|
||||
public interface Terminals extends NativeIntegration {
|
||||
enum Output {Stdout, Stderr}
|
||||
|
||||
/**
|
||||
@@ -58,8 +58,8 @@ public abstract class Platform {
|
||||
if (type.equals(net.rubygrapefruit.platform.Process.class)) {
|
||||
return type.cast(new DefaultProcess());
|
||||
}
|
||||
if (type.equals(TerminalAccess.class)) {
|
||||
return type.cast(new WindowsTerminalAccess());
|
||||
if (type.equals(Terminals.class)) {
|
||||
return type.cast(new WindowsTerminals());
|
||||
}
|
||||
return super.get(type);
|
||||
}
|
||||
@@ -74,8 +74,8 @@ public abstract class Platform {
|
||||
if (type.equals(Process.class)) {
|
||||
return type.cast(new DefaultProcess());
|
||||
}
|
||||
if (type.equals(TerminalAccess.class)) {
|
||||
return type.cast(new TerminfoTerminalAccess());
|
||||
if (type.equals(Terminals.class)) {
|
||||
return type.cast(new TerminfoTerminals());
|
||||
}
|
||||
if (type.equals(SystemInfo.class)) {
|
||||
MutableSystemInfo systemInfo = new MutableSystemInfo();
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.rubygrapefruit.platform.internal;
|
||||
|
||||
import net.rubygrapefruit.platform.NativeException;
|
||||
import net.rubygrapefruit.platform.Terminal;
|
||||
import net.rubygrapefruit.platform.TerminalAccess;
|
||||
import net.rubygrapefruit.platform.Terminals;
|
||||
import net.rubygrapefruit.platform.TerminalSize;
|
||||
import net.rubygrapefruit.platform.internal.jni.PosixTerminalFunctions;
|
||||
import net.rubygrapefruit.platform.internal.jni.TerminfoFunctions;
|
||||
@@ -10,14 +10,14 @@ import net.rubygrapefruit.platform.internal.jni.TerminfoFunctions;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class TerminfoTerminal extends AbstractTerminal {
|
||||
private final TerminalAccess.Output output;
|
||||
private final Terminals.Output output;
|
||||
private final PrintStream stream;
|
||||
private final TerminalCapabilities capabilities = new TerminalCapabilities();
|
||||
private Color foreground;
|
||||
|
||||
public TerminfoTerminal(TerminalAccess.Output output) {
|
||||
public TerminfoTerminal(Terminals.Output output) {
|
||||
this.output = output;
|
||||
stream = output == TerminalAccess.Output.Stdout ? System.out : System.err;
|
||||
stream = output == Terminals.Output.Stdout ? System.out : System.err;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.rubygrapefruit.platform.internal;
|
||||
|
||||
import net.rubygrapefruit.platform.Terminal;
|
||||
import net.rubygrapefruit.platform.TerminalAccess;
|
||||
import net.rubygrapefruit.platform.Terminals;
|
||||
import net.rubygrapefruit.platform.internal.jni.PosixTerminalFunctions;
|
||||
|
||||
public class TerminfoTerminalAccess implements TerminalAccess {
|
||||
public class TerminfoTerminals implements Terminals {
|
||||
private static Output currentlyOpen;
|
||||
private static TerminfoTerminal current;
|
||||
|
||||
@@ -2,14 +2,14 @@ package net.rubygrapefruit.platform.internal;
|
||||
|
||||
import net.rubygrapefruit.platform.NativeException;
|
||||
import net.rubygrapefruit.platform.Terminal;
|
||||
import net.rubygrapefruit.platform.TerminalAccess;
|
||||
import net.rubygrapefruit.platform.Terminals;
|
||||
import net.rubygrapefruit.platform.TerminalSize;
|
||||
import net.rubygrapefruit.platform.internal.jni.WindowsConsoleFunctions;
|
||||
|
||||
public class WindowsTerminal extends AbstractTerminal {
|
||||
private final TerminalAccess.Output output;
|
||||
private final Terminals.Output output;
|
||||
|
||||
public WindowsTerminal(TerminalAccess.Output output) {
|
||||
public WindowsTerminal(Terminals.Output output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package net.rubygrapefruit.platform.internal;
|
||||
|
||||
import net.rubygrapefruit.platform.NativeException;
|
||||
import net.rubygrapefruit.platform.Terminal;
|
||||
import net.rubygrapefruit.platform.TerminalAccess;
|
||||
import net.rubygrapefruit.platform.Terminals;
|
||||
import net.rubygrapefruit.platform.internal.jni.WindowsConsoleFunctions;
|
||||
|
||||
public class WindowsTerminalAccess implements TerminalAccess {
|
||||
public class WindowsTerminals implements Terminals {
|
||||
private static Output currentlyOpen;
|
||||
private static WindowsTerminal current;
|
||||
|
||||
@@ -8,18 +8,18 @@ import spock.lang.IgnoreIf
|
||||
|
||||
class TerminalTest extends Specification {
|
||||
@Rule TemporaryFolder tmpDir
|
||||
final TerminalAccess terminal = Native.get(TerminalAccess.class)
|
||||
final Terminals terminal = Native.get(Terminals.class)
|
||||
|
||||
def "can check if attached to terminal"() {
|
||||
expect:
|
||||
!terminal.isTerminal(TerminalAccess.Output.Stdout);
|
||||
!terminal.isTerminal(TerminalAccess.Output.Stderr);
|
||||
!terminal.isTerminal(Terminals.Output.Stdout);
|
||||
!terminal.isTerminal(Terminals.Output.Stderr);
|
||||
}
|
||||
|
||||
@IgnoreIf({Platform.current().windows})
|
||||
def "cannot access posix terminal from a test"() {
|
||||
when:
|
||||
terminal.getTerminal(TerminalAccess.Output.Stdout)
|
||||
terminal.getTerminal(Terminals.Output.Stdout)
|
||||
|
||||
then:
|
||||
NativeException e = thrown()
|
||||
@@ -29,7 +29,7 @@ class TerminalTest extends Specification {
|
||||
@IgnoreIf({!Platform.current().windows})
|
||||
def "cannot access windows console from a test"() {
|
||||
when:
|
||||
terminal.getTerminal(TerminalAccess.Output.Stdout)
|
||||
terminal.getTerminal(Terminals.Output.Stdout)
|
||||
|
||||
then:
|
||||
NativeException e = thrown()
|
||||
|
||||
Reference in New Issue
Block a user