Revision: 2118 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2118&view=re... Author: cesspit Date: 2011-08-04 05:48:55 +0000 (Thu, 04 Aug 2011)
Log Message: ----------- debugger calltips cache
Modified Paths: -------------- trunk/geany-plugins/debugger/src/callbacks.c trunk/geany-plugins/debugger/src/debug.c trunk/geany-plugins/debugger/src/debug.h
Modified: trunk/geany-plugins/debugger/src/callbacks.c =================================================================== --- trunk/geany-plugins/debugger/src/callbacks.c 2011-08-03 09:49:27 UTC (rev 2117) +++ trunk/geany-plugins/debugger/src/callbacks.c 2011-08-04 05:48:55 UTC (rev 2118) @@ -89,7 +89,7 @@ scintilla_send_message(doc->editor->sci, SCI_SETMOUSEDWELLTIME, 500, 0);
/* set tab size for calltips */ - scintilla_send_message(doc->editor->sci, SCI_CALLTIPUSESTYLE, 20, NULL); + scintilla_send_message(doc->editor->sci, SCI_CALLTIPUSESTYLE, 20, (long)NULL);
/* set caret policy */ scintilla_send_message(doc->editor->sci, SCI_SETYCARETPOLICY, CARET_SLOP | CARET_JUMPS | CARET_EVEN , 3); @@ -143,11 +143,10 @@
if (word->len) { - GString *calltip = debug_get_calltip_for_expression(word->str); + gchar *calltip = debug_get_calltip_for_expression(word->str); if (calltip) { - scintilla_send_message (editor->sci, SCI_CALLTIPSHOW, nt->position, (long)calltip->str); - g_string_free(calltip, TRUE); + scintilla_send_message (editor->sci, SCI_CALLTIPSHOW, nt->position, (long)calltip); } }
Modified: trunk/geany-plugins/debugger/src/debug.c =================================================================== --- trunk/geany-plugins/debugger/src/debug.c 2011-08-03 09:49:27 UTC (rev 2117) +++ trunk/geany-plugins/debugger/src/debug.c 2011-08-04 05:48:55 UTC (rev 2118) @@ -145,6 +145,9 @@ { NULL, NULL } };
+/* calltips cache */ +static GHashTable *calltips = NULL; + /* * Handlers for GUI maked changes in watches */ @@ -547,6 +550,9 @@ /* update debug state */ debug_state = DBS_STOPPED;
+ /* clear calltips cache */ + g_hash_table_remove_all(calltips); + /* if the stop was requested for asyncronous exitig - * stop debug module and exit */ if (exit_pending) @@ -719,6 +725,10 @@ g_list_free(read_only_pages); read_only_pages = NULL;
+ /* clear and destroy calltips cache */ + g_hash_table_destroy(calltips); + calltips = NULL; + /* enable widgets */ enable_sensitive_widgets(TRUE);
@@ -1160,41 +1170,52 @@ * return list of strings for the calltip * first line is a header, others should be shifted right with tab */ -GString* debug_get_calltip_for_expression(gchar* expression) +gchar* debug_get_calltip_for_expression(gchar* expression) { - GString *calltip = NULL; - - variable *var = active_module->add_watch(expression); - if (var) + gchar *calltip = NULL; + if (!calltips || !(calltip = g_hash_table_lookup(calltips, expression))) { - calltip = get_calltip_line(var, TRUE); - if (var->has_children) + GString *calltip_str = NULL; + variable *var = active_module->add_watch(expression); + if (var) { - int lines_left = MAX_CALLTIP_HEIGHT - 1; - GList* children = active_module->get_children(var->internal->str); - GList* child = children; - while(child && lines_left) + calltip_str = get_calltip_line(var, TRUE); + if (var->has_children) { - variable *varchild = (variable*)child->data; - GString *child_string = get_calltip_line(varchild, FALSE); - g_string_append_printf(calltip, "\n%s", child_string->str); - g_string_free(child_string, TRUE); + int lines_left = MAX_CALLTIP_HEIGHT - 1; + GList* children = active_module->get_children(var->internal->str); + GList* child = children; + while(child && lines_left) + { + variable *varchild = (variable*)child->data; + GString *child_string = get_calltip_line(varchild, FALSE); + g_string_append_printf(calltip_str, "\n%s", child_string->str); + g_string_free(child_string, TRUE);
- child = child->next; - lines_left--; + child = child->next; + lines_left--; + } + if (!lines_left && child) + { + g_string_append(calltip_str, "\n\t\t........"); + } + g_list_foreach(children, (GFunc)variable_free, NULL); + g_list_free(children); } - if (!lines_left && child) + + active_module->remove_watch(var->internal->str); + variable_free(var); + + calltip = g_string_free(calltip_str, FALSE); + + if (!calltips) { - g_string_append(calltip, "\n\t\t........"); + calltips = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free); } - g_list_foreach(children, (GFunc)variable_free, NULL); - g_list_free(children); + g_hash_table_insert(calltips, g_strdup(expression), calltip); } + }
- active_module->remove_watch(var->internal->str); - variable_free(var); - } - return calltip; }
Modified: trunk/geany-plugins/debugger/src/debug.h =================================================================== --- trunk/geany-plugins/debugger/src/debug.h 2011-08-03 09:49:27 UTC (rev 2117) +++ trunk/geany-plugins/debugger/src/debug.h 2011-08-04 05:48:55 UTC (rev 2118) @@ -54,5 +54,5 @@ gboolean debug_current_instruction_have_sources(); void debug_jump_to_current_instruction(); void debug_on_file_open(GeanyDocument *doc); -GString* debug_get_calltip_for_expression(gchar* expression); +gchar* debug_get_calltip_for_expression(gchar* expression);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org