红宝石宝石命令行程序:建立在bash一个新的会话 [英] Ruby gem command line application: creating a new session in bash
问题描述
我试图让我的命令行的比赛进入自己的会话(我不知道名字是什么,但它看起来像这样)的庆典
:结果
一>
I'm trying to make my command line game to enter its own session (I don't know what the name is, but it looks like this) in bash
:
我的第一次尝试是这样的:
一>结果
为了实现上述,我用:结果系统('清')
结果
和退出键 \\ r \\ E
来改写当前光标位置上方线:结果打印为\\ r \\ E [#{行} A
My first attempt looks like this:
To accomplish the above, I use:
system('clear')
and escape key \r\e
to rewrite lines above the cursor current position:
print "\r\e[#{lines}A"
我要的是在命令行应用程序退出,终端变回了previous状态,好像什么都没有发生,就像使用纳米
,少
,和许多其他命令行工具。
What I want is when the command line application exits, the terminal change back to its previous state as if nothing happened, just like using nano
, less
, and many other command line tools.
你怎么做一个命令行应用程序做,与红宝石?
How do you make a command line application do that with ruby?
推荐答案
我想你是正在寻找 rmcup
和 smcup
终端能力。
I think you're a looking for rmcup
and smcup
terminal capabilities.
print `tput smcup`
system('clear')
puts 'We are on alternate buffer'
puts 'press enter to switch back'
gets
print `tput rmcup`
您还可能要检查为什么不画面清晰运行时, VI?
这篇关于红宝石宝石命令行程序:建立在bash一个新的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!