Skip to content

Instantly share code, notes, and snippets.

@pricees
Created November 25, 2012 20:43
Show Gist options
  • Select an option

  • Save pricees/4145263 to your computer and use it in GitHub Desktop.

Select an option

Save pricees/4145263 to your computer and use it in GitHub Desktop.
Curses Part 2-3: Multiple windows
#!/usr/local/bin/ruby
require "curses"
begin
Curses.init_screen # bring it
line = nil
win = Curses::Window.new(5, 50, 10, 10)
wout = Curses::Window.new(5, 50, 20, 10)
begin
win.clear
win.box("|", "-")
win.setpos(2, 2)
win.addstr("Print a string ('quit' to quit):")
win.refresh
# Print line
if line
wout.clear
wout.box("|", "-")
wout.setpos(2, 2)
wout.addstr(%|You Typed: "#{line}"|)
wout.refresh
end
# Return cursor
win.setpos(3,2)
end while (line = win.getstr) != "quit"
win.close
ensure
Curses.close_screen
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment