transcendental-lisp/src/terminal/TerminalConfiguration.java

71 lines
1.7 KiB
Java
Raw Normal View History

2017-03-23 16:14:26 -04:00
package terminal;
2017-11-12 09:42:25 -05:00
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
2017-03-23 16:14:26 -04:00
import com.googlecode.lanterna.terminal.IOSafeTerminal;
2017-03-23 18:48:37 -04:00
import stream.UncheckedIOException;
2017-03-23 16:14:26 -04:00
public class TerminalConfiguration {
private PipedOutputStream inputWriter;
private PipedInputStream inputReader;
private PipedOutputStream outputWriter;
private PipedInputStream outputReader;
private IOSafeTerminal terminal;
2017-03-23 18:48:37 -04:00
public void setInputPair(PipedOutputStream inputWriter, PipedInputStream inputReader) {
2017-03-23 16:14:26 -04:00
this.inputWriter = inputWriter;
2017-03-23 18:48:37 -04:00
this.inputReader = inputReader;
2017-03-24 09:29:19 -04:00
connectInputPair();
2017-03-23 16:14:26 -04:00
}
2017-03-24 09:29:19 -04:00
private void connectInputPair() {
2017-03-23 18:48:37 -04:00
try {
inputWriter.connect(inputReader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
2017-03-23 16:14:26 -04:00
}
2017-03-23 18:48:37 -04:00
public void setOutputPair(PipedOutputStream outputWriter, PipedInputStream outputReader) {
2017-03-23 16:14:26 -04:00
this.outputWriter = outputWriter;
2017-03-23 18:48:37 -04:00
this.outputReader = outputReader;
connectOutputPair();
2017-03-23 16:14:26 -04:00
}
2017-03-23 18:48:37 -04:00
private void connectOutputPair() {
try {
outputWriter.connect(outputReader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
2017-03-23 16:14:26 -04:00
}
public void setTerminal(IOSafeTerminal terminal) {
this.terminal = terminal;
}
public PipedOutputStream getInputWriter() {
return inputWriter;
}
public PipedInputStream getInputReader() {
return inputReader;
}
public PipedOutputStream getOutputWriter() {
return outputWriter;
}
public PipedInputStream getOutputReader() {
return outputReader;
}
public IOSafeTerminal getTerminal() {
return terminal;
}
}