SF.net SVN: geany:[4245] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sun Sep 27 15:59:58 UTC 2009


Revision: 4245
          http://geany.svn.sourceforge.net/geany/?rev=4245&view=rev
Author:   ntrel
Date:     2009-09-27 15:59:58 +0000 (Sun, 27 Sep 2009)

Log Message:
-----------
Add get_keyfile_ints() instead of using tmp_style hack.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/highlighting.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-09-27 14:07:24 UTC (rev 4244)
+++ trunk/ChangeLog	2009-09-27 15:59:58 UTC (rev 4245)
@@ -20,6 +20,8 @@
    plugins/geanyfunctions.h, plugins/filebrowser.c:
    Add plugin_show_configure() API utility function.
    Add File Browser popup menu 'Preferences' item.
+ * src/highlighting.c:
+   Add get_keyfile_ints() instead of using tmp_style hack.
 
 
 2009-09-24  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2009-09-27 14:07:24 UTC (rev 4244)
+++ trunk/src/highlighting.c	2009-09-27 15:59:58 UTC (rev 4245)
@@ -88,18 +88,15 @@
 	GCS_MAX
 };
 
-typedef struct
-{
-	/* can take values 1 or 2 (or 3) */
-	guint marker:2;
-	guint lines:2;
-	guint draw_line:3;
-} FoldingStyle;
-
 static struct
 {
 	GeanyLexerStyle	 styling[GCS_MAX];
-	FoldingStyle	 folding_style;
+
+	/* can take values 1 or 2 (or 3) */
+	gint fold_marker;
+	gint fold_lines;
+	gint fold_draw_line;
+
 	gchar			*wordchars;
 } common_style_set;
 
@@ -353,7 +350,8 @@
 }
 
 
-/* FIXME: is not safe for badly formed key e.g. "key=" */
+/* Get first and second integer numbers, store in foreground and background fields of @a style.
+ * FIXME: is not safe for badly formed key e.g. "key=" */
 static void get_keyfile_int(GKeyFile *config, GKeyFile *configh, const gchar *section,
 							const gchar *key, gint fdefault_val, gint sdefault_val,
 							GeanyLexerStyle *style)
@@ -390,6 +388,22 @@
 }
 
 
+/* first or second can be NULL. */
+static void get_keyfile_ints(GKeyFile *config, GKeyFile *configh, const gchar *section,
+							const gchar *key,
+							gint fdefault_val, gint sdefault_val,
+							gint *first, gint *second)
+{
+	GeanyLexerStyle tmp_style;
+
+	get_keyfile_int(config, configh, section, key, fdefault_val, sdefault_val, &tmp_style);
+	if (first)
+		*first = tmp_style.foreground;
+	if (second)
+		*second = tmp_style.background;
+}
+
+
 static guint invert(guint icolour)
 {
 	if (interface_prefs.highlighting_invert_all)
@@ -557,41 +571,24 @@
 	get_keyfile_hex(config, config_home, "marker_line", 0x000000, 0xffff00, FALSE, &common_style_set.styling[GCS_MARKER_LINE]);
 	get_keyfile_hex(config, config_home, "marker_search", 0x000000, 0x00007f, FALSE, &common_style_set.styling[GCS_MARKER_SEARCH]);
 	get_keyfile_hex(config, config_home, "marker_mark", 0x000000, 0xb8f4b8, FALSE, &common_style_set.styling[GCS_MARKER_MARK]);
-	{
-		/* hack because get_keyfile_int uses a Style struct */
-		GeanyLexerStyle tmp_style;
-		get_keyfile_int(config, config_home, "styling", "folding_style",
-			1, 1, &tmp_style);
-		common_style_set.folding_style.marker = tmp_style.foreground;
-		common_style_set.folding_style.lines = tmp_style.background;
-		get_keyfile_int(config, config_home, "styling", "folding_horiz_line",
-			2, 0, &tmp_style);
-		common_style_set.folding_style.draw_line = tmp_style.foreground;
-		get_keyfile_int(config, config_home, "styling", "caret_width",
-			1, 0, &tmp_style);
-		common_style_set.styling[GCS_CARET].background = tmp_style.foreground;
-		get_keyfile_int(config, config_home, "styling", "line_wrap_visuals",
-			3, 0, &tmp_style);
-		common_style_set.styling[GCS_LINE_WRAP_VISUALS].foreground = tmp_style.foreground;
-		common_style_set.styling[GCS_LINE_WRAP_VISUALS].background = tmp_style.background;
-		get_keyfile_int(config, config_home, "styling", "line_wrap_indent",
-			0, 0, &tmp_style);
-		common_style_set.styling[GCS_LINE_WRAP_INDENT].foreground = tmp_style.foreground;
-		common_style_set.styling[GCS_LINE_WRAP_INDENT].background = tmp_style.background;
-		get_keyfile_int(config, config_home, "styling", "translucency",
-			256, 256, &tmp_style);
-		common_style_set.styling[GCS_TRANSLUCENCY].foreground = tmp_style.foreground;
-		common_style_set.styling[GCS_TRANSLUCENCY].background = tmp_style.background;
-		get_keyfile_int(config, config_home, "styling", "marker_translucency",
-			256, 256, &tmp_style);
-		common_style_set.styling[GCS_MARKER_TRANSLUCENCY].foreground = tmp_style.foreground;
-		common_style_set.styling[GCS_MARKER_TRANSLUCENCY].background = tmp_style.background;
-		get_keyfile_int(config, config_home, "styling", "line_height",
-			0, 0, &tmp_style);
-		common_style_set.styling[GCS_LINE_HEIGHT].foreground = tmp_style.foreground;
-		common_style_set.styling[GCS_LINE_HEIGHT].background = tmp_style.background;
-	}
 
+	get_keyfile_ints(config, config_home, "styling", "folding_style",
+		1, 1, &common_style_set.fold_marker, &common_style_set.fold_lines);
+	get_keyfile_ints(config, config_home, "styling", "folding_horiz_line",
+		2, 0, &common_style_set.fold_draw_line, NULL);
+	get_keyfile_ints(config, config_home, "styling", "caret_width",
+		1, 0, &common_style_set.styling[GCS_CARET].background, NULL); /* caret.foreground used earlier */
+	get_keyfile_int(config, config_home, "styling", "line_wrap_visuals",
+		3, 0, &common_style_set.styling[GCS_LINE_WRAP_VISUALS]);
+	get_keyfile_int(config, config_home, "styling", "line_wrap_indent",
+		0, 0, &common_style_set.styling[GCS_LINE_WRAP_INDENT]);
+	get_keyfile_int(config, config_home, "styling", "translucency",
+		256, 256, &common_style_set.styling[GCS_TRANSLUCENCY]);
+	get_keyfile_int(config, config_home, "styling", "marker_translucency",
+		256, 256, &common_style_set.styling[GCS_MARKER_TRANSLUCENCY]);
+	get_keyfile_int(config, config_home, "styling", "line_height",
+		0, 0, &common_style_set.styling[GCS_LINE_HEIGHT]);
+
 	get_keyfile_wordchars(config, config_home, &common_style_set.wordchars);
 	whitespace_chars = get_keyfile_whitespace_chars(config, config_home);
 }
@@ -663,7 +660,7 @@
 	SSM(sci, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
 
 	/* drawing a horizontal line when text if folded */
-	switch (common_style_set.folding_style.draw_line)
+	switch (common_style_set.fold_draw_line)
 	{
 		case 1:
 		{
@@ -683,7 +680,7 @@
 	}
 
 	/* choose the folding style - boxes or circles, I prefer boxes, so it is default ;-) */
-	switch (common_style_set.folding_style.marker)
+	switch (common_style_set.fold_marker)
 	{
 		case 2:
 		{
@@ -704,7 +701,7 @@
 	}
 
 	/* choose the folding style - straight or curved, I prefer straight, so it is default ;-) */
-	switch (common_style_set.folding_style.lines)
+	switch (common_style_set.fold_lines)
 	{
 		case 2:
 		{


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