[anjuta] language-support-cpp-java: Multi-Line Comment Asterisk



commit a1b45edead3def44e4c867f75d7d81d37fe8b519
Author: Eugenia Gabrielova <genia likes science gmail com>
Date:   Thu Oct 21 15:09:51 2010 -0500

    language-support-cpp-java: Multi-Line Comment Asterisk
    
    When continuing a multi-line comment beginning with "/*" on a new line,
    insert " * _" with cursor at "_" on the next line. Implemented in the
    C++/Java Language Support Plugin.

 .../anjuta-language-cpp-java.ui                    |   24 +++++++++++++++++--
 plugins/language-support-cpp-java/plugin.c         |   18 ++++++++++++++-
 2 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
index 41daaf6..256f420 100644
--- a/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
+++ b/plugins/language-support-cpp-java/anjuta-language-cpp-java.ui
@@ -26,8 +26,8 @@
                 <child>
                   <object class="GtkTable" id="table15">
                     <property name="visible">True</property>
+                    <property name="n_rows">3</property>
                     <property name="border_width">10</property>
-                    <property name="n_rows">2</property>
                     <property name="column_spacing">5</property>
                     <property name="row_spacing">5</property>
                     <child>
@@ -41,10 +41,28 @@
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
+                        <property name="position">0</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
                       </packing>
                     </child>
+                    <child>                    
+                      <object class="GtkCheckButton" id="preferences_toggle:bool:1:1:cpp-multiline-leading-asterisk">
+                        <property name="label" translatable="yes">Leading asterisk in multi-line comment</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkCheckButton" id="preferences_toggle:bool:1:1:cpp-indent-modeline">
                         <property name="label" translatable="yes">Prefer vim/emacs modelines over indentation settings</property>
@@ -57,8 +75,8 @@
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"></property>
                       </packing>
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 9d2f755..d47a426 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -61,6 +61,7 @@
 #define PREF_INDENT_PARANTHESE_LINEUP "cpp-indent-paranthese-lineup"
 #define PREF_INDENT_PARANTHESE_SIZE "cpp-indent-paranthese-size"
 #define PREF_BRACE_AUTOCOMPLETION "cpp-brace-autocompletion"
+#define PREF_COMMENT_LEADING_ASTERISK "cpp-multiline-leading-asterisk"
 
 #define TAB_SIZE (ianjuta_editor_get_tabsize (editor, NULL))
 
@@ -844,7 +845,12 @@ get_line_indentation_base (CppJavaPlugin *plugin,
 	gboolean current_line_is_preprocessor = FALSE;
 	gboolean current_line_is_continuation = FALSE;
 	gboolean line_checked_for_comment = FALSE;
-	
+
+    /* Determine whether or not to add multi-line comment asterisks */
+	gchar* comment_continued = " * ";
+	IAnjutaIterable* line_begin = ianjuta_editor_get_line_begin_position (editor, line_num, NULL);
+	IAnjutaIterable* line_end = ianjuta_editor_get_line_end_position (editor, line_num, NULL);
+
 	*incomplete_statement = -1;
 	*line_indent_spaces = 0;
 	
@@ -967,10 +973,20 @@ get_line_indentation_base (CppJavaPlugin *plugin,
 						if (!comment_end)
 						{
 							extra_indent++;
+
+							/* If a multiline comment is continuing, check the next line and insert " * " 
+							 * only if it does not already exist there. The purpose of this fix is to avoid
+							 * extra " * " on auto-indent. */
+
+							if (g_settings_get_boolean (plugin->settings, PREF_COMMENT_LEADING_ASTERISK) &&
+									ianjuta_iterable_compare (line_end, line_begin, NULL) == 0)
+								ianjuta_editor_insert (editor, line_begin, comment_continued, -1, NULL);
+
 							/* In the middle of a comment we can't know
 						     * if the statement is incomplete
 							 */
 							*incomplete_statement = -1;
+							
 							/* ":" have to be ignored inside comments */
 							if (*colon_indent)
 							{



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]