def __getitem__(self, Key):
   if Key < 0:
     Key = self.__len__() + Key
   # There is a horribly subtle distinction between an NSValue and
   # an NSPoint. SpeedPunk expects to see an NSValue here and dies
   # if it doesn't have one.
   return NSValue.valueWithPoint_(self._seg[Key].position)
Exemplo n.º 2
0
 def __getitem__(self, Key):
   if Key < 0:
     Key = self.__len__() + Key
   # There is a horribly subtle distinction between an NSValue and
   # an NSPoint. SpeedPunk expects to see an NSValue here and dies
   # if it doesn't have one.
   return NSValue.valueWithPoint_(self._seg[Key].position)
Exemplo n.º 3
0
def act(context, direction='out', mode='auto'):
    zen_target = 'html, html *, xml, xml *'
    if (mode.lower() == 'auto' and tea.cursor_in_zone(context, zen_target)) or \
       mode.lower() == 'zen':
        # HTML or XML, so use Zen-coding's excellent balancing commands
        
        # Using this method rather than tea.get_single_range() is better
        # because it won't cause the action to fail if there's more than
        # one selection
        editor = ZenEditor(context)
        action_name = 'match_pair_inward' if direction == 'in' else 'match_pair_outward'
        return zen_coding.run_action(action_name, editor)
    else:
        # No HTML or XML, so we'll rely on itemizers
        ranges = tea.get_ranges(context)
        targets = []
        for range in ranges:
            if direction.lower() == 'in':
                item = tea.get_item_for_range(context, range)
                if item is None:
                    # No item, so jump to next iteration
                    continue
                new_range = item.range()
                if new_range.location == range.location and \
                   new_range.length == range.length:
                    items = item.childItems()
                    if len(items) > 0:
                        new_range = items[0].range()
                targets.append(new_range)
            else:
                item = tea.get_item_parent_for_range(context, range)
                if item is None:
                    continue
                targets.append(item.range())
        
        # Set the selections, and return
        if len(targets) > 0:
            context.setSelectedRanges_([NSValue.valueWithRange_(range) for range in targets])
            return True
        else:
            return False
Exemplo n.º 4
0
def lerp(t,a,b):
  return NSValue.valueWithPoint_(NSPoint(int((1-t)*a.x + t*b.x), int((1-t)*a.y + t*b.y)))