Module: Ncurses
- Defined in:
- lib/sup/colormap.rb,
lib/sup/util/ncurses.rb
Defined Under Namespace
Modules: Form Classes: CharCode
Constant Summary collapse
- COLOR_DEFAULT =
-1
- NUM_COLORS =
`tput colors`.to_i
- MAX_PAIRS =
`tput pairs`.to_i
- KEY_ENTER =
10
- KEY_CANCEL =
ctrl-g
7
- KEY_TAB =
9
Class Method Summary collapse
- .color!(name, value) ⇒ Object
- .cols ⇒ Object
- .curx ⇒ Object
- .mutex ⇒ Object
-
.prepare_form_driver ⇒ Object
Create replacement wrapper for form_driver_w (), which is not (yet) a standard function in ncurses.
-
.rows ⇒ Object
class CharCode.
- .sync(&b) ⇒ Object
Instance Method Summary collapse
-
#x ⇒ Object
xterm 24-shade grayscale.
Class Method Details
.color!(name, value) ⇒ Object
7 8 9 |
# File 'lib/sup/colormap.rb', line 7 def self.color! name, value const_set "COLOR_#{name.to_s.upcase}", value end |
.cols ⇒ Object
186 187 188 189 190 |
# File 'lib/sup/util/ncurses.rb', line 186 def cols lame, lamer = [], [] stdscr.getmaxyx lame, lamer lamer.first end |
.curx ⇒ Object
192 193 194 195 196 |
# File 'lib/sup/util/ncurses.rb', line 192 def curx lame, lamer = [], [] stdscr.getyx lame, lamer lamer.first end |
.mutex ⇒ Object
237 |
# File 'lib/sup/util/ncurses.rb', line 237 def mutex; @mutex ||= Mutex.new; end |
.prepare_form_driver ⇒ Object
Create replacement wrapper for form_driver_w (), which is not (yet) a standard function in ncurses. Some systems (Mac OS X) does not have a working form_driver that accepts wide chars. We are just falling back to form_driver, expect problems.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/sup/util/ncurses.rb', line 201 def prepare_form_driver if not defined? Form.form_driver_w warn "Your Ncursesw does not have a form_driver_w function (wide char aware), " \ "non-ASCII chars may not work on your system." Form.module_eval <<-FRM_DRV, __FILE__, __LINE__ + 1 def form_driver_w form, status, c form_driver form, c end module_function :form_driver_w module DriverHelpers def form_driver c if !c.dumb? && c.printable? c.each_byte do |code| Ncurses::Form.form_driver @form, code end else Ncurses::Form.form_driver @form, c.code end end end FRM_DRV end # if not defined? Form.form_driver_w if not defined? Ncurses.get_wch warn "Your Ncursesw does not have a get_wch function (wide char aware), " \ "non-ASCII chars may not work on your system." Ncurses.module_eval <<-GET_WCH, __FILE__, __LINE__ + 1 def get_wch c = getch c == Ncurses::ERR ? [c, 0] : [Ncurses::OK, c] end module_function :get_wch GET_WCH CharCode.dumb! end # if not defined? Ncurses.get_wch end |
.rows ⇒ Object
class CharCode
180 181 182 183 184 |
# File 'lib/sup/util/ncurses.rb', line 180 def rows lame, lamer = [], [] stdscr.getmaxyx lame, lamer lame.first end |
.sync(&b) ⇒ Object
238 |
# File 'lib/sup/util/ncurses.rb', line 238 def sync &b; mutex.synchronize(&b); end |
Instance Method Details
#x ⇒ Object
xterm 24-shade grayscale
12 |
# File 'lib/sup/colormap.rb', line 12 Ncurses::NUM_COLORS.times { |x| color! x, x } |