gpt4 book ai didi

ruby - 执行 ruby​​ 时更改终端大小

转载 作者:太空宇宙 更新时间:2023-11-03 16:21:25 24 4
gpt4 key购买 nike

从命令行执行程序时,有没有办法改变终端窗口的大小?我尝试使用 IO#winsize= 但它似乎没有做任何事情。

最佳答案

Xterm Control Sequences用于窗口操作:

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)

要从 Ruby 中调用它们,您可以使用:("\e[" 是 CSI 的代码)

print "\e[8;40;80t" # resizes terminal window to 40x80 characters

这仅在您的终端支持控制序列时有效。

关于ruby - 执行 ruby​​ 时更改终端大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32561996/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com