在命令行执行程序时,是否有一种方法可以更改终端窗口的大小?我尝试使用IO#winsize =,但似乎没有任何作用。
在命令行执行程序时,是否有一种方法可以更改终端窗口的大小?我尝试使用IO#winsize =,但似乎没有任何作用。
有 Xterm 控制序列 用于窗口操作:
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
height and width in pixels.
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
[height;width] in characters.
Ps = 9 ; 0 -> Restore maximized window.
Ps = 9 ; 1 -> Maximize window (i.e., resize to screen
size).
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 as CSI 3 ; x; yt
Ps = 1 4 -> Report xterm window in pixels as CSI 4 ;
height ; width t
Ps = 1 8 -> Report the size of the text area in characters
as CSI 8 ; height ; width t
Ps = 1 9 -> Report the size of the screen in characters as
CSI 9 ; height ; width t
Ps = 2 0 -> Report xterm window's icon label as OSC L
label ST
Ps = 2 1 -> Report xterm window's title as OSC l title ST
Ps >= 2 4 -> Resize to Ps lines (DECSLPP)
"\e["
是CSI的代码)print "\e[8;40;80t" # resizes terminal window to 40x80 characters
resize -s 40 80
进行检查,该命令会发送特定的字符串)。当然,resize是一个实用程序(不是Ruby)。 - Thomas Dickey