Class: PPCurses::Screen
- Inherits:
-
Object
- Object
- PPCurses::Screen
- Defined in:
- lib/ppcurses/Screen.rb
Overview
Screen initializes the Curses screen Pass a code block to the run method to start things
noinspection RubyResolve
Instance Method Summary collapse
- #addstr(string) ⇒ Object
- #attroff(attributes) ⇒ Object
- #attron(attributes) ⇒ Object
- #clrtoeol ⇒ Object
- #cur_point ⇒ Object
- #curs_set(value) ⇒ Object
- #get_ch ⇒ Object
- #getch ⇒ Object
- #height ⇒ Object
- #print_with_attribute(toPrint, attribute) ⇒ Object
-
#run ⇒ Object
Creates a curses session.
- #set_pos_by_point(p) ⇒ Object
- #setpos(y, x) ⇒ Object
- #setup_curses ⇒ Object
- #shutdown_curses ⇒ Object
- #width ⇒ Object
Instance Method Details
#addstr(string) ⇒ Object
117 118 119 |
# File 'lib/ppcurses/Screen.rb', line 117 def addstr(string) Curses.stdscr.addstr(string) end |
#attroff(attributes) ⇒ Object
113 114 115 |
# File 'lib/ppcurses/Screen.rb', line 113 def attroff(attributes) Curses.stdscr.attroff(attributes) end |
#attron(attributes) ⇒ Object
109 110 111 |
# File 'lib/ppcurses/Screen.rb', line 109 def attron(attributes) Curses.stdscr.attron(attributes) end |
#clrtoeol ⇒ Object
105 106 107 |
# File 'lib/ppcurses/Screen.rb', line 105 def clrtoeol Curses.stdscr.clrtoeol end |
#cur_point ⇒ Object
125 126 127 |
# File 'lib/ppcurses/Screen.rb', line 125 def cur_point PPCurses::Point.new(Curses.stdscr.curx, Curses.stdscr.cury) end |
#curs_set(value) ⇒ Object
129 130 131 |
# File 'lib/ppcurses/Screen.rb', line 129 def curs_set(value) Curses.curs_set(value) end |
#get_ch ⇒ Object
85 86 87 |
# File 'lib/ppcurses/Screen.rb', line 85 def get_ch Curses.stdscr.getch end |
#getch ⇒ Object
121 122 123 |
# File 'lib/ppcurses/Screen.rb', line 121 def getch Curses.stdscr.getch end |
#height ⇒ Object
93 94 95 |
# File 'lib/ppcurses/Screen.rb', line 93 def height Curses.lines end |
#print_with_attribute(toPrint, attribute) ⇒ Object
79 80 81 82 83 |
# File 'lib/ppcurses/Screen.rb', line 79 def print_with_attribute( toPrint, attribute ) Curses.stdscr.attron( attribute ) Curses.stdscr.addstr( toPrint ) Curses.stdscr.attroff( attribute ) end |
#run ⇒ Object
Creates a curses session
Example:
>> myScreen.run { displayMenu() }
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# 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) ⇒ Object
97 98 99 |
# File 'lib/ppcurses/Screen.rb', line 97 def set_pos_by_point( p ) setpos(p.y, p.x) end |
#setpos(y, x) ⇒ Object
101 102 103 |
# File 'lib/ppcurses/Screen.rb', line 101 def setpos(y, x) Curses.stdscr.setpos(y, x) end |
#setup_curses ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# 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 ⇒ Object
134 135 136 |
# File 'lib/ppcurses/Screen.rb', line 134 def shutdown_curses Curses.close_screen end |
#width ⇒ Object
89 90 91 |
# File 'lib/ppcurses/Screen.rb', line 89 def width Curses.cols end |