Created
January 2, 2019 15:55
-
-
Save Freaky/2735f7bc14dd9c832b49911da29e6834 to your computer and use it in GitHub Desktop.
Print crap before readline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'readline' | |
run = true | |
puts | |
worker = Thread.new do | |
i = 0 | |
while run | |
STDOUT.print("\e[s\r\e[A\e[KMoo moo baa #{i += 1}\n\e[u"); | |
sleep 1 | |
end | |
end | |
out = Readline.readline("Moo: ") | |
run = false | |
worker.join | |
puts "Read: #{out.inspect}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment