⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 terminalio.java

📁 java telnet 服务器实现 .
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  public synchronized void setBackgroundColor(int color) throws IOException {    if (m_Terminal.supportsSGR()) {      //this method adds the offset to the fg color by itself      m_TelnetIO.write(m_Terminal.getGRSequence(BCOLOR, color + 10));      if (m_Autoflush) {        flush();      }    }  }//setBackgroundColor  public synchronized void setBold(boolean b) throws IOException {    if (m_Terminal.supportsSGR()) {      if (b) {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, BOLD));      } else {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, BOLD_OFF));      }      if (m_Autoflush) {        flush();      }    }  }//setBold  public synchronized void forceBold(boolean b) {    m_ForceBold = b;  }//forceBold  public synchronized void setUnderlined(boolean b) throws IOException {    if (m_Terminal.supportsSGR()) {      if (b) {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, UNDERLINED));      } else {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, UNDERLINED_OFF));      }      if (m_Autoflush) {        flush();      }    }  }//setUnderlined  public synchronized void setItalic(boolean b) throws IOException {    if (m_Terminal.supportsSGR()) {      if (b) {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, ITALIC));      } else {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, ITALIC_OFF));      }      if (m_Autoflush) {        flush();      }    }  }//setItalic  public synchronized void setBlink(boolean b) throws IOException {    if (m_Terminal.supportsSGR()) {      if (b) {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, BLINK));      } else {        m_TelnetIO.write(m_Terminal.getGRSequence(STYLE, BLINK_OFF));      }      if (m_Autoflush) {        flush();      }    }  }//setItalic  public synchronized void resetAttributes() throws IOException {    if (m_Terminal.supportsSGR()) {      m_TelnetIO.write(m_Terminal.getGRSequence(RESET, 0));    }  }//resetGR  /*** End of special terminal function methods ***************************/  /************************************************************************   * Auxiliary I/O methods						                        *   ************************************************************************/  /**   * Method that parses forward for escape sequences   */  private int handleEscapeSequence(int i) throws IOException {    if (i == ESCAPE) {      int[] bytebuf = new int[m_Terminal.getAtomicSequenceLength()];      //fill atomic length      //FIXME: ensure CAN, broken Escapes etc.      for (int m = 0; m < bytebuf.length; m++) {        bytebuf[m] = m_TelnetIO.read();      }      return m_Terminal.translateEscapeSequence(bytebuf);    }    if (i == BYTEMISSING) {      //FIXME:longer escapes etc...    }    return HANDLED;  }//handleEscapeSequence  /**   * Accessor method for the autoflushing mechanism.   */  public boolean isAutoflushing() {    return m_Autoflush;  }//isAutoflushing  public synchronized void resetTerminal() throws IOException {    m_TelnetIO.write(m_Terminal.getSpecialSequence(DEVICERESET));  }  public synchronized void setLinewrapping(boolean b) throws IOException {    if (b && !m_LineWrapping) {      m_TelnetIO.write(m_Terminal.getSpecialSequence(LINEWRAP));      m_LineWrapping = true;      return;    }    if (!b && m_LineWrapping) {      m_TelnetIO.write(m_Terminal.getSpecialSequence(NOLINEWRAP));      m_LineWrapping = false;      return;    }  }//setLineWrapping  public boolean isLineWrapping() {    return m_LineWrapping;  }//  /**   * Mutator method for the autoflushing mechanism.   */  public synchronized void setAutoflushing(boolean b) {    m_Autoflush = b;  }//setAutoflushing  /**   * Method to flush the Low-Level Buffer   */  public synchronized void flush() throws IOException {    m_TelnetIO.flush();  }//flush (implements the famous iToilet)  public synchronized void close() {    m_TelnetIO.closeOutput();    m_TelnetIO.closeInput();  }//close  /*** End of Auxiliary I/O methods  **************************************/  /************************************************************************   * Terminal management specific methods			                        *   ************************************************************************/  /**   * Accessor method to get the active terminal object   *   * @return Object that implements Terminal   */  public Terminal getTerminal() {    return m_Terminal;  }//getTerminal  /**   * Sets the default terminal ,which will either be   * the negotiated one for the connection, or the systems   * default.   */  public void setDefaultTerminal() throws IOException {    //set the terminal passing the negotiated string    setTerminal(m_ConnectionData.getNegotiatedTerminalType());  }//setDefaultTerminal  /**   * Mutator method to set the active terminal object   * If the String does not name a terminal we support   * then the vt100 is the terminal of selection automatically.   *   * @param terminalName String that represents common terminal name   */  public void setTerminal(String terminalName) throws IOException {    m_Terminal = TerminalManager.getReference().getTerminal(terminalName);    //Terminal is set we init it....    initTerminal();    //debug message    log.debug("Set terminal to " + m_Terminal.toString());  }//setTerminal  /**   * Terminal initialization   */  private synchronized void initTerminal() throws IOException {    m_TelnetIO.write(m_Terminal.getInitSequence());    flush();  }//initTerminal  /**   *   */  public int getRows() {    return m_ConnectionData.getTerminalRows();  }//getRows  /**   *   */  public int getColumns() {    return m_ConnectionData.getTerminalColumns();  }//getColumns  /**   * Accessor Method for the terminal geometry changed flag   */  public boolean isTerminalGeometryChanged() {    return m_ConnectionData.isTerminalGeometryChanged();  }//isTerminalGeometryChanged  /*** End of terminal management specific methods  ***********************/  /** Constants Declaration  **********************************************/  /**   * Terminal independent representation constants for terminal   * functions.   */  public static final int[] HOME = {0, 0};  public static final int      IOERROR = -1;		//IO error  public static final int// Positioning 10xx      UP = 1001; 		//one up  public static final int DOWN = 1002; 		//one down  public static final int RIGHT = 1003; 	//one left  public static final int LEFT = 1004; 		//one right  //HOME=1005,		//Home cursor pos(0,0)  public static final int// Functions 105x      STORECURSOR = 1051;	//store cursor position + attributes  public static final int RESTORECURSOR = 1052;	//restore cursor + attributes  public static final int// Erasing 11xx      EEOL = 1100;		//erase to end of line  public static final int EBOL = 1101;		//erase to beginning of line  public static final int EEL = 1103;		//erase entire line  public static final int EEOS = 1104;		//erase to end of screen  public static final int EBOS = 1105;		//erase to beginning of screen  public static final int EES = 1106;		//erase entire screen  public static final int// Escape Sequence-ing 12xx      ESCAPE = 1200;		//Escape  public static final int BYTEMISSING = 1201;	//another byte needed  public static final int UNRECOGNIZED = 1202;	//escape match missed  public static final int// Control Characters 13xx      ENTER = 1300;		//LF is ENTER at the moment  public static final int TABULATOR = 1301;	 	//Tabulator  public static final int DELETE = 1302;		//Delete  public static final int BACKSPACE = 1303;		//BACKSPACE  public static final int COLORINIT = 1304;		//Color inited  public static final int HANDLED = 1305;  public static final int LOGOUTREQUEST = 1306;		//CTRL-D beim login  /**   * Internal UpdateType Constants   */  public static final int      LineUpdate = 475,  CharacterUpdate = 476,  ScreenpartUpdate = 477;  /**   * Internal BufferType Constants   */  public static final int      EditBuffer = 575,  LineEditBuffer = 576;  /**   * Network Virtual Terminal Specific Keys   * Thats what we have to offer at least.   */  public static final int BEL = 7;  public static final int BS = 8;  public static final int DEL = 127;  public static final int CR = 13;  public static final int LF = 10;  public static final int FCOLOR = 10001;  public static final int BCOLOR = 10002;  public static final int STYLE = 10003;  public static final int RESET = 10004;  public static final int BOLD = 1;  public static final int BOLD_OFF = 22;  public static final int ITALIC = 3;  public static final int ITALIC_OFF = 23;  public static final int BLINK = 5;  public static final int BLINK_OFF = 25;  public static final int UNDERLINED = 4;  public static final int UNDERLINED_OFF = 24;  public static final int DEVICERESET = 10005;  public static final int LINEWRAP = 10006;  public static final int NOLINEWRAP = 10007;  /** end Constants Declaration  ******************************************/}//class TerminalIO

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -