Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs')
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs1422
1 files changed, 1018 insertions, 404 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index 305bced3be..ec7e3fd5ad 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -55,13 +55,18 @@ using System.Text;
using Mono.Addins;
using MonoDevelop.Components;
using Mono.TextEditor.Utils;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.SourceEditor.Wrappers;
+using MonoDevelop.Ide.Editor.Extension;
+using MonoDevelop.Ide.Editor.Highlighting;
namespace MonoDevelop.SourceEditor
{
- public class SourceEditorView : AbstractViewContent, IExtensibleTextEditor, IBookmarkBuffer, IClipboardHandler,
- ICompletionWidget, ISplittable, IFoldable, IToolboxDynamicProvider, IEncodedTextContent,
- ICustomFilteringToolboxConsumer, IZoomable, ITextEditorResolver, Mono.TextEditor.ITextEditorDataProvider,
- ICodeTemplateHandler, ICodeTemplateContextProvider, ISupportsProjectReload, IPrintable
+ partial class SourceEditorView : AbstractViewContent, IBookmarkBuffer, IClipboardHandler, ITextFile,
+ ICompletionWidget, ISplittable, IFoldable, IToolboxDynamicProvider,
+ ICustomFilteringToolboxConsumer, IZoomable, ITextEditorResolver, ITextEditorDataProvider,
+ ICodeTemplateHandler, ICodeTemplateContextProvider, ISupportsProjectReload, IPrintable,
+ ITextEditorImpl, IEditorActionHost, ITextMarkerFactory, IUndoHandler
{
readonly SourceEditorWidget widget;
bool isDisposed = false;
@@ -79,10 +84,13 @@ namespace MonoDevelop.SourceEditor
bool writeAllowed;
bool writeAccessChecked;
- public Mono.TextEditor.TextDocument Document {
+ public TextDocument Document {
get {
return widget.TextEditor.Document;
}
+ set {
+ widget.TextEditor.Document = value;
+ }
}
public DateTime LastSaveTimeUtc {
@@ -93,7 +101,8 @@ namespace MonoDevelop.SourceEditor
lastSaveTimeUtc = value;
}
}
- public ExtensibleTextEditor TextEditor {
+
+ internal ExtensibleTextEditor TextEditor {
get {
return widget.TextEditor;
}
@@ -105,7 +114,7 @@ namespace MonoDevelop.SourceEditor
}
}
- public override Gtk.Widget Control {
+ public override Widget Control {
get {
return widget != null ? widget.Vbox : null;
}
@@ -116,42 +125,12 @@ namespace MonoDevelop.SourceEditor
return Document.LineCount;
}
}
-
- public override Project Project {
- get {
- return base.Project;
- }
- set {
- if (value != base.Project)
- ((StyledSourceEditorOptions)SourceEditorWidget.TextEditor.Options).UpdateStyleParent (value, loadedMimeType);
- base.Project = value;
- }
- }
public override string TabPageLabel {
get { return GettextCatalog.GetString ("Source"); }
}
- uint autoSaveTimer = 0;
- void InformAutoSave ()
- {
- RemoveAutoSaveTimer ();
- autoSaveTimer = GLib.Timeout.Add (500, delegate {
- AutoSave.InformAutoSaveThread (Document);
- autoSaveTimer = 0;
- return false;
- });
- }
-
- void RemoveAutoSaveTimer ()
- {
- if (autoSaveTimer == 0)
- return;
- GLib.Source.Remove (autoSaveTimer);
- autoSaveTimer = 0;
- }
-
bool wasEdited = false;
uint removeMarkerTimeout;
Queue<MessageBubbleTextMarker> markersToRemove = new Queue<MessageBubbleTextMarker> ();
@@ -177,19 +156,27 @@ namespace MonoDevelop.SourceEditor
});
}
- public SourceEditorView ()
+ public SourceEditorView (IReadonlyTextDocument document = null)
{
Counters.LoadedEditors++;
widget = new SourceEditorWidget (this);
- widget.TextEditor.Document.SyntaxModeChanged += HandleSyntaxModeChanged;
+ if (document != null) {
+ var textDocument = document as TextDocument;
+ if (textDocument != null) {
+ widget.TextEditor.Document = textDocument;
+ } else {
+ widget.TextEditor.Document.Text = document.Text;
+ }
+ }
+
widget.TextEditor.Document.TextReplaced += HandleTextReplaced;
widget.TextEditor.Document.LineChanged += HandleLineChanged;
+ widget.TextEditor.Document.LineInserted += HandleLineChanged;
+ widget.TextEditor.Document.LineRemoved += HandleLineChanged;
widget.TextEditor.Document.BeginUndo += HandleBeginUndo;
widget.TextEditor.Document.EndUndo += HandleEndUndo;
- widget.TextEditor.Document.Undone += HandleUndone;
- widget.TextEditor.Document.Redone += HandleUndone;
widget.TextEditor.Document.TextReplacing += OnTextReplacing;
widget.TextEditor.Document.TextReplaced += OnTextReplaced;
@@ -201,13 +188,13 @@ namespace MonoDevelop.SourceEditor
widget.TextEditor.Caret.PositionChanged += HandlePositionChanged;
widget.TextEditor.IconMargin.ButtonPressed += OnIconButtonPress;
-
+
debugStackLineMarker = new DebugStackLineTextMarker (widget.TextEditor);
currentDebugLineMarker = new CurrentDebugLineTextMarker (widget.TextEditor);
- this.WorkbenchWindowChanged += HandleWorkbenchWindowChanged;
- this.ContentNameChanged += delegate {
- this.Document.FileName = this.ContentName;
+ WorkbenchWindowChanged += HandleWorkbenchWindowChanged;
+ ContentNameChanged += delegate {
+ Document.FileName = ContentName;
if (String.IsNullOrEmpty (ContentName) || !File.Exists (ContentName))
return;
@@ -240,10 +227,14 @@ namespace MonoDevelop.SourceEditor
widget.TextEditor.Options.Changed += HandleWidgetTextEditorOptionsChanged;
IdeApp.Preferences.DefaultHideMessageBubblesChanged += HandleIdeAppPreferencesDefaultHideMessageBubblesChanged;
Document.AddAnnotation (this);
+ if (document != null) {
+ Document.MimeType = document.MimeType;
+ Document.FileName = document.FileName;
+ }
FileRegistry.Add (this);
}
- void HandleLineChanged (object sender, LineEventArgs e)
+ void HandleLineChanged (object sender, Mono.TextEditor.LineEventArgs e)
{
UpdateBreakpoints ();
UpdateWidgetPositions ();
@@ -255,6 +246,9 @@ namespace MonoDevelop.SourceEditor
marker.GetLineHeight (widget.TextEditor);
}
}
+ var handler = LineChanged;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
}
void HandleTextReplaced (object sender, DocumentChangeEventArgs args)
@@ -265,9 +259,6 @@ namespace MonoDevelop.SourceEditor
if (widget.TextEditor.Document.IsInAtomicUndo) {
wasEdited = true;
}
- else {
- InformAutoSave ();
- }
}
int startIndex = args.Offset;
@@ -279,37 +270,23 @@ namespace MonoDevelop.SourceEditor
ResetRemoveMarker ();
}
- void HandleSyntaxModeChanged (object sender, SyntaxModeChangeEventArgs e)
- {
- var oldProvider = e.OldMode as IQuickTaskProvider;
- if (oldProvider != null)
- widget.RemoveQuickTaskProvider (oldProvider);
- var newProvider = e.NewMode as IQuickTaskProvider;
- if (newProvider != null)
- widget.AddQuickTaskProvider (newProvider);
- }
-
-
void HandleEndUndo (object sender, TextDocument.UndoOperationEventArgs e)
{
- if (wasEdited)
- InformAutoSave ();
+ OnEndUndo (EventArgs.Empty);
}
void HandleBeginUndo (object sender, EventArgs e)
{
wasEdited = false;
+ OnBeginUndo (EventArgs.Empty);
}
- void HandleUndone (object sender, TextDocument.UndoOperationEventArgs e)
- {
- AutoSave.InformAutoSaveThread (Document);
- }
void HandlePositionChanged (object sender, DocumentLocationEventArgs e)
{
OnCaretPositionSet (EventArgs.Empty);
FireCompletionContextChanged ();
+ OnCaretPositionChanged (EventArgs.Empty);
}
void HandleFileExtensionRemoved (object sender, FileExtensionEventArgs args)
@@ -326,7 +303,7 @@ namespace MonoDevelop.SourceEditor
AddFileExtension (args.Extension);
}
- Dictionary<TopLevelWidgetExtension,Gtk.Widget> widgetExtensions = new Dictionary<TopLevelWidgetExtension, Widget> ();
+ Dictionary<TopLevelWidgetExtension,Widget> widgetExtensions = new Dictionary<TopLevelWidgetExtension, Widget> ();
Dictionary<FileExtension,Tuple<TextLineMarker,DocumentLine>> markerExtensions = new Dictionary<FileExtension, Tuple<TextLineMarker,DocumentLine>> ();
void LoadExtensions ()
@@ -360,22 +337,22 @@ namespace MonoDevelop.SourceEditor
if (line == null)
return;
- var marker = lineExt.CreateMarker ();
+ var marker = (TextLineMarker)lineExt.CreateMarker ();
widget.TextEditor.Document.AddMarker (line, marker);
widget.TextEditor.QueueDraw ();
- markerExtensions [extension] = new Tuple<TextLineMarker,DocumentLine> (marker, line);
+ markerExtensions [extension] = new Tuple<TextLineMarker, DocumentLine> (marker, line);
}
}
void HandleScrollToViewRequested (object sender, EventArgs e)
{
var widgetExtension = (TopLevelWidgetExtension)sender;
- Gtk.Widget w;
+ Widget w;
if (widgetExtensions.TryGetValue (widgetExtension, out w)) {
int x, y;
widget.TextEditor.TextArea.GetTopLevelWidgetPosition (w, out x, out y);
var size = w.SizeRequest ();
- Gtk.Application.Invoke (delegate {
+ Application.Invoke (delegate {
widget.TextEditor.ScrollTo (new Gdk.Rectangle (x, y, size.Width, size.Height));
});
}
@@ -385,7 +362,7 @@ namespace MonoDevelop.SourceEditor
{
if (extension is TopLevelWidgetExtension) {
var widgetExtension = (TopLevelWidgetExtension)extension;
- Gtk.Widget w;
+ Widget w;
if (!widgetExtensions.TryGetValue (widgetExtension, out w))
return;
widgetExtensions.Remove (widgetExtension);
@@ -417,7 +394,7 @@ namespace MonoDevelop.SourceEditor
}
}
- bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, Gtk.Widget w, out int x, out int y)
+ bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, Widget w, out int x, out int y)
{
DocumentLine line = widget.TextEditor.Document.GetLine (widgetExtension.Line);
if (line == null) {
@@ -426,10 +403,10 @@ namespace MonoDevelop.SourceEditor
}
int lw, lh;
- var wrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
- wrapper.Layout.GetPixelSize (out lw, out lh);
- if (wrapper.IsUncached)
- wrapper.Dispose ();
+ var tmpWrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
+ tmpWrapper.Layout.GetPixelSize (out lw, out lh);
+ if (tmpWrapper.IsUncached)
+ tmpWrapper.Dispose ();
lh = (int) TextEditor.TextViewMargin.GetLineHeight (widgetExtension.Line);
x = (int)widget.TextEditor.TextViewMargin.XOffset + lw + 4;
y = (int)widget.TextEditor.LineToY (widgetExtension.Line);
@@ -487,9 +464,8 @@ namespace MonoDevelop.SourceEditor
void HandleWorkbenchWindowChanged (object sender, EventArgs e)
{
if (WorkbenchWindow != null) {
- widget.TextEditor.ExtensionContext = WorkbenchWindow.ExtensionContext;
WorkbenchWindow.ActiveViewContentChanged += HandleActiveViewContentChanged;
- this.WorkbenchWindowChanged -= HandleWorkbenchWindowChanged;
+ WorkbenchWindowChanged -= HandleWorkbenchWindowChanged;
}
}
@@ -509,7 +485,7 @@ namespace MonoDevelop.SourceEditor
{
var task = e.Tasks != null ? e.Tasks.FirstOrDefault () : null;
var doc = Document;
- if (task == null || doc == null || task.FileName != doc.FileName || this.TextEditor == null)
+ if (task == null || doc == null || task.FileName != doc.FileName || TextEditor == null)
return;
var lineSegment = doc.GetLine (task.Line);
if (lineSegment == null)
@@ -518,7 +494,7 @@ namespace MonoDevelop.SourceEditor
if (marker == null)
return;
- marker.SetPrimaryError (task.Description);
+ marker.SetPrimaryError (task);
if (TextEditor != null && TextEditor.IsComposited) {
/*if (messageBubbleHighlightPopupWindow != null)
@@ -534,7 +510,7 @@ namespace MonoDevelop.SourceEditor
void HandleIdeAppPreferencesDefaultHideMessageBubblesChanged (object sender, PropertyChangedEventArgs e)
{
currentErrorMarkers.ForEach (marker => marker.IsVisible =  !IdeApp.Preferences.DefaultHideMessageBubbles);
- this.TextEditor.QueueDraw ();
+ TextEditor.QueueDraw ();
}
void HandleIdeAppPreferencesShowMessageBubblesChanged (object sender, PropertyChangedEventArgs e)
@@ -544,7 +520,7 @@ namespace MonoDevelop.SourceEditor
void HandleErrorListPadTaskToggled (object sender, TaskEventArgs e)
{
- this.TextEditor.QueueDraw ();
+ TextEditor.QueueDraw ();
}
MessageBubbleCache messageBubbleCache;
@@ -593,7 +569,7 @@ namespace MonoDevelop.SourceEditor
//NRE and bring down MD
/*if (messageBubbleHighlightPopupWindow != null)
messageBubbleHighlightPopupWindow.Destroy ();*/
-
+
currentErrorMarkers.ForEach (em => {
widget.Document.RemoveMarker (em);
em.Dispose ();
@@ -610,9 +586,9 @@ namespace MonoDevelop.SourceEditor
return text;
}
- public override void Save (string fileName)
+ public override void Save (FileSaveInformation fileSaveInformation)
{
- Save (fileName, this.encoding);
+ Save (fileSaveInformation.FileName, fileSaveInformation.Encoding ?? encoding);
}
public void Save (string fileName, Encoding encoding)
@@ -620,9 +596,6 @@ namespace MonoDevelop.SourceEditor
if (widget.HasMessageBar)
return;
- if (!string.IsNullOrEmpty (ContentName))
- AutoSave.RemoveAutoSaveFile (ContentName);
-
if (ContentName != fileName) {
FileService.RequestFileEdit ((FilePath) fileName);
writeAllowed = true;
@@ -630,7 +603,7 @@ namespace MonoDevelop.SourceEditor
}
if (warnOverwrite) {
- if (fileName == ContentName) {
+ if (string.Equals (fileName, ContentName, FilePath.PathComparison)) {
string question = GettextCatalog.GetString (
"This file {0} has been changed outside of {1}. Are you sure you want to overwrite the file?",
fileName, BrandingService.ApplicationName
@@ -701,7 +674,7 @@ namespace MonoDevelop.SourceEditor
// writeBom =!Mono.TextEditor.Utils.TextFileUtility.IsASCII (writeText);
}
}
- Mono.TextEditor.Utils.TextFileUtility.WriteText (fileName, writeText, writeEncoding, writeBom);
+ TextFileUtility.WriteText (fileName, writeText, writeEncoding, writeBom);
} catch (InvalidEncodingException) {
var result = MessageService.AskQuestion (GettextCatalog.GetString ("Can't save file with current codepage."),
GettextCatalog.GetString ("Some unicode characters in this file could not be saved with the current encoding.\nDo you want to resave this file as Unicode ?\nYou can choose another encoding in the 'save as' dialog."),
@@ -709,9 +682,9 @@ namespace MonoDevelop.SourceEditor
AlertButton.Cancel,
new AlertButton (GettextCatalog.GetString ("Save as Unicode")));
if (result != AlertButton.Cancel) {
- this.hadBom = true;
+ hadBom = true;
this.encoding = Encoding.UTF8;
- Mono.TextEditor.Utils.TextFileUtility.WriteText (fileName, Document.Text, encoding, hadBom);
+ TextFileUtility.WriteText (fileName, Document.Text, encoding, hadBom);
} else {
return;
}
@@ -737,17 +710,12 @@ namespace MonoDevelop.SourceEditor
ContentName = fileName;
UpdateMimeType (fileName);
Document.SetNotDirtyState ();
- this.IsDirty = false;
- }
-
- public override void DiscardChanges ()
- {
- if (!string.IsNullOrEmpty (ContentName))
- AutoSave.RemoveAutoSaveFile (ContentName);
+ IsDirty = false;
}
- public override void LoadNew (Stream content, string mimeType)
+ public void InformLoadComplete ()
{
+ /*
Document.MimeType = mimeType;
string text = null;
if (content != null) {
@@ -757,52 +725,18 @@ namespace MonoDevelop.SourceEditor
}
this.CreateDocumentParsedHandler ();
RunFirstTimeFoldUpdate (text);
+ */
Document.InformLoadComplete ();
}
- public override void Load (string fileName)
+ public override void LoadNew (Stream content, string mimeType)
{
- Load (fileName, null);
+ throw new NotSupportedException ("Moved to TextEditorViewContent.LoadNew.");
}
-
- void RunFirstTimeFoldUpdate (string text)
+
+ public override void Load (FileOpenInformation fileOpenInformation)
{
- if (string.IsNullOrEmpty (text))
- return;
- ParsedDocument parsedDocument = null;
-
- var foldingParser = TypeSystemService.GetFoldingParser (Document.MimeType);
- if (foldingParser != null) {
- parsedDocument = foldingParser.Parse (Document.FileName, text);
- } else {
- var normalParser = TypeSystemService.GetParser (Document.MimeType);
- if (normalParser != null) {
- using (var sr = new StringReader (text))
- parsedDocument = normalParser.Parse (true, Document.FileName, sr, null);
- }
- }
- if (parsedDocument != null)
- widget.UpdateParsedDocument (parsedDocument);
- }
-
- void CreateDocumentParsedHandler ()
- {
- this.WorkbenchWindowChanged += delegate {
- if (WorkbenchWindow == null)
- return;
- WorkbenchWindow.DocumentChanged += delegate {
- if (WorkbenchWindow.Document == null)
- return;
- foreach (var provider in WorkbenchWindow.Document.GetContents<IQuickTaskProvider> ()) {
- widget.AddQuickTaskProvider (provider);
- }
- foreach (var provider in WorkbenchWindow.Document.GetContents<IUsageProvider> ()) {
- widget.AddUsageTaskProvider (provider);
- }
- ownerDocument = WorkbenchWindow.Document;
- ownerDocument.DocumentParsed += HandleDocumentParsed;
- };
- };
+ Load (fileOpenInformation.FileName, fileOpenInformation.Encoding);
}
MonoDevelop.Ide.Gui.Document ownerDocument;
@@ -813,11 +747,6 @@ namespace MonoDevelop.SourceEditor
protected virtual void HandleDocumentParsed (object sender, EventArgs e)
{
widget.UpdateParsedDocument (ownerDocument.ParsedDocument);
- }
-
- void IEncodedTextContent.Load (string fileName, Encoding loadEncoding)
- {
- Load (fileName, loadEncoding);
}
protected virtual string ProcessLoadText (string text)
@@ -827,9 +756,8 @@ namespace MonoDevelop.SourceEditor
public void Load (string fileName, Encoding loadEncoding, bool reload = false)
{
- // Handle the "reload" case.
- if (ContentName == fileName)
- AutoSave.RemoveAutoSaveFile (fileName);
+ widget.TextEditor.Document.TextReplaced -= OnTextReplaced;
+
if (warnOverwrite) {
warnOverwrite = false;
widget.RemoveMessageBar ();
@@ -841,7 +769,7 @@ namespace MonoDevelop.SourceEditor
bool didLoadCleanly;
if (AutoSave.AutoSaveExists (fileName)) {
widget.ShowAutoSaveWarning (fileName);
- this.encoding = loadEncoding;
+ encoding = loadEncoding;
didLoadCleanly = false;
}
else {
@@ -864,22 +792,22 @@ namespace MonoDevelop.SourceEditor
didLoadCleanly = true;
}
// TODO: Would be much easier if the view would be created after the containers.
- CreateDocumentParsedHandler ();
ContentName = fileName;
lastSaveTimeUtc = File.GetLastWriteTimeUtc (ContentName);
- RunFirstTimeFoldUpdate (text);
widget.TextEditor.Caret.Offset = 0;
UpdateExecutionLocation ();
UpdateBreakpoints ();
UpdatePinnedWatches ();
LoadExtensions ();
- this.IsDirty = !didLoadCleanly;
+ IsDirty = !didLoadCleanly;
UpdateTasks (null, null);
widget.TextEditor.TextArea.SizeAllocated += HandleTextEditorVAdjustmentChanged;
if (didLoadCleanly) {
- Document.InformLoadComplete ();
+ InformLoadComplete ();
widget.EnsureCorrectEolMarker (fileName);
}
+
+ widget.TextEditor.Document.TextReplaced += OnTextReplaced;
}
void HandleTextEditorVAdjustmentChanged (object sender, EventArgs e)
@@ -890,8 +818,8 @@ namespace MonoDevelop.SourceEditor
internal void LoadSettings ()
{
- FileSettingsStore.Settings settings;
- if (widget == null || string.IsNullOrEmpty (ContentName) || !FileSettingsStore.TryGetValue (ContentName, out settings))
+ MonoDevelop.Ide.Editor.FileSettingsStore.Settings settings;
+ if (widget == null || string.IsNullOrEmpty (ContentName) || !MonoDevelop.Ide.Editor.FileSettingsStore.TryGetValue (ContentName, out settings))
return;
widget.TextEditor.Caret.Offset = settings.CaretOffset;
@@ -913,7 +841,7 @@ namespace MonoDevelop.SourceEditor
// }
if (string.IsNullOrEmpty (ContentName))
return;
- FileSettingsStore.Store (ContentName, new FileSettingsStore.Settings () {
+ MonoDevelop.Ide.Editor.FileSettingsStore.Store (ContentName, new MonoDevelop.Ide.Editor.FileSettingsStore.Settings {
CaretOffset = widget.TextEditor.Caret.Offset,
vAdjustment = widget.TextEditor.VAdjustment.Value,
hAdjustment = widget.TextEditor.HAdjustment.Value//,
@@ -926,7 +854,7 @@ namespace MonoDevelop.SourceEditor
Encoding encoding;
bool hadBom = false;
- internal void ReplaceContent (string fileName, string content, Encoding encoding)
+ internal void ReplaceContent (string fileName, string content, Encoding enc)
{
if (warnOverwrite) {
warnOverwrite = false;
@@ -939,18 +867,16 @@ namespace MonoDevelop.SourceEditor
Document.Replace (0, Document.TextLength, content);
Document.DiffTracker.Reset ();
inLoad = false;
- this.encoding = encoding;
+ encoding = enc;
ContentName = fileName;
- RunFirstTimeFoldUpdate (content);
- CreateDocumentParsedHandler ();
UpdateExecutionLocation ();
UpdateBreakpoints ();
UpdatePinnedWatches ();
LoadExtensions ();
IsDirty = false;
- Document.InformLoadComplete ();
+ InformLoadComplete ();
}
-
+
void UpdateMimeType (string fileName)
{
// Look for a mime type for which there is a syntax mode
@@ -966,7 +892,6 @@ namespace MonoDevelop.SourceEditor
}
}
}
- ((StyledSourceEditorOptions)SourceEditorWidget.TextEditor.Options).UpdateStyleParent (Project, loadedMimeType);
}
}
@@ -976,13 +901,15 @@ namespace MonoDevelop.SourceEditor
public override void Dispose ()
{
+ if (isDisposed)
+ return;
+ isDisposed = true;
+
ClearExtensions ();
FileRegistry.Remove (this);
- RemoveAutoSaveTimer ();
-
+
StoreSettings ();
- this.isDisposed = true;
Counters.LoadedEditors--;
/* if (messageBubbleHighlightPopupWindow != null)
@@ -996,13 +923,10 @@ namespace MonoDevelop.SourceEditor
ClipbardRingUpdated -= UpdateClipboardRing;
- widget.TextEditor.Document.SyntaxModeChanged -= HandleSyntaxModeChanged;
widget.TextEditor.Document.TextReplaced -= HandleTextReplaced;
widget.TextEditor.Document.LineChanged -= HandleLineChanged;
widget.TextEditor.Document.BeginUndo -= HandleBeginUndo;
widget.TextEditor.Document.EndUndo -= HandleEndUndo;
- widget.TextEditor.Document.Undone -= HandleUndone;
- widget.TextEditor.Document.Redone -= HandleUndone;
widget.TextEditor.Caret.PositionChanged -= HandlePositionChanged;
widget.TextEditor.IconMargin.ButtonPressed -= OnIconButtonPress;
widget.TextEditor.Document.TextReplacing -= OnTextReplacing;
@@ -1043,13 +967,6 @@ namespace MonoDevelop.SourceEditor
RemoveMarkerQueue ();
}
-
- public Ambience GetAmbience ()
- {
- string file = this.IsUntitled ? this.UntitledName : this.ContentName;
- return AmbienceService.GetAmbienceForFile (file);
- }
-
bool CheckReadOnly (int line)
{
@@ -1069,9 +986,9 @@ namespace MonoDevelop.SourceEditor
void OnTextReplaced (object s, DocumentChangeEventArgs a)
{
- this.IsDirty = Document.IsDirty;
+ IsDirty = Document.IsDirty;
- DocumentLocation location = Document.OffsetToLocation (a.Offset);
+ var location = Document.OffsetToLocation (a.Offset);
int i = 0, lines = 0;
while (i != -1 && i < oldReplaceText.Length) {
@@ -1198,10 +1115,10 @@ namespace MonoDevelop.SourceEditor
if (w.OffsetX < 0) {
w.OffsetY = (int)widget.TextEditor.LineToY (w.Line);
int lw, lh;
- var wrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
- wrapper.Layout.GetPixelSize (out lw, out lh);
- if (wrapper.IsUncached)
- wrapper.Dispose ();
+ var tmpWrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
+ tmpWrapper.Layout.GetPixelSize (out lw, out lh);
+ if (tmpWrapper.IsUncached)
+ tmpWrapper.Dispose ();
w.OffsetX = (int)widget.TextEditor.TextViewMargin.XOffset + lw + 4;
}
wi.Widget = new PinnedWatchWidget (widget.TextEditor, w);
@@ -1405,7 +1322,7 @@ namespace MonoDevelop.SourceEditor
void OnIconButtonPress (object s, MarginMouseEventArgs args)
{
- if (args.LineNumber < DocumentLocation.MinLine)
+ if (args.LineNumber < Mono.TextEditor.DocumentLocation.MinLine)
return;
if (args.TriggersContextMenu ()) {
@@ -1420,51 +1337,23 @@ namespace MonoDevelop.SourceEditor
WorkbenchWindow.ExtensionContext ?? AddinManager.AddinEngine,
"/MonoDevelop/SourceEditor2/IconContextMenu/Editor");
} else if (args.Button == 1) {
- if (!string.IsNullOrEmpty (this.Document.FileName)) {
+ if (!string.IsNullOrEmpty (Document.FileName)) {
if (args.LineSegment != null) {
int column = TextEditor.Caret.Line == args.LineNumber ? TextEditor.Caret.Column : 1;
lock (breakpoints)
- breakpoints.Toggle (this.Document.FileName, args.LineNumber, column);
+ breakpoints.Toggle (Document.FileName, args.LineNumber, column);
}
}
}
}
-
- #region IExtensibleTextEditor
- public ITextEditorExtension Extension {
- get;
- set;
- }
-
- ITextEditorExtension IExtensibleTextEditor.AttachExtension (ITextEditorExtension extension)
- {
- Extension = extension;
- this.widget.TextEditor.Extension = extension;
- return this.widget;
- }
-
-// protected override void OnMoveCursor (MovementStep step, int count, bool extend_selection)
-// {
-// base.OnMoveCursor (step, count, extend_selection);
-// if (extension != null)
-// extension.CursorPositionChanged ();
-// }
-
-// protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
-// {
-// if (extension != null)
-// return extension.KeyPress (evnt.Key, evnt.State);
-// return this.KeyPress (evnt.Key, evnt.State);
-// }
- #endregion
-
+
#region IEditableTextBuffer
public bool EnableUndo {
get {
if (widget == null)
return false;
- return /*this.TextEditor.PreeditOffset < 0 &&*/ this.Document.CanUndo && widget.EditorHasFocus;
+ return /*this.TextEditor.PreeditOffset < 0 &&*/ Document.CanUndo && widget.EditorHasFocus;
}
}
@@ -1482,14 +1371,14 @@ namespace MonoDevelop.SourceEditor
}*/
if (MiscActions.CancelPreEditMode (TextEditor.GetTextEditorData ()))
return;
- MiscActions.Undo (this.TextEditor.GetTextEditorData ());
+ MiscActions.Undo (TextEditor.GetTextEditorData ());
}
public bool EnableRedo {
get {
if (widget == null)
return false;
- return /*this.TextEditor.PreeditOffset < 0 && */ this.Document.CanRedo && widget.EditorHasFocus;
+ return /*this.TextEditor.PreeditOffset < 0 && */ Document.CanRedo && widget.EditorHasFocus;
}
}
@@ -1526,7 +1415,7 @@ namespace MonoDevelop.SourceEditor
{
if (MiscActions.CancelPreEditMode (TextEditor.GetTextEditorData ()))
return;
- MiscActions.Redo (this.TextEditor.GetTextEditorData ());
+ MiscActions.Redo (TextEditor.GetTextEditorData ());
}
public IDisposable OpenUndoGroup ()
@@ -1553,8 +1442,7 @@ namespace MonoDevelop.SourceEditor
}
public event EventHandler CaretPositionSet;
- public event EventHandler<TextChangedEventArgs> TextChanged;
-
+
public bool HasInputFocus {
get { return TextEditor.HasFocus; }
}
@@ -1565,7 +1453,6 @@ namespace MonoDevelop.SourceEditor
}
#endregion
- #region ITextBuffer
public int CursorPosition {
get {
return TextEditor.Caret.Offset;
@@ -1574,56 +1461,28 @@ namespace MonoDevelop.SourceEditor
TextEditor.Caret.Offset = value;
}
}
-
- public int SelectionStartPosition {
- get {
- if (!TextEditor.IsSomethingSelected)
- return TextEditor.Caret.Offset;
- return TextEditor.SelectionRange.Offset;
- }
- }
-
- public int SelectionEndPosition {
- get {
- if (!TextEditor.IsSomethingSelected)
- return TextEditor.Caret.Offset;
- return TextEditor.SelectionRange.EndOffset;
- }
- }
-
- public void Select (int startPosition, int endPosition)
- {
- TextEditor.SelectionRange = new TextSegment (startPosition, endPosition - startPosition);
- TextEditor.ScrollToCaret ();
- }
-
- public void ShowPosition (int position)
- {
- // TODO
- }
- #endregion
#region ITextFile
public FilePath Name {
get {
- return this.ContentName ?? this.UntitledName;
+ return ContentName ?? UntitledName;
}
}
public string Text {
get {
- return this.widget.TextEditor.Document.Text;
+ return widget.TextEditor.Document.Text;
}
set {
this.IsDirty = true;
- TextDocument document = this.widget.TextEditor.Document;
+ var document = this.widget.TextEditor.Document;
document.Replace (0, document.TextLength, value);
}
}
public int Length {
get {
- return this.widget.TextEditor.Document.TextLength;
+ return widget.TextEditor.Document.TextLength;
}
}
@@ -1647,17 +1506,17 @@ namespace MonoDevelop.SourceEditor
public char GetCharAt (int position)
{
- return this.widget.TextEditor.Document.GetCharAt (position);
+ return widget.TextEditor.Document.GetCharAt (position);
}
public int GetPositionFromLineColumn (int line, int column)
{
- return this.widget.TextEditor.Document.LocationToOffset (new DocumentLocation (line, column));
+ return widget.TextEditor.Document.LocationToOffset (new Mono.TextEditor.DocumentLocation (line, column));
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
- DocumentLocation location = this.widget.TextEditor.Document.OffsetToLocation (position);
+ var location = widget.TextEditor.Document.OffsetToLocation (position);
line = location.Line;
column = location.Column;
}
@@ -1666,25 +1525,25 @@ namespace MonoDevelop.SourceEditor
#region IEditableTextFile
public int InsertText (int position, string text)
{
- return this.widget.TextEditor.Insert (position, text);
+ return widget.TextEditor.Insert (position, text);
}
public void DeleteText (int position, int length)
{
- this.widget.TextEditor.Remove (position, length);
+ widget.TextEditor.Remove (position, length);
}
#endregion
#region IBookmarkBuffer
DocumentLine GetLine (int position)
{
- DocumentLocation location = Document.OffsetToLocation (position);
+ var location = Document.OffsetToLocation (position);
return Document.GetLine (location.Line);
}
public void SetBookmarked (int position, bool mark)
{
- DocumentLine line = GetLine (position);
+ var line = GetLine (position);
if (line != null && line.IsBookmarked != mark) {
int lineNumber = widget.TextEditor.Document.OffsetToLineNumber (line.Offset);
line.IsBookmarked = mark;
@@ -1695,8 +1554,8 @@ namespace MonoDevelop.SourceEditor
public bool IsBookmarked (int position)
{
- DocumentLine line = GetLine (position);
- return line != null ? line.IsBookmarked : false;
+ var line = GetLine (position);
+ return line != null && line.IsBookmarked;
}
public void PrevBookmark ()
@@ -1794,7 +1653,7 @@ namespace MonoDevelop.SourceEditor
get {
if (TextEditor.IsSomethingSelected) {
if (TextEditor.MainSelection.SelectionMode == Mono.TextEditor.SelectionMode.Block)
- return System.Math.Abs (TextEditor.MainSelection.Anchor.Column - TextEditor.MainSelection.Lead.Column);
+ return Math.Abs (TextEditor.MainSelection.Anchor.Column - TextEditor.MainSelection.Lead.Column);
return TextEditor.SelectionRange.Length;
}
return 0;
@@ -1813,9 +1672,13 @@ namespace MonoDevelop.SourceEditor
get {
return TextEditor.Caret.Offset;
}
+ set {
+ TextEditor.Caret.Offset = value;
+ TextEditor.ScrollToCaret ();
+ }
}
- public Gtk.Style GtkStyle {
+ public Style GtkStyle {
get {
return widget.Vbox.Style.Copy ();
}
@@ -1838,7 +1701,7 @@ namespace MonoDevelop.SourceEditor
var loc = editor.Caret.Location;
result.TriggerLine = loc.Line;
result.TriggerLineOffset = loc.Column - 1;
- var p = this.widget.TextEditor.LocationToPoint (loc);
+ var p = widget.TextEditor.LocationToPoint (loc);
int tx, ty;
editor.ParentWindow.GetOrigin (out tx, out ty);
tx += editor.Allocation.X + p.X;
@@ -1850,7 +1713,7 @@ namespace MonoDevelop.SourceEditor
return result;
}
- public Gdk.Point DocumentToScreenLocation (DocumentLocation location)
+ public Gdk.Point DocumentToScreenLocation (Mono.TextEditor.DocumentLocation location)
{
var p = widget.TextEditor.LocationToPoint (location);
int tx, ty;
@@ -1874,21 +1737,25 @@ namespace MonoDevelop.SourceEditor
return Document.GetTextBetween (min, max);
}
- public void SetCompletionText (CodeCompletionContext ctx, string partial_word, string complete_word)
+ public void SetCompletionText (CodeCompletionContext ctx, string partialWord, string completeWord)
{
- SetCompletionText (ctx, partial_word, complete_word, complete_word.Length);
+ if (ctx == null)
+ throw new ArgumentNullException ("ctx");
+ if (completeWord == null)
+ throw new ArgumentNullException ("completeWord");
+ SetCompletionText (ctx, partialWord, completeWord, completeWord.Length);
}
- public static void SetCompletionText (TextEditorData data, CodeCompletionContext ctx, string partial_word, string complete_word, int wordOffset)
+ public static void SetCompletionText (TextEditorData data, CodeCompletionContext ctx, string partialWord, string completeWord, int wordOffset)
{
if (data == null || data.Document == null)
return;
int triggerOffset = ctx.TriggerOffset;
- int length = String.IsNullOrEmpty (partial_word) ? 0 : partial_word.Length;
+ int length = String.IsNullOrEmpty (partialWord) ? 0 : partialWord.Length;
// for named arguments invoke(arg:<Expr>);
- if (complete_word.EndsWith (":", StringComparison.Ordinal)) {
+ if (completeWord.EndsWith (":", StringComparison.Ordinal)) {
if (data.GetCharAt (triggerOffset + length) == ':')
length++;
}
@@ -1908,9 +1775,9 @@ namespace MonoDevelop.SourceEditor
}
// | in the completion text now marks the caret position
- int idx = complete_word.IndexOf ('|');
+ int idx = completeWord.IndexOf ('|');
if (idx >= 0) {
- complete_word = complete_word.Remove (idx, 1);
+ completeWord = completeWord.Remove (idx, 1);
}
triggerOffset += data.EnsureCaretIsNotVirtual ();
@@ -1925,11 +1792,11 @@ namespace MonoDevelop.SourceEditor
if (lineSegment == null)
continue;
int offset = lineSegment.Offset + column;
- data.Replace (offset, length, complete_word);
+ data.Replace (offset, length, completeWord);
}
- int minColumn = System.Math.Min (data.MainSelection.Anchor.Column, data.MainSelection.Lead.Column);
+ int minColumn = Math.Min (data.MainSelection.Anchor.Column, data.MainSelection.Lead.Column);
data.MainSelection = data.MainSelection.WithRange (
- new DocumentLocation (data.Caret.Line == minLine ? maxLine : minLine, minColumn),
+ new Mono.TextEditor.DocumentLocation (data.Caret.Line == minLine ? maxLine : minLine, minColumn),
data.Caret.Location
);
@@ -1937,7 +1804,7 @@ namespace MonoDevelop.SourceEditor
data.Caret.PreserveSelection = false;
}
} else {
- data.Replace (triggerOffset, length, complete_word);
+ data.Replace (triggerOffset, length, completeWord);
}
data.Document.CommitLineUpdate (data.Caret.Line);
@@ -1946,16 +1813,16 @@ namespace MonoDevelop.SourceEditor
}
- public void SetCompletionText (CodeCompletionContext ctx, string partial_word, string complete_word, int wordOffset)
+ public void SetCompletionText (CodeCompletionContext ctx, string partialWord, string completeWord, int wordOffset)
{
var data = GetTextEditorData ();
if (data == null)
return;
using (var undo = data.OpenUndoGroup ()) {
- SetCompletionText (data, ctx, partial_word, complete_word, wordOffset);
+ SetCompletionText (data, ctx, partialWord, completeWord, wordOffset);
var formatter = CodeFormatterService.GetFormatter (data.MimeType);
- if (formatter != null && complete_word.IndexOfAny (new [] {' ', '\t', '{', '}'}) > 0 && formatter.SupportsOnTheFlyFormatting) {
- formatter.OnTheFlyFormat (WorkbenchWindow.Document, ctx.TriggerOffset, ctx.TriggerOffset + complete_word.Length);
+ if (formatter != null && completeWord.IndexOfAny (new [] {' ', '\t', '{', '}'}) > 0 && formatter.SupportsOnTheFlyFormatting) {
+ formatter.OnTheFlyFormat (WorkbenchWindow.Document, ctx.TriggerOffset, ctx.TriggerOffset + completeWord.Length);
}
}
}
@@ -1979,10 +1846,12 @@ namespace MonoDevelop.SourceEditor
if (TextEditor.IsSomethingSelected) {
expression = TextEditor.SelectedText;
} else {
- DomRegion region;
+ MonoDevelop.Ide.Editor.DocumentRegion region;
var rr = TextEditor.GetLanguageItem (TextEditor.Caret.Offset, out region);
- if (rr != null && !rr.IsError)
- expression = TextEditor.GetTextBetween (region.Begin, region.End);
+ if (rr != null)
+ expression = TextEditor.GetTextBetween (
+ region.BeginLine, region.BeginColumn,
+ region.EndLine, region.EndColumn);
}
DebuggingService.ShowExpressionEvaluator (expression);
@@ -2051,18 +1920,18 @@ namespace MonoDevelop.SourceEditor
{
bool toggle = true;
- foreach (FoldSegment segment in Document.FoldSegments) {
- if (segment.FoldingType == FoldingType.TypeMember || segment.FoldingType == FoldingType.Comment)
+ foreach (var segment in Document.FoldSegments) {
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeMember || segment.FoldingType == Mono.TextEditor.FoldingType.Comment)
if (segment.IsFolded)
toggle = false;
}
- foreach (FoldSegment segment in Document.FoldSegments) {
- if (segment.FoldingType == FoldingType.TypeDefinition) {
+ foreach (var segment in Document.FoldSegments) {
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeDefinition) {
segment.IsFolded = false;
}
- if (segment.FoldingType == FoldingType.TypeMember || segment.FoldingType == FoldingType.Comment)
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeMember || segment.FoldingType == Mono.TextEditor.FoldingType.Comment)
segment.IsFolded = toggle;
}
@@ -2148,7 +2017,7 @@ namespace MonoDevelop.SourceEditor
item.Description += line;
}
item.Category = GettextCatalog.GetString ("Clipboard ring");
- item.Icon = DesktopService.GetIconForFile ("a.txt", Gtk.IconSize.Menu);
+ item.Icon = DesktopService.GetIconForFile ("a.txt", IconSize.Menu);
item.Name = text.Length > 16 ? text.Substring (0, 16) + "..." : text;
item.Name = item.Name.Replace ("\t", "\\t");
item.Name = item.Name.Replace ("\n", "\\n");
@@ -2159,6 +2028,7 @@ namespace MonoDevelop.SourceEditor
if (ClipbardRingUpdated != null)
ClipbardRingUpdated (null, EventArgs.Empty);
};
+ SyntaxModeLoader.Init ();
}
public void UpdateClipboardRing (object sender, EventArgs e)
@@ -2195,16 +2065,16 @@ namespace MonoDevelop.SourceEditor
{
var tn = item as ITextToolboxNode;
if (tn != null) {
- tn.InsertAtCaret (base.WorkbenchWindow.Document);
+ tn.InsertAtCaret (WorkbenchWindow.Document);
TextEditor.GrabFocus ();
}
}
#region dnd
- Gtk.Widget customSource;
+ Widget customSource;
ItemToolboxNode dragItem;
- void IToolboxConsumer.DragItem (ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx)
+ void IToolboxConsumer.DragItem (ItemToolboxNode item, Widget source, Gdk.DragContext ctx)
{
//FIXME: use the preview text
string text = GetDragPreviewText (item);
@@ -2242,7 +2112,7 @@ namespace MonoDevelop.SourceEditor
LoggingService.LogWarning ("Cannot use non-ITextToolboxNode toolbox items in the text editor.");
return null;
}
- return tn.GetDragPreview (base.WorkbenchWindow.Document);
+ return tn.GetDragPreview (WorkbenchWindow.Document);
}
System.ComponentModel.ToolboxItemFilterAttribute[] IToolboxConsumer.ToolboxFilterAttributes {
@@ -2261,10 +2131,10 @@ namespace MonoDevelop.SourceEditor
//int i = filename.LastIndexOf ('.');
//string ext = i < 0? null : filename.Substring (i + 1);
- return textNode.IsCompatibleWith (base.WorkbenchWindow.Document);
+ return textNode.IsCompatibleWith (WorkbenchWindow.Document);
}
- public Gtk.TargetEntry[] DragTargets {
+ public TargetEntry[] DragTargets {
get {
return ClipboardActions.CopyOperation.TargetEntries;
}
@@ -2285,48 +2155,48 @@ namespace MonoDevelop.SourceEditor
#region IZoomable
bool IZoomable.EnableZoomIn {
get {
- return this.TextEditor.Options.CanZoomIn;
+ return TextEditor.Options.CanZoomIn;
}
}
bool IZoomable.EnableZoomOut {
get {
- return this.TextEditor.Options.CanZoomOut;
+ return TextEditor.Options.CanZoomOut;
}
}
bool IZoomable.EnableZoomReset {
get {
- return this.TextEditor.Options.CanResetZoom;
+ return TextEditor.Options.CanResetZoom;
}
}
void IZoomable.ZoomIn ()
{
- this.TextEditor.Options.ZoomIn ();
+ TextEditor.Options.ZoomIn ();
}
void IZoomable.ZoomOut ()
{
- this.TextEditor.Options.ZoomOut ();
+ TextEditor.Options.ZoomOut ();
}
void IZoomable.ZoomReset ()
{
- this.TextEditor.Options.ZoomReset ();
+ TextEditor.Options.ZoomReset ();
}
#region ITextEditorResolver implementation
- public ResolveResult GetLanguageItem (int offset)
+ public Microsoft.CodeAnalysis.ISymbol GetLanguageItem (int offset)
{
- DomRegion region;
- return this.SourceEditorWidget.TextEditor.GetLanguageItem (offset, out region);
+ MonoDevelop.Ide.Editor.DocumentRegion region;
+ return SourceEditorWidget.TextEditor.GetLanguageItem (offset, out region);
}
- public ResolveResult GetLanguageItem (int offset, string expression)
+ public Microsoft.CodeAnalysis.ISymbol GetLanguageItem (int offset, string expression)
{
- return this.SourceEditorWidget.TextEditor.GetLanguageItem (offset, expression);
+ return SourceEditorWidget.TextEditor.GetLanguageItem (offset, expression);
}
#endregion
@@ -2346,27 +2216,24 @@ namespace MonoDevelop.SourceEditor
#endregion
#endregion
- public Mono.TextEditor.TextEditorData GetTextEditorData ()
+ public TextEditorData GetTextEditorData ()
{
var editor = TextEditor;
if (editor == null)
return null;
return editor.GetTextEditorData ();
}
-
- public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document doc)
- {
- TextEditor.InsertTemplate (template, doc);
- }
-
- [CommandHandler (TextEditorCommands.GotoMatchingBrace)]
- protected void OnGotoMatchingBrace ()
+
+ public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context)
{
- TextEditor.RunAction (MiscActions.GotoMatchingBracket);
+ TextEditor.InsertTemplate (template, editor, context);
}
-
+
void CorrectIndenting ()
{
+ var doc = ownerDocument.Editor;
+ if (doc == null)
+ return;
var formatter = CodeFormatterService.GetFormatter (Document.MimeType);
if (formatter == null || !formatter.SupportsCorrectingIndent)
return;
@@ -2380,52 +2247,22 @@ namespace MonoDevelop.SourceEditor
var version = TextEditor.Document.Version;
int max = selection.MaxLine;
for (int i = TextEditor.MainSelection.MinLine; i <= max; i++) {
- formatter.CorrectIndenting (policies, editorData, i);
+ formatter.CorrectIndenting (policies, doc, i);
}
editorData.SetSelection (version.MoveOffsetTo (editorData.Document.Version, anchor), version.MoveOffsetTo (editorData.Document.Version, lead));
}
} else {
- formatter.CorrectIndenting (policies, editorData, TextEditor.Caret.Line);
+ formatter.CorrectIndenting (policies, doc, TextEditor.Caret.Line);
}
}
- [CommandUpdateHandler (TextEditorCommands.MoveBlockUp)]
- [CommandUpdateHandler (TextEditorCommands.MoveBlockDown)]
- void MoveBlockUpdateHandler (CommandInfo cinfo)
+ public override object GetContent (Type type)
{
- cinfo.Enabled = widget.EditorHasFocus;
+ if (type.Equals (typeof(TextEditorData)))
+ return TextEditor.GetTextEditorData ();
+ return base.GetContent (type);
}
- [CommandHandler (TextEditorCommands.MoveBlockUp)]
- protected void OnMoveBlockUp ()
- {
- using (var undo = TextEditor.OpenUndoGroup ()) {
- TextEditor.RunAction (MiscActions.MoveBlockUp);
- CorrectIndenting ();
- }
- }
-
- [CommandHandler (TextEditorCommands.MoveBlockDown)]
- protected void OnMoveBlockDown ()
- {
- using (var undo = TextEditor.OpenUndoGroup ()) {
- TextEditor.RunAction (MiscActions.MoveBlockDown);
- CorrectIndenting ();
- }
- }
-
- [CommandUpdateHandler (TextEditorCommands.ToggleBlockSelectionMode)]
- protected void UpdateToggleBlockSelectionMode (CommandInfo cinfo)
- {
- cinfo.Enabled = TextEditor.IsSomethingSelected;
- }
-
- [CommandHandler (TextEditorCommands.ToggleBlockSelectionMode)]
- protected void OnToggleBlockSelectionMode ()
- {
- TextEditor.SelectionMode = TextEditor.SelectionMode == Mono.TextEditor.SelectionMode.Normal ? Mono.TextEditor.SelectionMode.Block : Mono.TextEditor.SelectionMode.Normal;
- TextEditor.QueueDraw ();
- }
#region widget command handlers
[CommandHandler (SearchCommands.EmacsFindNext)]
@@ -2524,57 +2361,805 @@ namespace MonoDevelop.SourceEditor
{
widget.MonodocResolverUpdate (cinfo);
}
-
- [CommandUpdateHandler (EditCommands.ToggleCodeComment)]
- internal void OnUpdateToggleComment (MonoDevelop.Components.Commands.CommandInfo info)
+
+ [CommandHandler (SourceEditorCommands.NextIssue)]
+ void NextIssue ()
{
- widget.OnUpdateToggleComment (info);
+ widget.NextIssue ();
+ }
+
+ [CommandHandler (SourceEditorCommands.PrevIssue)]
+ void PrevIssue ()
+ {
+ widget.PrevIssue ();
+ }
+
+ [CommandHandler (SourceEditorCommands.NextIssueError)]
+ void NextIssueError ()
+ {
+ widget.NextIssueError ();
+ }
+
+ [CommandHandler (SourceEditorCommands.PrevIssueError)]
+ void PrevIssueError ()
+ {
+ widget.PrevIssueError ();
+ }
+ #endregion
+
+ TextDocumentWrapper wrapper;
+ IReadonlyTextDocument ITextEditorImpl.Document {
+ get {
+ if (wrapper == null)
+ wrapper = new TextDocumentWrapper (widget.TextEditor.Document);
+ return wrapper;
+ }
+ set {
+ wrapper = (TextDocumentWrapper)value;
+ widget.TextEditor.Document = wrapper.Document;
+ }
+ }
+
+ event EventHandler ITextEditorImpl.SelectionChanged {
+ add {
+ TextEditor.SelectionChanged += value;
+ }
+ remove {
+ TextEditor.SelectionChanged -= value;
+ }
+ }
+
+ event EventHandler ITextEditorImpl.BeginMouseHover {
+ add {
+ TextEditor.BeginHover += value;
+ }
+ remove {
+ TextEditor.BeginHover -= value;
+ }
+ }
+
+ event EventHandler ITextEditorImpl.VAdjustmentChanged {
+ add {
+ TextEditor.VAdjustment.ValueChanged += value;
+ }
+ remove {
+ TextEditor.VAdjustment.ValueChanged -= value;
+ }
+ }
+
+ event EventHandler ITextEditorImpl.HAdjustmentChanged {
+ add {
+ TextEditor.HAdjustment.ValueChanged += value;
+ }
+ remove {
+ TextEditor.HAdjustment.ValueChanged -= value;
+ }
+ }
+
+ public event EventHandler CaretPositionChanged;
+ bool hasCaretPositionChanged;
+ protected virtual void OnCaretPositionChanged (EventArgs e)
+ {
+ if (widget.TextEditor.Document.IsInAtomicUndo) {
+ hasCaretPositionChanged = true;
+ return;
+ }
+ var handler = CaretPositionChanged;
+ if (handler != null)
+ handler (this, e);
+ }
+
+ public event EventHandler BeginAtomicUndoOperation;
+
+ protected virtual void OnBeginUndo (EventArgs e)
+ {
+ hasCaretPositionChanged = false;
+ var handler = BeginAtomicUndoOperation;
+ if (handler != null)
+ handler (this, e);
+ }
+
+ public event EventHandler EndAtomicUndoOperation;
+
+ protected virtual void OnEndUndo (EventArgs e)
+ {
+ var handler = EndAtomicUndoOperation;
+ if (handler != null)
+ handler (this, e);
+ if (hasCaretPositionChanged) {
+ OnCaretPositionChanged (e);
+ hasCaretPositionChanged = false;
+ }
+ }
+
+ void ITextEditorImpl.SetSelection (int anchorOffset, int leadOffset)
+ {
+ TextEditor.SetSelection (anchorOffset, leadOffset);
+ }
+
+ void ITextEditorImpl.ClearSelection ()
+ {
+ TextEditor.ClearSelection ();
+ }
+
+ void ITextEditorImpl.CenterToCaret ()
+ {
+ TextEditor.CenterToCaret ();
+ }
+
+ void ITextEditorImpl.StartCaretPulseAnimation ()
+ {
+ TextEditor.StartCaretPulseAnimation ();
+ }
+
+ int ITextEditorImpl.EnsureCaretIsNotVirtual ()
+ {
+ return TextEditor.GetTextEditorData ().EnsureCaretIsNotVirtual ();
+ }
+
+ void ITextEditorImpl.FixVirtualIndentation ()
+ {
+ TextEditor.GetTextEditorData ().FixVirtualIndentation ();
+ }
+
+ object ITextEditorImpl.CreateNativeControl ()
+ {
+ return Control;
}
- [CommandHandler (EditCommands.ToggleCodeComment)]
- public void ToggleCodeComment ()
+ string ITextEditorImpl.FormatString (int offset, string code)
{
- widget.ToggleCodeComment ();
+ return TextEditor.GetTextEditorData ().FormatString (offset, code);
}
- [CommandUpdateHandler (EditCommands.AddCodeComment)]
- internal void OnUpdateAddCodeComment (MonoDevelop.Components.Commands.CommandInfo info)
+ void ITextEditorImpl.StartInsertionMode (InsertionModeOptions insertionModeOptions)
{
- widget.OnUpdateToggleComment (info);
+ var mode = new InsertionCursorEditMode (TextEditor, insertionModeOptions.InsertionPoints.Select (ip => new Mono.TextEditor.InsertionPoint (
+ new Mono.TextEditor.DocumentLocation (ip.Location.Line, ip.Location.Column),
+ (Mono.TextEditor.NewLineInsertion)ip.LineBefore,
+ (Mono.TextEditor.NewLineInsertion)ip.LineAfter
+ )).ToList ());
+ if (mode.InsertionPoints.Count == 0) {
+ return;
+ }
+ var helpWindow = new Mono.TextEditor.PopupWindow.InsertionCursorLayoutModeHelpWindow ();
+ helpWindow.TitleText = insertionModeOptions.Operation;
+ mode.HelpWindow = helpWindow;
+ mode.CurIndex = insertionModeOptions.FirstSelectedInsertionPoint;
+ mode.StartMode ();
+ mode.Exited += delegate(object s, Mono.TextEditor.InsertionCursorEventArgs iCArgs) {
+ insertionModeOptions.ModeExitedAction (new MonoDevelop.Ide.Editor.InsertionCursorEventArgs (iCArgs.Success,
+ new MonoDevelop.Ide.Editor.InsertionPoint (
+ new MonoDevelop.Ide.Editor.DocumentLocation (iCArgs.InsertionPoint.Location.Line, iCArgs.InsertionPoint.Location.Column),
+ (MonoDevelop.Ide.Editor.NewLineInsertion)iCArgs.InsertionPoint.LineBefore,
+ (MonoDevelop.Ide.Editor.NewLineInsertion)iCArgs.InsertionPoint.LineAfter
+ )
+ ));
+ };
}
- [CommandHandler (EditCommands.AddCodeComment)]
- public void AddCodeComment ()
+ void ITextEditorImpl.StartTextLinkMode (TextLinkModeOptions textLinkModeOptions)
{
- widget.AddCodeComment ();
+ var convertedLinks = new List<Mono.TextEditor.TextLink> ();
+ foreach (var link in textLinkModeOptions.Links) {
+ var convertedLink = new Mono.TextEditor.TextLink (link.Name);
+ convertedLink.IsEditable = link.IsEditable;
+ convertedLink.IsIdentifier = link.IsIdentifier;
+ var func = link.GetStringFunc;
+ if (func != null) {
+ convertedLink.GetStringFunc = delegate(Func<string, string> arg) {
+ return new ListDataProviderWrapper (func (arg));
+ };
+ }
+ foreach (var segment in link.Links) {
+ convertedLink.AddLink (new Mono.TextEditor.TextSegment (segment.Offset, segment.Length));
+ }
+ convertedLinks.Add (convertedLink);
+ }
+
+ var tle = new TextLinkEditMode (TextEditor, 0, convertedLinks);
+ tle.SetCaretPosition = false;
+ if (tle.ShouldStartTextLinkMode) {
+ tle.OldMode = TextEditor.CurrentMode;
+ if (textLinkModeOptions.ModeExitedAction != null) {
+ tle.Cancel += (sender, e) => textLinkModeOptions.ModeExitedAction (new TextLinkModeEventArgs (false));
+ tle.Exited += (sender, e) => {
+ for (int i = 0; i < convertedLinks.Count; i++) {
+ textLinkModeOptions.Links[i].CurrentText = convertedLinks[i].CurrentText;
+ }
+ textLinkModeOptions.ModeExitedAction (new TextLinkModeEventArgs (true));
+
+ };
+ }
+ tle.StartMode ();
+ TextEditor.CurrentMode = tle;
+ }
}
- [CommandUpdateHandler (EditCommands.RemoveCodeComment)]
- internal void OnUpdateRemoveCodeComment (MonoDevelop.Components.Commands.CommandInfo info)
+ MonoDevelop.Ide.Editor.DocumentLocation ITextEditorImpl.PointToLocation (double xp, double yp, bool endAtEol)
{
- widget.OnUpdateToggleComment (info);
+ var pt = TextEditor.PointToLocation (xp, yp);
+ return new MonoDevelop.Ide.Editor.DocumentLocation (pt.Line, pt.Column);
}
- [CommandHandler (EditCommands.RemoveCodeComment)]
- public void RemoveCodeComment ()
+ Xwt.Point ITextEditorImpl.LocationToPoint (int line, int column)
{
- widget.RemoveCodeComment ();
+ var p = TextEditor.LocationToPoint (line, column);
+ return new Xwt.Point (p.X, p.Y);
}
- [CommandUpdateHandler (SourceEditorCommands.ToggleErrorTextMarker)]
- public void OnUpdateToggleErrorTextMarker (CommandInfo info)
+ void ITextEditorImpl.AddMarker (IDocumentLine line, ITextLineMarker lineMarker)
{
- widget.OnUpdateToggleErrorTextMarker (info);
+ var textLineMarker = lineMarker as TextLineMarker;
+ if (textLineMarker == null)
+ throw new InvalidOperationException ("Tried to add an incompatible text marker. Use the MarkerHost to create compatible ones.");
+
+ if (lineMarker is IUnitTestMarker) {
+ var actionMargin = TextEditor.ActionMargin;
+ if (actionMargin != null) {
+ actionMargin.IsVisible = true;
+ }
+ }
+
+ TextEditor.Document.AddMarker (((DocumentLineWrapper)line).Line, textLineMarker);
+ }
+
+ void ITextEditorImpl.RemoveMarker (ITextLineMarker lineMarker)
+ {
+ var textLineMarker = lineMarker as TextLineMarker;
+ if (textLineMarker == null)
+ throw new InvalidOperationException ("Tried to add an incompatible text marker.");
+ TextEditor.Document.RemoveMarker (textLineMarker);
+ }
+
+ IEnumerable<ITextLineMarker> ITextEditorImpl.GetLineMarkers (IDocumentLine line)
+ {
+ return ((DocumentLineWrapper)line).Line.Markers.OfType<ITextLineMarker> ();
+ }
+
+ IEnumerable<ITextSegmentMarker> ITextEditorImpl.GetTextSegmentMarkersAt (MonoDevelop.Core.Text.ISegment segment)
+ {
+ return TextEditor.Document.GetTextSegmentMarkersAt (new TextSegment (segment.Offset, segment.Length)).OfType<ITextSegmentMarker> ();
+ }
+
+ IEnumerable<ITextSegmentMarker> ITextEditorImpl.GetTextSegmentMarkersAt (int offset)
+ {
+ return TextEditor.Document.GetTextSegmentMarkersAt (offset).OfType<ITextSegmentMarker> ();
+ }
+
+ void ITextEditorImpl.AddMarker (ITextSegmentMarker marker)
+ {
+ var textSegmentMarker = marker as TextSegmentMarker;
+ if (textSegmentMarker == null)
+ throw new InvalidOperationException ("Tried to add an incompatible text marker. Use the MarkerHost to create compatible ones.");
+ TextEditor.Document.AddMarker (textSegmentMarker);
+ }
+
+ bool ITextEditorImpl.RemoveMarker (ITextSegmentMarker marker)
+ {
+ var textSegmentMarker = marker as TextSegmentMarker;
+ if (textSegmentMarker == null)
+ throw new InvalidOperationException ("Tried to remove an incompatible text marker.");
+ return TextEditor.Document.RemoveMarker (textSegmentMarker);
+ }
+
+ IFoldSegment ITextEditorImpl.CreateFoldSegment (int offset, int length, bool isFolded = false)
+ {
+ return new FoldSegmentWrapper (TextEditor.Document, "...", offset, length, Mono.TextEditor.FoldingType.None) { IsFolded = isFolded };
+ }
+
+ void ITextEditorImpl.SetFoldings (IEnumerable<IFoldSegment> foldings)
+ {
+ TextEditor.Document.UpdateFoldSegments (foldings.Cast<FoldSegment> ().ToList ());
+ }
+
+ IEnumerable<IFoldSegment> ITextEditorImpl.GetFoldingsContaining (int offset)
+ {
+ return TextEditor.Document.GetFoldingsFromOffset (offset).Cast<IFoldSegment> ();
+ }
+
+ IEnumerable<IFoldSegment> ITextEditorImpl.GetFoldingsIn (int offset, int length)
+ {
+ return TextEditor.Document.GetFoldingContaining (offset, length).Cast<IFoldSegment> ();
+ }
+
+ MonoDevelop.Ide.Editor.ITextEditorOptions ITextEditorImpl.Options {
+ get {
+ return((StyledSourceEditorOptions)TextEditor.Options).OptionsCore;
+ }
+ set {
+ ((StyledSourceEditorOptions)TextEditor.Options).OptionsCore = value;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.DocumentLocation ITextEditorImpl.CaretLocation {
+ get {
+ var loc = TextEditor.Caret.Location;
+ return new MonoDevelop.Ide.Editor.DocumentLocation (loc.Line, loc.Column);
+ }
+ set {
+ TextEditor.Caret.Location = new Mono.TextEditor.DocumentLocation (value.Line, value.Column);
+ TextEditor.ScrollToCaret ();
+ }
+ }
+
+ bool ITextEditorImpl.IsSomethingSelected {
+ get {
+ return TextEditor.IsSomethingSelected;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.SelectionMode ITextEditorImpl.SelectionMode {
+ get {
+ return (MonoDevelop.Ide.Editor.SelectionMode)TextEditor.SelectionMode;
+ }
+ }
+
+ MonoDevelop.Core.Text.ISegment ITextEditorImpl.SelectionRange {
+ get {
+ var range = TextEditor.SelectionRange;
+ return MonoDevelop.Core.Text.TextSegment.FromBounds (range.Offset, range.EndOffset);
+ }
+ set {
+ TextEditor.SelectionRange = new TextSegment (value.Offset, value.Length);
+ }
}
- [CommandHandler (SourceEditorCommands.ToggleErrorTextMarker)]
- public void OnToggleErrorTextMarker ()
+ int ITextEditorImpl.SelectionAnchorOffset {
+ get {
+ return TextEditor.SelectionAnchor;
+ }
+ set {
+ TextEditor.SelectionAnchor = value;
+ }
+ }
+
+ int ITextEditorImpl.SelectionLeadOffset {
+ get {
+ return TextEditor.SelectionLead;
+ }
+ set {
+ TextEditor.SelectionLead = value;
+ }
+ }
+
+
+
+ MonoDevelop.Ide.Editor.DocumentRegion ITextEditorImpl.SelectionRegion {
+ get {
+ return new MonoDevelop.Ide.Editor.DocumentRegion (
+ TextEditor.MainSelection.Start.Line,
+ TextEditor.MainSelection.Start.Column,
+ TextEditor.MainSelection.End.Line,
+ TextEditor.MainSelection.End.Column
+ );
+ }
+ set {
+ TextEditor.MainSelection = new Mono.TextEditor.Selection (
+ value.BeginLine,
+ value.BeginColumn,
+ value.EndLine,
+ value.EndColumn
+ );
+ }
+ }
+
+ IEditorActionHost ITextEditorImpl.Actions {
+ get {
+ return this;
+ }
+ }
+
+ double ITextEditorImpl.LineHeight {
+ get {
+ return TextEditor.GetTextEditorData ().LineHeight;
+ }
+ }
+
+ ITextMarkerFactory ITextEditorImpl.TextMarkerFactory {
+ get {
+ return this;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.EditMode ITextEditorImpl.EditMode {
+ get {
+ if (TextEditor.CurrentMode is TextLinkEditMode)
+ return MonoDevelop.Ide.Editor.EditMode.TextLink;
+ if (TextEditor.CurrentMode is InsertionCursorEditMode)
+ return MonoDevelop.Ide.Editor.EditMode.CursorInsertion;
+ return MonoDevelop.Ide.Editor.EditMode.Edit;
+ }
+ }
+
+ string ITextEditorImpl.GetVirtualIndentationString (int lineNumber)
+ {
+ if (!TextEditor.GetTextEditorData ().HasIndentationTracker)
+ return TextEditor.GetLineIndent (lineNumber);
+ return TextEditor.GetTextEditorData ().IndentationTracker.GetIndentationString (lineNumber, 1);
+ }
+
+ void ITextEditorImpl.SetIndentationTracker (IndentationTracker indentationTracker)
+ {
+ TextEditor.GetTextEditorData ().IndentationTracker = indentationTracker != null ? new IndentationTrackerWrapper (TextEditor.GetTextEditorData (), wrapper, indentationTracker) : null;
+ }
+
+ void ITextEditorImpl.SetSelectionSurroundingProvider (SelectionSurroundingProvider surroundingProvider)
+ {
+ TextEditor.GetTextEditorData ().SelectionSurroundingProvider = surroundingProvider != null ? new SelectionSurroundingProviderWrapper (surroundingProvider) : null;
+ }
+
+ void ITextEditorImpl.SetTextPasteHandler (TextPasteHandler textPasteHandler)
+ {
+ if (textPasteHandler == null) {
+ TextEditor.GetTextEditorData ().TextPasteHandler = null;
+ return;
+ }
+ var data = TextEditor.GetTextEditorData ();
+ if (data.TextPasteHandler != null)
+ ((TextPasteHandlerWrapper)data.TextPasteHandler).Dispose ();
+ data.TextPasteHandler = new TextPasteHandlerWrapper (data, textPasteHandler);
+ }
+
+ public IList<SkipChar> SkipChars {
+ get {
+ return TextEditor.GetTextEditorData ().SkipChars.Select (sk => new SkipChar (sk.Offset, sk.Char)).ToList ();
+ }
+ }
+
+ public void AddSkipChar (int offset, char ch)
+ {
+ TextEditor.GetTextEditorData ().SetSkipChar (offset, ch);
+ }
+
+ void ITextEditorImpl.ScrollTo (int offset)
+ {
+ TextEditor.ScrollTo (offset);
+ }
+
+ void ITextEditorImpl.CenterTo (int offset)
+ {
+ TextEditor.CenterTo (offset);
+ }
+
+ void ITextEditorImpl.ClearTooltipProviders ()
+ {
+ TextEditor.ClearTooltipProviders ();
+ }
+
+ IEnumerable<MonoDevelop.Ide.Editor.TooltipProvider> ITextEditorImpl.TooltipProvider {
+ get {
+ foreach (var p in GetTextEditorData ().TooltipProviders) {
+ var wrapper = p as TooltipProviderWrapper;
+ if (wrapper == null)
+ continue;
+ yield return wrapper.OriginalProvider;
+ }
+ }
+ }
+
+ void ITextEditorImpl.AddTooltipProvider (MonoDevelop.Ide.Editor.TooltipProvider provider)
+ {
+ TextEditor.AddTooltipProvider (new TooltipProviderWrapper (provider));
+ }
+
+ void ITextEditorImpl.RemoveTooltipProvider (MonoDevelop.Ide.Editor.TooltipProvider provider)
+ {
+ foreach (var p in GetTextEditorData ().TooltipProviders) {
+ var wrapper = p as TooltipProviderWrapper;
+ if (wrapper == null)
+ continue;
+ if (wrapper.OriginalProvider == provider) {
+ TextEditor.RemoveTooltipProvider (p);
+ return;
+ }
+ }
+ }
+
+ Xwt.Point ITextEditorImpl.GetEditorWindowOrigin ()
+ {
+ int ox, oy;
+ TextEditor.GdkWindow.GetOrigin (out ox, out oy);
+ return new Xwt.Point (ox, oy);
+ }
+
+ Xwt.Rectangle ITextEditorImpl.GetEditorAllocation ()
+ {
+ var alloc = TextEditor.Allocation;
+ return new Xwt.Rectangle (alloc.X, alloc.Y, alloc.Width, alloc.Height);
+ }
+
+
+ TextEditorExtension ITextEditorImpl.EditorExtension {
+ get {
+ return TextEditor.EditorExtension;
+ }
+ set {
+ TextEditor.EditorExtension = value;
+ }
+ }
+
+
+ SemanticHighlighting ITextEditorImpl.SemanticHighlighting {
+ get {
+ return TextEditor.SemanticHighlighting;
+ }
+ set {
+ TextEditor.SemanticHighlighting = value;
+ }
+ }
+
+ string ITextEditorImpl.GetPangoMarkup (int offset, int length)
+ {
+ return TextEditor.GetTextEditorData ().GetMarkup (offset, length, false);
+ }
+
+ void ITextEditorImpl.SetUsageTaskProviders (IEnumerable<UsageProviderEditorExtension> providers)
+ {
+ widget.ClearUsageTaskProvider ();
+ foreach (var p in providers) {
+ widget.AddUsageTaskProvider (p);
+ }
+ }
+
+ void ITextEditorImpl.SetQuickTaskProviders (IEnumerable<IQuickTaskProvider> providers)
+ {
+ widget.ClearQuickTaskProvider ();
+ foreach (var p in providers) {
+ widget.AddQuickTaskProvider (p);
+ }
+ }
+
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineChanged;
+
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineInserted;
+
+ void HandleLineInserted (object sender, Mono.TextEditor.LineEventArgs e)
+ {
+ var handler = LineInserted;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
+ }
+
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineRemoved;
+
+ void HandleLineRemoved (object sender, Mono.TextEditor.LineEventArgs e)
+ {
+ var handler = LineRemoved;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
+ }
+
+ public double ZoomLevel {
+ get { return TextEditor.Options.Zoom; }
+ set { TextEditor.Options.Zoom = value; }
+ }
+ event EventHandler ITextEditorImpl.ZoomLevelChanged {
+ add {
+ TextEditor.Options.ZoomChanged += value;
+ }
+ remove {
+ TextEditor.Options.ZoomChanged += value;
+ }
+ }
+
+ public void AddOverlay (Control messageOverlayContent, Func<int> sizeFunc)
+ {
+ widget.AddOverlay (messageOverlayContent.GetNativeWidget<Widget> (), sizeFunc);
+ }
+
+ public void RemoveOverlay (Control messageOverlayContent)
+ {
+ widget.RemoveOverlay (messageOverlayContent.GetNativeWidget<Widget> ());
+ }
+
+ #region IEditorActionHost implementation
+
+ void IEditorActionHost.MoveCaretDown ()
+ {
+ CaretMoveActions.Down (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretUp ()
+ {
+ CaretMoveActions.Up (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretRight ()
+ {
+ CaretMoveActions.Right (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretLeft ()
+ {
+ CaretMoveActions.Left (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretToLineEnd ()
+ {
+ CaretMoveActions.LineEnd (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretToLineStart ()
{
- widget.OnToggleErrorTextMarker ();
+ CaretMoveActions.LineHome (TextEditor.GetTextEditorData ());
}
- [CommandHandler (EditCommands.IndentSelection)]
- public void IndentSelection ()
+ void IEditorActionHost.MoveCaretToDocumentStart ()
+ {
+ CaretMoveActions.ToDocumentStart (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.MoveCaretToDocumentEnd ()
+ {
+ CaretMoveActions.ToDocumentEnd (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.Backspace ()
+ {
+ DeleteActions.Backspace (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.ClipboardCopy ()
+ {
+ ClipboardActions.Copy (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.ClipboardCut ()
+ {
+ ClipboardActions.Cut (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.ClipboardPaste ()
+ {
+ ClipboardActions.Paste (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.NewLine ()
+ {
+ MiscActions.InsertNewLine (TextEditor.GetTextEditorData ());
+ }
+
+ void IEditorActionHost.SwitchCaretMode ()
+ {
+ TextEditor.RunAction (MiscActions.SwitchCaretMode);
+ }
+
+ void IEditorActionHost.InsertTab ()
+ {
+ TextEditor.RunAction (MiscActions.InsertTab);
+ }
+
+ void IEditorActionHost.RemoveTab ()
+ {
+ TextEditor.RunAction (MiscActions.RemoveTab);
+ }
+
+ void IEditorActionHost.InsertNewLine ()
+ {
+ TextEditor.RunAction (MiscActions.InsertNewLine);
+ }
+
+ void IEditorActionHost.DeletePreviousWord ()
+ {
+ TextEditor.RunAction (DeleteActions.PreviousWord);
+ }
+
+ void IEditorActionHost.DeleteNextWord ()
+ {
+ TextEditor.RunAction (DeleteActions.NextWord);
+ }
+
+ void IEditorActionHost.DeletePreviousSubword ()
+ {
+ TextEditor.RunAction (DeleteActions.PreviousSubword);
+ }
+
+ void IEditorActionHost.DeleteNextSubword ()
+ {
+ TextEditor.RunAction (DeleteActions.NextSubword);
+ }
+
+ void IEditorActionHost.StartCaretPulseAnimation ()
+ {
+ TextEditor.StartCaretPulseAnimation ();
+ }
+
+ void IEditorActionHost.RecenterEditor ()
+ {
+ TextEditor.RunAction (MiscActions.RecenterEditor);
+ }
+
+ void IEditorActionHost.JoinLines ()
+ {
+ using (var undo = Document.OpenUndoGroup ()) {
+ TextEditor.RunAction (Mono.TextEditor.Vi.ViActions.Join);
+ }
+ }
+
+ void IEditorActionHost.MoveNextSubWord ()
+ {
+ TextEditor.RunAction (SelectionActions.MoveNextSubword);
+ }
+
+ void IEditorActionHost.MovePrevSubWord ()
+ {
+ TextEditor.RunAction (SelectionActions.MovePreviousSubword);
+ }
+
+ void IEditorActionHost.MoveNextWord ()
+ {
+ TextEditor.RunAction (CaretMoveActions.NextWord);
+ }
+
+ void IEditorActionHost.MovePrevWord ()
+ {
+ TextEditor.RunAction (CaretMoveActions.PreviousWord);
+ }
+
+ void IEditorActionHost.PageUp ()
+ {
+ TextEditor.RunAction (CaretMoveActions.PageUp);
+ }
+
+ void IEditorActionHost.PageDown ()
+ {
+ TextEditor.RunAction (CaretMoveActions.PageDown);
+ }
+
+ void IEditorActionHost.DeleteCurrentLine ()
+ {
+ TextEditor.RunAction (DeleteActions.CaretLine);
+ }
+
+ void IEditorActionHost.DeleteCurrentLineToEnd ()
+ {
+ TextEditor.RunAction (DeleteActions.CaretLineToEnd);
+ }
+
+ void IEditorActionHost.ScrollLineUp ()
+ {
+ TextEditor.RunAction (ScrollActions.Up);
+ }
+
+ void IEditorActionHost.ScrollLineDown ()
+ {
+ TextEditor.RunAction (ScrollActions.Down);
+ }
+
+ void IEditorActionHost.ScrollPageUp ()
+ {
+ TextEditor.RunAction (ScrollActions.PageUp);
+ }
+
+ void IEditorActionHost.ScrollPageDown ()
+ {
+ TextEditor.RunAction (ScrollActions.PageDown);
+ }
+
+ void IEditorActionHost.MoveBlockUp ()
+ {
+ using (var undo = TextEditor.OpenUndoGroup ()) {
+ TextEditor.RunAction (MiscActions.MoveBlockUp);
+ CorrectIndenting ();
+ }
+ }
+
+ void IEditorActionHost.MoveBlockDown ()
+ {
+ using (var undo = TextEditor.OpenUndoGroup ()) {
+ TextEditor.RunAction (MiscActions.MoveBlockDown);
+ CorrectIndenting ();
+ }
+ }
+
+ void IEditorActionHost.ToggleBlockSelectionMode ()
+ {
+ TextEditor.SelectionMode = TextEditor.SelectionMode == Mono.TextEditor.SelectionMode.Normal ? Mono.TextEditor.SelectionMode.Block : Mono.TextEditor.SelectionMode.Normal;
+ TextEditor.QueueDraw ();
+ }
+
+ void IEditorActionHost.IndentSelection ()
{
if (widget.TextEditor.IsSomethingSelected) {
MiscActions.IndentSelection (widget.TextEditor.GetTextEditorData ());
@@ -2583,45 +3168,74 @@ namespace MonoDevelop.SourceEditor
widget.TextEditor.Insert (offset, widget.TextEditor.Options.IndentationString);
}
}
-
- [CommandHandler (EditCommands.UnIndentSelection)]
- public void UnIndentSelection ()
+
+ void IEditorActionHost.UnIndentSelection ()
{
- Mono.TextEditor.MiscActions.RemoveTab (widget.TextEditor.GetTextEditorData ());
+ MiscActions.RemoveTab (widget.TextEditor.GetTextEditorData ());
}
-
- [CommandHandler (EditCommands.InsertGuid)]
- public void InsertGuid ()
+
+ #endregion
+
+
+ #region ISegmentMarkerHost implementation
+
+ ITextSegmentMarker ITextMarkerFactory.CreateUsageMarker (MonoDevelop.Ide.Editor.TextEditor editor, Usage usage)
{
- TextEditor.InsertAtCaret (Guid.NewGuid ().ToString ());
+ return new UsageSegmentMarker (usage);
}
- [CommandHandler (SourceEditorCommands.NextIssue)]
- void NextIssue ()
+ IUrlTextLineMarker ITextMarkerFactory.CreateUrlTextMarker (MonoDevelop.Ide.Editor.TextEditor editor, IDocumentLine line, string value, MonoDevelop.Ide.Editor.UrlType url, string syntax, int startCol, int endCol)
{
- widget.NextIssue ();
- }
+ return new UrlTextLineMarker (TextEditor.Document, line, value, (Mono.TextEditor.UrlType)url, syntax, startCol, endCol);
+ }
- [CommandHandler (SourceEditorCommands.PrevIssue)]
- void PrevIssue ()
+ ICurrentDebugLineTextMarker ITextMarkerFactory.CreateCurrentDebugLineTextMarker (MonoDevelop.Ide.Editor.TextEditor editor)
{
- widget.PrevIssue ();
+ return new CurrentDebugLineTextMarker (TextEditor);
}
- [CommandHandler (SourceEditorCommands.NextIssueError)]
- void NextIssueError ()
+ ITextLineMarker ITextMarkerFactory.CreateAsmLineMarker (MonoDevelop.Ide.Editor.TextEditor editor)
{
- widget.NextIssueError ();
- }
+ return new AsmLineMarker ();
+ }
- [CommandHandler (SourceEditorCommands.PrevIssueError)]
- void PrevIssueError ()
+ IUnitTestMarker ITextMarkerFactory.CreateUnitTestMarker (MonoDevelop.Ide.Editor.TextEditor editor, UnitTestMarkerHost host, UnitTestLocation unitTestLocation)
{
- widget.PrevIssueError ();
+ return new UnitTestMarker (TextEditor, host, unitTestLocation);
+ }
+
+ IMessageBubbleLineMarker ITextMarkerFactory.CreateMessageBubbleLineMarker (MonoDevelop.Ide.Editor.TextEditor editor)
+ {
+ return new MessageBubbleTextMarker (messageBubbleCache);
+ }
+
+ IGenericTextSegmentMarker ITextMarkerFactory.CreateGenericTextSegmentMarker (MonoDevelop.Ide.Editor.TextEditor editor, TextSegmentMarkerEffect effect, int offset, int length)
+ {
+ switch (effect) {
+ case TextSegmentMarkerEffect.DottedLine:
+ case TextSegmentMarkerEffect.WavedLine:
+ return new GenericUnderlineMarker (new TextSegment (offset, length), effect);
+ case TextSegmentMarkerEffect.GrayOut:
+ return new GrayOutMarker (new TextSegment (offset, length));
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
}
+ public ITextSegmentMarker CreateLinkMarker (MonoDevelop.Ide.Editor.TextEditor editor, int offset, int length, Action<LinkRequest> activateLink)
+ {
+ return new LinkMarker (offset, length, activateLink);
+ }
+ ISmartTagMarker ITextMarkerFactory.CreateSmartTagMarker (MonoDevelop.Ide.Editor.TextEditor editor, int offset, MonoDevelop.Ide.Editor.DocumentLocation realLocation)
+ {
+ return new SmartTagMarker (offset, realLocation);
+ }
+ IErrorMarker ITextMarkerFactory.CreateErrorMarker (MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.TypeSystem.Error info, int offset, int length)
+ {
+ return new ErrorMarker (info, offset, length);
+ }
#endregion