class PPCurses::Screen

Screen initializes the Curses screen Pass a code block to the run method to start things

noinspection RubyResolve

Constants

ESCDELAY

Public Instance Methods

addstr(string) click to toggle source
# File lib/ppcurses/Screen.rb, line 117
def addstr(string)
  Curses.stdscr.addstr(string)
end
attroff(attributes) click to toggle source
# File lib/ppcurses/Screen.rb, line 113
def attroff(attributes)
  Curses.stdscr.attroff(attributes)
end
attron(attributes) click to toggle source
# File lib/ppcurses/Screen.rb, line 109
def attron(attributes)
  Curses.stdscr.attron(attributes)
end
clrtoeol() click to toggle source
# File lib/ppcurses/Screen.rb, line 105
def clrtoeol
  Curses.stdscr.clrtoeol
end
cur_point() click to toggle source
# File lib/ppcurses/Screen.rb, line 125
def cur_point
  PPCurses::Point.new(Curses.stdscr.curx, Curses.stdscr.cury)
end
curs_set(value) click to toggle source
# File lib/ppcurses/Screen.rb, line 129
def curs_set(value)
  Curses.curs_set(value)
end
get_ch() click to toggle source
# File lib/ppcurses/Screen.rb, line 85
def get_ch
  Curses.stdscr.getch
end
getch() click to toggle source
# File lib/ppcurses/Screen.rb, line 121
def getch
  Curses.stdscr.getch
end
height() click to toggle source
# File lib/ppcurses/Screen.rb, line 93
def height
  Curses.lines
end
print_with_attribute( toPrint, attribute ) click to toggle source
run() { || ... } click to toggle source

Creates a curses session

Example:

>> myScreen.run { displayMenu() }
# File lib/ppcurses/Screen.rb, line 143
def run
  begin
    setup_curses

    return yield
    
  rescue SystemExit, Interrupt
    # Empty Catch block so ruby doesn't puke out
    # a stack trace when CTRL-C is used
  ensure
     shutdown_curses
  end
end
set_pos_by_point( p ) click to toggle source
# File lib/ppcurses/Screen.rb, line 97
def set_pos_by_point( p )
  setpos(p.y, p.x)
end
setpos(y, x) click to toggle source
# File lib/ppcurses/Screen.rb, line 101
def setpos(y, x)
  Curses.stdscr.setpos(y, x)
end
setup_curses() click to toggle source
# File lib/ppcurses/Screen.rb, line 57
def setup_curses
  Curses.init_screen
  Curses.raw

  # Can't implement regardless as this can cause an unsupportedOperationException on some configurations
  #  like cygwin.
  if OS.unix?
    Curses.ESCDELAY=0
  end


  #  Otherwise arrow keys, etc can't be read from the main screen and cause the
  #  program to stop.
  Curses.stdscr.keypad(true)

  Curses.clear
  Curses.curs_set(INVISIBLE)
  Curses.noecho
  Curses.cbreak
  Curses.start_color
end
shutdown_curses() click to toggle source
# File lib/ppcurses/Screen.rb, line 134
def shutdown_curses
  Curses.close_screen
end
width() click to toggle source
# File lib/ppcurses/Screen.rb, line 89
def width
  Curses.cols
end