示例#1
0
		public PatchWidget (ComparisonView comparisonView, VersionControlDocumentInfo info)
		{
			this.Build ();
			diffEditor = new Mono.TextEditor.TextEditor ();
			diffEditor.Document.MimeType = "text/x-diff";
			diffEditor.Options.FontName = info.Document.Editor.Options.FontName;
			diffEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme;
			diffEditor.Options.ShowFoldMargin = false;
			diffEditor.Options.ShowIconMargin = false;
			diffEditor.Options.ShowTabs = true;
			diffEditor.Options.ShowSpaces = true;
			diffEditor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines;
			diffEditor.Document.ReadOnly = true;
			scrolledwindow1.Child = diffEditor;
			diffEditor.ShowAll ();
			using (var writer = new StringWriter ()) {
				UnifiedDiff.WriteUnifiedDiff (comparisonView.Diff, writer, 
				                              System.IO.Path.GetFileName (info.Item.Path) + "    (repository)", 
				                              System.IO.Path.GetFileName (info.Item.Path) + "    (working copy)",
				                              3);
				diffEditor.Document.Text = writer.ToString ();
			}
			buttonSave.Clicked += delegate {
				var dlg = new OpenFileDialog (GettextCatalog.GetString ("Save as..."), FileChooserAction.Save) {
					TransientFor = IdeApp.Workbench.RootWindow
				};
				
				if (!dlg.Run ())
					return;
				File.WriteAllText (dlg.SelectedFile, diffEditor.Document.Text);
			};
		}
示例#2
0
        public PatchWidget(ComparisonView comparisonView, VersionControlDocumentInfo info)
        {
            this.Build();
            diffEditor = new Mono.TextEditor.TextEditor();
            diffEditor.Document.MimeType        = "text/x-diff";
            diffEditor.Options.FontName         = info.Document.TextEditorData.Options.FontName;
            diffEditor.Options.ColorScheme      = info.Document.TextEditorData.Options.ColorScheme;
            diffEditor.Options.ShowFoldMargin   = false;
            diffEditor.Options.ShowIconMargin   = false;
            diffEditor.Options.ShowTabs         = true;
            diffEditor.Options.ShowSpaces       = true;
            diffEditor.Options.ShowInvalidLines = info.Document.TextEditorData.Options.ShowInvalidLines;
            diffEditor.Document.ReadOnly        = true;
            scrolledwindow1.Child = diffEditor;
            diffEditor.ShowAll();
            using (var writer = new StringWriter()) {
                UnifiedDiff.WriteUnifiedDiff(comparisonView.Diff, writer,
                                             System.IO.Path.GetFileName(info.Item.Path) + "    (repository)",
                                             System.IO.Path.GetFileName(info.Item.Path) + "    (working copy)",
                                             3);
                diffEditor.Document.Text = writer.ToString();
            }
            buttonSave.Clicked += delegate {
                var dlg = new OpenFileDialog(GettextCatalog.GetString("Save as..."), FileChooserAction.Save)
                {
                    TransientFor = IdeApp.Workbench.RootWindow
                };

                if (!dlg.Run())
                {
                    return;
                }
                File.WriteAllText(dlg.SelectedFile, diffEditor.Document.Text);
            };
        }