Revision: 506 Author: eht16 Date: 2006-06-29 11:22:11 -0700 (Thu, 29 Jun 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=506&view=rev
Log Message: ----------- Added function is_opening_brace(). Use is_opening_brace() for better handling of calltips.
Modified Paths: -------------- trunk/ChangeLog trunk/src/sci_cb.c trunk/src/utils.c trunk/src/utils.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-06-29 17:14:52 UTC (rev 505) +++ trunk/ChangeLog 2006-06-29 18:22:11 UTC (rev 506) @@ -17,6 +17,9 @@ src/utils.c, src/prefs.c, geany.glade, src/interface.c, src/keybindings.c, src/document.c: Implemented simple printing support. + * src/utils.c: Added function is_opening_brace(). + * src/sci_cb.c: + Use is_opening_brace() for better handling of calltips.
2006-06-28 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/src/sci_cb.c =================================================================== --- trunk/src/sci_cb.c 2006-06-29 17:14:52 UTC (rev 505) +++ trunk/src/sci_cb.c 2006-06-29 18:22:11 UTC (rev 506) @@ -356,18 +356,26 @@ const GPtrArray *tags;
if (sci == NULL) return FALSE; - + lexer = SSM(sci, SCI_GETLEXER, 0, 0); idx = document_find_by_sci(sci); if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_type == NULL) return FALSE; - + word[0] = '\0'; if (pos == -1) - { // position of '(' is unknown, so go backwards to find it + { + gchar c; + // position of '(' is unknown, so go backwards to find it pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); - // I'm not sure if utils_isbrace() 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 ( - while (pos >= 0 && ! utils_isbrace(SSM(sci, SCI_GETCHARAT, pos, 0))) 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 ( + c = SSM(sci, SCI_GETCHARAT, pos, 0); + while (pos > 0 && ! utils_is_opening_brace(c) && c != ';') + { + c = SSM(sci, SCI_GETCHARAT, pos, 0); + pos--; + } }
style = SSM(sci, SCI_GETSTYLEAT, pos, 0); @@ -680,7 +688,7 @@ GString *words;
if (sci == NULL) return; - + ftags = g_ptr_array_sized_new(50); words = g_string_sized_new(200);
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-06-29 17:14:52 UTC (rev 505) +++ trunk/src/utils.c 2006-06-29 18:22:11 UTC (rev 506) @@ -335,7 +335,7 @@ switch (c) { case '<': - case '>': return TRUE; + case '>': return TRUE; } }
@@ -346,15 +346,37 @@ case '{': case '}': case '[': - case ']': return TRUE; - default: return FALSE; + case ']': return TRUE; + default: return FALSE; }
return FALSE; }
+gboolean utils_is_opening_brace(gchar c) +{ + // match < only if desired, because I don't like it, but some people do + if (app->brace_match_ltgt) + { + switch (c) + { + case '<': return TRUE; + } + }
+ switch (c) + { + case '(': + case '{': + case '[': return TRUE; + default: return FALSE; + } + + return FALSE; +} + + void utils_set_editor_font(const gchar *font_name) { gint i, size;
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2006-06-29 17:14:52 UTC (rev 505) +++ trunk/src/utils.h 2006-06-29 18:22:11 UTC (rev 506) @@ -54,6 +54,8 @@
gboolean utils_isbrace(gchar c);
+gboolean utils_is_opening_brace(gchar c); + /* This sets the window title according to the current filename. */ void utils_set_window_title(gint index);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.