Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
Created June 4, 2013 03:29
Show Gist options
  • Save stevenocchipinti/5703381 to your computer and use it in GitHub Desktop.
Save stevenocchipinti/5703381 to your computer and use it in GitHub Desktop.
Simple example of using Curses (built in to the ruby stdlib)
#!/usr/local/bin/ruby
require "curses"
include Curses
begin
init_screen
crmode
x = 0
y = 0
setpos(x, y)
addstr("Hit any key")
refresh
getch
setpos(x, y+12)
addstr("... AGAIN!")
refresh
getch
ensure
close_screen
end
@stevenocchipinti
Copy link
Author

Curses clears the screen

These characters move the cursor up and clear the line:

print "\x1B[1A\x1B[2K" # move up and clear
print "\x1B[1A" # move up

These characters were found in the KarmaJS source (thanks Seb)

This article may be useful:
http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-6.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment