在任何输出到控制台之前清除屏幕
Clear screen before any output to console
我使用 HighLine gem for UI. I want to clear the screen before output any data. Which method should I use? Patch 一些 Ruby 方法,例如 puts
?补丁高线?以某种方式更改我的应用程序?目前它有 Dialog
class 以及调用 HighLine 函数与用户交互的各种方法。或者也许 HighLine 有一个内置的方法来做到这一点?
嗯,需求不明确,我不会推荐这种方式,但陈述的问题可能会解决:
$stdout.singleton_class.prepend(Module.new do
def write(string)
super("\e[2J" << string)
end
end)
我认为,这个答案不适合 OP,但它完美地回答了所问的确切问题。
我使用 HighLine gem for UI. I want to clear the screen before output any data. Which method should I use? Patch 一些 Ruby 方法,例如 puts
?补丁高线?以某种方式更改我的应用程序?目前它有 Dialog
class 以及调用 HighLine 函数与用户交互的各种方法。或者也许 HighLine 有一个内置的方法来做到这一点?
嗯,需求不明确,我不会推荐这种方式,但陈述的问题可能会解决:
$stdout.singleton_class.prepend(Module.new do
def write(string)
super("\e[2J" << string)
end
end)
我认为,这个答案不适合 OP,但它完美地回答了所问的确切问题。