Sha256: db9e48f191f768346395fe2e3be3f796d505813f0fee2d451d54b759ab5a0e57

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

# Curses reference:
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/curses/rdoc/Curses.html

require 'curses'
include Curses

module PPCurses

  # Screen initializes the Curses screen 
  # Pass a code block to the run method to start things
  #
  # noinspection RubyResolve
  class Screen

    # Creates a curses session
    #
    # Example:
    #   >> myScreen.run { displayMenu() }
    #
    def run
      begin
        init_screen
        Curses.raw
        clear
        curs_set(0) # Makes cursor invisible
        noecho
        cbreak
        start_color
      
        yield 
        
      rescue SystemExit, Interrupt
        # Empty Catch block so ruby doesn't puke out
        # a stack trace when CTRL-C is used
      ensure
        close_screen
      end
    end 

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ppcurses-0.0.25 lib/ppcurses/Screen.rb
ppcurses-0.0.24 lib/ppcurses/Screen.rb
ppcurses-0.0.23 lib/ppcurses/Screen.rb
ppcurses-0.0.22 lib/ppcurses/Screen.rb