SF.net SVN: geany: [1386] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Mar 12 16:24:52 UTC 2007


Revision: 1386
          http://svn.sourceforge.net/geany/?rev=1386&view=rev
Author:   ntrel
Date:     2007-03-12 09:24:52 -0700 (Mon, 12 Mar 2007)

Log Message:
-----------
Update the status bar after setting the document file type, if it
has changed.
Update the status bar after colourising open files, so the current
tag is accurate.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-03-12 16:18:12 UTC (rev 1385)
+++ trunk/ChangeLog	2007-03-12 16:24:52 UTC (rev 1386)
@@ -8,6 +8,11 @@
 
  * src/build.c:
    Switch to Compiler window when using Next Error command.
+ * src/utils.c, src/document.c:
+   Update the status bar after setting the document file type, if it
+   has changed.
+   Update the status bar after colourising open files, so the current
+   tag is accurate.
 
 
 2007-03-10  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-03-12 16:18:12 UTC (rev 1385)
+++ trunk/src/document.c	2007-03-12 16:24:52 UTC (rev 1386)
@@ -1586,13 +1586,15 @@
 void document_set_filetype(gint idx, filetype *type)
 {
 	gboolean colourise = FALSE;
+	gboolean ft_changed;
 
 	if (type == NULL || ! DOC_IDX_VALID(idx))
 		return;
 
 	geany_debug("%s : %s (%s)",	doc_list[idx].file_name, type->name, doc_list[idx].encoding);
 
-	if (doc_list[idx].file_type != type)	// filetype has changed
+	ft_changed = (doc_list[idx].file_type != type);
+	if (ft_changed)	// filetype has changed
 	{
 		doc_list[idx].file_type = type;
 
@@ -1615,6 +1617,11 @@
 		if (! update_type_keywords(doc_list[idx].sci) && colourise)
 			sci_colourise(doc_list[idx].sci, 0, -1);
 	}
+	if (ft_changed)
+	{
+		utils_get_current_function(-1, NULL);
+		ui_update_statusbar(idx, -1);
+	}
 }
 
 
@@ -2179,6 +2186,11 @@
 	delay_colourise = FALSE;
 	g_array_free(doc_indexes, TRUE);
 	doc_indexes = NULL;
+
+	/* now that the current document is colourised, fold points are now accurate,
+	 * so force an update of the current function/tag. */
+	utils_get_current_function(-1, NULL);
+	ui_update_statusbar(-1, -1);
 }
 
 

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2007-03-12 16:18:12 UTC (rev 1385)
+++ trunk/src/utils.c	2007-03-12 16:24:52 UTC (rev 1386)
@@ -491,14 +491,29 @@
 }
 
 
+/* Sets *tagname to point at the current function or tag name.
+ * If idx is -1, reset the cached current tag data to ensure it will be reparsed on the next
+ * call to this function.
+ * Returns: line number of the current tag, or -1 if unknown. */
 gint utils_get_current_function(gint idx, const gchar **tagname)
 {
 	static gint tag_line = -1;
 	static gchar *cur_tag = NULL;
 	gint line;
 	gint fold_level;
-	TMWorkObject * tm_file = doc_list[idx].tm_file;
+	TMWorkObject *tm_file;
 
+	if (! DOC_IDX_VALID(idx))	// reset current function
+	{
+		current_function_changed(-1, -1, -1);
+		g_free(cur_tag);
+		cur_tag = g_strdup(_("unknown"));
+		if (tagname != NULL)
+			*tagname = cur_tag;
+		tag_line = -1;
+		return tag_line;
+	}
+
 	line = sci_get_current_line(doc_list[idx].sci, -1);
 	fold_level = sci_get_fold_level(doc_list[idx].sci, line);
 	// check if the cached line and file index have changed since last time:
@@ -518,6 +533,7 @@
 		tag_line = -1;
 		return tag_line;
 	}
+	tm_file = doc_list[idx].tm_file;
 
 	// if the document has no changes, get the previous function name from TM
 	if(! doc_list[idx].changed && tm_file != NULL && tm_file->tags_array != NULL)


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