Author: lluis
Date: 2007-07-18 08:19:05 -0400 (Wed, 18 Jul 2007)
New Revision: 82197
Added:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
* MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs,
MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs,
MonoDevelop.Ide.Commands/TextEditorCommands.cs,
MonoDevelop.Ide.addin.xml, MonoDevelop.Ide.mdp, Makefile.am,
MonoDevelop.Ide.Gui/Document.cs,
MonoDevelop.Ide.Gui/ViewCommandHandlers.cs,
MonoDevelop.Ide.Gui/TextEditor.cs,
MonoDevelop.Ide.Gui/Workbench.cs: Included text editor extensions
in the commad route, so extensions can now implement command
handlers. Implemented the ShowCompletionWindow as a command.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2007-07-18
12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2007-07-18
12:19:05 UTC (rev 82197)
@@ -1,3 +1,16 @@
+2007-07-18 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs,
+ MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs,
+ MonoDevelop.Ide.Commands/TextEditorCommands.cs,
+ MonoDevelop.Ide.addin.xml, MonoDevelop.Ide.mdp, Makefile.am,
+ MonoDevelop.Ide.Gui/Document.cs,
+ MonoDevelop.Ide.Gui/ViewCommandHandlers.cs,
+ MonoDevelop.Ide.Gui/TextEditor.cs,
+ MonoDevelop.Ide.Gui/Workbench.cs: Included text editor extensions
+ in the commad route, so extensions can now implement command
+ handlers. Implemented the ShowCompletionWindow as a command.
+
2007-07-17 Jeffrey Stedfast <[EMAIL PROTECTED]>
* MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs: Use cmd.Id
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2007-07-18
12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2007-07-18
12:19:05 UTC (rev 82197)
@@ -78,6 +78,7 @@
MonoDevelop.Ide.Commands/ProjectCommands.cs \
MonoDevelop.Ide.Commands/RefactoryCommands.cs \
MonoDevelop.Ide.Commands/SearchCommands.cs \
+ MonoDevelop.Ide.Commands/TextEditorCommands.cs \
MonoDevelop.Ide.Commands/ToolsCommands.cs \
MonoDevelop.Ide.Commands/ViewCommands.cs \
MonoDevelop.Ide.Commands/WindowCommands.cs \
Added:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -0,0 +1,11 @@
+
+
+using System;
+
+namespace MonoDevelop.Ide.Commands
+{
+ public enum TextEditorCommands
+ {
+ ShowCompletionWindow
+ }
+}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -124,10 +124,7 @@
get {
if (!editorChecked) {
editorChecked = true;
- if (GetContent<IEditableTextBuffer> ()
!= null)
- textEditor = new TextEditor
(Window.ViewContent);
- else
- textEditor = null;
+ textEditor = TextEditor.GetTextEditor
(Window.ViewContent);
}
return textEditor;
}
@@ -349,6 +346,10 @@
last.Next = editor.AttachExtension
(editorExtension);
}
+ internal object ExtendedCommandTargetChain {
+ get { return editorExtension; }
+ }
+
void OnEntryRemoved (object sender, CombineEntryEventArgs args)
{
if (args.CombineEntry == window.ViewContent.Project)
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -16,16 +16,20 @@
// All line and column numbers are 1-based
- public TextEditor (IBaseViewContent content)
+ public static TextEditor GetTextEditor (IBaseViewContent
content)
{
- bookmarkBuffer = (IBookmarkBuffer) content.GetContent
(typeof(IBookmarkBuffer));
- codeStyleOperations = (ICodeStyleOperations)
content.GetContent (typeof(ICodeStyleOperations));
- textBuffer = (IEditableTextBuffer) content.GetContent
(typeof(IEditableTextBuffer));
- encodedTextContent = (IEncodedTextContent)
content.GetContent (typeof(IEncodedTextContent));
- positionable = (IPositionable) content.GetContent
(typeof(IPositionable));
- completionWidget = (ICompletionWidget)
content.GetContent (typeof(ICompletionWidget));
- if (textBuffer == null)
- throw new InvalidOperationException ("Content
does not provide an IEditableTextBuffer implementation.");
+ IEditableTextBuffer tb = (IEditableTextBuffer)
content.GetContent (typeof(IEditableTextBuffer));
+ if (tb == null)
+ return null;
+
+ TextEditor ed = new TextEditor ();
+ ed.textBuffer = tb;
+ ed.bookmarkBuffer = (IBookmarkBuffer)
content.GetContent (typeof(IBookmarkBuffer));
+ ed.codeStyleOperations = (ICodeStyleOperations)
content.GetContent (typeof(ICodeStyleOperations));
+ ed.encodedTextContent = (IEncodedTextContent)
content.GetContent (typeof(IEncodedTextContent));
+ ed.positionable = (IPositionable) content.GetContent
(typeof(IPositionable));
+ ed.completionWidget = (ICompletionWidget)
content.GetContent (typeof(ICompletionWidget));
+ return ed;
}
public bool SupportsBookmarks {
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -48,14 +48,16 @@
namespace MonoDevelop.Ide.Gui
{
- public class ViewCommandHandlers: ICommandRouter
+ public class ViewCommandHandlers: ICommandDelegatorRouter
{
IWorkbenchWindow window;
object nextTarget;
+ Document doc;
public ViewCommandHandlers (IWorkbenchWindow window)
{
this.window = window;
+ doc = IdeApp.Workbench.WrapDocument (window);
}
public T GetContent <T>()
@@ -63,11 +65,16 @@
return (T) window.ActiveViewContent.GetContent
(typeof(T));
}
- object ICommandRouter.GetNextCommandTarget ()
+ object ICommandDelegatorRouter.GetNextCommandTarget ()
{
return nextTarget;
}
+ object ICommandDelegatorRouter.GetDelegatedCommandTarget ()
+ {
+ return doc.ExtendedCommandTargetChain;
+ }
+
public void SetNextCommandTarget (object nextTarget)
{
this.nextTarget = nextTarget;
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -479,7 +479,7 @@
ActiveDocumentChanged (s, a);
}
- Document WrapDocument (IWorkbenchWindow window)
+ internal Document WrapDocument (IWorkbenchWindow window)
{
if (window == null) return null;
Document doc = FindDocument (window);
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IExtensibleTextEditor.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -5,6 +5,7 @@
{
public interface IExtensibleTextEditor: IEditableTextBuffer
{
+ // The provided parameter is the first object of the extension
chain
// This method should return the terminator
ITextEditorExtension that
// will execute the default behavior (if any)
ITextEditorExtension AttachExtension (ITextEditorExtension
extension);
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
2007-07-18 12:18:44 UTC (rev 82196)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/TextEditorExtension.cs
2007-07-18 12:19:05 UTC (rev 82197)
@@ -4,10 +4,12 @@
using MonoDevelop.Projects.Gui.Completion;
using MonoDevelop.Projects.Parser;
using MonoDevelop.Projects.Ambience;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Ide.Commands;
namespace MonoDevelop.Ide.Gui.Content
{
- public class TextEditorExtension: ITextEditorExtension, IDisposable
+ public class TextEditorExtension: ITextEditorExtension, ICommandRouter,
IDisposable
{
internal ITextEditorExtension Next;
internal Document document;
@@ -105,21 +107,8 @@
// Handle code completion
if (completionWidget != null &&
currentCompletionContext == null) {
- ICompletionDataProvider cp = null;
- if (key == Gdk.Key.space && (modifier &
Gdk.ModifierType.ControlMask) != 0) {
- int cpos, wlen;
- if (!GetCompletionCommandOffset (out
cpos, out wlen)) {
- cpos = Editor.CursorPosition;
- wlen = 0;
- }
- currentCompletionContext =
completionWidget.CreateCodeCompletionContext (cpos);
-
currentCompletionContext.TriggerWordLength = wlen;
- cp = CodeCompletionCommand
(currentCompletionContext);
- }
- else {
- currentCompletionContext =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
- cp = HandleCodeCompletion
(currentCompletionContext, (char)(uint)key);
- }
+ currentCompletionContext =
completionWidget.CreateCodeCompletionContext (Editor.CursorPosition);
+ ICompletionDataProvider cp =
HandleCodeCompletion (currentCompletionContext, (char)(uint)key);
if (cp != null)
CompletionListWindow.ShowWindow
((char)(uint)key, cp, completionWidget, currentCompletionContext,
OnCompletionWindowClosed);
@@ -165,6 +154,36 @@
Next.CursorPositionChanged ();
}
+ [CommandUpdateHandler (TextEditorCommands.ShowCompletionWindow)]
+ internal void OnUpdateCompletionCommand (CommandInfo info)
+ {
+ info.Bypass = !CanRunCompletionCommand ();
+ }
+
+ [CommandHandler (TextEditorCommands.ShowCompletionWindow)]
+ public virtual void RunCompletionCommand ()
+ {
+ ICompletionDataProvider cp = null;
+ int cpos, wlen;
+ if (!GetCompletionCommandOffset (out cpos, out wlen)) {
+ cpos = Editor.CursorPosition;
+ wlen = 0;
+ }
+ currentCompletionContext =
completionWidget.CreateCodeCompletionContext (cpos);
+ currentCompletionContext.TriggerWordLength = wlen;
+ cp = CodeCompletionCommand (currentCompletionContext);
+
+ if (cp != null)
+ CompletionListWindow.ShowWindow ((char)0, cp,
completionWidget, currentCompletionContext, OnCompletionWindowClosed);
+ else
+ currentCompletionContext = null;
+ }
+
+ public virtual bool CanRunCompletionCommand ()
+ {
+ return (completionWidget != null &&
currentCompletionContext == null);
+ }
+
public virtual ICompletionDataProvider HandleCodeCompletion
(ICodeCompletionContext completionContext, char completionChar)
{
return null;
@@ -246,12 +265,29 @@
if (document == null)
throw new InvalidOperationException ("Editor
extension not yet initialized");
}
+
+ object ITextEditorExtension.GetExtensionCommandTarget ()
+ {
+ return this;
+ }
+
+ object ICommandRouter.GetNextCommandTarget ()
+ {
+ if (Next != null)
+ return Next.GetExtensionCommandTarget ();
+ else
+ return null;
+ }
}
public interface ITextEditorExtension
{
bool KeyPress (Gdk.Key key, Gdk.ModifierType modifier);
void CursorPositionChanged ();
+
+ // Return the object that is going to process commands, or null
+ // if commands don't need custom processing
+ object GetExtensionCommandTarget ();
}
class TextEditorExtensionMarker: TextEditorExtension
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
2007-07-18 12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
2007-07-18 12:19:05 UTC (rev 82197)
@@ -709,6 +709,14 @@
type="array"
_label = "Refactory Operations" />
</Category>
+
+ <!-- TextEditorCommands -->
+ <Category _name = "Text Editor" id = "TextEditor">
+
+ <Command id =
"MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow"
+ _label = "Show completion window"
+ shortcut = "Control|space" />
+ </Category>
</Extension>
<Extension path =
"/SharpDevelop/Views/ProjectBrowser/ContextMenu/CombineBrowserNode"
extension-nodes="CommandItem, SeparatorItem, ItemSet, LinkItem,
LocalCommandItem" description="Context menu for solutions in the solution pad.">
@@ -1075,6 +1083,7 @@
<CommandItem id =
"MonoDevelop.Ide.Commands.EditCommands.UncommentCode" />
<CommandItem id =
"MonoDevelop.Ide.Commands.EditCommands.IndentSelection" />
<CommandItem id =
"MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" />
+ <CommandItem id =
"MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" />
<ItemSet id = "Advanced" _label = "_Advanced">
<CommandItem id =
"MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" />
<CommandItem id =
"MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" />
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2007-07-18 12:18:44 UTC (rev 82196)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2007-07-18 12:19:05 UTC (rev 82197)
@@ -304,6 +304,7 @@
<File name="./MonoDevelop.Ide.Gui/InternalLog.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs"
subtype="Code" buildaction="Compile" />
<File
name="./gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs"
subtype="Code" buildaction="Compile" />
+ <File name="./MonoDevelop.Ide.Commands/TextEditorCommands.cs"
subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="gecko-sharp,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=ccf7d78a55e9f021" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches