diff options
Diffstat (limited to 'main/src/addins/VersionControl/MonoDevelop.VersionControl')
12 files changed, 501 insertions, 64 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BaseView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BaseView.cs index 26462b2335..f9bcd2461a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BaseView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BaseView.cs @@ -1,6 +1,7 @@ using System;
using System.IO;
using MonoDevelop.Ide.Gui;
+using System.Text;
namespace MonoDevelop.VersionControl {
@@ -13,10 +14,15 @@ namespace MonoDevelop.VersionControl this.name = name;
}
- protected virtual void SaveAs (string fileName)
+ protected virtual void SaveAs (FileSaveInformation fileSaveInformation)
{
}
+ void IViewContent.Load (FileOpenInformation fileOpenInformation)
+ {
+ throw new InvalidOperationException();
+ }
+
void IViewContent.Load (string fileName)
{
throw new InvalidOperationException();
@@ -38,9 +44,14 @@ namespace MonoDevelop.VersionControl void IViewContent.Save (string fileName)
{
- SaveAs (fileName);
- } - + SaveAs (new FileSaveInformation (fileName));
+ }
+
+ void IViewContent.Save (FileSaveInformation info)
+ {
+ SaveAs (info);
+ }
+
string IViewContent.ContentName {
get { return name; }
set { }
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs index e9de77d760..266cf16338 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs @@ -34,6 +34,7 @@ using MonoDevelop.Ide; using System.Threading; using MonoDevelop.Core; using MonoDevelop.Components.Commands; +using MonoDevelop.Components; namespace MonoDevelop.VersionControl.Views { @@ -53,7 +54,7 @@ namespace MonoDevelop.VersionControl.Views BlameRenderer overview; - TextEditor editor; + MonoTextEditor editor; List<ContainerChild> children = new List<ContainerChild> (); public Adjustment Vadjustment { @@ -74,7 +75,7 @@ namespace MonoDevelop.VersionControl.Views } } - public TextEditor Editor { + public MonoTextEditor Editor { get { return this.editor; } @@ -123,7 +124,7 @@ namespace MonoDevelop.VersionControl.Views hScrollBar = new HScrollbar (hAdjustment); AddChild (hScrollBar); - editor = new TextEditor (sourceEditor.TextEditor.Document, sourceEditor.TextEditor.Options); + editor = new MonoTextEditor (sourceEditor.TextEditor.Document, sourceEditor.TextEditor.Options); AddChild (editor); editor.SetScrollAdjustments (hAdjustment, vAdjustment); @@ -720,7 +721,7 @@ namespace MonoDevelop.VersionControl.Views e.Window.DrawLayout (Style.BlackGC, Allocation.Width - revisionWidth - margin - revisionWidth - dateRevisionSpacing, (int)(curY + (widget.Editor.LineHeight - h) / 2), layout); } - using (var authorLayout = PangoUtil.CreateLayout (this)) { + using (var authorLayout = MonoDevelop.Components.PangoUtil.CreateLayout (this)) { var description = Pango.FontDescription.FromString ("Tahoma " + (int)(10 * widget.Editor.Options.Zoom)); authorLayout.FontDescription = description; authorLayout.SetText (ann.Author); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CommonTextEditorOptions.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CommonTextEditorOptions.cs new file mode 100644 index 0000000000..65a172c36d --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CommonTextEditorOptions.cs @@ -0,0 +1,399 @@ + +// +// ComparisonWidget.cs +// +// Author: +// Mike Krüger <mkrueger@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using Gtk; +using Gdk; +using System.Collections.Generic; +using Mono.TextEditor; +using MonoDevelop.Ide; +using MonoDevelop.Components; +using System.ComponentModel; +using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Ide.Fonts; +using MonoDevelop.Ide.Editor.Extension; + +namespace MonoDevelop.VersionControl.Views +{ + // Code snatched from SourceEditor + class CommonTextEditorOptions : TextEditorOptions, Mono.TextEditor.ITextEditorOptions + { + static CommonTextEditorOptions instance; + //static TextStylePolicy defaultPolicy; + static bool inited; + + public static CommonTextEditorOptions Instance { + get { return instance; } + } + + static CommonTextEditorOptions () + { + Init (); + } + + public static void Init () + { + if (inited) + return; + inited = true; + + TextStylePolicy policy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain"); + instance = new CommonTextEditorOptions (policy); + MonoDevelop.Projects.Policies.PolicyService.DefaultPolicies.PolicyChanged += instance.HandlePolicyChanged; + } + + void HandlePolicyChanged (object sender, MonoDevelop.Projects.Policies.PolicyChangedEventArgs args) + { + TextStylePolicy pol = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain"); + UpdateStylePolicy (pol); + } + + CommonTextEditorOptions (MonoDevelop.Ide.Gui.Content.TextStylePolicy currentPolicy) + { + UpdateStylePolicy (currentPolicy); + MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.Changed += delegate(object sender, EventArgs e) { + OnChanged (e); + }; + } + + public override void Dispose() + { + FontService.RemoveCallback (UpdateFont); + } + + void UpdateFont () + { + base.FontName = FontName; + base.GutterFontName = GutterFontName; + this.OnChanged (EventArgs.Empty); + + } + + void UpdateStylePolicy (MonoDevelop.Ide.Gui.Content.TextStylePolicy currentPolicy) + { + this.defaultEolMarker = TextStylePolicy.GetEolMarker (currentPolicy.EolMarker); + base.TabsToSpaces = currentPolicy.TabsToSpaces; // PropertyService.Get ("TabsToSpaces", false); + base.IndentationSize = currentPolicy.TabWidth; //PropertyService.Get ("TabIndent", 4); + base.RulerColumn = currentPolicy.FileWidth; //PropertyService.Get ("RulerColumn", 80); + base.AllowTabsAfterNonTabs = !currentPolicy.NoTabsAfterNonTabs; //PropertyService.Get ("AllowTabsAfterNonTabs", true); + base.RemoveTrailingWhitespaces = currentPolicy.RemoveTrailingWhitespace; //PropertyService.Get ("RemoveTrailingWhitespaces", true); + } + + #region new options + + public bool EnableAutoCodeCompletion { + get { return CompletionTextEditorExtension.EnableAutoCodeCompletion; } + set { CompletionTextEditorExtension.EnableAutoCodeCompletion.Set (value); } + } + + public bool DefaultRegionsFolding { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.DefaultRegionsFolding; + } + set { + } + } + + public bool DefaultCommentFolding { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.DefaultCommentFolding; + } + set { + } + } + + public bool EnableSemanticHighlighting { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting; + } + set { + } + } + + public bool TabIsReindent { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.TabIsReindent; + } + set { + } + } + + public bool AutoInsertMatchingBracket { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket; + } + set { + } + } + + public bool SmartSemicolonPlacement { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.SmartSemicolonPlacement; + } + set { + } + } + + public bool UnderlineErrors { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.UnderlineErrors; + } + set { + } + } + + public override IndentStyle IndentStyle { + get { + return (IndentStyle)MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.IndentStyle; + } + set { + } + } + + public bool EnableHighlightUsages { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.EnableHighlightUsages; + } + set { + } + } + + MonoDevelop.Ide.Editor.LineEndingConversion lineEndingConversion; + public MonoDevelop.Ide.Editor.LineEndingConversion LineEndingConversion { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.LineEndingConversion; + } + set { + } + } + + + #endregion + public bool UseViModes { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.UseViModes; + } + set { + } + } + + public bool OnTheFlyFormatting { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.OnTheFlyFormatting; + } + set { + } + } + + #region old options + string defaultEolMarker; + public override string DefaultEolMarker { + get { return defaultEolMarker; } + } + + public MonoDevelop.Ide.Editor.ControlLeftRightMode ControlLeftRightMode { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.ControlLeftRightMode; + } + set { + } + } + + IWordFindStrategy wordFindStrategy = null; + public override IWordFindStrategy WordFindStrategy { + get { + if (wordFindStrategy == null) + SetWordFindStrategy (); + return this.wordFindStrategy; + } + set { + throw new System.NotImplementedException (); + } + } + + void SetWordFindStrategy () + { + if (UseViModes) { + this.wordFindStrategy = new Mono.TextEditor.Vi.ViWordFindStrategy (); + return; + } + + switch (ControlLeftRightMode) { + case MonoDevelop.Ide.Editor.ControlLeftRightMode.MonoDevelop: + this.wordFindStrategy = new EmacsWordFindStrategy (true); + break; + case MonoDevelop.Ide.Editor.ControlLeftRightMode.Emacs: + this.wordFindStrategy = new EmacsWordFindStrategy (false); + break; + case MonoDevelop.Ide.Editor.ControlLeftRightMode.SharpDevelop: + this.wordFindStrategy = new SharpDevelopWordFindStrategy (); + break; + } + } + + public override bool ShowLineNumberMargin { + get { + return true; + } + set { + } + } + + public override bool ShowFoldMargin { + get { + return false; + } + set { + } + } + + public override bool HighlightCaretLine { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.HighlightCaretLine; + } + set { + } + } + + public override bool EnableSyntaxHighlighting { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.EnableSyntaxHighlighting; + } + set { + } + } + + public override bool HighlightMatchingBracket { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.HighlightMatchingBracket; + } + set { + } + } + + public override bool ShowRuler { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.ShowRuler; + } + set { + } + } + + public override bool EnableAnimations { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.EnableAnimations; + } + set { + } + } + + public override bool DrawIndentationMarkers { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.DrawIndentationMarkers; + } + set { + } + } + + PropertyWrapper<ShowWhitespaces> showWhitespaces = new PropertyWrapper<ShowWhitespaces> ("ShowWhitespaces", ShowWhitespaces.Never); + public override ShowWhitespaces ShowWhitespaces { + get { + return showWhitespaces; + } + set { + if (showWhitespaces.Set (value)) + OnChanged (EventArgs.Empty); + } + } + + PropertyWrapper<IncludeWhitespaces> includeWhitespaces = new PropertyWrapper<IncludeWhitespaces> ("IncludeWhitespaces", IncludeWhitespaces.All); + public override IncludeWhitespaces IncludeWhitespaces { + get { + return includeWhitespaces; + } + set { + if (includeWhitespaces.Set (value)) + OnChanged (EventArgs.Empty); + } + } + + public override bool WrapLines { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.WrapLines; + } + set { + } + } + + public override bool EnableQuickDiff { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.EnableQuickDiff; + } + set { + } + } + + public override string FontName { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.FontName; + } + set { + throw new InvalidOperationException ("Set font through font service"); + } + } + + public override string GutterFontName { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.GutterFontName; + } + set { + throw new InvalidOperationException ("Set font through font service"); + } + } + + public override string ColorScheme { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.ColorScheme; + } + set { + } + } + + public override bool GenerateFormattingUndoStep { + get { + return MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.GenerateFormattingUndoStep; + } + set { + } + } + + #endregion + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs index 2b3fa3a3dc..30599ec58b 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs @@ -43,19 +43,19 @@ namespace MonoDevelop.VersionControl.Views { internal DropDownBox originalComboBox, diffComboBox; - public TextEditor OriginalEditor { + public MonoTextEditor OriginalEditor { get { return editors[1]; } } - public TextEditor DiffEditor { + public MonoTextEditor DiffEditor { get { return editors[0]; } } - protected override TextEditor MainEditor { + protected override MonoTextEditor MainEditor { get { return editors[1]; } @@ -69,8 +69,8 @@ namespace MonoDevelop.VersionControl.Views protected override void CreateComponents () { this.editors = new [] { - new TextEditor (new TextDocument (), new CommonTextEditorOptions ()), - new TextEditor (new TextDocument (), new CommonTextEditorOptions ()), + new MonoTextEditor (new TextDocument (), CommonTextEditorOptions.Instance), + new MonoTextEditor (new TextDocument (), CommonTextEditorOptions.Instance), }; if (!viewOnly) { @@ -148,7 +148,7 @@ namespace MonoDevelop.VersionControl.Views QueueDraw (); } - public void SetRevision (TextEditor toEditor, Revision rev) + public void SetRevision (MonoTextEditor toEditor, Revision rev) { BackgroundWorker worker = new BackgroundWorker (); worker.DoWork += delegate(object sender, DoWorkEventArgs e) { @@ -236,14 +236,14 @@ namespace MonoDevelop.VersionControl.Views { if (n == 0) { box.SetItem ("Local", null, new object()); - widget.SetLocal (((TextEditor)box.Tag).GetTextEditorData ()); + widget.SetLocal (((MonoTextEditor)box.Tag).GetTextEditorData ()); return; } - widget.RemoveLocal (((TextEditor)box.Tag).GetTextEditorData ()); - ((TextEditor)box.Tag).Document.ReadOnly = true; + widget.RemoveLocal (((MonoTextEditor)box.Tag).GetTextEditorData ()); + ((MonoTextEditor)box.Tag).Document.ReadOnly = true; if (n == 1) { box.SetItem ("Base", null, new object()); - if (((TextEditor)box.Tag) == widget.editors[0]) { + if (((MonoTextEditor)box.Tag) == widget.editors[0]) { widget.diffRevision = null; } else { widget.originalRevision = null; @@ -256,13 +256,13 @@ namespace MonoDevelop.VersionControl.Views MessageService.ShowError (text); } - ((TextEditor)box.Tag).Document.Text = text; + ((MonoTextEditor)box.Tag).Document.Text = text; widget.CreateDiff (); return; } Revision rev = widget.info.History[n - 2]; - widget.SetRevision ((TextEditor)box.Tag, rev); + widget.SetRevision ((MonoTextEditor)box.Tag, rev); } public int IconCount { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs index 9d92426ff6..715d6f4e26 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffParser.cs @@ -32,6 +32,7 @@ using MonoDevelop.Ide.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; using MonoDevelop.Projects; +using MonoDevelop.Core.Text; namespace MonoDevelop.VersionControl.Views { @@ -50,16 +51,16 @@ namespace MonoDevelop.VersionControl.Views static Regex eolExpression = new Regex (@"(?<eol>\r\n|\n|\r)", RegexOptions.Compiled); #region AbstractParser overrides - - public override ParsedDocument Parse (bool storeAst, string fileName, TextReader textReader, Project project = null) + + public override System.Threading.Tasks.Task<ParsedDocument> Parse (ParseOptions parseOptions, System.Threading.CancellationToken cancellationToken) { - var doc = new DefaultParsedDocument (fileName); + ParsedDocument doc = new DefaultParsedDocument (parseOptions.FileName); DefaultUnresolvedTypeDefinition currentFile = null; DefaultUnresolvedProperty currentRegion = null; string eol = Environment.NewLine; - string content = textReader.ReadToEnd (); + string content = parseOptions.Content.Text; Match eolMatch = eolExpression.Match (content); if (eolMatch != null && eolMatch.Success) eol = eolMatch.Groups ["eol"].Value; @@ -82,7 +83,7 @@ namespace MonoDevelop.VersionControl.Views // Create new file region currentFile = new DefaultUnresolvedTypeDefinition (string.Empty, string.Empty); currentFile.Region = currentFile.BodyRegion = new DomRegion (lastToken (lineMatch.Groups ["filepath"].Value), linenum, line.Length + 1, linenum, int.MaxValue); - doc.TopLevelTypeDefinitions.Add (currentFile); + // doc.TopLevelTypeDefinitions.Add (currentFile); } else { lineMatch = chunkExpression.Match (line); if (lineMatch != null && lineMatch.Success && currentFile != null) { @@ -110,7 +111,7 @@ namespace MonoDevelop.VersionControl.Views currentRegion.BodyRegion.BeginColumn, Math.Max (1, linenum - 2), int.MaxValue); - return doc; + return System.Threading.Tasks.Task.FromResult (doc); } #endregion diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs index 4d3521553b..8920fd588a 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs @@ -83,7 +83,7 @@ namespace MonoDevelop.VersionControl.Views #region IAttachableViewContent implementation - public int GetLineInCenter (Mono.TextEditor.TextEditor editor) + public int GetLineInCenter (Mono.TextEditor.MonoTextEditor editor) { double midY = editor.VAdjustment.Value + editor.Allocation.Height / 2; return editor.YToLine (midY); @@ -93,11 +93,10 @@ namespace MonoDevelop.VersionControl.Views { info.Start (); ComparisonWidget.UpdateLocalText (); - var buffer = info.Document.GetContent<ITextBuffer> (); + var buffer = info.Document.GetContent<MonoDevelop.Ide.Editor.TextEditor> (); if (buffer != null) { - int line, col; - buffer.GetLineColumnFromPosition (buffer.CursorPosition, out line, out col); - ComparisonWidget.OriginalEditor.SetCaretTo (line, col); + var loc = buffer.CaretLocation; + ComparisonWidget.OriginalEditor.SetCaretTo (loc.Line, loc.Column); } if (ComparisonWidget.Allocation.Height == 1 && ComparisonWidget.Allocation.Width == 1) { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs index fc7089a08b..d98b37dab1 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs @@ -33,7 +33,7 @@ namespace MonoDevelop.VersionControl.Views public partial class DiffWidget : Gtk.Bin { VersionControlDocumentInfo info; - Mono.TextEditor.TextEditor diffTextEditor; + Mono.TextEditor.MonoTextEditor diffTextEditor; ComparisonWidget comparisonWidget; Gtk.Button buttonNext; Gtk.Button buttonPrev; @@ -63,7 +63,7 @@ namespace MonoDevelop.VersionControl.Views } } - public Mono.TextEditor.TextEditor FocusedEditor { + public Mono.TextEditor.MonoTextEditor FocusedEditor { get { return comparisonWidget.FocusedEditor; } @@ -91,7 +91,7 @@ namespace MonoDevelop.VersionControl.Views }; comparisonWidget.SetVersionControlInfo (info); this.buttonDiff.Clicked += HandleButtonDiffhandleClicked; - diffTextEditor = new global::Mono.TextEditor.TextEditor (new Mono.TextEditor.TextDocument (), new CommonTextEditorOptions ()); + diffTextEditor = new global::Mono.TextEditor.MonoTextEditor (new Mono.TextEditor.TextDocument (), CommonTextEditorOptions.Instance); diffTextEditor.Document.MimeType = "text/x-diff"; diffTextEditor.Options.ShowFoldMargin = false; @@ -143,7 +143,7 @@ namespace MonoDevelop.VersionControl.Views } } - static string GetRevisionText (Mono.TextEditor.TextEditor editor, Revision rev) + static string GetRevisionText (Mono.TextEditor.MonoTextEditor editor, Revision rev) { if (!editor.Document.ReadOnly) return GettextCatalog.GetString ("(working copy)"); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DropDownBox.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DropDownBox.cs index 066ad679b2..32e8313988 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DropDownBox.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DropDownBox.cs @@ -29,6 +29,7 @@ using System.ComponentModel; using MonoDevelop.Ide; using Gtk; using Mono.TextEditor; +using MonoDevelop.Components; namespace MonoDevelop.VersionControl.Views { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs index ea883f870e..c4fe20f7f3 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs @@ -36,6 +36,7 @@ using MonoDevelop.Ide; using MonoDevelop.Core; using MonoDevelop.Components.Commands; using MonoDevelop.Projects.Text; +using MonoDevelop.Components; namespace MonoDevelop.VersionControl.Views { @@ -54,7 +55,7 @@ namespace MonoDevelop.VersionControl.Views DiffScrollbar rightDiffScrollBar, leftDiffScrollBar; MiddleArea[] middleAreas; - protected TextEditor[] editors; + protected MonoTextEditor[] editors; protected Widget[] headerWidgets; @@ -85,13 +86,13 @@ namespace MonoDevelop.VersionControl.Views static readonly Cairo.Color lightBlue = new Cairo.Color (190 / 255.0, 190 / 255.0, 240 / 255.0); static readonly Cairo.Color darkBlue = new Cairo.Color (133 / 255.0, 133 / 255.0, 168 / 255.0); - protected abstract TextEditor MainEditor { + protected abstract MonoTextEditor MainEditor { get; } - public TextEditor FocusedEditor { + public MonoTextEditor FocusedEditor { get { - foreach (TextEditor editor in editors) { + foreach (MonoTextEditor editor in editors) { if (editor.HasFocus) return editor; @@ -203,7 +204,7 @@ namespace MonoDevelop.VersionControl.Views this.MainEditor.EditorOptionsChanged += HandleMainEditorhandleEditorOptionsChanged; } - void ShowPopup (TextEditor editor, EventButton evt) + void ShowPopup (MonoTextEditor editor, EventButton evt) { CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet ("/MonoDevelop/VersionControl/DiffView/ContextMenu"); Gtk.Menu menu = IdeApp.CommandService.CreateMenu (cset); @@ -253,7 +254,7 @@ namespace MonoDevelop.VersionControl.Views protected abstract void CreateComponents (); - public static ICollection<Cairo.Rectangle> GetDiffRectangles (TextEditor editor, int startOffset, int endOffset) + public static ICollection<Cairo.Rectangle> GetDiffRectangles (MonoTextEditor editor, int startOffset, int endOffset) { ICollection<Cairo.Rectangle> rectangles = new List<Cairo.Rectangle> (); var startLine = editor.GetLineByOffset (startOffset); @@ -276,12 +277,12 @@ namespace MonoDevelop.VersionControl.Views diffCache.Clear (); } - static List<TextSegment> BreakTextInWords (TextEditor editor, int start, int count) + static List<TextSegment> BreakTextInWords (MonoTextEditor editor, int start, int count) { return TextBreaker.BreakLinesIntoWords(editor, start, count); } - static List<Cairo.Rectangle> CalculateChunkPath (TextEditor editor, List<Hunk> diff, List<TextSegment> words, bool useRemove) + static List<Cairo.Rectangle> CalculateChunkPath (MonoTextEditor editor, List<Hunk> diff, List<TextSegment> words, bool useRemove) { List<Cairo.Rectangle> result = new List<Cairo.Rectangle> (); int startOffset = -1; @@ -304,7 +305,7 @@ namespace MonoDevelop.VersionControl.Views return result; } - Tuple<List<Cairo.Rectangle>, List<Cairo.Rectangle>> GetDiffPaths (List<Hunk> diff, TextEditor editor, Hunk hunk) + Tuple<List<Cairo.Rectangle>, List<Cairo.Rectangle>> GetDiffPaths (List<Hunk> diff, MonoTextEditor editor, Hunk hunk) { if (!diffCache.ContainsKey (diff)) diffCache[diff] = new Dictionary<Hunk, Tuple<List<Cairo.Rectangle>, List<Cairo.Rectangle>>> (); @@ -375,7 +376,7 @@ namespace MonoDevelop.VersionControl.Views internal static void EditorFocusIn (object sender, FocusInEventArgs args) { - TextEditor editor = (TextEditor)sender; + MonoTextEditor editor = (MonoTextEditor)sender; UpdateCaretPosition (editor.Caret); } @@ -611,10 +612,11 @@ namespace MonoDevelop.VersionControl.Views throw new InvalidOperationException ("Version control info must be set before attaching the merge view to an editor."); dict[data.Document] = data; - var editor = info.Document.GetContent <ITextFile> (); - if (editor != null) + var editor = info.Document.GetContent <MonoDevelop.Ide.Editor.IReadonlyTextDocument> (); + if (editor != null) { data.Document.Text = editor.Text; - data.Document.ReadOnly = info.Document.GetContent<IEditableTextFile> () == null; + data.Document.ReadOnly = editor.IsReadOnly; + } CreateDiff (); data.Document.TextReplaced += HandleDataDocumentTextReplaced; @@ -624,9 +626,8 @@ namespace MonoDevelop.VersionControl.Views { var data = dict [(TextDocument)sender]; localUpdate.Remove (data); - var editor = info.Document.GetContent<IEditableTextFile> (); - editor.DeleteText (e.Offset, e.RemovalLength); - editor.InsertText (e.Offset, e.InsertedText.Text); + var editor = info.Document.GetContent<MonoDevelop.Ide.Editor.ITextDocument> (); + editor.ReplaceText (e.Offset, e.RemovalLength, e.InsertedText.Text); localUpdate.Add (data); UpdateDiff (); } @@ -637,7 +638,7 @@ namespace MonoDevelop.VersionControl.Views data.Document.TextReplaced -= HandleDataDocumentTextReplaced; } - protected virtual void UndoChange (TextEditor fromEditor, TextEditor toEditor, Hunk hunk) + protected virtual void UndoChange (MonoTextEditor fromEditor, MonoTextEditor toEditor, Hunk hunk) { using (var undo = toEditor.OpenUndoGroup ()) { var start = toEditor.Document.GetLine (hunk.InsertStart); @@ -668,7 +669,7 @@ namespace MonoDevelop.VersionControl.Views class MiddleArea : DrawingArea { EditorCompareWidgetBase widget; - TextEditor fromEditor, toEditor; + MonoTextEditor fromEditor, toEditor; bool useLeft; IEnumerable<Hunk> Diff { @@ -677,7 +678,7 @@ namespace MonoDevelop.VersionControl.Views } } - public MiddleArea (EditorCompareWidgetBase widget, TextEditor fromEditor, TextEditor toEditor, bool useLeft) + public MiddleArea (EditorCompareWidgetBase widget, MonoTextEditor fromEditor, MonoTextEditor toEditor, bool useLeft) { this.widget = widget; this.Events |= EventMask.PointerMotionMask | EventMask.ButtonPressMask; @@ -888,7 +889,7 @@ namespace MonoDevelop.VersionControl.Views // mx -= (int)x; // my -= (int)y; using (var gradient = new Cairo.RadialGradient (mx, my, h, mx, my, 2)) { - var color = (HslColor)Style.Mid (StateType.Normal); + var color = (MonoDevelop.Components.HslColor)Style.Mid (StateType.Normal); color.L *= 1.05; gradient.AddColorStop (0, color); color.L *= 1.07; @@ -896,11 +897,11 @@ namespace MonoDevelop.VersionControl.Views cr.SetSource (gradient); } } else { - cr.SetSourceColor ((HslColor)Style.Mid (StateType.Normal)); + cr.SetSourceColor ((MonoDevelop.Components.HslColor)Style.Mid (StateType.Normal)); } cr.FillPreserve (); - cr.SetSourceColor ((HslColor)Style.Dark (StateType.Normal)); + cr.SetSourceColor ((MonoDevelop.Components.HslColor)Style.Dark (StateType.Normal)); cr.Stroke (); cr.LineWidth = 1; cr.SetSourceRGB (0, 0, 0); @@ -930,13 +931,13 @@ namespace MonoDevelop.VersionControl.Views class DiffScrollbar : DrawingArea { - TextEditor editor; + MonoTextEditor editor; EditorCompareWidgetBase widget; bool useLeftDiff; bool paintInsert; Adjustment vAdjustment; - public DiffScrollbar (EditorCompareWidgetBase widget, TextEditor editor, bool useLeftDiff, bool paintInsert) + public DiffScrollbar (EditorCompareWidgetBase widget, MonoTextEditor editor, bool useLeftDiff, bool paintInsert) { this.editor = editor; this.useLeftDiff = useLeftDiff; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs index ab9c7898d6..02e20fc3f4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs @@ -38,7 +38,7 @@ namespace MonoDevelop.VersionControl.Views { public class MergeWidget : EditorCompareWidgetBase { - protected override TextEditor MainEditor { + protected override MonoTextEditor MainEditor { get { return editors != null && editors.Length >= 2 ? editors[1] : null; } @@ -49,7 +49,7 @@ namespace MonoDevelop.VersionControl.Views MainEditor.Document.TextReplaced += UpdateConflictsOnTextReplace; } - protected override void UndoChange (TextEditor fromEditor, TextEditor toEditor, Hunk hunk) + protected override void UndoChange (MonoTextEditor fromEditor, MonoTextEditor toEditor, Hunk hunk) { base.UndoChange (fromEditor, toEditor, hunk); int i = leftConflicts.IndexOf (hunk); @@ -100,9 +100,9 @@ namespace MonoDevelop.VersionControl.Views protected override void CreateComponents () { this.editors = new [] { - new TextEditor (new TextDocument (), new CommonTextEditorOptions ()), - new TextEditor (new TextDocument (), new CommonTextEditorOptions ()), - new TextEditor (new TextDocument (), new CommonTextEditorOptions ()), + new MonoTextEditor (new TextDocument (), CommonTextEditorOptions.Instance), + new MonoTextEditor (new TextDocument (), CommonTextEditorOptions.Instance), + new MonoTextEditor (new TextDocument (), CommonTextEditorOptions.Instance), }; this.editors[0].Document.ReadOnly = true; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj index 1de9cb6406..c329b72003 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj @@ -112,6 +112,22 @@ </Reference> <Reference Include="System.Core" /> <Reference Include="Mono.Cairo" /> + <Reference Include="System.Collections.Immutable"> + <HintPath>..\..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="System.Reflection.Metadata"> + <HintPath>..\..\..\..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Microsoft.CodeAnalysis.Desktop"> + <HintPath>..\..\..\..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc1\lib\net45\Microsoft.CodeAnalysis.Desktop.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="Microsoft.CodeAnalysis"> + <HintPath>..\..\..\..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc1\lib\net45\Microsoft.CodeAnalysis.dll</HintPath> + <Private>False</Private> + </Reference> </ItemGroup> <ItemGroup> <EmbeddedResource Include="icons\added-overlay-16.png"> @@ -407,10 +423,12 @@ <Compile Include="AddinInfo.cs" /> <Compile Include="MonoDevelop.VersionControl\VersionControlException.cs" /> <Compile Include="MonoDevelop.VersionControl\VersionControlTask.cs" /> + <Compile Include="MonoDevelop.VersionControl.Views\CommonTextEditorOptions.cs" /> <Compile Include="MonoDevelop.VersionControl.Views\BaseView.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> + <None Include="packages.config" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/packages.config b/main/src/addins/VersionControl/MonoDevelop.VersionControl/packages.config new file mode 100644 index 0000000000..d3fca62c00 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/packages.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Microsoft.CodeAnalysis.Common" version="1.0.0-rc1" targetFramework="net45" />
+ <package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
+ <package id="System.Reflection.Metadata" version="1.0.18-beta" targetFramework="net45" />
+</packages>
\ No newline at end of file |