Module: Responder
- Included in:
- Fox::Canvas::ShapeCanvas, Fox::FXIrb, Fox::FXPseudoTarget, Fox::FXUndoList
- Defined in:
- lib/fox16/responder.rb
Instance Method Summary collapse
-
#addMapEntry(lo, hi, func) ⇒ Object
Add new or replace existing map entry.
-
#assocIndex(lo, hi) ⇒ Object
Look up array index of this message map entry.
-
#FXMAPFUNC(type, id, func) ⇒ Object
Define one function.
-
#FXMAPFUNCS(type, keylo, keyhi, func) ⇒ Object
Define range of functions.
-
#FXMAPTYPE(type, func) ⇒ Object
Define one function type.
-
#FXMAPTYPES(typelo, typehi, func) ⇒ Object
Define range of function types.
-
#identifier(*ids) ⇒ Object
Generates identifiers as class constants.
-
#messageMap ⇒ Object
Return the array of (selector -> func) associations.
Instance Method Details
#addMapEntry(lo, hi, func) ⇒ Object
Add new or replace existing map entry
41 42 43 44 45 46 47 48 49 |
# File 'lib/fox16/responder.rb', line 41 def addMapEntry(lo, hi, func) func = func.intern if func.is_a? String currIndex = assocIndex(lo, hi) if currIndex < 0 .push([lo, hi, func]) else [currIndex] = [lo, hi, func] end end |
#assocIndex(lo, hi) ⇒ Object
Look up array index of this message map entry
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fox16/responder.rb', line 29 def assocIndex(lo, hi) currIndex = -1 assocs = assocs.each_index do |i| if assocs[i][0] == lo && assocs[i][1] == hi currIndex = i end end currIndex end |
#FXMAPFUNC(type, id, func) ⇒ Object
Define one function
67 68 69 |
# File 'lib/fox16/responder.rb', line 67 def FXMAPFUNC(type, id, func) addMapEntry(Fox.MKUINT(id, type), Fox.MKUINT(id, type), func) end |
#FXMAPFUNCS(type, keylo, keyhi, func) ⇒ Object
Define range of functions
62 63 64 |
# File 'lib/fox16/responder.rb', line 62 def FXMAPFUNCS(type, keylo, keyhi, func) addMapEntry(Fox.MKUINT(keylo, type), Fox.MKUINT(keyhi, type), func) end |
#FXMAPTYPE(type, func) ⇒ Object
Define one function type
57 58 59 |
# File 'lib/fox16/responder.rb', line 57 def FXMAPTYPE(type, func) addMapEntry(Fox.MKUINT(Fox::MINKEY, type), Fox.MKUINT(Fox::MAXKEY, type), func) end |
#FXMAPTYPES(typelo, typehi, func) ⇒ Object
Define range of function types
52 53 54 |
# File 'lib/fox16/responder.rb', line 52 def FXMAPTYPES(typelo, typehi, func) addMapEntry(Fox.MKUINT(Fox::MINKEY, typelo), Fox.MKUINT(Fox::MAXKEY, typehi), func) end |
#identifier(*ids) ⇒ Object
Generates identifiers as class constants. Originally submitted by Sean O’Halpin, slightly modified by Lyle.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fox16/responder.rb', line 9 def identifier(*ids) ids << :ID_LAST base = self.class.superclass::ID_LAST vals = enum(base, ids.size) ids.each_index do |i| unless self.class.const_defined?(ids[i]) self.class.class_eval("#{ids[i].id2name} = #{vals[i]}") end end end |
#messageMap ⇒ Object
Return the array of (selector -> func) associations
21 22 23 24 25 26 |
# File 'lib/fox16/responder.rb', line 21 def unless instance_variables.include?("@assocs") || instance_variables.include?(:@assocs) @assocs = [] end @assocs end |