Hi all

As threatened two weeks ago, I now created a patch to geany to enable
line_wrapping on a per-project basis. Seems to be working fine, I put
the checkbox to enable it on the Editor tab of the project properties.

I hope I did everything right:
- git clone git://github.com/geany/geany.git geany
- Made my changes
- Did a fresh git pull
- git commit -a
- git format-patch HEAD^


I attach the resulting patch to the email, please tell when you need it
in another way.


Kind regards
Tim

-- 
decentral.ch - IT Stuff
Tim Tassonis
Dennlerstasse 36
8047 Zürich

st...@decentral.ch
+41 79 229 36 17
>From 68d265ba46ce34aae1acfd274f379b118dd9fbb9 Mon Sep 17 00:00:00 2001
From: Tim Tassonis <st...@decentral.ch>
Date: Thu, 25 Sep 2014 10:20:48 +0200
Subject: [PATCH] Enable per-project line wrapping

---
 data/geany.glade     | 16 ++++++++++++++++
 src/editor.c         | 12 ++++++++++++
 src/project.c        | 12 ++++++++++--
 src/projectprivate.h |  1 +
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/data/geany.glade b/data/geany.glade
index 1d9b211..9b6f4e4 100644
--- a/data/geany.glade
+++ b/data/geany.glade
@@ -9029,6 +9029,22 @@
                     <property name="position">0</property>
                   </packing>
                 </child>
+                            <child>
+                              <object class="GtkCheckButton" id="check_line_wrapping1">
+                                <property name="label" translatable="yes">Line wrapping</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Wrap the line at the window border and continue it on the next line. Note: line wrapping has a high performance cost for large documents so should be disabled on slow machines.</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
               </object>
               <packing>
                 <property name="position">2</property>
diff --git a/src/editor.c b/src/editor.c
index 779e028..3f5945b 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -375,6 +375,16 @@ static gboolean is_style_php(gint style)
 }
 
 
+static gint editor_get_line_wrapping(void)
+{
+	if (app->project) 
+		return app->project->priv->line_wrapping;
+	if (!editor_prefs.line_wrapping)
+		return 0;
+	else
+		return editor_prefs.line_wrapping;
+}
+
 static gint editor_get_long_line_type(void)
 {
 	if (app->project)
@@ -415,6 +425,7 @@ get_default_prefs(void)
 	eprefs.indentation = (GeanyIndentPrefs*)editor_get_indent_prefs(NULL);
 	eprefs.long_line_type = editor_get_long_line_type();
 	eprefs.long_line_column = editor_get_long_line_column();
+	eprefs.line_wrapping = editor_get_line_wrapping();
 	return &eprefs;
 }
 
@@ -5009,6 +5020,7 @@ void editor_apply_update_prefs(GeanyEditor *editor)
 	sci_set_autoc_max_height(sci, editor_prefs.symbolcompletion_max_height);
 	SSM(sci, SCI_AUTOCSETDROPRESTOFWORD, editor_prefs.completion_drops_rest_of_word, 0);
 
+	editor_set_line_wrapping(editor,editor_get_line_wrapping());
 	editor_set_indentation_guides(editor);
 
 	sci_set_visible_white_spaces(sci, editor_prefs.show_white_space);
diff --git a/src/project.c b/src/project.c
index 7d20332..541cf1a 100644
--- a/src/project.c
+++ b/src/project.c
@@ -56,7 +56,6 @@ ProjectPrefs project_prefs = { NULL, FALSE, FALSE };
 
 static GeanyProjectPrivate priv;
 static GeanyIndentPrefs indentation;
-
 static GSList *stash_groups = NULL;
 
 static struct
@@ -684,6 +683,7 @@ static GeanyProject *create_project(void)
 
 	project->priv->long_line_behaviour = 1 /* use global settings */;
 	project->priv->long_line_column = editor_prefs.long_line_column;
+	project->priv->line_wrapping = editor_prefs.line_wrapping;
 
 	app->project = project;
 	return project;
@@ -1063,6 +1063,8 @@ static gboolean load_config(const gchar *filename)
 		"long_line_behaviour", 1 /* follow global */);
 	p->priv->long_line_column = utils_get_setting_integer(config, "long line marker",
 		"long_line_column", editor_prefs.long_line_column);
+	p->priv->line_wrapping = utils_get_setting_boolean(config, "line_wrapping",
+		"line_wrapping", editor_prefs.line_wrapping);
 	apply_editor_prefs();
 
 	build_load_menu(config, GEANY_BCS_PROJ, (gpointer)p);
@@ -1132,6 +1134,7 @@ static gboolean write_config(gboolean emit_signal)
 	g_key_file_set_integer(config, "long line marker", "long_line_behaviour", p->priv->long_line_behaviour);
 	g_key_file_set_integer(config, "long line marker", "long_line_column", p->priv->long_line_column);
 
+	g_key_file_set_boolean(config, "line_wrapping", "line_wrapping", p->priv->line_wrapping);
 	/* store the session files into the project too */
 	if (project_prefs.project_session)
 		configuration_save_session_files(config);
@@ -1261,7 +1264,6 @@ static void init_stash_prefs(void)
 	indentation = *editor_get_indent_prefs(NULL);
 	stash_group_set_use_defaults(group, FALSE);
 	add_stash_group(group);
-
 	stash_group_add_spin_button_integer(group, &indentation.width,
 		"indent_width", 4, "spin_indent_width_project");
 	stash_group_add_radio_buttons(group, (gint*)(gpointer)&indentation.type,
@@ -1289,6 +1291,12 @@ static void init_stash_prefs(void)
 		"strip_trailing_spaces", file_prefs.strip_trailing_spaces, "check_trailing_spaces1");
 	stash_group_add_toggle_button(group, &priv.replace_tabs,
 		"replace_tabs", file_prefs.replace_tabs, "check_replace_tabs1");
+	group = stash_group_new("file_prefs");
+	add_stash_group(group);
+
+	group = stash_group_new("line_wrapping");
+	stash_group_add_toggle_button(group, &priv.line_wrapping,
+		"line_wrapping", editor_prefs.line_wrapping, "check_line_wrapping1");
 	add_stash_group(group);
 	/* apply defaults */
 	kf = g_key_file_new();
diff --git a/src/projectprivate.h b/src/projectprivate.h
index 2bdd9c7..2bcd1bf 100644
--- a/src/projectprivate.h
+++ b/src/projectprivate.h
@@ -39,6 +39,7 @@ typedef struct GeanyProjectPrivate
 	GPtrArray *build_filetypes_list; /* Project has custom filetype builds for these. */
 	gint long_line_behaviour; /* 0 - disabled, 1 - follow global settings, 2 - enabled (custom) */
 	gint long_line_column; /* Long line marker position. */
+	gboolean	line_wrapping;
 }
 GeanyProjectPrivate;
 
-- 
1.9.1

_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel

Reply via email to