From 80776ace98f5d532366e4432beaf20cd96e10a3b Mon Sep 17 00:00:00 2001 From: a14m Date: Wed, 10 Feb 2021 22:35:11 +0100 Subject: Better and more performant ruby rendering in alternative terminal Ref: https://github.com/ruby/ruby/blob/ruby_2_7/lib/irb/easter-egg.rb#L112-L131 Ref: https://stackoverflow.com/questions/11023929/using-the-alternate-screen-in-a-bash-script Ref: https://superuser.com/questions/122911/what-commands-can-i-use-to-reset-and-clear-my-terminal --- CLI/ruby/bin/game-of-life | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'CLI/ruby/bin') diff --git a/CLI/ruby/bin/game-of-life b/CLI/ruby/bin/game-of-life index 16dc0fa..08dbeca 100755 --- a/CLI/ruby/bin/game-of-life +++ b/CLI/ruby/bin/game-of-life @@ -8,7 +8,7 @@ class CLI < Thor map %w[-v --version] => :version desc "--version, -v", "Prints the Game of Life version information" def version - puts "Game of Life version #{GameOfLife::VERSION}" + print "Game of Life version #{GameOfLife::VERSION}" end default_task :start @@ -50,8 +50,10 @@ end begin CLI.start(ARGV) rescue SystemExit, Interrupt - "Do nothing when user exits with Interrupt (CMD/Ctrl + C)" + # Print Seed/File used in previous run when user exits with Interrupt (CMD/Ctrl + C) + print "\e[?1049l" + print "#{GameOfLife::BANNER}\n\e[0m" rescue NotImplementedError, GameOfLife::Error => e - puts e.message + print e.message exit(-1) end -- cgit v1.2.3