[gnumeric] Improve function syntax tooltips.



commit 6cd156daf216b6462182c37fab4565f7540da4e3
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jun 18 13:45:08 2010 -0600

    Improve function syntax tooltips.
    
    2010-06-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_check_tooltip): Handle strings (and
    	  sheet names) better.

 NEWS                              |    3 +++
 src/widgets/ChangeLog             |    5 +++++
 src/widgets/gnumeric-expr-entry.c |   23 +++++++++++++++++++++--
 3 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index ece8b0e..991ac23 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Gnumeric 1.10.7
 
+Andreas:
+	* Improve function syntax and formula guru tooltips.
+
 Jean:
 	* Fixed autofilter (and other) combos position. [#621817]
 
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 46479c2..466bb29 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gnumeric-expr-entry.c (gee_check_tooltip): Handle strings (and 
+	  sheet names) better.
+
 2010-06-18  Morten Welinder  <terra gnome org>
 
 	* gnumeric-expr-entry.c (gee_check_tooltip): Make this work for
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 59c5a17..c12a3b8 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -740,11 +740,13 @@ gee_check_tooltip (GnmExprEntry *gee)
 	GtkEditable *editable = GTK_EDITABLE (gee->entry);
 	gint  end;
 	char *str;
-	char *prefix;
+	char *prefix, *start;
 	char *str_end;
 	int   args = 0;
 	gchar sep = go_locale_get_arg_sep ();
 	gint  para = 0, stuff = 0;
+	gboolean in_string = FALSE;
+	char quote;
 
 	if (!gee->tooltip.enabled || gee->is_cell_renderer ||
 	    (gee->flags & GNM_EE_SINGLE_RANGE) ||
@@ -760,6 +762,23 @@ gee_check_tooltip (GnmExprEntry *gee)
 
 	str = gtk_editable_get_chars (editable, 0, end);
 	prefix = str_end = str + strlen (str) - 1;
+	start = str;
+	while (*start != '\0') {
+		if ((*start == '"' || *start == '\'') 
+		    && (start == str || start[-1] != '\\')) {
+			in_string = !in_string;
+			quote = *start;
+		}
+		start++;
+	}
+	if (in_string) {
+		stuff = 1;
+		/* note that the first condition should never be false */
+		while (str <= prefix && *prefix != quote) {
+			prefix--;
+		}
+		prefix--;
+	}
 
 	while (str < prefix) {
 		if (*prefix == ')') {
@@ -797,7 +816,7 @@ gee_check_tooltip (GnmExprEntry *gee)
 			stuff++;
 
 		if (*prefix == '\'' || *prefix == '"') {
-			char quote = *prefix--;
+			quote = *prefix--;
 
 			while (*prefix != quote ||
 			       (prefix > str && prefix[-1] == '\\')) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]