通过代码改变xshell、putty等终端的长度宽度

来源:互联网 发布:js中的事件方法有哪些 编辑:程序博客网 时间:2024/06/05 14:13

前提是代码中通过ssh、telnet等方式连接服务器,然后获取服务端到终端的输出流OutputStream


然后,通过输出流向终端输出更改屏幕大小的命令:("\033[8;" + height + ";" + width + "t").getBytes()


依据的原理如下:


CSI Ps ; Ps ; Ps t          Window manipulation (from dtterm, as well as extensions).          These controls may be disabled using the allowWindowOps          resource.  Valid values for the first (and any additional          parameters) are:            Ps = 1  -> De-iconify window.            Ps = 2  -> Iconify window.            Ps = 3  ;  x ;  y -> Move window to [x, y].            Ps = 4  ;  height ;  width -> Resize the xterm window to          given height and width in pixels.  Omitted parameters reuse          the current height or width.  Zero parameters use the dis-          play's height or width.            Ps = 5  -> Raise the xterm window to the front of the stack-          ing order.            Ps = 6  -> Lower the xterm window to the bottom of the          stacking order.            Ps = 7  -> Refresh the xterm window.            Ps = 8  ;  height ;  width -> Resize the text area to given          height and width in characters.  Omitted parameters reuse the          current height or width.  Zero parameters use the display's          height or width.            Ps = 9  ;  0  -> Restore maximized window.            Ps = 9  ;  1  -> Maximize window (i.e., resize to screen          size).            Ps = 9  ;  2  -> Maximize window vertically.            Ps = 9  ;  3  -> Maximize window horizontally.            Ps = 1 0  ;  0  -> Undo full-screen mode.            Ps = 1 0  ;  1  -> Change to full-screen.            Ps = 1 0  ;  2  -> Toggle full-screen.            Ps = 1 1  -> Report xterm window state.  If the xterm window          is open (non-iconified), it returns CSI 1 t .  If the xterm          window is iconified, it returns CSI 2 t .            Ps = 1 3  -> Report xterm window position.          Result is CSI 3 ; x ; y t            Ps = 1 4  -> Report xterm window in pixels.          Result is CSI  4  ;  height ;  width t            Ps = 1 8  -> Report the size of the text area in characters.          Result is CSI  8  ;  height ;  width t            Ps = 1 9  -> Report the size of the screen in characters.          Result is CSI  9  ;  height ;  width t            Ps = 2 0  -> Report xterm window's icon label.          Result is OSC  L  label ST            Ps = 2 1  -> Report xterm window's title.          Result is OSC  l  label ST            Ps = 2 2  ;  0  -> Save xterm icon and window title on          stack.            Ps = 2 2  ;  1  -> Save xterm icon title on stack.            Ps = 2 2  ;  2  -> Save xterm window title on stack.            Ps = 2 3  ;  0  -> Restore xterm icon and window title from          stack.            Ps = 2 3  ;  1  -> Restore xterm icon title from stack.            Ps = 2 3  ;  2  -> Restore xterm window title from stack.            Ps >= 2 4  -> Resize to Ps lines (DECSLPP).


参考 http://invisible-island.net/xterm/ctlseqs/ctlseqs.html


0 0
原创粉丝点击