Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] C/C++ Command Patch

So the other day I was trying to do some development using the CDT and
wanted to
comment/uncomment a block of code.  I know that in Java that this can be
done using
the CTRL-/ and CTRL-\ keyshortcuts ... looking into it some more I found
that "Hey,
there are _no_ commands defined for CDT".

This provides the initial scope for the editor and some of the groundwork
(and also
allows us to start playing in the configurable key binding game), but is a
start not the
end.  I think that the CDT should consider adopting a new menu item (like
Source
under Java) which contains some of these source editing functions.

ChangeLog:
 Define a specific editing scope for the C/C++ Editor and define the
framework for
 adding in additional commands. Two commands added initially: comment and
uncomment.
 Removed some Java nomenclature from some of the C properties.

Thanks,
  Thomas
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.properties,v
retrieving revision 1.18
diff -u -r1.18 plugin.properties
--- plugin.properties	27 May 2003 21:33:02 -0000	1.18
+++ plugin.properties	9 Jun 2003 17:54:45 -0000
@@ -59,8 +59,23 @@
 CFolderActionSet.label=C Folder Actions
 CFolderActionSet.description=C Folder Action Set
 
+# Editor 
 Editors.DefaultTextEditor = Default Text Editor
 AsmEditor.name = Assembly Editor
+
+# Scope and Key Commands 
+scope.cEditor.name=C/C++ Editor
+cEditor.description=Editor for C/C++ Source Files
+
+category.source.name=C/C++ Source
+category.source.description= C/C++ Source Actions
+
+ActionDefinition.comment.name= Comment
+ActionDefinition.comment.description= Turn the selected lines into // style comments
+
+ActionDefinition.uncomment.name= Uncomment
+ActionDefinition.uncomment.description= Uncomment the selected // style comment lines
+
 
 # Task Action
 DeleteTaskAction.label=Delete C/C++ Markers
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.xml,v
retrieving revision 1.26
diff -u -r1.26 plugin.xml
--- plugin.xml	27 May 2003 21:33:02 -0000	1.26
+++ plugin.xml	9 Jun 2003 17:54:46 -0000
@@ -525,5 +525,43 @@
             id="org.eclipse.cdt.gnu.tools.tabGroupLD">
       </toolTabGroup>
    </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <scope
+            name="%scope.cEditor.name"
+            parent="org.eclipse.ui.textEditorScope"
+            description="%cEditor.description"
+            id="org.eclipse.cdt.ui.cEditorScope">
+      </scope>
+      <category
+            name="%category.source.name"
+            descrption="%category.source.description"
+            id="org.eclipse.cdt.ui.category.source">
+      </category>
+      <command
+            name="%ActionDefinition.comment.name"
+            description="%ActionDefinition.comment.description"
+            category="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.comment">
+      </command>
+      <keyBinding
+            string="Ctrl+/"
+            scope="org.eclipse.cdt.ui.cEditorScope"
+            command="org.eclipse.cdt.ui.edit.text.c.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <command
+            name="%ActionDefinition.uncomment.name"
+            description="%ActionDefinition.uncomment.description"
+            category="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.uncomment">
+      </command>
+      <keyBinding
+            string="Ctrl+\"
+            scope="org.eclipse.cdt.ui.cEditorScope"
+            command="org.eclipse.cdt.ui.edit.text.c.uncomment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+   </extension>
 
 </plugin>
Index: src/org/eclipse/cdt/internal/ui/editor/CEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java,v
retrieving revision 1.24
diff -u -r1.24 CEditor.java
--- src/org/eclipse/cdt/internal/ui/editor/CEditor.java	28 Apr 2003 02:37:26 -0000	1.24
+++ src/org/eclipse/cdt/internal/ui/editor/CEditor.java	9 Jun 2003 17:54:50 -0000
@@ -794,4 +794,12 @@
 	protected void setOutlinerContextMenuId(String menuId) {
 		fOutlinerContextMenuId = menuId;
 	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
+	 */
+	protected void initializeKeyBindingScopes() {
+		setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } );
+	}
+
 }
Index: src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties,v
retrieving revision 1.4
diff -u -r1.4 CEditorMessages.properties
--- src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties	21 Apr 2003 17:05:46 -0000	1.4
+++ src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties	9 Jun 2003 17:54:50 -0000
@@ -110,11 +110,11 @@
 
 Comment.label=&Comment
 Comment.tooltip=Comment the Selected Lines
-Comment.description=Turn the selected lines into Java comments
+Comment.description=Turn the selected lines into C // style comments
 
 Uncomment.label=Uncommen&t
-Uncomment.tooltip=Uncomment the Selected Java Comment Lines
-Uncomment.description=Uncomment the selected Java comment lines
+Uncomment.tooltip=Uncomment the Selected C // comment Lines
+Uncomment.description=Uncomment the selected C // comment lines
 
 Format.label=F&ormat
 Format.tooltip=Format the Selected Text

Back to the top