private static async Task RequestOverview(string aBeatmapSetPath) { try { if (State.LoadedBeatmapSetPath != aBeatmapSetPath) { return; } string html = OverviewRenderer.Render(State.LoadedBeatmapSet); await SendMessage("UpdateOverview", html); } catch (Exception exception) { string html = ExceptionRenderer.Render(exception); await SendMessage("UpdateException", "Overview:" + html); } }
public ComparisonWidget(VersionControlDocumentInfo info) { vAdjustment = new Adjustment(0, 0, 0, 0, 0, 0); vAdjustment.Changed += HandleAdjustmentChanged; vScrollBar = new VScrollbar(vAdjustment); AddChild(vScrollBar); vScrollBar.Hide(); hAdjustment = new Adjustment(0, 0, 0, 0, 0, 0); hAdjustment.Changed += HandleAdjustmentChanged; leftHScrollBar = new HScrollbar(hAdjustment); AddChild(leftHScrollBar); rightHScrollBar = new HScrollbar(hAdjustment); AddChild(rightHScrollBar); originalComboBox = new DropDownBox(); originalComboBox.Text = "Local"; AddChild(originalComboBox); originalEditor = new TextEditor(); AddChild(originalEditor); originalEditor.SetScrollAdjustments(hAdjustment, vAdjustment); diffComboBox = new DropDownBox(); diffComboBox.Text = "Base"; AddChild(diffComboBox); diffEditor = new TextEditor(); AddChild(diffEditor); diffEditor.Document.ReadOnly = true; diffEditor.SetScrollAdjustments(hAdjustment, vAdjustment); this.vAdjustment.ValueChanged += delegate { middleArea.QueueDraw(); }; overview = new OverviewRenderer(this); AddChild(overview); middleArea = new MiddleArea(this); AddChild(middleArea); prev = new Button(); prev.Add(new Arrow(ArrowType.Up, ShadowType.None)); AddChild(prev); prev.ShowAll(); prev.Clicked += delegate { if (this.Diff == null) { return; } originalEditor.GrabFocus(); int line = originalEditor.Caret.Line; int max = -1, searched = -1; foreach (Diff.Hunk hunk in this.Diff) { if (hunk.Same) { continue; } max = System.Math.Max(hunk.Left.Start, max); if (hunk.Left.Start < line) { searched = System.Math.Max(hunk.Left.Start, searched); } } if (max >= 0) { originalEditor.Caret.Line = searched < 0 ? max : searched; originalEditor.CenterToCaret(); } }; next = new Button(); next.BorderWidth = 0; next.Add(new Arrow(ArrowType.Down, ShadowType.None)); next.Clicked += delegate { if (this.Diff == null) { return; } originalEditor.GrabFocus(); int line = originalEditor.Caret.Line; int min = Int32.MaxValue, searched = Int32.MaxValue; foreach (Diff.Hunk hunk in this.Diff) { if (hunk.Same) { continue; } min = System.Math.Min(hunk.Left.Start, min); if (hunk.Left.Start > line) { searched = System.Math.Min(hunk.Left.Start, searched); } } if (min < Int32.MaxValue) { originalEditor.Caret.Line = searched == Int32.MaxValue ? min : searched; originalEditor.CenterToCaret(); } }; AddChild(next); next.ShowAll(); this.DoubleBuffered = true; originalEditor.ExposeEvent += HandleLeftEditorExposeEvent; diffEditor.ExposeEvent += HandleRightEditorExposeEvent; }
public ComparisonWidget (VersionControlDocumentInfo info) { this.info = info; vAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); vAdjustment.Changed += HandleAdjustmentChanged; leftVAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); Connect (leftVAdjustment, vAdjustment); rightVAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); Connect (rightVAdjustment, vAdjustment); vScrollBar = new VScrollbar (vAdjustment); AddChild (vScrollBar); vScrollBar.Hide (); hAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); hAdjustment.Changed += HandleAdjustmentChanged; leftHAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); Connect (leftHAdjustment, hAdjustment); rightHAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); Connect (rightHAdjustment, hAdjustment); leftHScrollBar = new HScrollbar (hAdjustment); AddChild (leftHScrollBar); rightHScrollBar = new HScrollbar (hAdjustment); AddChild (rightHScrollBar); originalEditor = new TextEditor (); originalEditor.Caret.PositionChanged += CaretPositionChanged; originalEditor.FocusInEvent += EditorFocusIn; AddChild (originalEditor); originalEditor.SetScrollAdjustments (leftHAdjustment, leftVAdjustment); originalComboBox = new DropDownBox (); originalComboBox.WindowRequestFunc = CreateComboBoxSelector; originalComboBox.Text = "Local"; originalComboBox.Tag = originalEditor; AddChild (originalComboBox); diffEditor = new TextEditor (); diffEditor.Caret.PositionChanged += CaretPositionChanged; diffEditor.FocusInEvent += EditorFocusIn; AddChild (diffEditor); diffEditor.Document.ReadOnly = true; diffEditor.SetScrollAdjustments (leftHAdjustment, leftVAdjustment); this.vAdjustment.ValueChanged += delegate { middleArea.QueueDraw (); }; diffComboBox = new DropDownBox (); diffComboBox.WindowRequestFunc = CreateComboBoxSelector; diffComboBox.Text = "Base"; diffComboBox.Tag = diffEditor; AddChild (diffComboBox); overview = new OverviewRenderer (this); AddChild (overview); middleArea = new MiddleArea (this); AddChild (middleArea); prev = new Button (); prev.Add (new Arrow (ArrowType.Up, ShadowType.None)); AddChild (prev); prev.ShowAll (); prev.Clicked += delegate { if (this.Diff == null) return; originalEditor.GrabFocus (); int line = originalEditor.Caret.Line; int max = -1, searched = -1; foreach (Diff.Hunk hunk in this.Diff) { if (hunk.Same) continue; max = System.Math.Max (hunk.Right.Start, max); if (hunk.Right.Start < line) searched = System.Math.Max (hunk.Right.Start, searched); } if (max >= 0) { originalEditor.Caret.Line = searched < 0 ? max : searched; originalEditor.CenterToCaret (); } }; next = new Button (); next.BorderWidth = 0; next.Add (new Arrow (ArrowType.Down, ShadowType.None)); next.Clicked += delegate { if (this.Diff == null) return; originalEditor.GrabFocus (); int line = originalEditor.Caret.Line; int min = Int32.MaxValue, searched = Int32.MaxValue; foreach (Diff.Hunk hunk in this.Diff) { if (hunk.Same) continue; min = System.Math.Min (hunk.Right.Start, min); if (hunk.Right.Start > line) searched = System.Math.Min (hunk.Right.Start, searched); } if (min < Int32.MaxValue) { originalEditor.Caret.Line = searched == Int32.MaxValue ? min : searched; originalEditor.CenterToCaret (); } }; AddChild (next); next.ShowAll (); this.DoubleBuffered = true; originalEditor.ExposeEvent += HandleLeftEditorExposeEvent; diffEditor.ExposeEvent += HandleRightEditorExposeEvent; info.Document.Editor.Document.TextReplaced += HandleInfoDocumentTextEditorDataDocumentTextReplaced; }