SF.net SVN: geany: [1956] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Oct 18 11:52:48 UTC 2007


Revision: 1956
          http://geany.svn.sourceforge.net/geany/?rev=1956&view=rev
Author:   ntrel
Date:     2007-10-18 04:52:47 -0700 (Thu, 18 Oct 2007)

Log Message:
-----------
Apply patch from Catalin Marinas to add a 'newline strips trailing
spaces' pref (thanks).

Modified Paths:
--------------
    trunk/THANKS
    trunk/geany.glade
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/editor.c
    trunk/src/editor.h
    trunk/src/interface.c
    trunk/src/keyfile.c
    trunk/src/plugindata.h
    trunk/src/prefs.c

Modified: trunk/THANKS
===================================================================
--- trunk/THANKS	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/THANKS	2007-10-18 11:52:47 UTC (rev 1956)
@@ -37,6 +37,7 @@
 Jean-François Wauthy <pollux(at)xfce(dot)org> - Symbol list icons patch
 blackdog <blackdog(at)ipowerhouse(dot)com> - Haxe filetype patch
 Sebastian Kraft <kraft(dot)sebastian(at)googlemail(dot)com> - new Geany icon
+Catalin Marinas <catalin(dot)marinas(at)gmail(dot)com> - newline strips trailing spaces patch
 
 Translators:
 ------------

Modified: trunk/geany.glade
===================================================================
--- trunk/geany.glade	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/geany.glade	2007-10-18 11:52:47 UTC (rev 1956)
@@ -5890,6 +5890,26 @@
 			      <property name="fill">False</property>
 			    </packing>
 			  </child>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="check_newline_strip">
+			      <property name="visible">True</property>
+			      <property name="tooltip" translatable="yes">Enable newline to strip the trailing spaces on the previous line.</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Newline strips trailing spaces</property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">False</property>
+			      <property name="active">False</property>
+			      <property name="inconsistent">False</property>
+			      <property name="draw_indicator">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
 			</widget>
 		      </child>
 		    </widget>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/document.c	2007-10-18 11:52:47 UTC (rev 1956)
@@ -2074,6 +2074,27 @@
 }
 
 
+void document_strip_line_trailing_spaces(gint idx, gint line)
+{
+	gint line_start = sci_get_position_from_line(doc_list[idx].sci, line);
+	gint line_end = sci_get_line_end_position(doc_list[idx].sci, line);
+	gint i = line_end - 1;
+	gchar ch = sci_get_char_at(doc_list[idx].sci, i);
+
+	while ((i >= line_start) && ((ch == ' ') || (ch == '\t')))
+	{
+		i--;
+		ch = sci_get_char_at(doc_list[idx].sci, i);
+	}
+	if (i < (line_end-1))
+	{
+		sci_target_start(doc_list[idx].sci, i + 1);
+		sci_target_end(doc_list[idx].sci, line_end);
+		sci_target_replace(doc_list[idx].sci, "", FALSE);
+	}
+}
+
+
 void document_strip_trailing_spaces(gint idx)
 {
 	gint max_lines = sci_get_line_count(doc_list[idx].sci);
@@ -2083,22 +2104,7 @@
 
 	for (line = 0; line < max_lines; line++)
 	{
-		gint line_start = sci_get_position_from_line(doc_list[idx].sci, line);
-		gint line_end = sci_get_line_end_position(doc_list[idx].sci, line);
-		gint i = line_end - 1;
-		gchar ch = sci_get_char_at(doc_list[idx].sci, i);
-
-		while ((i >= line_start) && ((ch == ' ') || (ch == '\t')))
-		{
-			i--;
-			ch = sci_get_char_at(doc_list[idx].sci, i);
-		}
-		if (i < (line_end-1))
-		{
-			sci_target_start(doc_list[idx].sci, i + 1);
-			sci_target_end(doc_list[idx].sci, line_end);
-			sci_target_replace(doc_list[idx].sci, "", FALSE);
-		}
+		document_strip_line_trailing_spaces(idx, line);
 	}
 	sci_end_undo_action(doc_list[idx].sci);
 }

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/document.h	2007-10-18 11:52:47 UTC (rev 1956)
@@ -191,6 +191,8 @@
 
 void document_replace_tabs(gint idx);
 
+void document_strip_line_trailing_spaces(gint idx, gint line);
+
 void document_strip_trailing_spaces(gint idx);
 
 void document_ensure_final_newline(gint idx);

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/editor.c	2007-10-18 11:52:47 UTC (rev 1956)
@@ -396,6 +396,7 @@
 {
 	ScintillaObject *sci = doc_list[idx].sci;
 	gint pos = sci_get_current_position(sci);
+	gint line = sci_get_current_line(sci);
 
 	// simple indentation
 	if (doc_list[idx].auto_indent)
@@ -425,6 +426,12 @@
 
 		editor_auto_latex(idx, pos);
 	}
+
+	if (editor_prefs.newline_strip)
+	{
+		// strip the trailing spaces on the previous line
+		document_strip_line_trailing_spaces(idx, line - 1);
+	}
 }
 
 

Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/editor.h	2007-10-18 11:52:47 UTC (rev 1956)
@@ -66,6 +66,7 @@
 	IndentMode	indent_mode;
 	gboolean	disable_dnd;
 	gboolean	smart_home_key;
+	gboolean	newline_strip;
 	gboolean	auto_complete_symbols;
 	gboolean	auto_close_xml_tags;
 	gboolean	auto_complete_constructs;

Modified: trunk/src/interface.c
===================================================================
--- trunk/src/interface.c	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/interface.c	2007-10-18 11:52:47 UTC (rev 1956)
@@ -2579,6 +2579,7 @@
   GtkWidget *check_folding;
   GtkWidget *check_unfold_children;
   GtkWidget *check_indicators;
+  GtkWidget *check_newline_strip;
   GtkWidget *label172;
   GtkWidget *frame18;
   GtkWidget *alignment21;
@@ -3612,6 +3613,12 @@
   gtk_tooltips_set_tip (tooltips, check_indicators, _("Whether to use indicators (a squiggly underline) to highlight the lines where the compiler found a warning or an error."), NULL);
   gtk_button_set_focus_on_click (GTK_BUTTON (check_indicators), FALSE);
 
+  check_newline_strip = gtk_check_button_new_with_mnemonic (_("Newline strips trailing spaces"));
+  gtk_widget_show (check_newline_strip);
+  gtk_box_pack_start (GTK_BOX (vbox17), check_newline_strip, FALSE, FALSE, 0);
+  gtk_tooltips_set_tip (tooltips, check_newline_strip, _("Enable newline to strip the trailing spaces on the previous line."), NULL);
+  gtk_button_set_focus_on_click (GTK_BUTTON (check_newline_strip), FALSE);
+
   label172 = gtk_label_new (_("<b>Features</b>"));
   gtk_widget_show (label172);
   gtk_frame_set_label_widget (GTK_FRAME (frame14), label172);
@@ -4372,6 +4379,7 @@
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_unfold_children, "check_unfold_children");
   GLADE_HOOKUP_OBJECT (prefs_dialog, check_indicators, "check_indicators");
+  GLADE_HOOKUP_OBJECT (prefs_dialog, check_newline_strip, "check_newline_strip");
   GLADE_HOOKUP_OBJECT (prefs_dialog, label172, "label172");
   GLADE_HOOKUP_OBJECT (prefs_dialog, frame18, "frame18");
   GLADE_HOOKUP_OBJECT (prefs_dialog, alignment21, "alignment21");

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/keyfile.c	2007-10-18 11:52:47 UTC (rev 1956)
@@ -195,6 +195,7 @@
 	g_key_file_set_boolean(config, PACKAGE, "pref_editor_use_tabs", editor_prefs.use_tabs);
 	g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
 	g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
+	g_key_file_set_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
 
 	// files
 	g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[prefs.default_new_encoding].charset);
@@ -469,6 +470,7 @@
 	editor_prefs.use_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_use_tabs", TRUE);
 	editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
 	editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
+	editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
 	editor_prefs.use_gtk_word_boundaries = utils_get_setting_boolean(config, PACKAGE, "use_gtk_word_boundaries", TRUE);
 	editor_prefs.auto_complete_whilst_editing = utils_get_setting_boolean(config, PACKAGE, "auto_complete_whilst_editing", FALSE);
 

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/plugindata.h	2007-10-18 11:52:47 UTC (rev 1956)
@@ -70,13 +70,13 @@
 
 
 /* The API version should be incremented whenever any plugin data types below are
- * modified. */
-static const gint api_version = 23;
+ * modified or appended to. */
+static const gint api_version = 24;
 
 /* The ABI version should be incremented whenever existing fields in the plugin
  * data types below have to be changed or reordered. It should stay the same if fields
  * are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 12;
+static const gint abi_version = 13;
 
 /* This performs runtime checks that try to ensure:
  * 1. Geany ABI data types are compatible with this plugin.

Modified: trunk/src/prefs.c
===================================================================
--- trunk/src/prefs.c	2007-10-18 11:37:45 UTC (rev 1955)
+++ trunk/src/prefs.c	2007-10-18 11:52:47 UTC (rev 1956)
@@ -315,6 +315,9 @@
 	widget = lookup_widget(ui_widgets.prefs_dialog, "check_smart_home");
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.smart_home_key);
 
+	widget = lookup_widget(ui_widgets.prefs_dialog, "check_newline_strip");
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.newline_strip);
+
 	if (editor_prefs.use_tabs)
 		widget = lookup_widget(ui_widgets.prefs_dialog, "radio_indent_tabs");
 	else
@@ -695,6 +698,9 @@
 		widget = lookup_widget(ui_widgets.prefs_dialog, "check_smart_home");
 		editor_prefs.smart_home_key = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
+		widget = lookup_widget(ui_widgets.prefs_dialog, "check_newline_strip");
+		editor_prefs.newline_strip = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
 		widget = lookup_widget(ui_widgets.prefs_dialog, "radio_indent_tabs");
 		{
 			gboolean use_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list