| Method from com.sshtools.daemon.terminal.TerminalIO Detail: |
public void attachStreams(InputStream in,
OutputStream out) {
this.in = new DataInputStream(new BufferedInputStream(in));
this.out = new DataOutputStream(new BufferedOutputStream(out));
}
|
public void bell() throws IOException {
if (acousticSignalling) {
write(BEL);
}
if (autoflush) {
flush();
}
}
|
public void bindSlaveInputStream(InputStream slaveIn) {
this.slaveIn = slaveIn;
this.ios = new IOStreamConnector(slaveIn, masterOut);
}
|
public void bindSlaveOutputStream(OutputStream slaveOut) {
this.slaveOut = slaveOut;
}
|
public void close() throws IOException {
closeOutput();
}
|
public void closeInput() throws IOException {
if (in == null) {
throw new IOException(
"The terminal is not attached to an inputstream");
}
in.close();
}
|
public void closeOutput() throws IOException {
if (out == null) {
throw new IOException(
"The terminal is not attached to an outputstream");
}
closing = true;
out.close();
}
|
public boolean defineScrollRegion(int topmargin,
int bottommargin) throws IOException {
if (terminal.supportsScrolling()) {
write(terminal.getScrollMarginsSequence(topmargin, bottommargin));
flush();
return true;
} else {
return false;
}
}
|
public void detachStreams() {
this.in = null;
this.out = null;
}
|
public void eraseLine() throws IOException {
doErase(EEL);
}
|
public void eraseScreen() throws IOException {
doErase(EES);
}
|
public void eraseToBeginOfLine() throws IOException {
doErase(EBOL);
}
|
public void eraseToBeginOfScreen() throws IOException {
doErase(EBOS);
}
|
public void eraseToEndOfLine() throws IOException {
doErase(EEOL);
}
|
public void eraseToEndOfScreen() throws IOException {
doErase(EEOS);
}
|
public void flush() throws IOException {
if (out == null) {
throw new IOException(
"The terminal is not attached to an outputstream");
}
// If were attached then flush, else ignore
out.flush();
}
|
public InputStream getAttachedInputStream() throws IOException {
if (in == null) {
throw new IOException(
"The teminal is not attached to an InputStream");
}
return in;
}
|
public OutputStream getAttachedOutputStream() throws IOException {
if (out == null) {
throw new IOException(
"The terminal is not attached to an OutputStream");
}
return out;
}
|
public int getColumns() {
return cols;
}
|
public int getEOL() {
return eol;
}
|
public String getEOLString() {
return ((eol == EOL_CR) ? "\r" : "\r\n");
}
|
public String getEncodedTerminalModes() {
return "";
}
|
public int getHeight() {
return 0;
}
|
public InputStream getMasterInputStream() {
return masterIn;
}
|
public int getRows() {
return rows;
}
|
public OutputStream getSlaveOutputStream() {
return slaveOut;
}
|
public String getTerm() {
return terminal.getName();
}
|
public Terminal getTerminal() {
return terminal;
}
|
public int getWidth() {
return 0;
}
|
public void homeCursor() throws IOException {
write(terminal.getCursorPositioningSequence(HOME));
if (autoflush) {
flush();
}
}
|
public boolean isAutoflushing() {
return autoflush;
}
|
public boolean isSignalling() {
return acousticSignalling;
}
|
public void moveCursor(int direction,
int times) throws IOException {
write(terminal.getCursorMoveSequence(direction, times));
if (autoflush) {
flush();
}
}
|
public void moveDown(int times) throws IOException {
moveCursor(DOWN, times);
}
|
public void moveLeft(int times) throws IOException {
moveCursor(LEFT, times);
}
|
public void moveRight(int times) throws IOException {
moveCursor(RIGHT, times);
}
|
public void moveUp(int times) throws IOException {
moveCursor(UP, times);
}
|
public void println() throws IOException {
write(getEOLString().getBytes());
if (autoflush) {
flush();
}
}
|
public void println(String str) throws IOException {
write(str);
write(getEOLString().getBytes());
if (autoflush) {
flush();
}
}
|
public int read() throws IOException {
int i = stripCRSeq(rawread());
//translate possible control sequences
i = terminal.translateControlCharacter(i);
if ((i > 256) && (i == ESCAPE)) {
i = handleEscapeSequence(i);
}
return i;
}
|
public void resetAttributes() throws IOException {
if (terminal.supportsSGR()) {
write(terminal.getGRSequence(RESET, 0));
}
}
|
public void restoreCursor() throws IOException {
write(terminal.getSpecialSequence(RESTORECURSOR));
}
|
public void setAutoflushing(boolean b) {
autoflush = b;
}
|
public void setBackgroundColor(int color) throws IOException {
if (terminal.supportsSGR()) {
//this method adds the offset to the fg color by itself
write(terminal.getGRSequence(BCOLOR, color + 10));
if (autoflush) {
flush();
}
}
}
|
public void setBlink(boolean b) throws IOException {
if (terminal.supportsSGR()) {
if (b) {
write(terminal.getGRSequence(STYLE, BLINK));
} else {
write(terminal.getGRSequence(STYLE, BLINK_OFF));
}
if (autoflush) {
flush();
}
}
}
|
public void setBold(boolean b) throws IOException {
if (terminal.supportsSGR()) {
if (b) {
write(terminal.getGRSequence(STYLE, BOLD));
} else {
write(terminal.getGRSequence(STYLE, BOLD_OFF));
}
if (autoflush) {
flush();
}
}
}
|
public void setCursor(int row,
int col) throws IOException {
int[] pos = new int[2];
pos[0] = row;
pos[1] = col;
write(terminal.getCursorPositioningSequence(pos));
if (autoflush) {
flush();
}
}
|
public void setDefaultTerminal() throws IOException {
//set the terminal passing the negotiated string
setTerminal(term);
}
|
public void setEOL(int eol) {
this.eol = eol;
}
|
public void setForegroundColor(int color) throws IOException {
if (terminal.supportsSGR()) {
write(terminal.getGRSequence(FCOLOR, color));
if (autoflush) {
flush();
}
}
}
|
public void setItalic(boolean b) throws IOException {
if (terminal.supportsSGR()) {
if (b) {
write(terminal.getGRSequence(STYLE, ITALIC));
} else {
write(terminal.getGRSequence(STYLE, ITALIC_OFF));
}
if (autoflush) {
flush();
}
}
}
|
public void setSignalling(boolean bool) {
acousticSignalling = bool;
}
|
public void setTerminal(String terminalName) throws IOException {
terminal = TerminalFactory.newInstance(terminalName);
//Terminal is set we init it....
initTerminal();
}
|
public void setUnderlined(boolean b) throws IOException {
if (terminal.supportsSGR()) {
if (b) {
write(terminal.getGRSequence(STYLE, UNDERLINED));
} else {
write(terminal.getGRSequence(STYLE, UNDERLINED_OFF));
}
if (autoflush) {
flush();
}
}
}
|
public void storeCursor() throws IOException {
write(terminal.getSpecialSequence(STORECURSOR));
}
|
public void write(char ch) throws IOException {
write((byte) ch);
if (autoflush) {
flush();
}
}
|
public void write(String str) throws IOException {
write((color.colorize(str, terminal.supportsSGR())).getBytes());
if (autoflush) {
flush();
}
}
|
public void write(byte b) throws IOException {
if (out == null) {
throw new IOException(
"The terminal is not attached to an outputstream");
}
if (eol == EOL_CRLF) {
if (!cr && (b == 10)) {
out.write(13);
//if(masterOut!=null)
// masterOut.write(13);
}
//ensure CRLF(\r\n) is written for CR(\r) to adhere
//to the telnet protocol.
if (cr && (b != 10)) {
out.write(10);
// if(masterOut!=null)
// masterOut.write(10);
}
out.write(b);
// if(masterOut!=null)
// masterOut.write(b);
if (b == 13) {
cr = true;
} else {
cr = false;
}
} else {
out.write(b);
// if(masterOut!=null)
// masterOut.write(b);
}
}
|
public void write(int i) throws IOException {
write((byte) i);
}
|
public void write(byte[] sequence) throws IOException {
for (int z = 0; z < sequence.length; z++) {
write(sequence[z]);
}
}
|
public void write(int[] sequence) throws IOException {
for (int j = 0; j < sequence.length; j++) {
write((byte) sequence[j]);
}
}
|