1#!/usr/local/bin/ruby 2 3require "curses" 4include Curses 5 6def show_message(message) 7 width = message.length + 6 8 win = Window.new(5, width, 9 (lines - 5) / 2, (cols - width) / 2) 10 win.box(?|, ?-) 11 win.setpos(2, 3) 12 win.addstr(message) 13 win.refresh 14 win.getch 15 win.close 16end 17 18init_screen 19begin 20 crmode 21# show_message("Hit any key") 22 setpos((lines - 5) / 2, (cols - 10) / 2) 23 addstr("Hit any key") 24 refresh 25 getch 26 show_message("Hello, World!") 27 refresh 28ensure 29 close_screen 30end 31