sugarcube 2.12.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/all/sugarcube-repl/repl.rb +191 -0
- data/lib/all/sugarcube/log.rb +2 -2
- data/lib/android/sugarcube-repl/repl.rb +42 -0
- data/lib/android/sugarcube/log.rb +8 -0
- data/lib/cocoa/sugarcube-repl/repl.rb +48 -214
- data/lib/cocoa/sugarcube/log.rb +1 -1
- data/lib/ios/sugarcube-568/uiimage.rb +3 -0
- data/lib/ios/sugarcube-repl/repl.rb +27 -30
- data/lib/osx/sugarcube-repl/repl.rb +14 -25
- data/lib/sugarcube-568.rb +2 -9
- data/lib/sugarcube-animations.rb +2 -12
- data/lib/sugarcube-anonymous.rb +2 -9
- data/lib/sugarcube-appkit.rb +3 -12
- data/lib/sugarcube-attributedstring.rb +3 -12
- data/lib/sugarcube-awesome.rb +2 -9
- data/lib/sugarcube-color.rb +2 -9
- data/lib/sugarcube-constants.rb +2 -9
- data/lib/sugarcube-coregraphics.rb +3 -9
- data/lib/sugarcube-corelocation.rb +6 -9
- data/lib/sugarcube-events.rb +2 -9
- data/lib/sugarcube-factories.rb +2 -9
- data/lib/sugarcube-files.rb +2 -9
- data/lib/sugarcube-foundation.rb +3 -9
- data/lib/sugarcube-gestures.rb +2 -9
- data/lib/sugarcube-image.rb +2 -9
- data/lib/sugarcube-indexpath.rb +2 -9
- data/lib/sugarcube-legacy.rb +2 -18
- data/lib/sugarcube-localized.rb +2 -9
- data/lib/sugarcube-modal.rb +2 -9
- data/lib/sugarcube-notifications.rb +2 -9
- data/lib/sugarcube-nscoder.rb +3 -9
- data/lib/sugarcube-nsdata.rb +3 -12
- data/lib/sugarcube-nsdate.rb +3 -14
- data/lib/sugarcube-nsuserdefaults.rb +3 -9
- data/lib/sugarcube-numbers.rb +2 -15
- data/lib/sugarcube-pipes.rb +2 -9
- data/lib/sugarcube-pointer.rb +2 -9
- data/lib/sugarcube-repl.rb +2 -16
- data/lib/sugarcube-spritekit.rb +6 -12
- data/lib/sugarcube-timer.rb +2 -14
- data/lib/sugarcube-to_s.rb +2 -15
- data/lib/sugarcube-uikit.rb +3 -12
- data/lib/sugarcube-unholy.rb +2 -9
- data/lib/sugarcube.rb +33 -19
- data/lib/sugarcube_pre_setup.rb +44 -0
- data/lib/version.rb +1 -1
- data/spec/cocoa/nsindexpath_spec.rb +12 -0
- metadata +9 -6
- data/lib/ios/sugarcube/sugarcube_cleanup.rb +0 -16
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: af8ff35d025712022d4072681b4e992bbdf35933
         | 
| 4 | 
            +
              data.tar.gz: fa3313ebe914b87fc53dba1fefbbe7850b15f1c9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 356bcc1d1b071d764f689f12a0b451e51923af1c45c58862c6a9bddff0fbec2b2c5ab9b4101dc9e2647ed35a3fcf714aab2faf45ac3b55626edca5ad498f2c2c
         | 
| 7 | 
            +
              data.tar.gz: 3ebd09a8e365620ba204ed78ae0cc0f35c0af051b9f949cf095e407ff7b9bcec3cf72ba1dfd69eca62013b2ab369cf7382df367137f0e422e1f9f4b09f04746f
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1658,9 +1658,9 @@ Open up `CLLocationCoordinate2D` to provide handy-dandies | |
| 1658 1658 | 
             
            ```ruby
         | 
| 1659 1659 | 
             
            # distances
         | 
| 1660 1660 |  | 
| 1661 | 
            -
            > denver_co = CLLocationCoordinate2D.new(39.739188 | 
| 1661 | 
            +
            > denver_co = CLLocationCoordinate2D.new(39.739188, -104.985223)
         | 
| 1662 1662 | 
             
            => #<CLLocationCoordinate2D latitude=39.7391815185547 longitude=-104.985198974609>
         | 
| 1663 | 
            -
            > loveland_oh = CLLocationCoordinate2D.new(39.268128 | 
| 1663 | 
            +
            > loveland_oh = CLLocationCoordinate2D.new(39.268128, -84.257648)
         | 
| 1664 1664 | 
             
            => #<CLLocationCoordinate2D latitude=39.2681274414062 longitude=-84.2576293945312>
         | 
| 1665 1665 | 
             
            > denver_co.distance_to(loveland_oh)
         | 
| 1666 1666 | 
             
            => 1773425.54893302  # in meters
         | 
| @@ -0,0 +1,191 @@ | |
| 1 | 
            +
            module SugarCube
         | 
| 2 | 
            +
              class Repl
         | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  @adjust_item = nil
         | 
| 6 | 
            +
                  @tree_items = nil
         | 
| 7 | 
            +
                  @collapsed_items = nil
         | 
| 8 | 
            +
                  @restore = nil
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def adjust(item=nil)
         | 
| 11 | 
            +
                    return @adjust_item unless item
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                    if item.is_a? Fixnum
         | 
| 14 | 
            +
                      @tree_items ||= build_default_tree
         | 
| 15 | 
            +
                      item = @tree_items[item]
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    # a/adjust will return this object
         | 
| 19 | 
            +
                    @adjust_item = item
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    adjust_init(item)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    item
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def collapse(item)
         | 
| 27 | 
            +
                    if item.is_a? Fixnum
         | 
| 28 | 
            +
                      @tree_items ||= build_default_tree
         | 
| 29 | 
            +
                      item = @tree_items[item]
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    @collapsed_items ||= []
         | 
| 33 | 
            +
                    if @collapsed_items.include?(item)
         | 
| 34 | 
            +
                      @collapsed_items.delete(item)
         | 
| 35 | 
            +
                    else
         | 
| 36 | 
            +
                      @collapsed_items << item
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    retval = tree
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                    if @collapsed_items
         | 
| 42 | 
            +
                      @collapsed_items.keep_if { |v| @tree_items.include? v }
         | 
| 43 | 
            +
                    end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                    retval
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def set_default(item)
         | 
| 49 | 
            +
                    @default = item
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  def clear_default
         | 
| 53 | 
            +
                    @default = nil
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  def register_tree_selector(klass, selector=nil, &sel_blk)
         | 
| 57 | 
            +
                    if selector && sel_blk
         | 
| 58 | 
            +
                      raise "You can't hand me a block AND a selector.  I don't know what to do with both!"
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
                    tree_selectors[klass] = selector || sel_blk
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  def tree_selectors(klass=nil)
         | 
| 64 | 
            +
                    if ! @tree_selectors
         | 
| 65 | 
            +
                      @tree_selectors ||= {}
         | 
| 66 | 
            +
                      @tree_selectors[nil.class] = -> (foo) { nil }
         | 
| 67 | 
            +
                      register_default_tree_selectors
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    if klass
         | 
| 71 | 
            +
                      @tree_selectors[klass]
         | 
| 72 | 
            +
                    else
         | 
| 73 | 
            +
                      @tree_selectors
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  # @param item this can be a tree-like item (View, ViewController, CALayer,
         | 
| 78 | 
            +
                  #     Menu) or an integer, in which case it will select that window.  Defalt
         | 
| 79 | 
            +
                  #     is to display the keyWindow
         | 
| 80 | 
            +
                  # @param selector If you pass an unsupported object to tree, you will need
         | 
| 81 | 
            +
                  #     to pass a selector as well - this method should return an array of
         | 
| 82 | 
            +
                  #     items which are passed recursively to tree
         | 
| 83 | 
            +
                  # @block sel_blk If a block is passed, it will be used to build the array of
         | 
| 84 | 
            +
                  #     items that are called recursively
         | 
| 85 | 
            +
                  def tree(item=nil, selector=nil, &sel_blk)
         | 
| 86 | 
            +
                    item = get_tree_item(item)
         | 
| 87 | 
            +
                    if selector || sel_blk
         | 
| 88 | 
            +
                      register_tree_selector(item.class, selector, &sel_blk)
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                    @tree_items = build_tree(item)
         | 
| 92 | 
            +
                    if @collapsed_items
         | 
| 93 | 
            +
                      @collapsed_items.keep_if { |v| @tree_items.include? v }
         | 
| 94 | 
            +
                    end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                    draw_tree(item)
         | 
| 97 | 
            +
                    puts ''
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                    return item
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  def draw_tree(item, tab=nil, is_last=true, items_index=0)
         | 
| 103 | 
            +
                    space = ' '
         | 
| 104 | 
            +
                    if items_index < 10
         | 
| 105 | 
            +
                      print '  '
         | 
| 106 | 
            +
                    elsif items_index < 100
         | 
| 107 | 
            +
                      print ' '
         | 
| 108 | 
            +
                    elsif items_index > 999  # good god, man!
         | 
| 109 | 
            +
                      space = ''
         | 
| 110 | 
            +
                    end
         | 
| 111 | 
            +
                    print items_index.to_s + ":" + space
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    if tab
         | 
| 114 | 
            +
                      print tab
         | 
| 115 | 
            +
                      if @collapsed_items && @collapsed_items.include?(item)
         | 
| 116 | 
            +
                        print '<<< '
         | 
| 117 | 
            +
                      else
         | 
| 118 | 
            +
                        if is_last
         | 
| 119 | 
            +
                          print '`-- '
         | 
| 120 | 
            +
                          tab += '    '
         | 
| 121 | 
            +
                        else
         | 
| 122 | 
            +
                          print '+-- '
         | 
| 123 | 
            +
                          tab += '|   '
         | 
| 124 | 
            +
                        end
         | 
| 125 | 
            +
                      end
         | 
| 126 | 
            +
                    else
         | 
| 127 | 
            +
                      print '. '
         | 
| 128 | 
            +
                      tab = ''
         | 
| 129 | 
            +
                    end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                    if self == item || @adjust_item == item
         | 
| 132 | 
            +
                      print "\033[1m"
         | 
| 133 | 
            +
                    end
         | 
| 134 | 
            +
                    print draw_tree_item(item)
         | 
| 135 | 
            +
                    if self == item || @adjust_item == item
         | 
| 136 | 
            +
                      print "\033[0m"
         | 
| 137 | 
            +
                    end
         | 
| 138 | 
            +
                    puts
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                    items = call_item_selector(item)
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    unless @collapsed_items && @collapsed_items.include?(item)
         | 
| 143 | 
            +
                      items.each_with_index do |subitem, index|
         | 
| 144 | 
            +
                        items_index += 1
         | 
| 145 | 
            +
                        if self.respond_to? :draw_tree
         | 
| 146 | 
            +
                          items_index = draw_tree(subitem, tab, index == items.length - 1, items_index)
         | 
| 147 | 
            +
                        else
         | 
| 148 | 
            +
                          items_index = draw_tree(subitem, tab, index == items.length - 1, items_index)
         | 
| 149 | 
            +
                        end
         | 
| 150 | 
            +
                      end
         | 
| 151 | 
            +
                    end
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                    return items_index
         | 
| 154 | 
            +
                  end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                  def build_tree(item)
         | 
| 157 | 
            +
                    items = call_item_selector(item)
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    ret = [item]
         | 
| 160 | 
            +
                    return ret if @collapsed_items && @collapsed_items.include?(item)
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                    items.each_with_index do |subitem, index|
         | 
| 163 | 
            +
                      ret.concat build_tree(subitem)
         | 
| 164 | 
            +
                    end
         | 
| 165 | 
            +
                    ret
         | 
| 166 | 
            +
                  end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                  def call_item_selector(item)
         | 
| 169 | 
            +
                    selector = nil
         | 
| 170 | 
            +
                    klass = item.class
         | 
| 171 | 
            +
                    while klass && !selector
         | 
| 172 | 
            +
                      selector = tree_selectors(klass)
         | 
| 173 | 
            +
                      klass = klass.superclass
         | 
| 174 | 
            +
                    end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                    if !selector
         | 
| 177 | 
            +
                      raise "Unable to determine a SugarCube::Repl::tree selector for #{item.class.to_s}"
         | 
| 178 | 
            +
                    end
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                    if selector.is_a? Proc
         | 
| 181 | 
            +
                      items = selector.call(item)
         | 
| 182 | 
            +
                    else
         | 
| 183 | 
            +
                      items = item.send(selector)
         | 
| 184 | 
            +
                    end
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                    return items || []
         | 
| 187 | 
            +
                  end
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                end
         | 
| 190 | 
            +
              end
         | 
| 191 | 
            +
            end
         | 
    
        data/lib/all/sugarcube/log.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ module SugarCube | |
| 11 11 | 
             
                if suppress?
         | 
| 12 12 | 
             
                  log << message
         | 
| 13 13 | 
             
                elsif log?
         | 
| 14 | 
            -
                  stderr(message)
         | 
| 14 | 
            +
                  SugarCube.stderr(message)
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                self
         | 
| @@ -25,7 +25,7 @@ module SugarCube | |
| 25 25 | 
             
                  output << "\n"
         | 
| 26 26 | 
             
                  output << message
         | 
| 27 27 | 
             
                end
         | 
| 28 | 
            -
                 | 
| 28 | 
            +
                SugarCube.stderr(output)
         | 
| 29 29 | 
             
                @log = nil
         | 
| 30 30 | 
             
              end
         | 
| 31 31 |  | 
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            module SugarCube
         | 
| 2 | 
            +
              class << Repl
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def build_default_tree
         | 
| 5 | 
            +
                  build_tree(@default)
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def adjust_init(item)
         | 
| 9 | 
            +
                  if item.is_a?(Android::View)
         | 
| 10 | 
            +
                    @restore = {}
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def register_default_tree_selectors
         | 
| 15 | 
            +
                  register_tree_selector(Android::ViewLayout) do |view|
         | 
| 16 | 
            +
                    views = []
         | 
| 17 | 
            +
                    item.getChildCount.times do |index|
         | 
| 18 | 
            +
                      views << item.getChildAt(index)
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                    views
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                  register_tree_selector(Android::View) { |view| [view] }
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def draw_tree_item(item)
         | 
| 26 | 
            +
                  item.to_s
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def get_tree_item(item)
         | 
| 30 | 
            +
                  if item.nil?
         | 
| 31 | 
            +
                    @default
         | 
| 32 | 
            +
                  else
         | 
| 33 | 
            +
                    item
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def format_frame(frame)
         | 
| 38 | 
            +
                  "[[#{frame.origin.x}, #{frame.origin.y}], [#{frame.size.width}, #{frame.size.height}]]"
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
| @@ -1,63 +1,23 @@ | |
| 1 1 | 
             
            module SugarCube
         | 
| 2 | 
            -
               | 
| 3 | 
            -
                module_function
         | 
| 2 | 
            +
              class << Repl
         | 
| 4 3 |  | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
                @sugarcube_collapsed_items = nil
         | 
| 8 | 
            -
                @sugarcube_restore = nil
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def adjust(view=nil)
         | 
| 11 | 
            -
                  return @sugarcube_view unless view
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  if view.is_a? Fixnum
         | 
| 14 | 
            -
                    @sugarcube_items ||= SugarCube::Repl::build_tree(window, :subviews)
         | 
| 15 | 
            -
                    view = @sugarcube_items[view]
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                  # a/adjust will return this object
         | 
| 19 | 
            -
                  @sugarcube_view = view
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  adjust_init(view)
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                  view
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
                alias a adjust
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                def collapse(view)
         | 
| 28 | 
            -
                  if view.is_a? Fixnum
         | 
| 29 | 
            -
                    @sugarcube_items ||= SugarCube::Repl::build_tree(window, :subviews)
         | 
| 30 | 
            -
                    view = @sugarcube_items[view]
         | 
| 31 | 
            -
                  end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  @sugarcube_collapsed_items ||= []
         | 
| 34 | 
            -
                  if @sugarcube_collapsed_items.include?(view)
         | 
| 35 | 
            -
                    @sugarcube_collapsed_items.delete(view)
         | 
| 36 | 
            -
                  else
         | 
| 37 | 
            -
                    @sugarcube_collapsed_items << view
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  retval = tree
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  if @sugarcube_collapsed_items
         | 
| 43 | 
            -
                    @sugarcube_collapsed_items.keep_if { |v| @sugarcube_items.include? v }
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  retval
         | 
| 4 | 
            +
                def build_default_tree
         | 
| 5 | 
            +
                  build_tree(window)
         | 
| 47 6 | 
             
                end
         | 
| 48 | 
            -
                alias coll collapse
         | 
| 49 7 |  | 
| 50 8 | 
             
                ##|  FRAME
         | 
| 51 9 | 
             
                def frame(f=nil)
         | 
| 52 10 | 
             
                  return unless check_sugarcube_view
         | 
| 53 11 |  | 
| 54 | 
            -
                  return @ | 
| 12 | 
            +
                  return @adjust_item.frame unless f
         | 
| 55 13 |  | 
| 56 | 
            -
                   | 
| 57 | 
            -
             | 
| 14 | 
            +
                  if defined?(SugarCube::CoreGraphics)
         | 
| 15 | 
            +
                    f = SugarCube::CoreGraphics::Rect(f)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                  @adjust_item.frame = f
         | 
| 58 18 | 
             
                  puts format_frame(f)
         | 
| 59 19 |  | 
| 60 | 
            -
                  @ | 
| 20 | 
            +
                  @adjust_item
         | 
| 61 21 | 
             
                end
         | 
| 62 22 | 
             
                alias f frame
         | 
| 63 23 |  | 
| @@ -70,12 +30,12 @@ module SugarCube | |
| 70 30 | 
             
                def right(val=1)
         | 
| 71 31 | 
             
                  return unless check_sugarcube_view
         | 
| 72 32 |  | 
| 73 | 
            -
                  f = @ | 
| 33 | 
            +
                  f = @adjust_item.frame
         | 
| 74 34 | 
             
                  f.origin.x += val
         | 
| 75 | 
            -
                  @ | 
| 35 | 
            +
                  @adjust_item.frame = f
         | 
| 76 36 | 
             
                  puts format_frame(f)
         | 
| 77 37 |  | 
| 78 | 
            -
                  @ | 
| 38 | 
            +
                  @adjust_item
         | 
| 79 39 | 
             
                end
         | 
| 80 40 | 
             
                alias r right
         | 
| 81 41 |  | 
| @@ -87,31 +47,35 @@ module SugarCube | |
| 87 47 | 
             
                def down(val=1)
         | 
| 88 48 | 
             
                  return unless check_sugarcube_view
         | 
| 89 49 |  | 
| 90 | 
            -
                  f = @ | 
| 50 | 
            +
                  f = @adjust_item.frame
         | 
| 91 51 | 
             
                  f.origin.y += val
         | 
| 92 | 
            -
                  @ | 
| 52 | 
            +
                  @adjust_item.frame = f
         | 
| 93 53 | 
             
                  puts format_frame(f)
         | 
| 94 54 |  | 
| 95 | 
            -
                  @ | 
| 55 | 
            +
                  @adjust_item
         | 
| 96 56 | 
             
                end
         | 
| 97 57 | 
             
                alias d down
         | 
| 98 58 |  | 
| 99 59 | 
             
                def origin x=nil, y=nil
         | 
| 100 60 | 
             
                  return unless check_sugarcube_view
         | 
| 101 61 |  | 
| 102 | 
            -
                  f = @ | 
| 62 | 
            +
                  f = @adjust_item.frame
         | 
| 103 63 | 
             
                  return f.origin unless x
         | 
| 104 64 |  | 
| 105 65 | 
             
                  if y
         | 
| 106 66 | 
             
                    f.origin.x = x
         | 
| 107 67 | 
             
                    f.origin.y = y
         | 
| 108 68 | 
             
                  else
         | 
| 109 | 
            -
                     | 
| 69 | 
            +
                    if defined?(SugarCube::CoreGraphics)
         | 
| 70 | 
            +
                      f.origin = SugarCube::CoreGraphics::Point(x)
         | 
| 71 | 
            +
                    else
         | 
| 72 | 
            +
                      f.origin = x
         | 
| 73 | 
            +
                    end
         | 
| 110 74 | 
             
                  end
         | 
| 111 | 
            -
                  @ | 
| 75 | 
            +
                  @adjust_item.frame = f
         | 
| 112 76 | 
             
                  puts format_frame(f)
         | 
| 113 77 |  | 
| 114 | 
            -
                  @ | 
| 78 | 
            +
                  @adjust_item
         | 
| 115 79 | 
             
                end
         | 
| 116 80 | 
             
                alias o origin
         | 
| 117 81 |  | 
| @@ -124,12 +88,12 @@ module SugarCube | |
| 124 88 | 
             
                def wider(val=1)
         | 
| 125 89 | 
             
                  return unless check_sugarcube_view
         | 
| 126 90 |  | 
| 127 | 
            -
                  f = @ | 
| 91 | 
            +
                  f = @adjust_item.frame
         | 
| 128 92 | 
             
                  f.size.width += val
         | 
| 129 | 
            -
                  @ | 
| 93 | 
            +
                  @adjust_item.frame = f
         | 
| 130 94 | 
             
                  puts format_frame(f)
         | 
| 131 95 |  | 
| 132 | 
            -
                  @ | 
| 96 | 
            +
                  @adjust_item
         | 
| 133 97 | 
             
                end
         | 
| 134 98 | 
             
                alias w wider
         | 
| 135 99 |  | 
| @@ -141,31 +105,35 @@ module SugarCube | |
| 141 105 | 
             
                def taller(val=1)
         | 
| 142 106 | 
             
                  return unless check_sugarcube_view
         | 
| 143 107 |  | 
| 144 | 
            -
                  f = @ | 
| 108 | 
            +
                  f = @adjust_item.frame
         | 
| 145 109 | 
             
                  f.size.height += val
         | 
| 146 | 
            -
                  @ | 
| 110 | 
            +
                  @adjust_item.frame = f
         | 
| 147 111 | 
             
                  puts format_frame(f)
         | 
| 148 112 |  | 
| 149 | 
            -
                  @ | 
| 113 | 
            +
                  @adjust_item
         | 
| 150 114 | 
             
                end
         | 
| 151 115 | 
             
                alias t taller
         | 
| 152 116 |  | 
| 153 117 | 
             
                def size(w=nil, h=nil)
         | 
| 154 118 | 
             
                  return unless check_sugarcube_view
         | 
| 155 119 |  | 
| 156 | 
            -
                  f = @ | 
| 120 | 
            +
                  f = @adjust_item.frame
         | 
| 157 121 | 
             
                  return f.size unless w
         | 
| 158 122 |  | 
| 159 123 | 
             
                  if h
         | 
| 160 124 | 
             
                    f.size.width = w
         | 
| 161 125 | 
             
                    f.size.height = h
         | 
| 162 126 | 
             
                  else
         | 
| 163 | 
            -
                     | 
| 127 | 
            +
                    if defined?(SugarCube::CoreGraphics)
         | 
| 128 | 
            +
                      f.size = SugarCube::CoreGraphics::Size(w)
         | 
| 129 | 
            +
                    else
         | 
| 130 | 
            +
                      f.size = w
         | 
| 131 | 
            +
                    end
         | 
| 164 132 | 
             
                  end
         | 
| 165 | 
            -
                  @ | 
| 133 | 
            +
                  @adjust_item.frame = f
         | 
| 166 134 | 
             
                  puts format_frame(f)
         | 
| 167 135 |  | 
| 168 | 
            -
                  @ | 
| 136 | 
            +
                  @adjust_item
         | 
| 169 137 | 
             
                end
         | 
| 170 138 | 
             
                alias z size
         | 
| 171 139 |  | 
| @@ -173,7 +141,7 @@ module SugarCube | |
| 173 141 | 
             
                def restore
         | 
| 174 142 | 
             
                  return unless check_sugarcube_view
         | 
| 175 143 |  | 
| 176 | 
            -
                  @ | 
| 144 | 
            +
                  @restore.each do |msg, value|
         | 
| 177 145 | 
             
                    SugarCube::Repl.send(msg, value)
         | 
| 178 146 | 
             
                  end
         | 
| 179 147 | 
             
                end
         | 
| @@ -203,7 +171,7 @@ module SugarCube | |
| 203 171 | 
             
                  element = 1 unless element
         | 
| 204 172 | 
             
                  total = 1 unless total
         | 
| 205 173 |  | 
| 206 | 
            -
                  view = @ | 
| 174 | 
            +
                  view = @adjust_item
         | 
| 207 175 |  | 
| 208 176 | 
             
                  left = view.origin.x
         | 
| 209 177 | 
             
                  top = view.origin.y
         | 
| @@ -223,17 +191,17 @@ module SugarCube | |
| 223 191 | 
             
                end
         | 
| 224 192 | 
             
                alias c center
         | 
| 225 193 |  | 
| 226 | 
            -
                def  | 
| 227 | 
            -
                   | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
                   | 
| 194 | 
            +
                def register_default_tree_selectors
         | 
| 195 | 
            +
                  register_tree_selector(CALayer, :sublayers)
         | 
| 196 | 
            +
                  if defined?(SKNode)
         | 
| 197 | 
            +
                    register_tree_selector(SKNode, :children)
         | 
| 198 | 
            +
                  end
         | 
| 199 | 
            +
                  register_platform_tree_selectors
         | 
| 232 200 | 
             
                end
         | 
| 233 201 |  | 
| 234 202 | 
             
                def get_tree_item(item)
         | 
| 235 | 
            -
                  if item.nil? && @ | 
| 236 | 
            -
                    @ | 
| 203 | 
            +
                  if item.nil? && @default
         | 
| 204 | 
            +
                    @default
         | 
| 237 205 | 
             
                  elsif item.nil? || item.is_a?(Fixnum)
         | 
| 238 206 | 
             
                    window(item)
         | 
| 239 207 | 
             
                  else
         | 
| @@ -241,142 +209,8 @@ module SugarCube | |
| 241 209 | 
             
                  end
         | 
| 242 210 | 
             
                end
         | 
| 243 211 |  | 
| 244 | 
            -
                # @param item this can be a tree-like item (View, ViewController, CALayer,
         | 
| 245 | 
            -
                #     Menu) or an integer, in which case it will select that window.  Defalt
         | 
| 246 | 
            -
                #     is to display the keyWindow
         | 
| 247 | 
            -
                # @param selector If you pass an unsupported object to tree, you will need
         | 
| 248 | 
            -
                #     to pass a selector as well - this method should return an array of
         | 
| 249 | 
            -
                #     items which are passed recursively to tree
         | 
| 250 | 
            -
                # @block sel_blk If a block is passed, it will be used to build the array of
         | 
| 251 | 
            -
                #     items that are called recursively
         | 
| 252 | 
            -
                def tree(item=nil, selector=nil, &sel_blk)
         | 
| 253 | 
            -
                  item = get_tree_item(item)
         | 
| 254 | 
            -
             | 
| 255 | 
            -
                  if sel_blk && selector
         | 
| 256 | 
            -
                    raise "You can't hand me a block AND a selector.  I don't know what to do with them!"
         | 
| 257 | 
            -
                  elsif sel_blk
         | 
| 258 | 
            -
                    selector = sel_blk
         | 
| 259 | 
            -
                  elsif ! selector
         | 
| 260 | 
            -
                    if item.is_a? CALayer
         | 
| 261 | 
            -
                      selector = :sublayers
         | 
| 262 | 
            -
                    elsif defined?(SKNode) && item.is_a?(SKNode)
         | 
| 263 | 
            -
                      selector = :children
         | 
| 264 | 
            -
                    else
         | 
| 265 | 
            -
                      selector = get_tree_selector(item)
         | 
| 266 | 
            -
                    end
         | 
| 267 | 
            -
             | 
| 268 | 
            -
                    if !selector && @sugarcube_tree_selectors
         | 
| 269 | 
            -
                      klass = item.class
         | 
| 270 | 
            -
                      while klass && !selector
         | 
| 271 | 
            -
                        selector = @sugarcube_tree_selectors[klass]
         | 
| 272 | 
            -
                        klass = klass.superclass
         | 
| 273 | 
            -
                      end
         | 
| 274 | 
            -
                    end
         | 
| 275 | 
            -
             | 
| 276 | 
            -
                    unless selector
         | 
| 277 | 
            -
                      raise "Unable to determine a SugarCube::Repl::tree selector for #{item.class.to_s}"
         | 
| 278 | 
            -
                    end
         | 
| 279 | 
            -
                  end
         | 
| 280 | 
            -
             | 
| 281 | 
            -
                  @sugarcube_items = SugarCube::Repl::build_tree(item, selector)
         | 
| 282 | 
            -
                  if @sugarcube_collapsed_items
         | 
| 283 | 
            -
                    @sugarcube_collapsed_items.keep_if { |v| @sugarcube_items.include? v }
         | 
| 284 | 
            -
                  end
         | 
| 285 | 
            -
                  if self.respond_to? :draw_tree
         | 
| 286 | 
            -
                    draw_tree(item, selector)
         | 
| 287 | 
            -
                  else
         | 
| 288 | 
            -
                    SugarCube::Repl::draw_tree(item, selector)
         | 
| 289 | 
            -
                  end
         | 
| 290 | 
            -
                  puts ''
         | 
| 291 | 
            -
             | 
| 292 | 
            -
                  return item
         | 
| 293 | 
            -
                end
         | 
| 294 | 
            -
             | 
| 295 | 
            -
                def register_tree_selector(klass, selector=nil, &sel_blk)
         | 
| 296 | 
            -
                  @sugarcube_tree_selectors ||= {}
         | 
| 297 | 
            -
                  @sugarcube_tree_selectors[klass] = selector || sel_blk
         | 
| 298 | 
            -
                end
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                # Draws the tree items
         | 
| 301 | 
            -
                def draw_tree(item, selector, tab=nil, is_last=true, items_index=0)
         | 
| 302 | 
            -
                  space = ' '
         | 
| 303 | 
            -
                  if items_index < 10
         | 
| 304 | 
            -
                    print '  '
         | 
| 305 | 
            -
                  elsif items_index < 100
         | 
| 306 | 
            -
                    print ' '
         | 
| 307 | 
            -
                  elsif items_index > 999  # good god, man!
         | 
| 308 | 
            -
                    space = ''
         | 
| 309 | 
            -
                  end
         | 
| 310 | 
            -
                  print items_index.to_s + ":" + space
         | 
| 311 | 
            -
             | 
| 312 | 
            -
                  if tab
         | 
| 313 | 
            -
                    print tab
         | 
| 314 | 
            -
                    if @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
         | 
| 315 | 
            -
                      print '<<< '
         | 
| 316 | 
            -
                    else
         | 
| 317 | 
            -
                      if is_last
         | 
| 318 | 
            -
                        print '`-- '
         | 
| 319 | 
            -
                        tab += '    '
         | 
| 320 | 
            -
                      else
         | 
| 321 | 
            -
                        print '+-- '
         | 
| 322 | 
            -
                        tab += '|   '
         | 
| 323 | 
            -
                      end
         | 
| 324 | 
            -
                    end
         | 
| 325 | 
            -
                  else
         | 
| 326 | 
            -
                    print '. '
         | 
| 327 | 
            -
                    tab = ''
         | 
| 328 | 
            -
                  end
         | 
| 329 | 
            -
             | 
| 330 | 
            -
                  if self == item || @sugarcube_view == item
         | 
| 331 | 
            -
                    print "\033[1m"
         | 
| 332 | 
            -
                  end
         | 
| 333 | 
            -
                  print draw_tree_item(item)
         | 
| 334 | 
            -
                  if self == item || @sugarcube_view == item
         | 
| 335 | 
            -
                    print "\033[0m"
         | 
| 336 | 
            -
                  end
         | 
| 337 | 
            -
                  puts
         | 
| 338 | 
            -
             | 
| 339 | 
            -
                  if selector.is_a? Proc
         | 
| 340 | 
            -
                    items = selector.call(item)
         | 
| 341 | 
            -
                  else
         | 
| 342 | 
            -
                    items = item.send(selector)
         | 
| 343 | 
            -
                  end
         | 
| 344 | 
            -
                  items ||= []
         | 
| 345 | 
            -
             | 
| 346 | 
            -
                  unless @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
         | 
| 347 | 
            -
                    items.each_with_index do |subview, index|
         | 
| 348 | 
            -
                      items_index += 1
         | 
| 349 | 
            -
                      if self.respond_to? :draw_tree
         | 
| 350 | 
            -
                        items_index = draw_tree(subview, selector, tab, index == items.length - 1, items_index)
         | 
| 351 | 
            -
                      else
         | 
| 352 | 
            -
                        items_index = SugarCube::Repl::draw_tree(subview, selector, tab, index == items.length - 1, items_index)
         | 
| 353 | 
            -
                      end
         | 
| 354 | 
            -
                    end
         | 
| 355 | 
            -
                  end
         | 
| 356 | 
            -
             | 
| 357 | 
            -
                  return items_index
         | 
| 358 | 
            -
                end
         | 
| 359 | 
            -
             | 
| 360 | 
            -
                def build_tree(item, selector)
         | 
| 361 | 
            -
             | 
| 362 | 
            -
                  if selector.is_a? Proc
         | 
| 363 | 
            -
                    items = selector.call(item)
         | 
| 364 | 
            -
                  else
         | 
| 365 | 
            -
                    items = item.send(selector)
         | 
| 366 | 
            -
                  end
         | 
| 367 | 
            -
                  items ||= []
         | 
| 368 | 
            -
             | 
| 369 | 
            -
                  ret = [item]
         | 
| 370 | 
            -
                  return ret if @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
         | 
| 371 | 
            -
             | 
| 372 | 
            -
                  items.each_with_index do |subview, index|
         | 
| 373 | 
            -
                    ret.concat SugarCube::Repl::build_tree(subview, selector)
         | 
| 374 | 
            -
                  end
         | 
| 375 | 
            -
                  ret
         | 
| 376 | 
            -
                end
         | 
| 377 | 
            -
             | 
| 378 212 | 
             
                def check_sugarcube_view
         | 
| 379 | 
            -
                  raise 'no view has been assigned to SugarCube::Repl::adjust' unless @ | 
| 213 | 
            +
                  raise 'no view has been assigned to SugarCube::Repl::adjust' unless @adjust_item
         | 
| 380 214 |  | 
| 381 215 | 
             
                  true
         | 
| 382 216 | 
             
                end
         |