void LoadFile (CoverageView.ClassItem klass) { int[] coverage = klass.Model.sourceFile.Coverage; StreamReader infile = new StreamReader (klass.Model.sourceFile.sourceFile); int pos = 1; while (infile.Peek () > -1) { TextIter end = text_buffer.EndIter; text_buffer.Insert (ref end, String.Format ("{0, 6} {1}\n", pos, infile.ReadLine ())); if (pos < coverage.Length) { int count = coverage [pos]; TextIter text_end = text_buffer.EndIter; TextIter text_start = text_end; text_start.BackwardLines (1); if (count > 0) text_buffer.ApplyTag (hit_color, text_start, text_end); else if (count == 0) text_buffer.ApplyTag (missed_color, text_start, text_end); } pos++; } }
public void CenterOnMethod (CoverageView.MethodItem method) { TextIter iter = text_buffer.GetIterAtLine (method.Model.startLine - 1); // this doesn't seem to work text_view.ScrollToIter (iter, 0.0, true, 0, 0.5); text_view.PlaceCursorOnscreen (); Console.WriteLine ("scrolled to line: {0}", method.Model.startLine - 1); // the first time we need to do this workaround for // it to actually work... while (Application.EventsPending ()) Application.RunIteration (); text_view.ScrollToIter (iter, 0.0, true, 0, 0.5); text_view.PlaceCursorOnscreen (); }
public SourceWindow(CoverageView.ClassItem klass) { this.classItem = klass; text_buffer = new TextBuffer (new TextTagTable ()); text_view = new TextView (text_buffer); text_view.Editable = false; Add (text_view); hit_color = new TextTag ("hit"); hit_color.Foreground = "blue"; text_buffer.TagTable.Add (hit_color); missed_color = new TextTag ("miss"); missed_color.Foreground = "red"; text_buffer.TagTable.Add (missed_color); LoadFile (klass); ShowAll (); }
private void OpenFile(string fileName) { // if (coverageView != null) // coverageView.Close (true); progressbar1.Show(); coverageView = new CoverageView(fileName, progressbar1); main.Title = (CAPTION + " - " + new FileInfo(fileName).Name); scrolledwindow1.Add(coverageView.Widget); main.ShowAll(); // allow some time for user feedback GLib.Timeout.Add(1000, delegate { progressbar1.Hide(); return(false); }); }
private void OpenFile (string fileName) { // if (coverageView != null) // coverageView.Close (true); if (coverageView != null) { scrolledwindow1.Remove (coverageView.Widget); } progressbar1.Show (); try { coverageView = new CoverageView (fileName, progressbar1); main.Title = (CAPTION + " - " + new FileInfo (fileName).Name); scrolledwindow1.Add (coverageView.Widget); main.ShowAll (); // allow some time for user feedback GLib.Timeout.Add (1000, delegate { progressbar1.Hide (); return false; }); } catch (Exception e) { if (coverageView != null) scrolledwindow1.Remove (coverageView.Widget); coverageView = null; progressbar1.Hide (); main.Title = CAPTION; MessageDialog messageDialog = new MessageDialog (main, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, e.Message); messageDialog.Title = "Error"; messageDialog.Run (); messageDialog.Destroy (); } }
public SourceWindow (CoverageView.ClassItem klass) : base (klass.Model.sourceFile.sourceFile) { SetDefaultSize (800, 600); ScrolledWindow sw = new ScrolledWindow (); text_buffer = new TextBuffer (new TextTagTable ()); text_view = new TextView (text_buffer); text_view.Editable = false; sw.Add (text_view); Add (sw); hit_color = new TextTag ("hit"); hit_color.Foreground = "blue"; text_buffer.TagTable.Add (hit_color); missed_color = new TextTag ("miss"); missed_color.Foreground = "red"; text_buffer.TagTable.Add (missed_color); LoadFile (klass); ShowAll (); }
private void OpenFile(string fileName) { // if (coverageView != null) // coverageView.Close (true); if (coverageView != null) { scrolledwindow1.Remove (coverageView.Widget); coverageView.ShowSource -= OnShowSource; OnCloseAllTabs (this, EventArgs.Empty); } progressbar1.Show (); try { coverageView = new CoverageView (fileName, progressbar1); coverageView.ShowSource += OnShowSource; main.Title = (CAPTION + " - " + new FileInfo (fileName).Name); scrolledwindow1.Add (coverageView.Widget); main.ShowAll (); // allow some time for user feedback GLib.Timeout.Add (1000, delegate { progressbar1.Hide (); return false; }); } catch (Exception e) { if (coverageView != null) { scrolledwindow1.Remove (coverageView.Widget); coverageView.ShowSource -= OnShowSource; } coverageView = null; progressbar1.Hide (); main.Title = CAPTION; MessageDialog messageDialog = new MessageDialog (main, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, e.Message); messageDialog.Title = "Error"; messageDialog.Run (); messageDialog.Destroy (); } }
private void OnShowSource(object sender, CoverageView.ShowSourceEventArgs e) { foreach (Widget widget in notebook1.Children) { SourceWindow notebookSourceWindow = widget as SourceWindow; if (notebookSourceWindow == null) continue; if (notebookSourceWindow.classItem.Model.sourceFile.sourceFile != e.methodItem.ParentClass.Model.sourceFile.sourceFile) continue; notebook1.CurrentPage = notebook1.PageNum (notebookSourceWindow); notebookSourceWindow.CenterOnMethod (e.methodItem); return; } SourceWindow sourceWindow = new SourceWindow (e.methodItem.ParentClass); sourceWindow.CenterOnMethod (e.methodItem); string sourceFile = e.methodItem.ParentClass.Model.sourceFile.sourceFile; sourceFile = Path.GetFileName (sourceFile); NotebookTabLabel notebookTabLabel = new NotebookTabLabel (sourceFile); int index = notebook1.AppendPage (sourceWindow, notebookTabLabel); notebook1.CurrentPage = index; notebookTabLabel.CloseClicked += delegate(object obj, EventArgs eventArgs) { notebook1.CurrentPage = notebook1.PageNum (sourceWindow); OnCloseTab (this, EventArgs.Empty); }; }
private void OpenFile (string fileName) { // if (coverageView != null) // coverageView.Close (true); progressbar1.Show (); coverageView = new CoverageView (fileName, progressbar1); main.Title = (CAPTION + " - " + new FileInfo (fileName).Name); scrolledwindow1.Add (coverageView.Widget); main.ShowAll (); // allow some time for user feedback GLib.Timeout.Add (1000, delegate { progressbar1.Hide (); return false; }); }