Last active
December 11, 2015 18:21
-
-
Save spraints/985c95ee839d66157c40 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def main | |
message = "THIS IS IMPORTANT" | |
red_message = color(31, message) | |
puts "", red_message, "" | |
10.times do | |
print restore_pos(up_line(2) + erase_line) | |
sleep 0.5 | |
print restore_pos(up_line(2) + red_message) | |
sleep 0.5 | |
end | |
end | |
def color(code, str) | |
csi("#{code}m") + str + csi("0m") | |
end | |
def restore_pos(str) | |
csi("s") + str + csi("u") | |
end | |
def up_line(n) | |
csi("#{n}F") | |
end | |
def erase_line | |
csi("K") | |
end | |
def csi(x) | |
"\e[#{x}" | |
end | |
trap(:INT) { exit } | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment