ruby: curses: 不要在程序结束时清屏?
ruby: curses: Do not clear screen at end of program?
我正在使用 ruby curses 包 (ruby 2.1.5)。
在某些情况下,我希望屏幕 而不是 在我的程序结束时被清除,以便 [=27 的最终内容=] 程序退出时仍在我的终端上显示。
我试过省略对 Curses.close_screen 的调用,但终端屏幕在退出时仍然被清除。
有什么方法可以让 ruby 中的 curses 在程序终止时不清除屏幕?
提前致谢。
我想通了:事实证明,如果我使用 exit! 而不是 exit、none 的 curses 屏幕重置逻辑被调用,stdscr 的最新内容保留在我的屏幕上。
我在调用 Curses.init_screen 之前还执行了以下操作 ...
require 'termios'
$orig_termios = Termios.tcgetattr($stdin)
... 我在 exit! ...
之前发出此命令
Termios.tcsetattr($stdin, Termios::TCSANOW, $orig_termios)
(我想接受这个答案,但是我不能再做2天了,到时候我会做的)。
捆绑的 Ruby curses 模块缺少(许多)curses 函数,例如 reset_shell_mode
,这是执行此操作的常用方法:
The reset_prog_mode
and reset_shell_mode
routines restore
the terminal to "program" (in curses) or "shell" (out of
curses) state. These are done automatically by endwin(3x)
and, after an endwin
, by doupdate
, so they normally are
not called.
或者,您可以使用 MRuby(提供函数)。
在任何一种情况下,这样退出都可以将终端的特殊键设置为 application mode。解决方法是发送一个转义序列(在终端数据库中找到 rmkx
)。
我正在使用 ruby curses 包 (ruby 2.1.5)。
在某些情况下,我希望屏幕 而不是 在我的程序结束时被清除,以便 [=27 的最终内容=] 程序退出时仍在我的终端上显示。
我试过省略对 Curses.close_screen 的调用,但终端屏幕在退出时仍然被清除。
有什么方法可以让 ruby 中的 curses 在程序终止时不清除屏幕?
提前致谢。
我想通了:事实证明,如果我使用 exit! 而不是 exit、none 的 curses 屏幕重置逻辑被调用,stdscr 的最新内容保留在我的屏幕上。
我在调用 Curses.init_screen 之前还执行了以下操作 ...
require 'termios'
$orig_termios = Termios.tcgetattr($stdin)
... 我在 exit! ...
之前发出此命令Termios.tcsetattr($stdin, Termios::TCSANOW, $orig_termios)
(我想接受这个答案,但是我不能再做2天了,到时候我会做的)。
捆绑的 Ruby curses 模块缺少(许多)curses 函数,例如 reset_shell_mode
,这是执行此操作的常用方法:
The
reset_prog_mode
andreset_shell_mode
routines restore the terminal to "program" (in curses) or "shell" (out of curses) state. These are done automatically by endwin(3x) and, after anendwin
, bydoupdate
, so they normally are not called.
或者,您可以使用 MRuby(提供函数)。
在任何一种情况下,这样退出都可以将终端的特殊键设置为 application mode。解决方法是发送一个转义序列(在终端数据库中找到 rmkx
)。