ext/curses/hello.rb


DEFINITIONS

This source file includes following functions.


   1  #!/usr/local/bin/ruby
   2  
   3  require "curses"
   4  include Curses
   5  
   6  def 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
  16  end
  17  
  18  init_screen
  19  begin
  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
  28  ensure
  29    close_screen
  30  end