diff options
| author | a14m <[email protected]> | 2021-02-10 22:44:29 +0100 |
|---|---|---|
| committer | a14m <[email protected]> | 2021-02-10 22:44:29 +0100 |
| commit | 1dfa5fcb5e860bb90e23f8381b1aa5ee2a469d68 (patch) | |
| tree | 6ec5ef3dc99784721a79bbb28a49139845387f53 /CLI/ruby/lib | |
| parent | 9ba51d3f6b2920291deb0793413661b29322b75a (diff) | |
| parent | 80776ace98f5d532366e4432beaf20cd96e10a3b (diff) | |
Merge branch 'feature/ruby-canavas'
Diffstat (limited to 'CLI/ruby/lib')
| -rw-r--r-- | CLI/ruby/lib/game_of_life.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/CLI/ruby/lib/game_of_life.rb b/CLI/ruby/lib/game_of_life.rb index 2ff548c..b1a95f1 100644 --- a/CLI/ruby/lib/game_of_life.rb +++ b/CLI/ruby/lib/game_of_life.rb @@ -106,9 +106,13 @@ module GameOfLife # and rendering of the current universe/banner info # based on the delay/cell configured by the user def render(universe) - puts "\33c\e[3J" # Clears the screen and scrollback buffer. - puts universe.to_s - puts BANNER + # Use Alternate Screen (\e[?1049h) and move cursor to top left (\e[H) + # 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 + print "\e[?1049h\e[H" + print universe.to_s + print BANNER sleep(DELAY / 1000.0) end end |
