SF.net SVN: geany: [1101] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Dec 15 12:52:52 UTC 2006


Revision: 1101
          http://svn.sourceforge.net/geany/?rev=1101&view=rev
Author:   ntrel
Date:     2006-12-15 04:52:52 -0800 (Fri, 15 Dec 2006)

Log Message:
-----------
Fix setting project typenames for the new D lexer.
Add sci_cb_lexer_is_c_like() which returns TRUE for C++/D lexers.
Only recolourise C-like files when updating project typename
keywords.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/sci_cb.c
    trunk/src/sci_cb.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-12-15 12:40:18 UTC (rev 1100)
+++ trunk/ChangeLog	2006-12-15 12:52:52 UTC (rev 1101)
@@ -5,6 +5,11 @@
    indent contains one too many spaces.
  * src/highlighting.c, data/filetypes.d:
    Show D typedefs in bold.
+ * src/sci_cb.c, src/sci_cb.h, src/document.c:
+   Fix setting project typenames for the new D lexer.
+   Add sci_cb_lexer_is_c_like() which returns TRUE for C++/D lexers.
+   Only recolourise C-like files when updating project typename
+   keywords.
 
 
 2006-12-14  Frank Lanitz  <frank at frank.uvena.de>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-12-15 12:40:18 UTC (rev 1100)
+++ trunk/src/document.c	2006-12-15 12:52:52 UTC (rev 1101)
@@ -1303,9 +1303,43 @@
 }
 
 
+/* Returns: whether sci_colourise has been called for sci */
+static gboolean update_type_keywords(ScintillaObject *sci)
+{
+	gboolean ret = FALSE;
+
+	// For C/C++/Java files, get list of typedefs for colourising
+	if (sci_cb_lexer_is_c_like(sci_get_lexer(sci)))
+	{
+		GString *s = get_project_typenames();
+
+		if (s != NULL)
+		{
+			guint n;
+
+			for (n = 0; n < doc_array->len; n++)
+			{
+				ScintillaObject *wid = doc_list[n].sci;
+
+				if (wid && sci_cb_lexer_is_c_like(sci_get_lexer(wid)))
+				{
+					sci_set_keywords(wid, 3, s->str);
+					sci_colourise(wid, 0, -1);
+				}
+			}
+			g_string_free(s, TRUE);
+			ret = TRUE;
+		}
+	}
+	return ret;
+}
+
+
 /* sets the filetype of the document (sets syntax highlighting and tagging) */
 void document_set_filetype(gint idx, filetype *type)
 {
+	gboolean colourise = FALSE;
+
 	if (type == NULL || ! DOC_IDX_VALID(idx))
 		return;
 
@@ -1323,32 +1357,13 @@
 		}
 		build_menu_update(idx);
 		type->style_func_ptr(doc_list[idx].sci);	// set new styles
+		colourise = TRUE;
 	}
 
 	document_update_tag_list(idx, TRUE);
-
-	// For C/C++/Java files, get list of typedefs for colourising
-	if (sci_get_lexer(doc_list[idx].sci) == SCLEX_CPP)
-	{
-		GString *s = get_project_typenames();
-
-		if (s != NULL)
-		{
-			guint n;
-
-			for (n = 0; n < doc_array->len; n++)
-			{
-				if (doc_list[n].sci)
-				{
-					sci_set_keywords(doc_list[n].sci, 3, s->str);
-					sci_colourise(doc_list[n].sci, 0, -1);
-				}
-			}
-			//SSM(doc_list[idx].sci, SCI_SETKEYWORDS, 3, (sptr_t) s->str);
-			g_string_free(s, TRUE);
-		}
-	}
-	sci_colourise(doc_list[idx].sci, 0, -1);
+	colourise &= ! update_type_keywords(doc_list[idx].sci);
+	if (colourise)
+		sci_colourise(doc_list[idx].sci, 0, -1);
 }
 
 

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2006-12-15 12:40:18 UTC (rev 1100)
+++ trunk/src/sci_cb.c	2006-12-15 12:52:52 UTC (rev 1101)
@@ -1778,3 +1778,19 @@
 		g_free(previous_line);
 	}
 }
+
+
+gboolean sci_cb_lexer_is_c_like(gint lexer)
+{
+	switch (lexer)
+	{
+		case SCLEX_CPP:
+		case SCLEX_D:
+		return TRUE;
+
+		default:
+		return FALSE;
+	}
+}
+
+

Modified: trunk/src/sci_cb.h
===================================================================
--- trunk/src/sci_cb.h	2006-12-15 12:40:18 UTC (rev 1100)
+++ trunk/src/sci_cb.h	2006-12-15 12:52:52 UTC (rev 1101)
@@ -81,4 +81,6 @@
 
 void sci_cb_auto_close_bracket(ScintillaObject *sci, gint pos, gchar c);
 
+gboolean sci_cb_lexer_is_c_like(gint lexer);
+
 #endif


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