Class: Ncurses::FFIWINDOW
Overview
This is a window pointer wrapper, to be used for stdscr and others. Ideally ffi-ncurses should do this, if it returns a pointer, I’ll do this.
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Instance Method Summary collapse
- #del ⇒ Object (also: #delete)
-
#initialize(*args, &block) ⇒ FFIWINDOW
constructor
A new instance of FFIWINDOW.
- #method_missing(name, *args) ⇒ Object
- #respond_to?(name) ⇒ Boolean
Constructor Details
#initialize(*args, &block) ⇒ FFIWINDOW
Returns a new instance of FFIWINDOW.
182 183 184 185 186 187 188 |
# File 'lib/canis/core/system/ncurses.rb', line 182 def initialize(*args, &block) if block_given? @pointer = args.first else @pointer = FFI::NCurses.newwin(*args) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/canis/core/system/ncurses.rb', line 189 def method_missing(name, *args) name = name.to_s if (name[0,2] == "mv") test_name = name.dup test_name[2,0] = "w" # insert "w" after"mv" if (FFI::NCurses.respond_to?(test_name)) return FFI::NCurses.send(test_name, @pointer, *args) end end test_name = "w" + name if (FFI::NCurses.respond_to?(test_name)) return FFI::NCurses.send(test_name, @pointer, *args) end FFI::NCurses.send(name, @pointer, *args) end |
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
181 182 183 |
# File 'lib/canis/core/system/ncurses.rb', line 181 def pointer @pointer end |
Instance Method Details
#del ⇒ Object Also known as: delete
211 212 213 |
# File 'lib/canis/core/system/ncurses.rb', line 211 def del FFI::NCurses.delwin(@pointer) end |
#respond_to?(name) ⇒ Boolean
204 205 206 207 208 209 210 |
# File 'lib/canis/core/system/ncurses.rb', line 204 def respond_to?(name) name = name.to_s if (name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1])) return true end FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name) end |