Beispiel #1
0
 int[,] GetLCS(Diff.Hunk hunk)
 {
     int[,] result;
     if (llcsCache.TryGetValue(hunk, out result))
     {
         return(result);
     }
     return(null);
 }
Beispiel #2
0
 public static Cairo.Color GetColor(Diff.Hunk hunk, double alpha)
 {
     if (hunk.Left.Count == 0)
     {
         return(new Cairo.Color(0.4, 0.8, 0.4, alpha));
     }
     if (hunk.Right.Count == 0)
     {
         return(new Cairo.Color(0.8, 0.4, 0.4, alpha));
     }
     return(new Cairo.Color(0.4, 0.8, 0.8, alpha));
 }
Beispiel #3
0
            protected override bool OnMotionNotifyEvent(EventMotion evnt)
            {
                int delta = widget.OriginalEditor.Allocation.Y - Allocation.Y;

                Diff.Hunk selectedHunk = null;
                foreach (Diff.Hunk hunk in widget.Diff)
                {
                    if (!hunk.Same)
                    {
                        int y1 = delta + widget.OriginalEditor.LineToVisualY(hunk.Right.Start) - (int)widget.OriginalEditor.VAdjustment.Value;
                        int y2 = delta + widget.OriginalEditor.LineToVisualY(hunk.Right.Start + hunk.Right.Count) - (int)widget.OriginalEditor.VAdjustment.Value;
                        if (y1 == y2)
                        {
                            y2 = y1 + 1;
                        }

                        int z1 = delta + widget.DiffEditor.LineToVisualY(hunk.Left.Start) - (int)widget.DiffEditor.VAdjustment.Value;
                        int z2 = delta + widget.DiffEditor.LineToVisualY(hunk.Left.Start + hunk.Left.Count) - (int)widget.DiffEditor.VAdjustment.Value;

                        if (z1 == z2)
                        {
                            z2 = z1 + 1;
                        }

                        int x = (Allocation.Width) / 2;
                        int y = ((y1 + y2) / 2 + (z1 + z2) / 2) / 2;
                        if (Math.Sqrt(System.Math.Abs(x - evnt.X) * System.Math.Abs(x - evnt.X) +
                                      System.Math.Abs(y - evnt.Y) * System.Math.Abs(y - evnt.Y)) < 10)
                        {
                            selectedHunk = hunk;
                            break;
                        }
                    }
                }

                if (this.selectedHunk != selectedHunk)
                {
                    this.selectedHunk = selectedHunk;
                    QueueDraw();
                }

                return(base.OnMotionNotifyEvent(evnt));
            }
Beispiel #4
0
 // Tauberer
 public DiffChunk(Diff.Hunk hunk)
 {
     Left  = new Range(hunk.Left.Start, hunk.Left.End, hunk.Left.Count);
     Right = new Range(hunk.Right.Start, hunk.Right.End, hunk.Right.Count);
     //TempDump("T ");
 }