SF.net SVN: geany: [666] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Aug 3 13:27:36 UTC 2006


Revision: 666
Author:   ntrel
Date:     2006-08-03 06:27:30 -0700 (Thu, 03 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=666&view=rev

Log Message:
-----------
Wrap calltip and prevent it obscuring the current line

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/sci_cb.c
    trunk/src/utils.c
    trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-03 09:38:22 UTC (rev 665)
+++ trunk/ChangeLog	2006-08-03 13:27:30 UTC (rev 666)
@@ -1,3 +1,9 @@
+2006-08-03  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/utils.c, src/utils.h, src/sci_cb.c:
+   Wrap calltip and prevent it obscuring the current line.
+
+
 2006-08-02  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/callbacks.c:

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2006-08-03 09:38:22 UTC (rev 665)
+++ trunk/src/sci_cb.c	2006-08-03 13:27:30 UTC (rev 666)
@@ -351,6 +351,7 @@
 
 gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx)
 {
+	gint orig_pos = pos; //the position for the calltip
 	gint lexer;
 	gint style;
 	gchar word[GEANY_MAX_WORD_LENGTH];
@@ -368,6 +369,7 @@
 		gchar c;
 		// position of '(' is unknown, so go backwards to find it
 		pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0);
+		orig_pos = pos;
 		// I'm not sure if utils_is_opening_brace() is a good idea, but it is the simplest way,
 		// but we need something more intelligent than only check for '(' because e.g. LaTeX
 		// uses {, [ or (
@@ -397,7 +399,8 @@
 		else
 			calltip = g_strconcat(tag->name, " ", tag->atts.entry.arglist, NULL);
 
-		SSM(sci, SCI_CALLTIPSHOW, pos, (sptr_t) calltip);
+		utils_wrap_string(calltip, -1);
+		SSM(sci, SCI_CALLTIPSHOW, orig_pos, (sptr_t) calltip);
 		g_free(calltip);
 	}
 

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-08-03 09:38:22 UTC (rev 665)
+++ trunk/src/utils.c	2006-08-03 13:27:30 UTC (rev 666)
@@ -2532,3 +2532,25 @@
 	app->ignore_callback = FALSE;
 
 }
+
+
+/* Wraps a string in place, replacing a space with a newline character.
+ * wrapstart is the minimum position to start wrapping or -1 for default */
+gboolean utils_wrap_string(gchar *string, gint wrapstart)
+{
+	gchar *pos, *linestart;
+	gboolean ret = FALSE;
+
+	if (wrapstart < 0) wrapstart = 80;
+
+	for (pos = linestart = string; *pos != '\0'; pos++)
+	{
+		if (pos - linestart >= wrapstart && *pos == ' ')
+		{
+			*pos = '\n';
+			linestart = pos;
+			ret = TRUE;
+		}
+	}
+	return ret;
+}

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2006-08-03 09:38:22 UTC (rev 665)
+++ trunk/src/utils.h	2006-08-03 13:27:30 UTC (rev 666)
@@ -227,4 +227,8 @@
 
 void utils_document_show_hide(gint idx);
 
+/* Wraps a string in place, replacing a space with a newline character.
+ * wrapstart is the minimum position to start wrapping or -1 for default */
+gboolean utils_wrap_string(gchar *string, gint wrapstart);
+
 #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