Author: lluis
Date: 2007-07-18 12:18:57 -0400 (Wed, 18 Jul 2007)
New Revision: 82222

Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.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.addin.xml
Log:
* MonoDevelop.Ide.Commands/TextEditorCommands.cs,
  MonoDevelop.Ide.addin.xml,
  MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Added new editor
  commands.
* MonoDevelop.Ide.Commands/HelpCommands.cs: New help command.
* MonoDevelop.Ide.Gui/TextEditor.cs: Added new helper methods.

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-07-18 
16:16:19 UTC (rev 82221)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2007-07-18 
16:18:57 UTC (rev 82222)
@@ -1,3 +1,12 @@
+2007-07-18  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Ide.Commands/TextEditorCommands.cs,
+         MonoDevelop.Ide.addin.xml,
+         MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Added new editor
+         commands.
+       * MonoDevelop.Ide.Commands/HelpCommands.cs: New help command.
+       * MonoDevelop.Ide.Gui/TextEditor.cs: Added new helper methods.
+
 2007-07-18  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * MonoDevelop.Ide.StandardHeader/StandardHeaderService.cs (Load): Only

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs
 2007-07-18 16:16:19 UTC (rev 82221)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/HelpCommands.cs
 2007-07-18 16:18:57 UTC (rev 82222)
@@ -23,6 +23,7 @@
 {
        public enum HelpCommands
        {
+               Help,
                TipOfTheDay,
                About
        }

Modified: 
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 16:16:19 UTC (rev 82221)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs
   2007-07-18 16:18:57 UTC (rev 82222)
@@ -6,6 +6,22 @@
 {
        public enum TextEditorCommands
        {
-               ShowCompletionWindow
+               ShowCompletionWindow,
+               LineEnd,
+               LineStart,
+               DeleteLeftChar,
+               DeleteRightChar,
+               CharLeft,
+               CharRight,
+               LineUp,
+               LineDown,
+               DocumentStart,
+               DocumentEnd,
+               PageUp,
+               PageDown,
+               ScrollLineUp,
+               ScrollLineDown,
+               DeleteLine,
+               DeleteToLineEnd
        }
 }

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 16:16:19 UTC (rev 82221)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs    
    2007-07-18 16:18:57 UTC (rev 82222)
@@ -109,6 +109,28 @@
                        get { return textBuffer.SelectionEndPosition; }
                }
                
+               public int CursorLine {
+                       get {
+                               int line, column;
+                               textBuffer.GetLineColumnFromPosition 
(textBuffer.CursorPosition, out line, out column);
+                               return line;
+                       }
+                       set {
+                               textBuffer.CursorPosition = 
textBuffer.GetPositionFromLineColumn (value, CursorColumn);
+                       }
+               }
+               
+               public int CursorColumn {
+                       get {
+                               int line, column;
+                               textBuffer.GetLineColumnFromPosition 
(textBuffer.CursorPosition, out line, out column);
+                               return column;
+                       }
+                       set {
+                               textBuffer.CursorPosition = 
textBuffer.GetPositionFromLineColumn (CursorLine, value);
+                       }
+               }
+               
                public void Select (int startPosition, int endPosition)
                {
                        textBuffer.Select (startPosition, endPosition);
@@ -119,6 +141,11 @@
                        textBuffer.ShowPosition (position);
                }
                
+               public void ShowCursorPosition ()
+               {
+                       textBuffer.ShowPosition (textBuffer.CursorPosition);
+               }
+               
                public string Text {
                        get { return textBuffer.Text; }
                }
@@ -157,6 +184,16 @@
                        textBuffer.DeleteText (position, length);
                }
                
+               public void DeleteLine (int line)
+               {
+                       int pos1 = GetPositionFromLineColumn (line, 1);
+                       int pos2 = GetPositionFromLineColumn (line + 1, 1);
+                       if (pos2 == -1)
+                               DeleteText (pos1, TextLength - pos1);
+                       else
+                               DeleteText (pos1, pos2 - pos1);
+               }
+               
                public void JumpTo (int line, int col)
                {
                        if (positionable != null)

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 16:16:19 UTC (rev 82221)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
       2007-07-18 16:18:57 UTC (rev 82222)
@@ -382,5 +382,122 @@
                {
                        info.Enabled = GetContent <IEditableTextBuffer> () != 
null;
                }
+               
+
+               // Text editor commands
+               
+               [CommandUpdateHandler (TextEditorCommands.LineEnd)]
+               [CommandUpdateHandler (TextEditorCommands.LineStart)]
+               [CommandUpdateHandler (TextEditorCommands.DeleteLeftChar)]
+               [CommandUpdateHandler (TextEditorCommands.DeleteRightChar)]
+               [CommandUpdateHandler (TextEditorCommands.CharLeft)]
+               [CommandUpdateHandler (TextEditorCommands.CharRight)]
+               [CommandUpdateHandler (TextEditorCommands.LineUp)]
+               [CommandUpdateHandler (TextEditorCommands.LineDown)]
+               [CommandUpdateHandler (TextEditorCommands.DocumentStart)]
+               [CommandUpdateHandler (TextEditorCommands.DocumentEnd)]
+               [CommandUpdateHandler (TextEditorCommands.DeleteLine)]
+               [CommandUpdateHandler (TextEditorCommands.DeleteToLineEnd)]     
        
+               protected void OnUpdateLineEnd (CommandInfo info)
+               {
+                       // If the current document is not an editor, just 
ignore the text
+                       // editor commands.
+                       info.Bypass = doc.TextEditor == null;
+               }
+               
+               [CommandHandler (TextEditorCommands.LineEnd)]
+               protected void OnLineEnd ()
+               {
+                       doc.TextEditor.CursorColumn = int.MaxValue;
+               }
+               
+               [CommandHandler (TextEditorCommands.LineStart)]
+               protected void OnLineStart ()
+               {
+                       doc.TextEditor.CursorColumn = 1;
+               }
+               
+               [CommandHandler (TextEditorCommands.DeleteLeftChar)]
+               protected void OnDeleteLeftChar ()
+               {
+                       int pos = doc.TextEditor.CursorPosition;
+                       if (pos > 0) {
+                               doc.TextEditor.DeleteText (pos-1, 1);
+                       }
+               }
+               
+               [CommandHandler (TextEditorCommands.DeleteRightChar)]
+               protected void OnDeleteRightChar ()
+               {
+                       int pos = doc.TextEditor.CursorPosition;
+                       if (pos < doc.TextEditor.TextLength) {
+                               doc.TextEditor.DeleteText (pos, 1);
+                       }
+               }
+               
+               [CommandHandler (TextEditorCommands.CharLeft)]
+               protected void OnCharLeft ()
+               {
+                       int pos = doc.TextEditor.CursorPosition;
+                       if (pos > 0) {
+                               doc.TextEditor.CursorPosition = pos - 1;
+                       }
+               }
+               
+               [CommandHandler (TextEditorCommands.CharRight)]
+               protected void OnCharRight ()
+               {
+                       int pos = doc.TextEditor.CursorPosition;
+                       if (pos < doc.TextEditor.TextLength) {
+                               doc.TextEditor.CursorPosition = pos + 1;
+                       }
+               }
+               
+               [CommandHandler (TextEditorCommands.LineUp)]
+               protected void OnLineUp ()
+               {
+                       int lin = doc.TextEditor.CursorLine;
+                       if (lin > 1) {
+                               doc.TextEditor.CursorLine = lin - 1;
+                       }
+               }
+               
+               [CommandHandler (TextEditorCommands.LineDown)]
+               protected void OnLineDown ()
+               {
+                       doc.TextEditor.CursorLine++;
+               }
+               
+               [CommandHandler (TextEditorCommands.DocumentStart)]
+               protected void OnDocumentStart ()
+               {
+                       doc.TextEditor.CursorPosition = 0;
+               }
+               
+               [CommandHandler (TextEditorCommands.DocumentEnd)]
+               protected void OnDocumentEnd ()
+               {
+                       doc.TextEditor.CursorPosition = 
doc.TextEditor.TextLength;
+               }
+               
+               [CommandHandler (TextEditorCommands.DeleteLine)]
+               protected void OnDeleteLine ()
+               {
+                       doc.TextEditor.DeleteLine (doc.TextEditor.CursorLine);
+                       doc.TextEditor.ShowCursorPosition ();
+               }
+               
+               [CommandHandler (TextEditorCommands.DeleteToLineEnd)]
+               protected void OnDeleteToLineEnd ()
+               {
+                       int len = doc.TextEditor.GetLineLength 
(doc.TextEditor.CursorLine);
+                       int col = doc.TextEditor.CursorColumn;
+                       if (col == len + 1) {
+                               int npos = 
doc.TextEditor.GetPositionFromLineColumn (doc.TextEditor.CursorLine + 1, 1);
+                               doc.TextEditor.DeleteText 
(doc.TextEditor.CursorPosition, npos - doc.TextEditor.CursorPosition);
+                       } else {
+                               doc.TextEditor.DeleteText 
(doc.TextEditor.CursorPosition, len - col + 1);
+                       }
+               }
        }
 }

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2007-07-18 16:16:19 UTC (rev 82221)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2007-07-18 16:18:57 UTC (rev 82222)
@@ -612,6 +612,10 @@
                <!-- HelpCommands -->
                <Category _name = "Help" id = "Help">
                
+               <Command id = "MonoDevelop.Ide.Commands.HelpCommands.Help"
+                               _label = "Help" 
+                               description = "Help"
+                               shortcut = "F1" />
                <Command id = 
"MonoDevelop.Ide.Commands.HelpCommands.TipOfTheDay"
                                defaultHandler = 
"MonoDevelop.Ide.Commands.TipOfTheDayHandler"
                                _label = "_Tip of the Day..." 
@@ -716,6 +720,42 @@
                <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow"
                                _label = "Show completion window" 
                                shortcut = "Control|space" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd"
+                               _label = "Go to end of line" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.LineStart"
+                               _label = "Go to beginning of line" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar"
+                               _label = "Delete left character" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar"
+                               _label = "Delete right character" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft"
+                               _label = "Go left one character" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.CharRight"
+                               _label = "Go right one character" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.LineUp"
+                               _label = "Go to previous line" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.LineDown"
+                               _label = "Go to next line" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart"
+                               _label = "Go to beginning of document" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd"
+                               _label = "Go to end of document" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.PageUp"
+                               _label = "Go up one page" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.PageDown"
+                               _label = "Go down one page" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineUp"
+                               _label = "Scroll line up"
+                               shortcut = "Control|Up" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineDown"
+                               _label = "Scroll line down"
+                               shortcut = "Control|Down" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine"
+                               _label = "Delete entire line" />
+               <Command id = 
"MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd"
+                               _label = "Delete to end of line"
+                               shortcut="Control|K" />
+                               
                </Category>
        </Extension>
        

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to