[Monodevelop-patches-list] r829 - trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sun Feb 8 20:42:14 EST 2004
Author: tberman
Date: 2004-02-08 20:42:14 -0500 (Sun, 08 Feb 2004)
New Revision: 829
Added:
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CodeActions.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CommentRegionCommand.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FoldingCommands.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FormatCommands.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ICSharpCode.SharpDevelop.DefaultEditor.Commands.GenerateCodeAction.resources
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/IEditAction.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ProjectCommands.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/SearchCommands.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/TextAreaContextmenuCommands.cs
trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs
Log:
blah blah, more cruft
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CodeActions.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/CodeActions.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/CodeActions.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CodeActions.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,1163 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.AddIns;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.Services;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.TextEditor.Actions;
+using ICSharpCode.TextEditor;
+using SharpDevelop.Internal.Parser;
+using ICSharpCode.SharpDevelop.Services;
+
+using MonoDevelop.EditorBindings.FormattingStrategy;
+using MonoDevelop.SourceEditor.Gui;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class GenerateCodeAction : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not ported to the new editor yet");
+ /*
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+
+ IParserService parserService = (IParserService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+
+ IParseInformation parseInformation = parserService.GetParseInformation(textEditorControl.FileName);
+
+ if (parseInformation == null) {
+ return;
+ }
+
+ ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit;
+ if (cu == null) {
+ return;
+ }
+ IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName);
+
+ if (currentClass != null) {
+ ArrayList categories = new ArrayList();
+ /*using (FormVersion1 form = new FormVersion1(textEditorControl, new CodeGenerator[] {
+ new ConstructorCodeGenerator(currentClass),
+ new GetPropertiesCodeGenerator(currentClass),
+ new SetPropertiesCodeGenerator(currentClass),
+ new GetSetPropertiesCodeGenerator(currentClass),
+ new OnXXXMethodsCodeGenerator(currentClass),
+ new OverrideMethodsCodeGenerator(currentClass),
+ new InterfaceImplementorCodeGenerator(currentClass),
+ new AbstractClassImplementorCodeGenerator(currentClass)
+ })) {
+ form.ShowDialog();
+ }*/
+ }
+ }
+
+ /// <remarks>
+ /// Returns the class in which the carret currently is, returns null
+ /// if the carret is outside the class boundaries.
+ /// </remarks>
+ /*IClass GetCurrentClass(TextEditorControl textEditorControl, ICompilationUnit cu, string fileName)
+ {
+
+ IDocument document = textEditorControl.Document;
+ if (cu != null) {
+ int caretLineNumber = document.GetLineNumberForOffset(textEditorControl.ActiveTextAreaControl.Caret.Offset) + 1;
+ int caretColumn = textEditorControl.ActiveTextAreaControl.Caret.Offset - document.GetLineSegment(caretLineNumber - 1).Offset + 1;
+
+ foreach (IClass c in cu.Classes) {
+ if (c.Region.IsInside(caretLineNumber, caretColumn)) {
+ return c;
+ }
+ }
+ }
+ return null;
+ }*/
+ }
+
+ public class SurroundCodeAction : AbstractEditAction
+ {
+ public override void Execute(SourceEditorView editActionHandler)
+ {
+// SelectionWindow selectionWindow = new SelectionWindow("Surround");
+// selectionWindow.Show();
+ }
+ }
+
+ /// <summary>
+ /// Add summary description for form
+ /// </summary>
+ /*
+ public class FormVersion1 //: Form
+ {
+ //private System.Windows.Forms.ColumnHeader createdObject0;
+ //private System.Windows.Forms.ListView categoryListView;
+ //private System.Windows.Forms.Label statusLabel;
+ //private System.Windows.Forms.CheckedListBox selectionListBox;
+
+
+ TextEditorControl textEditorControl;
+
+ CodeGenerator SelectedCodeGenerator {
+ get {
+ if (categoryListView.SelectedItems.Count != 1) {
+ return null;
+ }
+ return (CodeGenerator)categoryListView.SelectedItems[0].Tag;
+ return null;
+ }
+ }
+
+ public FormVersion1(TextEditorControl textEditorControl, CodeGenerator[] codeGenerators)
+ {
+ this.textEditorControl = textEditorControl;
+
+ // Must be called for initialization
+ this.InitializeComponents();
+
+ Point caretPos = textEditorControl.ActiveTextAreaControl.Caret.Position;
+ Point visualPos = new Point(textEditorControl.ActiveTextAreaControl.TextArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X) + textEditorControl.ActiveTextAreaControl.TextArea.TextView.DrawingPosition.X,
+ (int)((1 + caretPos.Y) * textEditorControl.ActiveTextAreaControl.TextArea.TextView.FontHeight) - textEditorControl.ActiveTextAreaControl.TextArea.VirtualTop.Y - 1 + textEditorControl.ActiveTextAreaControl.TextArea.TextView.DrawingPosition.Y);
+ //Location = textEditorControl.ActiveTextAreaControl.TextArea.PointToScreen(visualPos); //FIXME:Should we be defining this pedro?
+ //StartPosition = FormStartPosition.Manual;
+
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ //categoryListView.SmallImageList = categoryListView.LargeImageList = classBrowserIconService.ImageList;
+
+ foreach (CodeGenerator codeGenerator in codeGenerators) {
+ if (codeGenerator.Content.Count > 0) {
+ //ListViewItem newItem = new ListViewItem(codeGenerator.CategoryName);
+ //newItem.ImageIndex = codeGenerator.ImageIndex;
+ //newItem.Tag = codeGenerator;
+ //categoryListView.Items.Add(newItem);
+ }
+ }
+
+ //categoryListView.SelectedIndexChanged += new EventHandler(CategoryListViewItemChanged);
+ }
+ protected void OnActivated(EventArgs e)
+ {
+ //base.OnActivated(e);
+ if (categoryListView.Items.Count > 0) {
+ categoryListView.Select();
+ categoryListView.Focus();
+ categoryListView.Items[0].Focused = categoryListView.Items[0].Selected = true;
+ } else {
+ Close();
+ }
+ }
+
+ protected bool ProcessDialogKey()
+ {
+
+ switch (keyData) {
+ case Keys.Escape:
+ Close();
+ return true;
+ case Keys.Back:
+ categoryListView.Focus();
+ return true;
+ case Keys.Return:
+ if (categoryListView.Focused) {
+ selectionListBox.Focus();
+ } else {
+ Close();
+ SelectedCodeGenerator.GenerateCode(textEditorControl.ActiveTextAreaControl.TextArea, selectionListBox.CheckedItems.Count > 0 ? (IList)selectionListBox.CheckedItems : (IList)selectionListBox.SelectedItems);
+ }
+ return true;
+ }
+ return base.ProcessDialogKey(keyData);
+
+ return false;
+ }
+
+ void CategoryListViewItemChanged(object sender, EventArgs e)
+ {
+
+ CodeGenerator codeGenerator = SelectedCodeGenerator;
+ if (codeGenerator == null) {
+ return;
+ }
+ statusLabel.Text = codeGenerator.Hint;
+ selectionListBox.BeginUpdate();
+ selectionListBox.Items.Clear();
+ foreach (object o in codeGenerator.Content) {
+ selectionListBox.Items.Add(o);
+ }
+ selectionListBox.SelectedIndex = 0;
+ selectionListBox.EndUpdate();
+
+ }
+
+ /// <summary>
+ /// This method was autogenerated - do not change the contents manually
+ /// </summary>
+ private void InitializeComponents()
+ {
+
+ //
+ // Set up generated class form
+ //
+ this.SuspendLayout();
+ this.Name = "form";
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.Size = new System.Drawing.Size(264, 312);
+ this.ShowInTaskbar = false;
+
+ //
+ // Set up member selectionListBox
+ //
+ selectionListBox = new System.Windows.Forms.CheckedListBox();
+ selectionListBox.Name = "selectionListBox";
+ selectionListBox.Location = new System.Drawing.Point(0, 128);
+ selectionListBox.Size = new System.Drawing.Size(264, 184);
+ selectionListBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ selectionListBox.TabIndex = 2;
+ this.Controls.Add(selectionListBox);
+
+ //
+ // Set up member statusLabel
+ //
+ statusLabel = new System.Windows.Forms.Label();
+ statusLabel.Name = "statusLabel";
+ statusLabel.Text = "Choose fields to generate getters and setters";
+ statusLabel.TabIndex = 1;
+ statusLabel.Size = new System.Drawing.Size(264, 16);
+ statusLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ statusLabel.Location = new System.Drawing.Point(0, 112);
+ statusLabel.Dock = System.Windows.Forms.DockStyle.Top;
+ this.Controls.Add(statusLabel);
+
+ //
+ // Set up member categoryListView
+ //
+ categoryListView = new System.Windows.Forms.ListView();
+ categoryListView.Name = "categoryListView";
+ categoryListView.Dock = System.Windows.Forms.DockStyle.Top;
+ categoryListView.TabIndex = 0;
+ categoryListView.View = System.Windows.Forms.View.Details;
+ categoryListView.Size = new System.Drawing.Size(264, 112);
+ categoryListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
+
+ //
+ // Set up member createdObject0
+ //
+ createdObject0 = new System.Windows.Forms.ColumnHeader();
+ createdObject0.Width = 258;
+ categoryListView.Columns.Add(createdObject0);
+ this.Controls.Add(categoryListView);
+ this.ResumeLayout(false);
+
+ }
+ }
+ */
+
+ /*
+ public abstract class CodeGenerator
+ {
+ ArrayList content = new ArrayList();
+ protected int numOps = 0;
+ protected IAmbience csa;
+ protected IClass currentClass = null;
+ //protected TextArea editActionHandler;
+
+ public CodeGenerator(IClass currentClass)
+ {
+ try {
+ csa = (IAmbience)AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/Ambiences").BuildChildItem("CSharp", this);
+ } catch {
+ Console.WriteLine("CSharpAmbience not found -- is the C# backend binding loaded???");
+ return;
+ }
+
+ this.currentClass = currentClass;
+ csa.ConversionFlags = ConversionFlags.All;
+ }
+
+ public abstract string CategoryName {
+ get;
+ }
+ public abstract string Hint {
+ get;
+ }
+ public abstract int ImageIndex {
+ get;
+ }
+
+ public ArrayList Content {
+ get {
+ return content;
+ }
+ }
+
+ public void GenerateCode(TextArea editActionHandler, IList items)
+ {
+ numOps = 0;
+ this.editActionHandler = editActionHandler;
+ editActionHandler.BeginUpdate();
+
+ bool save1 = editActionHandler.TextEditorProperties.AutoInsertCurlyBracket;
+ IndentStyle save2 = editActionHandler.TextEditorProperties.IndentStyle;
+ editActionHandler.TextEditorProperties.AutoInsertCurlyBracket = false;
+ editActionHandler.TextEditorProperties.IndentStyle = IndentStyle.Smart;
+
+
+ StartGeneration(items);
+
+ if (numOps > 0) {
+ editActionHandler.Document.UndoStack.UndoLast(numOps);
+ }
+ // restore old property settings
+ editActionHandler.TextEditorProperties.AutoInsertCurlyBracket = save1;
+ editActionHandler.TextEditorProperties.IndentStyle = save2;
+ editActionHandler.EndUpdate();
+
+ editActionHandler.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
+ editActionHandler.Document.CommitUpdate();
+ }
+
+ protected abstract void StartGeneration(IList items);
+
+ protected void Return()
+ {
+ IndentLine();
+ new Return().Execute(editActionHandler);++numOps;
+ }
+
+ protected void IndentLine()
+ {
+ int delta = editActionHandler.Document.FormattingStrategy.IndentLine(editActionHandler.Document, editActionHandler.Document.GetLineNumberForOffset(editActionHandler.Caret.Offset));
+ if (delta != 0) {
+ ++numOps;
+ LineSegment caretLine = editActionHandler.Document.GetLineSegmentForOffset(editActionHandler.Caret.Offset);
+ editActionHandler.Caret.Position = editActionHandler.Document.OffsetToPosition(Math.Min(editActionHandler.Caret.Offset + delta, caretLine.Offset + caretLine.Length));
+ }
+ }
+ }
+ */
+
+ /*
+ public abstract class FieldCodeGenerator : CodeGenerator
+ {
+ public FieldCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ foreach (IField field in currentClass.Fields) {
+ Content.Add(new FieldWrapper(field));
+ }
+ }
+
+ public class FieldWrapper
+ {
+ IField field;
+
+ public IField Field {
+ get {
+ return field;
+ }
+ }
+
+ public FieldWrapper(IField field)
+ {
+ this.field = field;
+ }
+
+ public override string ToString()
+ {
+ AmbienceService ambienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
+ return ambienceService.CurrentAmbience.Convert(field);
+ }
+ }
+ }
+
+ public class ConstructorCodeGenerator : FieldCodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Constructor";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose fields to initialize by constructor";
+ }
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.MethodIndex;
+ }
+ }
+
+ public ConstructorCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+ editActionHandler.InsertString("public " + currentClass.Name + "(");
+ ++numOps;
+
+ for (int i = 0; i < items.Count; ++i) {
+ FieldWrapper fw = (FieldWrapper)items[i];
+ editActionHandler.InsertString(csa.Convert(fw.Field.ReturnType) + " " + fw.Field.Name);
+ ++numOps;
+ if (i + 1 < items.Count) {
+ editActionHandler.InsertString(", ");
+ ++numOps;
+ }
+ }
+
+ editActionHandler.InsertChar(')');++numOps;
+ Return();
+ editActionHandler.InsertChar('{');++numOps;
+ Return();
+
+ for (int i = 0; i < items.Count; ++i) {
+ FieldWrapper fw = (FieldWrapper)items[i];
+ editActionHandler.InsertString("this." + fw.Field.Name + " = " + fw.Field.Name + ";");++numOps;
+ Return();
+ }
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ IndentLine();
+ }
+ }
+
+ public abstract class PropertiesCodeGenerator : FieldCodeGenerator
+ {
+
+ public PropertiesCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.PropertyIndex;
+ }
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+ for (int i = 0; i < items.Count; ++i) {
+ FieldWrapper fw = (FieldWrapper)items[i];
+
+ editActionHandler.InsertString("public " + (fw.Field.IsStatic ? "static " : "") + csa.Convert(fw.Field.ReturnType) + " " + Char.ToUpper(fw.Field.Name[0]) + fw.Field.Name.Substring(1) + " {");++numOps;
+ Return();
+
+ GeneratePropertyBody(editActionHandler, fw);
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ IndentLine();
+ }
+ }
+
+ protected void GenerateGetter(TextArea editActionHandler, FieldWrapper fw)
+ {
+ editActionHandler.InsertString("get {");++numOps;
+ Return();
+
+ editActionHandler.InsertString("return " + fw.Field.Name+ ";");++numOps;
+ Return();
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ }
+
+ protected void GenerateSetter(TextArea editActionHandler, FieldWrapper fw)
+ {
+ editActionHandler.InsertString("set {");++numOps;
+ Return();
+
+ editActionHandler.InsertString(fw.Field.Name+ " = value;");++numOps;
+ Return();
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ }
+
+ protected abstract void GeneratePropertyBody(TextArea editActionHandler, FieldWrapper fw);
+ }*/
+
+ /*
+
+ public class GetPropertiesCodeGenerator : PropertiesCodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Getter";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose fields to generate getters";
+ }
+ }
+
+ public GetPropertiesCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ }
+
+ protected override void GeneratePropertyBody(TextArea editActionHandler, FieldWrapper fw)
+ {
+ GenerateGetter(editActionHandler, fw);
+ }
+ }
+
+ public class SetPropertiesCodeGenerator : PropertiesCodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Setter";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose fields to generate setters";
+ }
+ }
+
+ public SetPropertiesCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ }
+
+ protected override void GeneratePropertyBody(TextArea editActionHandler, FieldWrapper fw)
+ {
+ GenerateSetter(editActionHandler, fw);
+ }
+ }
+
+ public class GetSetPropertiesCodeGenerator : PropertiesCodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Getter and Setter";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose fields to generate getters and setters";
+ }
+ }
+
+ public GetSetPropertiesCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ }
+ protected override void GeneratePropertyBody(TextArea editActionHandler, FieldWrapper fw)
+ {
+ GenerateGetter(editActionHandler, fw);
+ GenerateSetter(editActionHandler, fw);
+ }
+ }
+
+ public class OnXXXMethodsCodeGenerator : CodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Event OnXXX methods";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose events to generate OnXXX methods";
+ }
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.EventIndex;
+ }
+ }
+
+ public OnXXXMethodsCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ foreach (IEvent evt in currentClass.Events) {
+ Content.Add(new EventWrapper(evt));
+ }
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+ for (int i = 0; i < items.Count; ++i) {
+ EventWrapper ew = (EventWrapper)items[i];
+ string eventArgsName = String.Empty;
+ if (ew.Event.ReturnType.FullyQualifiedName.EndsWith("Handler")) {
+ eventArgsName = ew.Event.ReturnType.FullyQualifiedName.Substring(0, ew.Event.ReturnType.FullyQualifiedName.Length - "Handler".Length);
+ } else {
+ eventArgsName = ew.Event.ReturnType.FullyQualifiedName;
+ }
+ eventArgsName += "Args";
+
+ editActionHandler.InsertString("protected " + (ew.Event.IsStatic ? "static" : "virtual") + " void On" + ew.Event.Name + "(" + eventArgsName + " e)");++numOps;
+ Return();
+ editActionHandler.InsertChar('{');++numOps;
+ Return();
+
+ editActionHandler.InsertString("if (" + ew.Event.Name + " != null) {");++numOps;
+ Return();
+ editActionHandler.InsertString(ew.Event.Name + "(this, e);");++numOps;
+ Return();
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ IndentLine();
+ }
+ }
+
+ class EventWrapper
+ {
+ IEvent evt;
+ public IEvent Event {
+ get {
+ return evt;
+ }
+ }
+ public EventWrapper(IEvent evt)
+ {
+ this.evt = evt;
+ }
+
+ public override string ToString()
+ {
+ AmbienceService ambienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
+ return ambienceService.CurrentAmbience.Convert(evt);
+ }
+ }
+ }
+
+ public class InterfaceImplementorCodeGenerator : CodeGenerator
+ {
+ ICompilationUnit unit;
+
+ public override string CategoryName {
+ get {
+ return "Interface implementation";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose interfaces to implement";
+ }
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.InterfaceIndex;
+ }
+ }
+
+ public InterfaceImplementorCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ IParserService parserService = (IParserService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+
+ foreach (string className in currentClass.BaseTypes) {
+ IClass baseType = parserService.GetClass(className);
+ if (baseType == null) {
+ this.unit = currentClass == null ? null : currentClass.CompilationUnit;
+ if (unit != null) {
+ foreach (IUsing u in unit.Usings) {
+ baseType = u.SearchType(className);
+ if (baseType != null) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (baseType != null && baseType.ClassType == ClassType.Interface) {
+ Content.Add(new ClassWrapper(baseType));
+ }
+ }
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+ for (int i = 0; i < items.Count; ++i) {
+ ClassWrapper cw = (ClassWrapper)items[i];
+ Queue interfaces = new Queue();
+ interfaces.Enqueue(cw.Class);
+ while (interfaces.Count > 0) {
+ IClass intf = (IClass)interfaces.Dequeue();
+ GenerateInterface(intf);
+
+ // search an enqueue all base interfaces
+ foreach (string interfaceName in intf.BaseTypes) {
+ IClass baseType = null;
+ foreach (IUsing u in unit.Usings) {
+ baseType = u.SearchType(interfaceName);
+ if (baseType != null) {
+ break;
+ }
+ }
+ if (baseType != null) {
+ interfaces.Enqueue(baseType);
+ }
+ }
+ }
+ }
+ }
+
+ void GenerateInterface(IClass intf)
+ {
+ Return();
+ Return();
+ editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " interface implementation\n\t\t");++numOps;
+
+ foreach (IProperty property in intf.Properties) {
+ string returnType = csa.Convert(property.ReturnType);
+ editActionHandler.InsertString("public " + returnType + " " + property.Name + " {");++numOps;
+ Return();
+
+ if (property.CanGet) {
+ editActionHandler.InsertString("\tget {");++numOps;
+ Return();
+ editActionHandler.InsertString("\t\treturn " + GetReturnValue(returnType) +";");++numOps;
+ Return();
+ editActionHandler.InsertString("\t}");++numOps;
+ Return();
+ }
+
+ if (property.CanSet) {
+ editActionHandler.InsertString("\tset {");++numOps;
+ Return();
+ editActionHandler.InsertString("\t}");++numOps;
+ Return();
+ }
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ Return();
+ IndentLine();
+ }
+
+ for (int i = 0; i < intf.Methods.Count; ++i) {
+ IMethod method = intf.Methods[i];
+ string parameters = String.Empty;
+ string returnType = csa.Convert(method.ReturnType);
+
+ for (int j = 0; j < method.Parameters.Count; ++j) {
+ parameters += csa.Convert(method.Parameters[j]);
+ if (j + 1 < method.Parameters.Count) {
+ parameters += ", ";
+ }
+ }
+
+ editActionHandler.InsertString("public " + returnType + " " + method.Name + "(" + parameters + ")");++numOps;
+ Return();++numOps;
+ editActionHandler.InsertChar('{');++numOps;
+ Return();
+
+ switch (returnType) {
+ case "void":
+ break;
+ default:
+ editActionHandler.InsertString("return " + GetReturnValue(returnType) + ";");++numOps;
+ break;
+ }
+ Return();
+
+ editActionHandler.InsertChar('}');++numOps;
+ if (i + 1 < intf.Methods.Count) {
+ Return();
+ Return();
+ IndentLine();
+ } else {
+ IndentLine();
+ }
+ }
+
+ Return();
+ editActionHandler.InsertString("#endregion");++numOps;
+ Return();
+ }
+
+ string GetReturnValue(string returnType)
+ {
+ switch (returnType) {
+ case "string":
+ return "String.Empty";
+ case "char":
+ return "'\\0'";
+ case "bool":
+ return "false";
+ case "int":
+ case "long":
+ case "short":
+ case "byte":
+ case "uint":
+ case "ulong":
+ case "ushort":
+ case "double":
+ case "float":
+ case "decimal":
+ return "0";
+ default:
+ return "null";
+ }
+ }
+
+ class ClassWrapper
+ {
+ IClass c;
+ public IClass Class {
+ get {
+ return c;
+ }
+ }
+ public ClassWrapper(IClass c)
+ {
+ this.c = c;
+ }
+
+ public override string ToString()
+ {
+ AmbienceService ambienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
+ return ambienceService.CurrentAmbience.Convert(c);
+ }
+ }
+ }
+
+ public class OverrideMethodsCodeGenerator : CodeGenerator
+ {
+ public override string CategoryName {
+ get {
+ return "Override methods";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose methods to override";
+ }
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.MethodIndex;
+ }
+ }
+
+ public OverrideMethodsCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ foreach (IClass c in currentClass.ClassInheritanceTree) {
+ if (c.FullyQualifiedName != currentClass.FullyQualifiedName) {
+ foreach (IMethod method in c.Methods) {
+ if (!method.IsPrivate && (method.IsAbstract || method.IsVirtual || method.IsOverride)) {
+ Content.Add(new MethodWrapper(method));
+ }
+ }
+ }
+ }
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+// bool moveToMethod = sf.SelectedItems.Count == 1;
+// int caretPos = 0;
+ for (int i = 0; i < items.Count; ++i) {
+ MethodWrapper mw = (MethodWrapper)items[i];
+
+ string parameters = String.Empty;
+ string paramList = String.Empty;
+ string returnType = csa.Convert(mw.Method.ReturnType);
+
+ for (int j = 0; j < mw.Method.Parameters.Count; ++j) {
+ paramList += mw.Method.Parameters[j].Name;
+ parameters += csa.Convert(mw.Method.Parameters[j]);
+ if (j + 1 < mw.Method.Parameters.Count) {
+ parameters += ", ";
+ paramList += ", ";
+ }
+ }
+
+ editActionHandler.InsertString(csa.Convert(mw.Method.Modifiers) + "override " + returnType + " " + mw.Method.Name + "(" + parameters + ")");++numOps;
+ Return();
+ editActionHandler.InsertChar('{');++numOps;
+ Return();
+
+ if (returnType != "void") {
+ string str = "return base." + mw.Method.Name + "(" + paramList + ");";
+ editActionHandler.InsertString(str);++numOps;
+ }
+
+ Return();
+// caretPos = editActionHandler.Document.Caret.Offset;
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ IndentLine();
+ }
+// if (moveToMethod) {
+// editActionHandler.Document.Caret.Offset = caretPos;
+// }
+ }
+
+ class MethodWrapper
+ {
+ IMethod method;
+
+ public IMethod Method {
+ get {
+ return method;
+ }
+ }
+
+ public MethodWrapper(IMethod method)
+ {
+ this.method = method;
+ }
+
+ public override string ToString()
+ {
+ AmbienceService ambienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
+ IAmbience ambience = ambienceService.CurrentAmbience;
+ ambience.ConversionFlags = ConversionFlags.None;
+ return ambience.Convert(method);
+ }
+ }
+ }
+
+ public class AbstractClassImplementorCodeGenerator : CodeGenerator
+ {
+ ICompilationUnit unit;
+
+ public override string CategoryName {
+ get {
+ return "Abstract class overridings";
+ }
+ }
+
+ public override string Hint {
+ get {
+ return "Choose abstract class to override";
+ }
+ }
+
+ public override int ImageIndex {
+ get {
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ return classBrowserIconService.InterfaceIndex;
+ }
+ }
+
+ public AbstractClassImplementorCodeGenerator(IClass currentClass) : base(currentClass)
+ {
+ IParserService parserService = (IParserService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+
+ foreach (string className in currentClass.BaseTypes) {
+ IClass baseType = parserService.GetClass(className);
+ if (baseType == null) {
+ this.unit = currentClass == null ? null : currentClass.CompilationUnit;
+ if (unit != null) {
+ foreach (IUsing u in unit.Usings) {
+ baseType = u.SearchType(className);
+ if (baseType != null) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (baseType != null && baseType.ClassType == ClassType.Class && baseType.IsAbstract) {
+ Content.Add(new ClassWrapper(baseType));
+ }
+ }
+ }
+
+ protected override void StartGeneration(IList items)
+ {
+ for (int i = 0; i < items.Count; ++i) {
+ ClassWrapper cw = (ClassWrapper)items[i];
+ Queue interfaces = new Queue();
+ interfaces.Enqueue(cw.Class);
+ while (interfaces.Count > 0) {
+ IClass intf = (IClass)interfaces.Dequeue();
+ GenerateInterface(intf);
+
+ // search an enqueue all base interfaces
+ foreach (string interfaceName in intf.BaseTypes) {
+ IClass baseType = null;
+ foreach (IUsing u in unit.Usings) {
+ baseType = u.SearchType(interfaceName);
+ if (baseType != null) {
+ break;
+ }
+ }
+ if (baseType != null) {
+ interfaces.Enqueue(baseType);
+ }
+ }
+ }
+ }
+ }
+
+ void GenerateInterface(IClass intf)
+ {
+ Return();Return();
+ editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " abstract class implementation\n\t\t");++numOps;
+
+ foreach (IProperty property in intf.Properties) {
+ if (!property.IsAbstract) {
+ continue;
+ }
+ string returnType = csa.Convert(property.ReturnType);
+ if (property.IsProtected) {
+ editActionHandler.InsertString("protected ");
+ } else {
+ editActionHandler.InsertString("public ");
+ }
+
+ editActionHandler.InsertString("override " + returnType + " " + property.Name + " {\n");++numOps;
+
+ if (property.CanGet) {
+ editActionHandler.InsertString("\tget {");++numOps;
+ Return();
+ editActionHandler.InsertString("\t\treturn " + GetReturnValue(returnType) +";");++numOps;
+ Return();
+ editActionHandler.InsertString("\t}");++numOps;
+ Return();
+ }
+
+ if (property.CanSet) {
+ editActionHandler.InsertString("\tset {");++numOps;
+ Return();
+ editActionHandler.InsertString("\t}");++numOps;
+ Return();
+ }
+
+ editActionHandler.InsertChar('}');++numOps;
+ Return();
+ Return();
+ IndentLine();
+ }
+
+ for (int i = 0; i < intf.Methods.Count; ++i) {
+ IMethod method = intf.Methods[i];
+ string parameters = String.Empty;
+ string returnType = csa.Convert(method.ReturnType);
+ if (!method.IsAbstract) {
+ continue;
+ }
+ for (int j = 0; j < method.Parameters.Count; ++j) {
+ parameters += csa.Convert(method.Parameters[j]);
+ if (j + 1 < method.Parameters.Count) {
+ parameters += ", ";
+ }
+ }
+ if (method.IsProtected) {
+ editActionHandler.InsertString("protected ");
+ } else {
+ editActionHandler.InsertString("public ");
+ }
+
+ editActionHandler.InsertString("override " + returnType + " " + method.Name + "(" + parameters + ")");++numOps;
+ Return();
+ editActionHandler.InsertChar('{');++numOps;
+ Return();
+
+ switch (returnType) {
+ case "void":
+ break;
+ default:
+ editActionHandler.InsertString("return " + GetReturnValue(returnType) + ";");++numOps;
+ break;
+ }
+ Return();
+
+ editActionHandler.InsertChar('}');++numOps;
+ if (i + 1 < intf.Methods.Count) {
+ Return();
+ Return();
+ IndentLine();
+ } else {
+ IndentLine();
+ }
+ }
+ Return();
+ editActionHandler.InsertString("#endregion");++numOps;
+ Return();
+ }
+
+ string GetReturnValue(string returnType)
+ {
+ switch (returnType) {
+ case "string":
+ return "String.Empty";
+ case "char":
+ return "'\\0'";
+ case "bool":
+ return "false";
+ case "int":
+ case "long":
+ case "short":
+ case "byte":
+ case "uint":
+ case "ulong":
+ case "ushort":
+ case "double":
+ case "float":
+ case "decimal":
+ return "0";
+ default:
+ return "null";
+ }
+ }
+
+ class ClassWrapper
+ {
+ IClass c;
+ public IClass Class {
+ get {
+ return c;
+ }
+ }
+ public ClassWrapper(IClass c)
+ {
+ this.c = c;
+ }
+
+ public override string ToString()
+ {
+ AmbienceService ambienceService = (AmbienceService)ServiceManager.Services.GetService(typeof(AmbienceService));
+ return ambienceService.CurrentAmbience.Convert(c);
+ }
+ }
+ }
+}*/
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CommentRegionCommand.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/CommentRegionCommand.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/CommentRegionCommand.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/CommentRegionCommand.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,47 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Markus Palme" email="MarkusPalme at gmx.de"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.AddIns;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.Core.Properties;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.TextEditor;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class CommentRegion : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not ported to the new editor yet");
+ /*
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+
+ TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+ new ICSharpCode.TextEditor.Actions.ToggleComment().Execute(textarea.ActiveTextAreaControl.TextArea);
+ */
+ }
+ }
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FoldingCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/FoldingCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/FoldingCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FoldingCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,68 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+using System.Xml;
+using System.Xml.Xsl;
+
+using ICSharpCode.Core.AddIns;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Actions;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Gui.HtmlControl;
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class ToggleFolding : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ //return new ICSharpCode.TextEditor.Actions.ToggleFolding();
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ }
+ }
+ }
+
+ public class ToggleAllFoldings : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ToggleAllFoldings();
+ }
+ }
+ }
+
+ public class ShowDefinitionsOnly : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ShowDefinitionsOnly();
+ }
+ }
+ }
+
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FormatCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/FormatCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/FormatCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/FormatCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,270 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.Services;
+using ICSharpCode.Core.AddIns;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.Core.Properties;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Actions;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class RemoveLeadingWS : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.RemoveLeadingWS();
+ }
+ }
+ }
+
+ public class RemoveTrailingWS : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.RemoveTrailingWS();
+ }
+ }
+ }
+
+
+ public class ToUpperCase : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ToUpperCase();
+ }
+ }
+ }
+
+ public class ToLowerCase : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ToLowerCase();
+ }
+ }
+ }
+
+ public class InvertCaseAction : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.InvertCaseAction();
+ }
+ }
+ }
+
+ public class CapitalizeAction : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.CapitalizeAction();
+ }
+ }
+ }
+
+ public class ConvertTabsToSpaces : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ConvertTabsToSpaces();
+ }
+ }
+ }
+
+ public class ConvertSpacesToTabs : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ConvertSpacesToTabs();
+ }
+ }
+ }
+
+ public class ConvertLeadingTabsToSpaces : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ConvertLeadingTabsToSpaces();
+ }
+ }
+ }
+
+ public class ConvertLeadingSpacesToTabs : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.ConvertLeadingSpacesToTabs();
+ }
+ }
+ }
+
+ /// <summary>
+ /// This is a sample editaction plugin, it indents the selected area.
+ /// </summary>
+ public class IndentSelection : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in the new Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.FormatBuffer();
+ }
+ }
+ }
+
+ /// <summary>
+ /// This is a sample editaction plugin, it indents the selected area.
+ /// </summary>
+ public class SortSelection : AbstractMenuCommand
+ {
+ static PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
+ class SortComparer : IComparer
+ {
+
+ //SortDirection sortDirection;
+ bool isCaseSensitive;
+ bool ignoreWhitespaces;
+
+ public SortComparer()
+ {
+ //isCaseSensitive = propertyService.GetProperty(SortOptionsDialog.caseSensitiveOption, true);
+ //ignoreWhitespaces = propertyService.GetProperty(SortOptionsDialog.ignoreWhiteSpacesOption, true);
+ //sortDirection = (SortDirection)propertyService.GetProperty(SortOptionsDialog.sortDirectionOption, SortDirection.Ascending);
+ }
+
+ public int Compare(object x, object y)
+ {
+ if (x == null || y == null) {
+ return -1;
+ }
+ string str1;
+ string str2;
+
+ //if (sortDirection == SortDirection.Ascending) {
+ str1 = x.ToString();
+ str2 = y.ToString();
+ //} else {
+ str1 = y.ToString();
+ str2 = x.ToString();
+ //}
+
+ if (ignoreWhitespaces) {
+ str1 = str1.Trim();
+ str2 = str2.Trim();
+ }
+
+ if (!isCaseSensitive) {
+ str1 = str1.ToUpper();
+ str2 = str2.ToUpper();
+ }
+
+ return str1.CompareTo(str2);
+ }
+ }
+
+ /*
+ public void SortLines(IDocument document, int startLine, int endLine)
+ {
+ ArrayList lines = new ArrayList();
+ for (int i = startLine; i <= endLine; ++i) {
+ LineSegment line = document.GetLineSegment(i);
+ lines.Add(document.GetText(line.Offset, line.Length));
+ }
+
+ lines.Sort(new SortComparer());
+
+ //bool removeDupes = propertyService.GetProperty(SortOptionsDialog.removeDupesOption, false);
+ bool removeDupes = false; //FIXME: TMP
+ if (removeDupes) {
+ for (int i = 0; i < lines.Count - 1; ++i) {
+ if (lines[i].Equals(lines[i + 1])) {
+ lines.RemoveAt(i);
+ --i;
+ }
+ }
+ }
+
+ for (int i = 0; i < lines.Count; ++i) {
+ LineSegment line = document.GetLineSegment(startLine + i);
+ document.Replace(line.Offset, line.Length, lines[i].ToString());
+ }
+
+ // remove removed duplicate lines
+ for (int i = startLine + lines.Count; i <= endLine; ++i) {
+ LineSegment line = document.GetLineSegment(startLine + lines.Count);
+ document.Remove(line.Offset, line.TotalLength);
+ }
+ }*/
+
+ public override void Run()
+ {
+ Console.WriteLine ("Not ported to the new Option Panel");
+ /*IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+
+ using (SortOptionsDialog sortOptionsDialog = new SortOptionsDialog()) {
+ sortOptionsDialog.Owner = (Form)WorkbenchSingleton.Workbench;
+ if (sortOptionsDialog.ShowDialog() == DialogResult.OK) {
+ TextArea textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl.ActiveTextAreaControl.TextArea;
+ textarea.BeginUpdate();
+ if (textarea.SelectionManager.HasSomethingSelected) {
+ foreach (ISelection selection in textarea.SelectionManager.SelectionCollection) {
+ SortLines(textarea.Document, selection.StartPosition.Y, selection.EndPosition.Y);
+ }
+ } else {
+ SortLines(textarea.Document, 0, textarea.Document.TotalNumberOfLines - 1);
+ }
+ textarea.Caret.ValidateCaretPos();
+ textarea.EndUpdate();
+ textarea.Refresh();
+ }
+ }*/
+ }
+ }
+
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ICSharpCode.SharpDevelop.DefaultEditor.Commands.GenerateCodeAction.resources (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/ICSharpCode.SharpDevelop.DefaultEditor.Commands.GenerateCodeAction.resources)
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/IEditAction.cs (from rev 814, trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Actions/IEditAction.cs)
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Actions/IEditAction.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/IEditAction.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,61 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+using MonoDevelop.SourceEditor.Gui;
+
+using Gdk;
+
+namespace ICSharpCode.TextEditor.Actions
+{
+ /// <summary>
+ /// To define a new key for the textarea, you must write a class which
+ /// implements this interface.
+ /// </summary>
+ public interface IEditAction
+ {
+ /// <value>
+ /// An array of keys on which this edit action occurs.
+ /// </value>
+ Gdk.Key[] Keys {
+ get;
+ set;
+ }
+
+ /// <remarks>
+ /// When the key which is defined per XML is pressed, this method will be launched.
+ /// </remarks>
+ void Execute(SourceEditorView textArea);
+ }
+
+ /// <summary>
+ /// To define a new key for the textarea, you must write a class which
+ /// implements this interface.
+ /// </summary>
+ public abstract class AbstractEditAction : IEditAction
+ {
+ Gdk.Key[] keys = null;
+
+ /// <value>
+ /// An array of keys on which this edit action occurs.
+ /// </value>
+ public Gdk.Key[] Keys {
+ get {
+ return keys;
+ }
+ set {
+ keys = value;
+ }
+ }
+
+ /// <remarks>
+ /// When the key which is defined per XML is pressed, this method will be launched.
+ /// </remarks>
+ public abstract void Execute(SourceEditorView textArea);
+ }
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ProjectCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/ProjectCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/ProjectCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ProjectCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,45 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.AddIns;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+using ICSharpCode.Core.Services;
+
+using ICSharpCode.SharpDevelop.Services;
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class ExportProjectToHtml : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
+ if (projectService.CurrentSelectedProject != null) {
+ //ExportProjectToHtmlDialog ephd = new ExportProjectToHtmlDialog(projectService.CurrentSelectedProject);
+ //ephd.Owner = (Form)WorkbenchSingleton.Workbench;
+ //ephd.ShowDialog();
+ //ephd.Dispose();
+ }
+ }
+ }
+
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/SearchCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/SearchCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/SearchCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/SearchCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,180 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.AddIns;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Actions;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+
+ public abstract class AbstractEditActionMenuCommand : AbstractMenuCommand
+ {
+ public abstract IEditAction EditAction {
+ get;
+ }
+
+ public override void Run()
+ {
+ Console.WriteLine ("Not implemented in the new editor");
+ /*IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ TextEditorControl textEditor = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+ EditAction.Execute(textEditor.ActiveTextAreaControl.TextArea);*/
+ }
+ }
+
+ public class Find : AbstractMenuCommand
+ {
+ public static void SetSearchPattern()
+ {
+// // Get Highlighted value and set it to FindDialog.searchPattern
+// IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+//
+// if (window != null && (window.ViewContent is ITextEditorControlProvider)) {
+// TextAreaControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextAreaControl;
+// string selectedText = textarea.Document.SelectedText;
+// if (selectedText != null && selectedText.Length > 0) {
+// SearchReplaceManager.SearchOptions.SearchPattern = selectedText;
+// }
+// }
+ }
+
+ public override void Run()
+ {
+ Console.WriteLine ("Not implemented in the new editor");
+ /*
+ SetSearchPattern();
+ if (SearchReplaceManager.ReplaceDialog != null) {
+ if (SearchReplaceManager.ReplaceDialog.replaceMode == false) {
+ SearchReplaceManager.ReplaceDialog.SetSearchPattern(SearchReplaceManager.SearchOptions.SearchPattern);
+ SearchReplaceManager.ReplaceDialog.Present ();
+ } else {
+ SearchReplaceManager.ReplaceDialog.Destroy ();
+ ReplaceDialog rd = new ReplaceDialog (false);
+ rd.ShowAll ();
+ }
+ } else {
+ ReplaceDialog rd = new ReplaceDialog(false);
+ rd.ShowAll();
+ }*/
+ }
+ }
+
+ public class FindNext : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ //SearchReplaceManager.FindNext();
+ }
+ }
+
+ public class Replace : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not implemented in the new editor");
+ //Find.SetSearchPattern();
+
+ /*if (SearchReplaceManager.ReplaceDialog != null) {
+ if (SearchReplaceManager.ReplaceDialog.replaceMode == true) {
+ SearchReplaceManager.ReplaceDialog.SetSearchPattern(SearchReplaceManager.SearchOptions.SearchPattern);
+ SearchReplaceManager.ReplaceDialog.Present ();
+ } else {
+ SearchReplaceManager.ReplaceDialog.Destroy ();
+ ReplaceDialog rd = new ReplaceDialog (true);
+ rd.ShowAll ();
+ }
+ } else {
+ ReplaceDialog rd = new ReplaceDialog(true);
+ rd.ShowAll();
+ }*/
+ }
+ }
+
+ public class FindInFiles : AbstractMenuCommand
+ {
+ public static void SetSearchPattern()
+ {
+// // Get Highlighted value and set it to FindDialog.searchPattern
+// IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+//
+// if (window != null && (window.ViewContent is ITextEditorControlProvider)) {
+// TextAreaControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextAreaControl;
+// string selectedText = textarea.Document.SelectedText;
+// if (selectedText != null && selectedText.Length > 0) {
+// SearchReplaceInFilesManager.SearchOptions.SearchPattern = selectedText;
+// }
+// }
+ }
+ public override void Run()
+ {
+ SetSearchPattern();
+ //using (ReplaceInFilesDialog rd = new ReplaceInFilesDialog(false)) {
+ // rd.Owner = (Form)WorkbenchSingleton.Workbench;
+ // rd.ShowDialog();
+ //}
+ }
+ }
+
+ public class ReplaceInFiles : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ FindInFiles.SetSearchPattern();
+
+ //using (ReplaceInFilesDialog rd = new ReplaceInFilesDialog(true)) {
+ // rd.Owner = (Form)WorkbenchSingleton.Workbench;
+ // rd.ShowDialog();
+ //}
+ }
+ }
+
+ public class GotoLineNumber : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not implemented in the new editor");
+ /*if (!GotoLineNumberDialog.IsVisible) {
+ GotoLineNumberDialog gnd = new GotoLineNumberDialog();
+ gnd.Run ();
+ gnd.Hide ();
+ }*/
+ }
+ }
+
+ public class GotoMatchingBrace : AbstractEditActionMenuCommand
+ {
+ public override IEditAction EditAction {
+ get {
+ Console.WriteLine ("Not implemented in New Editor");
+ return null;
+ //return new ICSharpCode.TextEditor.Actions.GotoMatchingBrace();
+ }
+ }
+ }
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/TextAreaContextmenuCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/TextAreaContextmenuCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/TextAreaContextmenuCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/TextAreaContextmenuCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,105 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using ICSharpCode.Core.AddIns;
+using ICSharpCode.Core.AddIns.Conditions;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.SharpDevelop.Gui.Components;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.TextEditor;
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class ShowBufferOptions : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not ported to the new editor yet");
+ /*
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+ PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
+ ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
+ */
+ /*TabbedOptions o = new TabbedOptions(resourceService.GetString("Dialog.Options.BufferOptions"),
+ ((IProperties)propertyService.GetProperty("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new DefaultProperties())),
+ AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/ViewContent/DefaultTextEditor/OptionsDialog"));*/
+ //o.Width = 450;
+ //o.Height = 425;
+ //o.FormBorderStyle = FormBorderStyle.FixedDialog;
+ //o.ShowDialog();
+ //o.Dispose();
+ //textarea.OptionsChanged();
+ }
+ }
+
+
+ public class HighlightingTypeBuilder : ISubmenuBuilder
+ {
+
+ //TextEditorControl control = null;
+ //Gtk.MenuItem[] menuCommands = null;
+
+
+ public Gtk.MenuItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
+ {
+ /*
+ control = (TextEditorControl)owner;
+
+ ArrayList menuItems = new ArrayList();
+
+ foreach (DictionaryEntry entry in HighlightingManager.Manager.HighlightingDefinitions) {
+ SdMenuCheckBox item = new SdMenuCheckBox(null, null, entry.Key.ToString());
+ item.Active = control.Document.HighlightingStrategy.Name == entry.Key.ToString();
+ item.Toggled += new EventHandler(ChangeSyntax);
+ menuItems.Add(item);
+ }
+ menuCommands = (Gtk.MenuItem[])menuItems.ToArray(typeof(Gtk.MenuItem));
+ return menuCommands;
+ */
+ return null;
+ }
+
+ void ChangeSyntax(object sender, EventArgs e)
+ {
+ /*
+ if (control != null) {
+ SdMenuCheckBox item = (SdMenuCheckBox)sender;
+ foreach (SdMenuCheckBox i in menuCommands) {
+ i.Active = false;
+ }
+ item.Active = true;
+ IHighlightingStrategy strat = HighlightingStrategyFactory.CreateHighlightingStrategy(((Gtk.Label)item.Child).Text);
+ if (strat == null) {
+ throw new Exception("Strategy can't be null");
+ }
+ control.Document.HighlightingStrategy = strat;
+ control.Refresh();
+ }*/
+ }
+ }
+}
Copied: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs (from rev 814, trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/ToolCommands.cs)
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/TextEditor/Commands/ToolCommands.cs 2004-02-07 23:57:58 UTC (rev 814)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Commands/ToolCommands.cs 2004-02-09 01:42:14 UTC (rev 829)
@@ -0,0 +1,249 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Threading;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Collections;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+using System.Xml;
+using System.Xml.Xsl;
+
+using ICSharpCode.Core.AddIns;
+
+using ICSharpCode.Core.Properties;
+using ICSharpCode.Core.AddIns.Codons;
+
+using ICSharpCode.SharpDevelop.Gui.Dialogs;
+using ICSharpCode.TextEditor;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Gui.HtmlControl;
+using ICSharpCode.Core.Services;
+
+using Gtk;
+using GtkSharp;
+
+namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
+{
+ public class ColorDialog : ColorSelectionDialog
+ {
+ public ColorDialog () : base ("DON'T use this dialog it DOESN'T work correctly")
+ {
+ this.ColorSelection.HasPalette = true;
+ this.ColorSelection.HasOpacityControl = false;
+ }
+
+ public string ColorStr ()
+ {
+ Gdk.Color color = this.ColorSelection.CurrentColor;
+ StringBuilder s = new StringBuilder ();
+ ushort[] vals = { color.red, color.green, color.blue };
+ // debug line
+ // Console.WriteLine("r {0}, b {1}, g{2}", color.red, color.green, color.blue );
+ char[] hexchars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+ s.Append ("#FF");
+ foreach (ushort val in vals) {
+ /* Convert to a range of 0-255, then lookup the
+ * digit for each half-byte */
+ byte rounded = (byte) (val >> 8);
+ s.Append (hexchars[(rounded & 0xf0) >> 4]);
+ s.Append (hexchars[rounded & 0x0f]);
+ }
+ return s.ToString ();
+ }
+ }
+
+ public class ShowColorDialog : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not Ported to the new editor yet");
+
+ /*IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ //TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+ //FIXME:
+ // - The return sting value is not the same choosen in the Dialog
+ // - Return color name (not color value) if it IsKnownColor but it's still not implemented for System.Drawing.Color
+ ColorDialog dialog = new ColorDialog ();
+ if ( dialog.Run () == (int) ResponseType.Ok) {
+ string ColorStr = dialog.ColorStr();
+ //string ColorStr = dialog.ColorSelection.CurrentColor.ToString();
+ //textarea.Document.Insert(textarea.ActiveTextAreaControl.Caret.Offset, ColorStr);
+ //int lineNumber = textarea.Document.GetLineNumberForOffset(textarea.ActiveTextAreaControl.Caret.Offset);
+ //textarea.ActiveTextAreaControl.Caret.Column += ColorStr.Length;
+ //textarea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new Point(0, lineNumber)));
+ //textarea.Document.CommitUpdate();
+
+
+ };
+ dialog.Hide();
+
+ */
+ /*using (ColorDialog cd = new ColorDialog()) {
+ if (cd.ShowDialog() == DialogResult.OK) {
+ string colorstr = "#" + cd.Color.ToArgb().ToString("X");
+ if (cd.Color.IsKnownColor) {
+ colorstr = cd.Color.ToKnownColor().ToString();
+ }
+
+ textarea.Document.Insert(textarea.ActiveTextAreaControl.Caret.Offset, colorstr);
+ int lineNumber = textarea.Document.GetLineNumberForOffset(textarea.ActiveTextAreaControl.Caret.Offset);
+ textarea.ActiveTextAreaControl.Caret.Column += colorstr.Length;
+ textarea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new Point(0, lineNumber)));
+ textarea.Document.CommitUpdate();
+ }
+ }*/
+ }
+ }
+
+ public class QuickDocumentation : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not ported to the new editor yet");
+ /*
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ TextEditorControl textAreaControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+
+ int startLine = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.ActiveTextAreaControl.Caret.Offset);
+ int endLine = startLine;
+
+ LineSegment line = textAreaControl.Document.GetLineSegment(startLine);
+ string curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
+ if (!curLine.StartsWith("///")) {
+ return;
+ }
+
+ while (startLine > 0) {
+ line = textAreaControl.Document.GetLineSegment(startLine);
+ curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
+ if (curLine.StartsWith("///")) {
+ --startLine;
+ } else {
+ break;
+ }
+ }
+
+ while (endLine < textAreaControl.Document.TotalNumberOfLines - 1) {
+ line = textAreaControl.Document.GetLineSegment(endLine);
+ curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
+ if (curLine.StartsWith("///")) {
+ ++endLine;
+ } else {
+ break;
+ }
+ }
+
+ StringBuilder documentation = new StringBuilder();
+ for (int lineNr = startLine + 1; lineNr < endLine; ++lineNr) {
+ line = textAreaControl.Document.GetLineSegment(lineNr);
+ curLine = textAreaControl.Document.GetText(line.Offset, line.Length).Trim();
+ documentation.Append(curLine.Substring(3));
+ documentation.Append('\n');
+ }
+ string xml = "<member>" + documentation.ToString() + "</member>";
+
+ string html = String.Empty;
+
+ try {
+ FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
+ PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
+ html = ICSharpCode.SharpDevelop.Internal.Project.ConvertXml.ConvertData(xml,
+ propertyService.DataDirectory +
+ Path.DirectorySeparatorChar + "ConversionStyleSheets" +
+ Path.DirectorySeparatorChar + "ShowXmlDocumentation.xsl",
+ null);
+ } catch (Exception e) {
+ //MessageBox.Show(e.ToString());
+ }
+ //new ToolWindowForm(textAreaControl, html).Show();
+ */
+ }
+
+ class ToolWindowForm //: Form
+ {/*
+ public ToolWindowForm(TextEditorControl textEditorControl, string html)
+ {
+ Point caretPos = textEditorControl.ActiveTextAreaControl.Caret.Position;
+ Point visualPos = new Point(textEditorControl.ActiveTextAreaControl.TextArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X) + textEditorControl.ActiveTextAreaControl.TextArea.TextView.DrawingPosition.X,
+ (int)((1 + caretPos.Y) * textEditorControl.ActiveTextAreaControl.TextArea.TextView.FontHeight) - textEditorControl.ActiveTextAreaControl.TextArea.VirtualTop.Y - 1 + textEditorControl.ActiveTextAreaControl.TextArea.TextView.DrawingPosition.Y);
+ //Location = textEditorControl.ActiveTextAreaControl.TextArea.PointToScreen(visualPos); //FIXME: Again, should we have this method?!?
+ PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
+
+ HtmlControl hc = new HtmlControl();
+ hc.Html = html;
+ FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
+ hc.CascadingStyleSheet = propertyService.DataDirectory +
+ Path.DirectorySeparatorChar + "resources" +
+ Path.DirectorySeparatorChar + "css" +
+ Path.DirectorySeparatorChar + "MsdnHelp.css";
+ //hc.Dock = DockStyle.Fill;
+ hc.BeforeNavigate += new BrowserNavigateEventHandler(BrowserNavigateCancel);
+ //Controls.Add(hc);
+
+ //ShowInTaskbar = false;
+ //FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ //StartPosition = FormStartPosition.Manual;
+ }
+
+ void BrowserNavigateCancel(object sender, BrowserNavigateEventArgs e)
+ {
+ e.Cancel = true;
+ }
+
+ protected void OnDeactivate(EventArgs e)
+ {
+ //Close();
+ }
+
+ protected bool ProcessDialogKey()
+ {
+
+ //if (keyData == Keys.Escape) {
+ // Close();
+ // return true;
+ //}
+ //return base.ProcessDialogKey(keyData);
+
+ //return false;
+ }
+ */
+ }
+ }
+
+ public class SplitTextEditor : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ Console.WriteLine ("Not implemented in the new Editor");
+ /*
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+
+ if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
+ return;
+ }
+ TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
+ if (textEditorControl != null) {
+ //textEditorControl.Split();
+ }
+ */
+ }
+ }
+
+}
+
More information about the Monodevelop-patches-list
mailing list