Ejemplo n.º 1
0
 protected override bool OnLeaveNotifyEvent(EventCrossing evnt)
 {
     selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
     TooltipText  = null;
     QueueDraw();
     return(base.OnLeaveNotifyEvent(evnt));
 }
Ejemplo n.º 2
0
 public static Cairo.Color GetColor(Mono.TextEditor.Utils.Hunk hunk, bool removeSide, bool dark, double alpha)
 {
     Cairo.Color result;
     if (hunk.Removed > 0 && hunk.Inserted > 0)
     {
         result = dark ? darkBlue : lightBlue;
     }
     else if (removeSide)
     {
         if (hunk.Removed > 0)
         {
             result = dark ? darkRed : lightRed;
         }
         else
         {
             result = dark ? darkGreen : lightGreen;
         }
     }
     else
     {
         if (hunk.Inserted > 0)
         {
             result = dark ? darkGreen : lightGreen;
         }
         else
         {
             result = dark ? darkRed : lightRed;
         }
     }
     result.A = alpha;
     return(result);
 }
Ejemplo n.º 3
0
            protected override bool OnMotionNotifyEvent(EventMotion evnt)
            {
                bool hideButton = widget.MainEditor.Document.ReadOnly;

                Mono.TextEditor.Utils.Hunk selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
                if (!hideButton)
                {
                    int delta = widget.MainEditor.Allocation.Y - Allocation.Y;
                    if (Diff != null)
                    {
                        foreach (var hunk in Diff)
                        {
                            double z1 = delta + fromEditor.LineToY(hunk.RemoveStart) - fromEditor.VAdjustment.Value;
                            double z2 = delta + fromEditor.LineToY(hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value;
                            if (z1 == z2)
                            {
                                z2 = z1 + 1;
                            }

                            double y1 = delta + toEditor.LineToY(hunk.InsertStart) - toEditor.VAdjustment.Value;
                            double y2 = delta + toEditor.LineToY(hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value;

                            if (y1 == y2)
                            {
                                y2 = y1 + 1;
                            }
                            double x, y, w, h;
                            GetButtonPosition(hunk, y1, y2, z1, z2, out x, out y, out w, out h);

                            if (evnt.X >= x && evnt.X < x + w && evnt.Y >= y && evnt.Y < y + h)
                            {
                                selectedHunk = hunk;
                                TooltipText  = GettextCatalog.GetString("Revert this change");
                                QueueDrawArea((int)x, (int)y, (int)w, (int)h);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
                }

                if (selectedHunk.IsEmpty)
                {
                    TooltipText = null;
                }

                if (this.selectedHunk != selectedHunk)
                {
                    this.selectedHunk = selectedHunk;
                    QueueDraw();
                }
                return(base.OnMotionNotifyEvent(evnt));
            }
Ejemplo n.º 4
0
            public bool GetButtonPosition(Mono.TextEditor.Utils.Hunk hunk, double y1, double y2, double z1, double z2, out double x, out double y, out double w, out double h)
            {
                if (hunk.Removed > 0)
                {
                    var b1 = z1;
                    var b2 = z2;
                    x = useLeft ? 0 : Allocation.Width - buttonSize;
                    y = b1;
                    w = buttonSize;
                    h = b2 - b1;
                    return(hunk.Inserted > 0);
                }
                else
                {
                    var b1 = y1;
                    var b2 = y2;

                    x = useLeft ? Allocation.Width - buttonSize : 0;
                    y = b1;
                    w = buttonSize;
                    h = b2 - b1;
                    return(hunk.Removed > 0);
                }
            }
Ejemplo n.º 5
0
			protected override bool OnLeaveNotifyEvent (EventCrossing evnt)
			{
				selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
				TooltipText = null;
				QueueDraw ();
				return base.OnLeaveNotifyEvent (evnt);
			}
Ejemplo n.º 6
0
			protected override bool OnMotionNotifyEvent (EventMotion evnt)
			{
				bool hideButton = widget.MainEditor.Document.ReadOnly;
				Mono.TextEditor.Utils.Hunk selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
				if (!hideButton) {
					int delta = widget.MainEditor.Allocation.Y - Allocation.Y;
					if (Diff != null) {
						foreach (var hunk in Diff) {
							double z1 = delta + fromEditor.LineToY (hunk.RemoveStart) - fromEditor.VAdjustment.Value;
							double z2 = delta + fromEditor.LineToY (hunk.RemoveStart + hunk.Removed) - fromEditor.VAdjustment.Value;
							if (z1 == z2)
								z2 = z1 + 1;
	
							double y1 = delta + toEditor.LineToY (hunk.InsertStart) - toEditor.VAdjustment.Value;
							double y2 = delta + toEditor.LineToY (hunk.InsertStart + hunk.Inserted) - toEditor.VAdjustment.Value;
	
							if (y1 == y2)
								y2 = y1 + 1;
							double x, y, w, h;
							GetButtonPosition (hunk, y1, y2, z1, z2, out x, out y, out w, out h);
	
							if (evnt.X >= x && evnt.X < x + w && evnt.Y >= y && evnt.Y < y + h) {
								selectedHunk = hunk;
								TooltipText = GettextCatalog.GetString ("Revert this change");
								QueueDrawArea ((int)x, (int)y, (int)w, (int)h);
								break;
							}
						}
					}
				} else {
					selectedHunk = Mono.TextEditor.Utils.Hunk.Empty;
				}

				if (selectedHunk.IsEmpty)
					TooltipText = null;

				if (this.selectedHunk != selectedHunk) {
					this.selectedHunk = selectedHunk;
					QueueDraw ();
				}
				return base.OnMotionNotifyEvent (evnt);
			}
Ejemplo n.º 7
0
 void IncPos(Mono.TextEditor.Utils.Hunk h, ref int pos)
 {
     pos += System.Math.Max(h.Inserted, h.Removed);
 }
Ejemplo n.º 8
0
 public bool Overlaps(Hunk other)
 {
     return(DistanceTo(other) < this.Context * 2);
 }
Ejemplo n.º 9
0
 public int DistanceTo(Hunk other)
 {
     return(other.RemoveStart - (this.RemoveStart + this.Removed));
 }