예제 #1
0
    def _linkmap_process_event(self, event, side, x, pix_width, pix_height):
        src_idx, dst_idx = side, 1 if side == 0 else 0
        src, dst = self.view_indices[src_idx], self.view_indices[dst_idx]

        yoffset = self.allocation.y
        vis_offset = [t.get_visible_rect().y for t in self.views]
        rel_offset = [t.allocation.y - self.allocation.y for t in self.views]
        height = self.allocation.height

        bounds = []
        for v in (self.views[src_idx], self.views[dst_idx]):
            visible = v.get_visible_rect()
            bounds.append(v.get_line_num_for_y(visible.y))
            bounds.append(v.get_line_num_for_y(visible.y + visible.height))

        view_offset_line = lambda v, l: self.views[v].get_y_for_line_num(l) - \
                                        vis_offset[v] + rel_offset[v]
        for c in self.filediff.linediffer.pair_changes(src, dst, bounds):
            f0, f1 = [view_offset_line(src_idx, l) for l in c[1:3]]
            t0, t1 = [view_offset_line(dst_idx, l) for l in c[3:5]]

            f0 = view_offset_line(src_idx, c[1])

            if f0 < event.y < f0 + pix_height:
                if (t0 < 0 and t1 < 0) or (t0 > height and t1 > height) or \
                   (f0 < 0 and f1 < 0) or (f0 > height and f1 > height):
                    break

                # _classify_change_actions assumes changes are left->right
                action_change = diffutil.reverse_chunk(c) if dst < src else c
                actions = self._classify_change_actions(action_change)
                if actions[side] is not None:
                    rect = gtk.gdk.Rectangle(x, f0, pix_width, pix_height)
                    self.mouse_chunk = ((src, dst), rect, c, actions[side])
                break
예제 #2
0
    def _linkmap_process_event(self, event, side, x, pix_width, pix_height):
        src_idx, dst_idx = side, 1 if side == 0 else 0
        src, dst = self.view_indices[src_idx], self.view_indices[dst_idx]

        yoffset = self.allocation.y
        rel_offset = self.views[side].allocation.y - yoffset
        vis_offset = self.views[side].get_visible_rect().y

        bounds = []
        for v in (self.views[src_idx], self.views[dst_idx]):
            visible = v.get_visible_rect()
            bounds.append(v.get_line_num_for_y(visible.y))
            bounds.append(v.get_line_num_for_y(visible.y + visible.height))

        for c in self.filediff.linediffer.pair_changes(src, dst, bounds):
            h = self.views[src_idx].get_y_for_line_num(c[1]) - \
                vis_offset + rel_offset
            if h < event.y < h + pix_height:
                # _classify_change_actions assumes changes are left->right
                action_change = diffutil.reverse_chunk(c) if dst < src else c
                actions = self._classify_change_actions(action_change)
                if actions[side] is not None:
                    rect = gtk.gdk.Rectangle(x, h, pix_width, pix_height)
                    self.mouse_chunk = ((src, dst), rect, c, actions[side])
                break