Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Thu, 12 Apr 2012 20:44:12 Commit: b80681d13e07b28940ac287ba847a9c9c6de62ad https://github.com/geany/geany-plugins/commit/b80681d13e07b28940ac287ba847a9...
Log Message: ----------- Merge branch 'master' of github.com:geany/geany-plugins
Modified Paths: -------------- build/geanylua.m4 debugger/ChangeLog debugger/TODO debugger/src/bptree.c debugger/src/callbacks.c debugger/src/cell_renderers/cellrendererbreakicon.c debugger/src/cell_renderers/cellrendererframeicon.c debugger/src/cell_renderers/cellrenderertoggle.c debugger/src/dbm_gdb.c debugger/src/debug.c debugger/src/envtree.c debugger/src/stree.c debugger/src/stree.h debugger/src/vtree.c debugger/src/wtree.c devhelp/devhelp/Makefile.am devhelp/src/Makefile.am geanylua/Makefile.am geanylua/wscript_build geanylua/wscript_configure geanymacro/src/geanymacro.c geanynumberedbookmarks/src/geanynumberedbookmarks.c po/POTFILES.in
Modified: build/geanylua.m4 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -16,6 +16,7 @@ AC_DEFUN([GP_CHECK_GEANYLUA], LUA_VERSION=5.1 GP_CHECK_PLUGIN_DEPS([GeanyLua], [LUA], [${LUA_PKG_NAME} >= ${LUA_VERSION}]) + GP_CHECK_PLUGIN_DEPS([GeanyLua], [GMODULE], [gmodule-2.0]) GP_STATUS_PLUGIN_ADD([GeanyLua], [$enable_geanylua])
AC_CONFIG_FILES([
Modified: debugger/ChangeLog 19 files changed, 19 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,22 @@ +08-04-2012 Alexander Petukhov devel@apetukhov.ru + + * fixed a bug with wrong error message when a breakpoint condition/hitscounr can't be set + * fixed a bug when gdb exits without a stop reason + +07-04-2012 Alexander Petukhov devel@apetukhov.ru + + * fixed a bug with calltips still being shown when a pointer leaves editor window + +04-04-2012 Alexander Petukhov devel@apetukhov.ru + + * fixing exiting with code case that was unhandled and caused SIGSEGV (gdb) + * set current directory to executable's one (gdb) + * handling spaces in target and breakpoints filenames (gdb) + * fixing memory leaks on gtk_tree_row_reference_get_path and tree/list stores + * fixing SIGSEGV when selecting a cell in custom cell renderers using a keyboard + * fixing lack of breakpoint/stack frame markers after plugin unload and load + * fixing "jump to current instruction" behaviour (does not change an active frame) + 10-03-2012 Alexander Petukhov devel@apetukhov.ru
* switching between frames by clicking a frame arrow in the stack window
Modified: debugger/TODO 39 files changed, 20 insertions(+), 19 deletions(-) =================================================================== @@ -1,26 +1,27 @@ BUGS: -- terminal stops to produce any output after some debug seesions -- tooltip appears even if a pointer in no longer inside editor window -- check possible memory leaks on a)gtk_tree_row_reference_get_path b)missing unrefs on tree/list stores -- cell_renderer_toogle SIGSEGV in cell_renderer_toggle_activate when activating a cell using a keyboard (event->button == NULL) -- debug geany with debugger project. switch frames then step over -> continue instead, then close geany being debugged -> dbm_gdb.c:502 (no step reason, probably the record from the previos step command???)
FEATURES: -- custom tooltip with sticking facilities -- don't hide a tooltip until run hasn't happent, move it if document is being scrolled -- use lexer to lookup for a symbol under cursor when presenting a tooltip -- geany menu integration -- toolbar buttons -- margin context menu -- step back -- tree views column width/autowidth -- attach functionality: dbm_ methods providing target lists, common dialog -- android support -- bashdb support -- windows support + +- debug callbacks names (refactoring) - gdb backend step speed -- debug callbacks names +- windows support + +- attach functionality: dbm_ methods providing target lists, common dialog - interrupt thread using stack window -- custom tooltip on breaks and stack trace windows with code snippet around break or frame +- step back + +- margin context menu +- editor context menu (add watch, add/remove breakpoint) + - font from the geany settings for a message window +- use left/right keys to collapse/expand in breakpoints tree +- use lexer to lookup for a symbol under cursor when presenting a tooltip - a button in the upper right path of a right notebook for a hiding/showing button panel +- minimum width of the debug panel notebooks +- tree views column width/autowidth +- custom tooltip on breaks and stack trace windows with code snippet around break or frame +- custom tooltip(in an editor in debug mode) with sticking facilities +- don't hide a tooltip until run hasn't happent, move it if document is being scrolled + +- android support +- bashdb support
Modified: debugger/src/bptree.c 5 files changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -616,6 +616,7 @@ gboolean bptree_init(move_to_line_cb cb) G_TYPE_STRING); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); + g_object_unref(store); /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); @@ -802,7 +803,9 @@ void bptree_add_breakpoint(breakpoint* bp) } else { - gtk_tree_model_get_iter(model, &file_iter, gtk_tree_row_reference_get_path(file_reference)); + GtkTreePath *path = gtk_tree_row_reference_get_path(file_reference); + gtk_tree_model_get_iter(model, &file_iter, path); + gtk_tree_path_free(path); } /* lookup where to insert new row */
Modified: debugger/src/callbacks.c 26 files changed, 23 insertions(+), 3 deletions(-) =================================================================== @@ -155,6 +155,21 @@ void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_data) }
/* + * Handles mouse leave event to check if a calltip is still present and hides it if yes + */ +static gint leave_signal; +static gboolean on_mouse_leave(GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + ScintillaObject *so = (ScintillaObject*)widget; + if (scintilla_send_message (so, SCI_CALLTIPACTIVE, 0, 0)) + { + g_signal_handler_disconnect(G_OBJECT(widget), leave_signal); + scintilla_send_message (so, SCI_CALLTIPCANCEL, 0, 0); + } + return FALSE; +} + +/* * Occures on notify from editor. * Handles margin click to set/remove breakpoint */ @@ -194,7 +209,7 @@ gboolean on_editor_notify( { if (DBS_STOPPED != debug_get_state ()) break; - + /* get a word under the cursor */ GString *word = get_word_at_position(editor->sci, nt->position);
@@ -203,6 +218,7 @@ gboolean on_editor_notify( gchar *calltip = debug_get_calltip_for_expression(word->str); if (calltip) { + leave_signal = g_signal_connect(G_OBJECT(editor->sci), "leave-notify-event", G_CALLBACK(on_mouse_leave), NULL); scintilla_send_message (editor->sci, SCI_CALLTIPSHOW, nt->position, (long)calltip); } } @@ -216,7 +232,11 @@ gboolean on_editor_notify( if (DBS_STOPPED != debug_get_state ()) break;
- scintilla_send_message (editor->sci, SCI_CALLTIPCANCEL, 0, 0); + if (scintilla_send_message (editor->sci, SCI_CALLTIPACTIVE, 0, 0)) + { + g_signal_handler_disconnect(G_OBJECT(editor->sci), leave_signal); + scintilla_send_message (editor->sci, SCI_CALLTIPCANCEL, 0, 0); + } break; } case SCN_MODIFYATTEMPTRO: @@ -330,7 +350,7 @@ gboolean keys_callback(guint key_id) { debug_jump_to_current_instruction(); gtk_widget_set_sensitive(tab_call_stack, FALSE); - stree_select_first_frame(); + stree_select_first_frame(FALSE); gtk_widget_set_sensitive(tab_call_stack, TRUE); } }
Modified: debugger/src/cell_renderers/cellrendererbreakicon.c 50 files changed, 31 insertions(+), 19 deletions(-) =================================================================== @@ -261,8 +261,12 @@ static void cell_renderer_break_icon_render(GtkCellRenderer *cell, GdkDrawable * static gint cell_renderer_break_icon_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit (cell, clicked_signal, 0, path); } @@ -411,24 +415,32 @@ GType cell_renderer_break_icon_get_type(void) if(0 == cell_break_icon_type) { - static const GTypeInfo cell_break_icon_info = + if ( (cell_break_icon_type = g_type_from_name("CellRendererBreakIcon")) ) { - sizeof (CellRendererBreakIconClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) cell_renderer_break_icon_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CellRendererBreakIcon), - 0, /* n_preallocs */ - (GInstanceInitFunc) cell_renderer_break_icon_init, - }; - - /* Derive from GtkCellRenderer */ - cell_break_icon_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, - "CellRendererBreakIcon", - &cell_break_icon_info, - 0); + parent_class = g_type_class_peek_static(g_type_parent(cell_break_icon_type)); + clicked_signal = g_signal_lookup("clicked", cell_break_icon_type); + } + else + { + static const GTypeInfo cell_break_icon_info = + { + sizeof (CellRendererBreakIconClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) cell_renderer_break_icon_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CellRendererBreakIcon), + 0, /* n_preallocs */ + (GInstanceInitFunc) cell_renderer_break_icon_init, + }; + + /* Derive from GtkCellRenderer */ + cell_break_icon_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, + "CellRendererBreakIcon", + &cell_break_icon_info, + 0); + } } return cell_break_icon_type;
Modified: debugger/src/cell_renderers/cellrendererframeicon.c 50 files changed, 31 insertions(+), 19 deletions(-) =================================================================== @@ -45,8 +45,12 @@ enum { static gint cell_renderer_frame_icon_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit (cell, clicked_signal, 0, path); } @@ -311,24 +315,32 @@ GType cell_renderer_frame_icon_get_type(void) if(0 == cell_frame_icon_type) { - static const GTypeInfo cell_frame_icon_info = + if ( (cell_frame_icon_type = g_type_from_name("CellRendererFrameIcon")) ) { - sizeof (CellRendererFrameIconClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) cell_renderer_frame_icon_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CellRendererFrameIcon), - 0, /* n_preallocs */ - (GInstanceInitFunc) cell_renderer_frame_icon_init, - }; - - /* Derive from GtkCellRenderer */ - cell_frame_icon_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, - "CellRendererFrameIcon", - &cell_frame_icon_info, - 0); + parent_class = g_type_class_peek_static(g_type_parent(cell_frame_icon_type)); + clicked_signal = g_signal_lookup("clicked", cell_frame_icon_type); + } + else + { + static const GTypeInfo cell_frame_icon_info = + { + sizeof (CellRendererFrameIconClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) cell_renderer_frame_icon_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CellRendererFrameIcon), + 0, /* n_preallocs */ + (GInstanceInitFunc) cell_renderer_frame_icon_init, + }; + + /* Derive from GtkCellRenderer */ + cell_frame_icon_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, + "CellRendererFrameIcon", + &cell_frame_icon_info, + 0); + } } return cell_frame_icon_type;
Modified: debugger/src/cell_renderers/cellrenderertoggle.c 16 files changed, 10 insertions(+), 6 deletions(-) =================================================================== @@ -35,8 +35,12 @@ static gint cell_renderer_toggle_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) { - if (event->button.x >= cell_area->x && - event->button.x < (cell_area->x + cell_area->width)) + if (!event || + ( + event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width) + ) + ) { g_signal_emit_by_name(cell, "toggled", path); } @@ -66,9 +70,9 @@ static void cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class) */ GType cell_renderer_toggle_get_type(void) { - static GType cell_brekpoint_type = 0; + static GType cell_break_toggle_type = 0; - if(0 == cell_brekpoint_type) + if(0 == cell_break_toggle_type && !(cell_break_toggle_type = g_type_from_name("CellRendererToggle"))) { static const GTypeInfo cell_file_info = { @@ -84,13 +88,13 @@ GType cell_renderer_toggle_get_type(void) };
/* Derive from GtkToggleCellRenderer */ - cell_brekpoint_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE, + cell_break_toggle_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE, "CellRendererToggle", &cell_file_info, 0); } - return cell_brekpoint_type; + return cell_break_toggle_type; }
/*
Modified: debugger/src/dbm_gdb.c 44 files changed, 34 insertions(+), 10 deletions(-) =================================================================== @@ -72,6 +72,7 @@ enum sr { SR_EXITED_NORMALLY, SR_SIGNAL_RECIEVED, SR_EXITED_SIGNALLED, + SR_EXITED_WITH_CODE, } stop_reason;
/* callbacks to use for messaging, error reporting and state change alerting */ @@ -490,11 +491,13 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d stop_reason = SR_EXITED_NORMALLY; else if (!strcmp(reason, "exited-signalled")) stop_reason = SR_EXITED_SIGNALLED; + else if (!strcmp(reason, "exited")) + stop_reason = SR_EXITED_WITH_CODE; } else { /* somehow, sometimes there can be no stop reason */ - stop_reason = SR_END_STEPPING_RANGE; + stop_reason = SR_EXITED_NORMALLY; } if (SR_BREAKPOINT_HIT == stop_reason || SR_END_STEPPING_RANGE == stop_reason || SR_SIGNAL_RECIEVED == stop_reason) @@ -531,8 +534,18 @@ static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer d dbg_cbs->set_stopped(atoi(thread_id)); } } - else if (stop_reason == SR_EXITED_NORMALLY || stop_reason == SR_EXITED_SIGNALLED) + else if (stop_reason == SR_EXITED_NORMALLY || stop_reason == SR_EXITED_SIGNALLED || stop_reason == SR_EXITED_WITH_CODE) { + if (stop_reason == SR_EXITED_WITH_CODE) + { + gchar *code = strstr(reason + strlen(reason) + 1,"exit-code="") + strlen("exit-code=""); + *(strchr(code, '"')) = '\0'; + gchar *message = g_strdup_printf(_("Program exited with code "%i""), (int)(char)strtol(code, NULL, 8)); + dbg_cbs->report_error(message); + + g_free(message); + } + stop(); } } @@ -692,13 +705,17 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit /* spawn GDB */ const gchar *exclude[] = { "LANG", NULL }; gchar **gdb_env = utils_copy_environment(exclude, "LANG", "C", NULL); - if (!g_spawn_async_with_pipes(NULL, (gchar**)gdb_args, gdb_env, + gchar *working_directory = g_path_get_dirname(file); + if (!g_spawn_async_with_pipes(working_directory, (gchar**)gdb_args, gdb_env, GDB_SPAWN_FLAGS, NULL, NULL, &gdb_pid, &gdb_in, &gdb_out, NULL, &err)) { dbg_cbs->report_error(_("Failed to spawn gdb process")); + g_free(working_directory); + g_strfreev(gdb_env); return FALSE; } + g_free(working_directory); g_strfreev(gdb_env); /* move gdb to it's own process group */ @@ -743,8 +760,8 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit
/* loading file */ GString *command = g_string_new(""); - g_string_printf(command, "-file-exec-and-symbols %s", file); - commands = add_to_queue(commands, _("~"Loading target file ...""), command->str, _("Error loading file"), FALSE); + g_string_printf(command, "-file-exec-and-symbols "%s"", file); + commands = add_to_queue(commands, _("~"Loading target file.\n""), command->str, _("Error loading file"), FALSE); g_string_free(command, TRUE);
/* setting asyncronous mode */ @@ -792,7 +809,7 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit { breakpoint *bp = (breakpoint*)biter->data; command = g_string_new(""); - g_string_printf(command, "-break-insert -f %s:%i", bp->file, bp->line); + g_string_printf(command, "-break-insert -f "\"%s\":%i"", bp->file, bp->line);
GString *error_message = g_string_new(""); g_string_printf(error_message, _("Breakpoint at %s:%i cannot be set\nDebugger message: %s"), bp->file, bp->line, "%s"); @@ -800,7 +817,6 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit commands = add_to_queue(commands, NULL, command->str, error_message->str, TRUE);
g_string_free(command, TRUE); - g_string_free(error_message, TRUE);
if (bp->hitscount) { @@ -824,6 +840,8 @@ gboolean run(const gchar* file, const gchar* commandline, GList* env, GList *wit g_string_free(command, TRUE); }
+ g_string_free(error_message, TRUE); + bp_index++; biter = biter->next; } @@ -934,8 +952,14 @@ int get_break_number(char* file, int line) *strchr(bstart, '"') = '\0'; int bline = atoi(bstart); - if (!strcmp(fname, file) && bline == line) + gchar *file_quoted = g_strdup_printf("\"%s\"", file); + int break_found = !strcmp(fname, file_quoted) && bline == line; + g_free(file_quoted); + + if (break_found) + { return num; + } bstart += strlen(bstart) + 1; } @@ -957,11 +981,11 @@ gboolean set_break(breakpoint* bp, break_set_activity bsa) gchar *record = NULL; /* 1. insert breakpoint */ - sprintf (command, "-break-insert %s:%i", bp->file, bp->line); + sprintf (command, "-break-insert "\"%s\":%i"", bp->file, bp->line); if (RC_DONE != exec_sync_command(command, TRUE, &record)) { g_free(record); - sprintf (command, "-break-insert -f %s:%i", bp->file, bp->line); + sprintf (command, "-break-insert -f "\"%s\":%i"", bp->file, bp->line); if (RC_DONE != exec_sync_command(command, TRUE, &record)) { g_free(record);
Modified: debugger/src/debug.c 16 files changed, 13 insertions(+), 3 deletions(-) =================================================================== @@ -240,7 +240,9 @@ static void on_watch_changed(GtkCellRendererText *renderer, gchar *path, gchar * -1);
/* check if it is empty row */ - gboolean is_empty_row = !gtk_tree_path_compare (tree_path, wtree_empty_path()); + GtkTreePath *empty_path = wtree_empty_path(); + gboolean is_empty_row = !gtk_tree_path_compare (tree_path, empty_path); + gtk_tree_path_free(empty_path);
gchar *striped = g_strstrip(g_strdup(new_text)); if (!strlen(striped) && @@ -447,6 +449,8 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even
gtk_tree_store_remove(wstore, &titer); + + gtk_tree_path_free(path); } iter = iter->next; @@ -455,7 +459,11 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even /* if all (with or without empty row) was selected - set empty row as a path to be selected after deleting */ if (!reference_to_select) - reference_to_select = gtk_tree_row_reference_new (gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)), wtree_empty_path()); + { + GtkTreePath *path = wtree_empty_path(); + reference_to_select = gtk_tree_row_reference_new (gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)), path); + gtk_tree_path_free(path); + }
/* set selection */ gtk_tree_selection_unselect_all(selection); @@ -471,6 +479,8 @@ static gboolean on_watch_key_pressed_callback(GtkWidget *widget, GdkEvent *even config_set_debug_changed(); }
+ gtk_tree_path_free(empty_path); + /* free rows list */ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (rows); @@ -669,7 +679,7 @@ static void on_debugger_stopped (int thread_id) stree_add(f); iter = g_list_next(iter); } - stree_select_first_frame(); + stree_select_first_frame(TRUE);
/* files */ GList *files = active_module->get_files();
Modified: debugger/src/envtree.c 23 files changed, 18 insertions(+), 5 deletions(-) =================================================================== @@ -151,6 +151,7 @@ static void delete_selected_rows() gtk_tree_model_get_iter(model, &titer, path); gtk_list_store_remove(store, &titer);
+ gtk_tree_path_free(path); iter = iter->next; }
@@ -159,6 +160,7 @@ static void delete_selected_rows() GtkTreePath *path = gtk_tree_row_reference_get_path(reference_to_select); gtk_tree_selection_select_path(selection, path); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(tree), path, NULL, TRUE, 0.5, 0.5); + gtk_tree_path_free(path);
/* free references list */ g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL); @@ -168,6 +170,8 @@ static void delete_selected_rows() /* free selection reference */ gtk_tree_row_reference_free(reference_to_select);
+ gtk_tree_path_free(empty_path); + /* free rows list */ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); g_list_free (rows); @@ -213,9 +217,11 @@ static void on_render_value(GtkTreeViewColumn *tree_column, { /* do not allow to edit value for empty row */ GtkTreePath *path = gtk_tree_model_get_path(tree_model, iter); - gboolean empty = !gtk_tree_path_compare(path, gtk_tree_row_reference_get_path(empty_row)); + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + gboolean empty = !gtk_tree_path_compare(path, empty_path); g_object_set (cell, "editable", entering_new_var || !empty, NULL); gtk_tree_path_free(path); + gtk_tree_path_free(empty_path); } }
@@ -226,8 +232,10 @@ static void on_value_changed(GtkCellRendererText *renderer, gchar *path, gchar * { GtkTreeIter iter; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); - - gboolean empty = !gtk_tree_path_compare(tree_path, gtk_tree_row_reference_get_path(empty_row)); + + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + gboolean empty = !gtk_tree_path_compare(tree_path, empty_path); + gtk_tree_path_free(empty_path);
gtk_tree_model_get_iter ( model, @@ -300,7 +308,8 @@ static void on_value_editing_cancelled(GtkCellRenderer *renderer, gpointer user_ { /* check whether escape was pressed when editing new variable value cell */ - if(!gtk_tree_path_compare(being_edited_value, gtk_tree_row_reference_get_path(empty_row))) + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row); + if(!gtk_tree_path_compare(being_edited_value, empty_path)) { /* if so - clear name sell */ GtkTreeIter iter; @@ -318,6 +327,7 @@ static void on_value_editing_cancelled(GtkCellRenderer *renderer, gpointer user_ g_object_set (renderer_value, "editable", FALSE, NULL);
gtk_tree_path_free(being_edited_value); + gtk_tree_path_free(empty_path); }
/* @@ -327,8 +337,9 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n { GtkTreeIter iter; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);
- gboolean empty = !gtk_tree_path_compare(tree_path, gtk_tree_row_reference_get_path(empty_row)); + gboolean empty = !gtk_tree_path_compare(tree_path, empty_path);
gtk_tree_model_get_iter ( model, @@ -371,6 +382,7 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n } gtk_tree_path_free(tree_path); + gtk_tree_path_free(empty_path); g_free(oldvalue); g_free(striped); } @@ -387,6 +399,7 @@ static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *n G_TYPE_STRING); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); + g_object_unref(store); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE); g_signal_connect(G_OBJECT(tree), "key-press-event", G_CALLBACK (on_envtree_keypressed), NULL);
Modified: debugger/src/stree.c 27 files changed, 19 insertions(+), 8 deletions(-) =================================================================== @@ -136,7 +136,7 @@ static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean key } else if (column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), S_ADRESS && bx >= start_pos && bx < start_pos + width)) { - gtk_tooltip_set_text(tooltip, gtk_tree_path_get_indices(tpath)[1] == active_frame_index ? _("Active frame") : _("Switch to a frame")); + gtk_tooltip_set_text(tooltip, gtk_tree_path_get_indices(tpath)[1] == active_frame_index ? _("Active frame") : _("Click an arrow to switch to a frame")); gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); show = TRUE; } @@ -333,6 +333,7 @@ static void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_ model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); + g_object_unref(store); /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); @@ -411,7 +412,9 @@ void stree_add(frame *f) { GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *path = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, path); + gtk_tree_path_free(path);
GtkTreeIter frame_iter; gtk_tree_store_insert_before(store, &frame_iter, &thread_iter, 0); @@ -437,16 +440,22 @@ void stree_clear() /* * select first frame in the stack */ -void stree_select_first_frame() +void stree_select_first_frame(gboolean make_active) { gtk_tree_view_expand_all(GTK_TREE_VIEW(tree)); GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter, frame_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *active_path = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, active_path); + gtk_tree_path_free(active_path); if(gtk_tree_model_iter_children(model, &frame_iter, &thread_iter)) { - gtk_tree_store_set (store, &frame_iter, S_ACTIVE, TRUE, -1); + if (make_active) + { + gtk_tree_store_set (store, &frame_iter, S_ACTIVE, TRUE, -1); + active_frame_index = 0; + }
GtkTreePath* path = gtk_tree_model_get_path(model, &frame_iter); @@ -455,8 +464,6 @@ void stree_select_first_frame() path);
gtk_tree_path_free(path); - - active_frame_index = 0; } }
@@ -534,6 +541,8 @@ void stree_remove_thread(int thread_id) gtk_tree_store_remove(store, &iter);
g_hash_table_remove(threads, (gpointer)(glong)thread_id); + + gtk_tree_path_free(tpath); }
/* @@ -543,7 +552,9 @@ void stree_remove_frames() { GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); GtkTreeIter thread_iter; - gtk_tree_model_get_iter(model, &thread_iter, gtk_tree_row_reference_get_path(reference)); + GtkTreePath *tpath = gtk_tree_row_reference_get_path(reference); + gtk_tree_model_get_iter(model, &thread_iter, tpath); + gtk_tree_path_free(tpath);
GtkTreeIter child; if (gtk_tree_model_iter_children(model, &child, &thread_iter))
Modified: debugger/src/stree.h 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -28,7 +28,7 @@ void stree_add_thread(int thread_id); void stree_remove_thread(int thread_id);
-void stree_select_first_frame(); +void stree_select_first_frame(gboolean make_active); void stree_remove_frames();
void stree_set_active_thread_id(int thread_id);
Modified: debugger/src/vtree.c 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -148,6 +148,7 @@ void render_value(GtkTreeViewColumn *tree_column, G_TYPE_INT, G_TYPE_INT); GtkWidget* tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); + g_object_unref(store); /* set tree view parameters */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
Modified: debugger/src/wtree.c 6 files changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -99,10 +99,12 @@ static void on_render_name(GtkTreeViewColumn *tree_column, GtkTreeIter wtree_empty_row() { GtkTreeIter empty; - + + GtkTreePath *path = gtk_tree_row_reference_get_path(empty_row); gtk_tree_model_get_iter(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)), &empty, - gtk_tree_row_reference_get_path(empty_row)); + path); + gtk_tree_path_free(path); return empty; }
Modified: devhelp/devhelp/Makefile.am 6 files changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -1,3 +1,7 @@ +if ENABLE_DEVHELP +noinst_LTLIBRARIES = libdevhelp-2.la +endif + dh_headers = \ dh-assistant.h \ dh-assistant-view.h \ @@ -28,8 +32,6 @@ EXTRA_DIST = \ dh-enum-types.c.template \ dh-enum-types.h.template
-noinst_LTLIBRARIES = libdevhelp-2.la - libdevhelp_2_la_SOURCES = \ dh-assistant.c \ dh-assistant-view.c \
Modified: devhelp/src/Makefile.am 1 files changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -1,5 +1,4 @@ include $(top_srcdir)/build/vars.build.mk -include $(top_srcdir)/build/vars.docs.mk
plugin = devhelp
Modified: geanylua/Makefile.am 2 files changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -38,10 +38,12 @@ libgeanylua_la_SOURCES = \
geanylua_la_CFLAGS = \ $(AM_CFLAGS) \ + $(GMODULE_CFLAGS) \ $(LUA_CFLAGS)
geanylua_la_LIBADD = \ $(COMMONLIBS) \ + $(GMODULE_LIBS) \ $(LUA_LIBS)
libgeanylua_la_CFLAGS = $(geanylua_la_CFLAGS)
Modified: geanylua/wscript_build 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -28,7 +28,7 @@ sources = ['geanylua.c'] lua_sources = [ 'glspi_init.c', 'glspi_app.c', 'glspi_dlg.c', 'glspi_doc.c', 'glspi_kfile.c', 'glspi_run.c', 'glspi_sci.c', 'gsdlg_lua.c' ] -libraries = ['LUA'] +libraries = ['LUA', 'GMODULE']
build_plugin(bld, name, sources=sources, libraries=libraries)
Modified: geanylua/wscript_configure 6 files changed, 6 insertions(+), 0 deletions(-) =================================================================== @@ -42,3 +42,9 @@ def try_to_find_lua_package(): found_lua_package = try_to_find_lua_package() if not found_lua_package: raise ConfigurationError('You need Lua 5.1 for the GeanyLua plugin') + +check_cfg_cached(conf, + package='gmodule-2.0', + mandatory=True, + uselib_store='GMODULE', + args='--cflags --libs')
Modified: geanymacro/src/geanymacro.c 636 files changed, 504 insertions(+), 132 deletions(-) =================================================================== @@ -29,10 +29,7 @@ typedef struct { gint message; - /* I'm leaving wparam commented out as this may prove useful if it's used by a Scintilla - * message that's recorded in a macro that I'm not aware of yet - */ - /* gulong wparam; */ + gulong wparam; glong lparam; } MacroEvent;
@@ -100,39 +97,39 @@ {SCI_WORDLEFTEND,N_("Move Cursor to end of Word to the Left")}, {SCI_WORDRIGHTEND,N_("Move Cursor to end of Word to the Right")},
-{SCI_LINEDOWNEXTEND,N_("Move Selection down a line")}, -{SCI_LINEUPEXTEND,N_("Move Selection up a line")}, -{SCI_CHARLEFTEXTEND,N_("Move Selection Left a line")}, -{SCI_CHARRIGHTEXTEND,N_("Move Selection Right a line")}, -{SCI_WORDLEFTEXTEND,N_("Move Selection to start of Word to the Left")}, -{SCI_WORDRIGHTEXTEND,N_("Move Selection to start of Word to the Right")}, -{SCI_WORDPARTLEFTEXTEND,N_("Move Selection to start of Part of Word to the Left")}, -{SCI_WORDPARTRIGHTEXTEND,N_("Move Selection to start of Part of Word to the Right")}, -{SCI_HOMEEXTEND,N_("Move Selection to start of line")}, -{SCI_LINEENDEXTEND,N_("Move Selection to end of line")}, -{SCI_DOCUMENTSTARTEXTEND,N_("Move Selection to start of document")}, -{SCI_DOCUMENTENDEXTEND,N_("Move Selection to end of document")}, -{SCI_PAGEUPEXTEND,N_("Move Selection up one Page")}, -{SCI_PAGEDOWNEXTEND,N_("Move Selection down one Page")}, -{SCI_HOMEDISPLAYEXTEND,N_("Move Selection to fist visible character")}, -{SCI_LINEENDDISPLAYEXTEND,N_("Move Selection to last visible character")}, -{SCI_VCHOMEEXTEND,N_("Move Selection to 1st non-whitespace character of line, or 1st character of\ +{SCI_LINEDOWNEXTEND,N_("Extend Selection down a line")}, +{SCI_LINEUPEXTEND,N_("Extend Selection up a line")}, +{SCI_CHARLEFTEXTEND,N_("Extend Selection Left a line")}, +{SCI_CHARRIGHTEXTEND,N_("Extend Selection Right a line")}, +{SCI_WORDLEFTEXTEND,N_("Extend Selection to start of Word to the Left")}, +{SCI_WORDRIGHTEXTEND,N_("Extend Selection to start of Word to the Right")}, +{SCI_WORDPARTLEFTEXTEND,N_("Extend Selection to start of Part of Word to the Left")}, +{SCI_WORDPARTRIGHTEXTEND,N_("Extend Selection to start of Part of Word to the Right")}, +{SCI_HOMEEXTEND,N_("Extend Selection to start of line")}, +{SCI_LINEENDEXTEND,N_("Extend Selection to end of line")}, +{SCI_DOCUMENTSTARTEXTEND,N_("Extend Selection to start of document")}, +{SCI_DOCUMENTENDEXTEND,N_("Extend Selection to end of document")}, +{SCI_PAGEUPEXTEND,N_("Extend Selection up one Page")}, +{SCI_PAGEDOWNEXTEND,N_("Extend Selection down one Page")}, +{SCI_HOMEDISPLAYEXTEND,N_("Extend Selection to fist visible character")}, +{SCI_LINEENDDISPLAYEXTEND,N_("Extend Selection to last visible character")}, +{SCI_VCHOMEEXTEND,N_("Extend Selection to 1st non-whitespace character of line, or 1st character of\ line if already at 1st non-whitespace character")}, -{SCI_PARADOWNEXTEND,N_("Move Selection to begining of next paragraph")}, -{SCI_PARAUPEXTEND,N_("Move Selection up to beginning of current/previous paragraph")}, -{SCI_WORDLEFTENDEXTEND,N_("Move Selection to end of Word to the Left")}, -{SCI_WORDRIGHTENDEXTEND,N_("Move Selection to end of Word to the Right")}, - -{SCI_LINEDOWNRECTEXTEND,N_("Move Rectangular Selection down a line")}, -{SCI_LINEUPRECTEXTEND,N_("Move Rectangular Selection up a line")}, -{SCI_CHARLEFTRECTEXTEND,N_("Move Rectangular Selection Left a line")}, -{SCI_CHARRIGHTRECTEXTEND,N_("Move Rectangular Selection Right a line")}, -{SCI_HOMERECTEXTEND,N_("Move Rectangular Selection to start of line")}, -{SCI_LINEENDRECTEXTEND,N_("Move Rectangular Selection to end of line")}, -{SCI_PAGEUPRECTEXTEND,N_("Move Rectangular Selection up one Page")}, -{SCI_PAGEDOWNRECTEXTEND,N_("Move Rectangular Selection down one Page")}, -{SCI_VCHOMERECTEXTEND,N_("Move Rectangular Selection to 1st non-whitespace character of line, or 1st\ - character of line if already at 1st non-whitespace character")}, +{SCI_PARADOWNEXTEND,N_("Extend Selection to begining of next paragraph")}, +{SCI_PARAUPEXTEND,N_("Extend Selection up to beginning of current/previous paragraph")}, +{SCI_WORDLEFTENDEXTEND,N_("Extend Selection to end of Word to the Left")}, +{SCI_WORDRIGHTENDEXTEND,N_("Extend Selection to end of Word to the Right")}, + +{SCI_LINEDOWNRECTEXTEND,N_("Extend Rectangular Selection down a line")}, +{SCI_LINEUPRECTEXTEND,N_("Extend Rectangular Selection up a line")}, +{SCI_CHARLEFTRECTEXTEND,N_("Extend Rectangular Selection Left a line")}, +{SCI_CHARRIGHTRECTEXTEND,N_("Extend Rectangular Selection Right a line")}, +{SCI_HOMERECTEXTEND,N_("Extend Rectangular Selection to start of line")}, +{SCI_LINEENDRECTEXTEND,N_("Extend Rectangular Selection to end of line")}, +{SCI_PAGEUPRECTEXTEND,N_("Extend Rectangular Selection up one Page")}, +{SCI_PAGEDOWNRECTEXTEND,N_("Extend Rectangular Selection down one Page")}, +{SCI_VCHOMERECTEXTEND,N_("Extend Rectangular Selection to 1st non-whitespace character of line, or\ + 1st character of line if already at 1st non-whitespace character")},
{SCI_CANCEL,N_("Cancel Selection")},
@@ -150,7 +147,11 @@ {SCI_SELECTIONDUPLICATE,N_("Insert duplicate of selected text after selection. If nothing selected,\ duplicate line")},
-/* editor commands that don't seem to work well in editing +{SCI_SEARCHNEXT,"Search for next """}, +{SCI_SEARCHPREV,"Search for previous """}, +{SCI_SEARCHANCHOR,"Set start of search to beginning of selection"}, + +/* editor commands that don't seem to work well in editing * {SCI_FORMFEED,N_("FormFeed")}, * * other commands ommited as they don't appear to do anything different to existing commands @@ -178,7 +179,7 @@ enum GEANY_MACRO_BUTTON { PLUGIN_VERSION_CHECK(147)
PLUGIN_SET_INFO(_("Macros"),_("Macros for Geany"), - "1.0","William Fraser william.fraser@virgin.net"); + "1.1","William Fraser william.fraser@virgin.net");
/* Plugin user alterable settings */ static gboolean bSaveMacros=TRUE; @@ -207,20 +208,27 @@ enum GEANY_MACRO_BUTTON { MacroEvent *me; GSList * gslTemp=gsl;
+ /* free data held in GSLIST structure */ while(gslTemp!=NULL) { me=gslTemp->data; - /* check to see if it's a message that has string attached, and free it if so */ - if(me->message==SCI_REPLACESEL) + /* check to see if it's a message that has string attached, and free it if so + * lparam might be NULL for SCI_SEARCHNEXT or SCI_SEARCHPREV but g_free is ok + * with this + */ + if(me->message==SCI_REPLACESEL || + me->message==SCI_SEARCHNEXT || + me->message==SCI_SEARCHPREV) g_free((void*)(me->lparam));
g_free((void*)(gslTemp->data)); gslTemp=g_slist_next(gslTemp); }
- g_slist_free(gsl); + /* free SLIST structure */ + g_slist_free(gsl);
- return NULL; + return NULL; }
@@ -316,6 +324,7 @@ static void ClearAllMacros(void) FreeMacro((Macro*)(gsl->data)); gsl=g_slist_next(gsl); } + g_slist_free(mList); mList=NULL; } @@ -327,15 +336,46 @@ static void ReplayMacro(Macro *m) MacroEvent *me; GSList *gsl=m->MacroEvents; ScintillaObject* sci=document_get_current()->editor->sci; + gchar *clipboardcontents; + gboolean bFoundAnchor=FALSE;
scintilla_send_message(sci,SCI_BEGINUNDOACTION,0,0);
while(gsl!=NULL) { me=gsl->data; -/* may be needed if come across any scintilla messages that use wparam */ -/* scintilla_send_message(sci,me->message,me->wparam,me->lparam); */ - scintilla_send_message(sci,me->message,0,me->lparam); + + /* make not if anchor has been found */ + if(me->message==SCI_SEARCHANCHOR) + bFoundAnchor=TRUE; + + /* possibility that user edited macros might not have anchor before search */ + if((me->message==SCI_SEARCHNEXT || me->message==SCI_SEARCHPREV) && + bFoundAnchor==FALSE) + { + scintilla_send_message(sci,SCI_SEARCHANCHOR,0,0); + bFoundAnchor=TRUE; + } + + /* search might use clipboard to look for: check & hanndle */ + if((me->message==SCI_SEARCHNEXT || me->message==SCI_SEARCHPREV) && + ((gchar*)me->lparam)==NULL) + { + clipboardcontents=gtk_clipboard_wait_for_text(gtk_clipboard_get( + GDK_SELECTION_CLIPBOARD)); + /* ensure there is something in the clipboard */ + if(clipboardcontents==NULL) + { + dialogs_show_msgbox(GTK_MESSAGE_INFO,_("No text in clipboard!")); + break; + } + + scintilla_send_message(sci,me->message,me->wparam,(glong)clipboardcontents); + } + else + scintilla_send_message(sci,me->message,me->wparam,me->lparam); + + /* move to next macro event */ gsl=g_slist_next(gsl); }
@@ -382,9 +422,26 @@ static void ReplayMacro(Macro *m) /* get event number */ me->message=strtoll(s[(*k)++],NULL,10);
+ /* default to 0 */ + me->wparam=0; + /* now handle lparam if required */ switch(me->message) { + case SCI_SEARCHNEXT: + case SCI_SEARCHPREV: + /* get text */ + me->lparam=(glong)(g_strcompress(s[(*k)++])); + /* if text is empty string replace with NULL to signify use clipboard */ + if((*((gchar*)(me->lparam)))==0) + { + g_free((gchar*)me->lparam); + me->lparam=(glong)NULL; + } + + /* get search flags */ + me->wparam=strtoll(s[(*k)++],NULL,10); + break; case SCI_REPLACESEL: /* get text */ me->lparam=(glong)(g_strcompress(s[(*k)++])); @@ -415,6 +472,27 @@ static void ReplayMacro(Macro *m) /* now handle lparam if required */ switch(me->message) { + case SCI_SEARCHNEXT: + case SCI_SEARCHPREV: + /* check if string is NULL */ + if(((gchar*)(me->lparam))==NULL) + { + /* now merge code and data */ + szNumberAndData=g_strdup_printf("%s,,%lu",szMacroNumber,me->wparam); + /* free memory */ + g_free(szMacroNumber); + return szNumberAndData; + } + + /* first get string reprisentation of data */ + pTemp=MakeStringSaveable((gchar*)(me->lparam)); + /* now merge code and data */ + szNumberAndData=g_strdup_printf("%s,%s,%lu",szMacroNumber,pTemp,me->wparam); + /* free memory */ + g_free(szMacroNumber); + g_free(pTemp); + return szNumberAndData; + case SCI_REPLACESEL: /* first get string reprisentation of data */ pTemp=MakeStringSaveable((gchar*)(me->lparam)); @@ -424,6 +502,7 @@ static void ReplayMacro(Macro *m) g_free(szMacroNumber); g_free(pTemp); return szNumberAndData; + /* default handler for messages without extra data */ default: return szMacroNumber; @@ -431,9 +510,15 @@ static void ReplayMacro(Macro *m) }
+/* Is there a document open in the editor */ +static gboolean DocumentPresent() +{ + return (document_get_current()!=NULL); +} + + /* check editor notifications and remember editor events */ -static gboolean Notification_Handler(GObject *obj, GeanyEditor *editor, SCNotification *nt, - gpointer user_data) +static gboolean Notification_Handler(GObject *obj,GeanyEditor *ed,SCNotification *nt,gpointer ud) { MacroEvent *me; gint i; @@ -466,9 +551,12 @@ static gboolean Notification_Handler(GObject *obj, GeanyEditor *editor, SCNotifi } me=g_new0(MacroEvent,1); me->message=nt->message; -/* me->wparam=nt->wParam; */ - /* Special handling for text inserting, duplicate inserted string */ - me->lparam=(me->message==SCI_REPLACESEL)?((glong) g_strdup((gchar *)(nt->lParam))) : nt->lParam; + me->wparam=nt->wParam; + /* Special handling for text in lparam */ + me->lparam=(me->message==SCI_SEARCHNEXT || + me->message==SCI_SEARCHPREV || + me->message==SCI_REPLACESEL) + ?((glong) g_strdup((gchar *)(nt->lParam))) : nt->lParam;
/* more efficient to create reverse list and reverse it at the end */ RecordingMacro->MacroEvents=g_slist_prepend(RecordingMacro->MacroEvents,me); @@ -641,7 +729,7 @@ static void LoadSettings(void)
/* extract settings */ bQueryOverwriteMacros=utils_get_setting_boolean(config,"Settings", - "Question_Macro_Overwrite",FALSE); + "Question_Macro_Overwrite",FALSE); bSaveMacros=utils_get_setting_boolean(config,"Settings","Save_Macros",FALSE);
/* extract macros */ @@ -676,8 +764,10 @@ static void LoadSettings(void) g_free(pcTemp); /* now go through macro data generating macros */ for(k=0,m->MacroEvents=NULL;pcMacroCommands[k]!=NULL;) - m->MacroEvents=g_slist_prepend(m->MacroEvents,GetMacroEventFromString(pcMacroCommands, - &k)); + m->MacroEvents=g_slist_prepend(m->MacroEvents, + GetMacroEventFromString(pcMacroCommands, + &k)); + /* list created in reverse as more efficient, now turn it around */ m->MacroEvents=g_slist_reverse(m->MacroEvents); /* macro now complete, add it to the list */ @@ -692,13 +782,6 @@ static void LoadSettings(void) }
-PluginCallback plugin_callbacks[] = -{ - { "editor-notify", (GCallback) &Notification_Handler, FALSE, NULL }, - { NULL, NULL, FALSE, NULL } -}; - - /* handle button presses in the preferences dialog box */ static void on_configure_response(GtkDialog *dialog, gint response, gpointer user_data) { @@ -767,7 +850,7 @@ void plugin_help(void) GTK_STOCK_OK,GTK_RESPONSE_ACCEPT, NULL);
-/* setup help text */ + /* setup help text */ cText=g_strconcat( _("This Plugin implements Macros in Geany.\n\n"), _("This plugin allows you to record and use your own macros. "), @@ -830,7 +913,6 @@ void plugin_help(void)
/* free memory */ g_free(cText); - }
@@ -1093,34 +1175,65 @@ static gboolean InitializeMacroRecord(void) }
+/* function to start the macro recording process */ +static void StartRecordingMacro() +{ + /* start recording process, but quit if error, or user cancels */ + if(!InitializeMacroRecord()) + return; + + /* start actual recording */ + scintilla_send_message(document_get_current()->editor->sci,SCI_STARTRECORD,0,0); + gtk_widget_hide(Record_Macro_menu_item); + gtk_widget_show(Stop_Record_Macro_menu_item); +} + + +/* function to finish recording a macro */ +static void StopRecordingMacro() +{ + scintilla_send_message(document_get_current()->editor->sci,SCI_STOPRECORD,0,0); + /* Recorded in reverse as more efficient */ + RecordingMacro->MacroEvents=g_slist_reverse(RecordingMacro->MacroEvents); + /* add macro to list */ + AddMacroToList(RecordingMacro); + /* set ready to record new macro (don't free as macro has been saved in macrolist) */ + RecordingMacro=NULL; + gtk_widget_show(Record_Macro_menu_item); + gtk_widget_hide(Stop_Record_Macro_menu_item); + + /* Macros have been changed */ + bMacrosHaveChanged=TRUE; +} + + +/* check to see if we are recording a macro and stop it if we are */ +static void on_document_close(GObject *obj, GeanyDocument *doc, gpointer user_data) +{ + if(RecordingMacro!=NULL) + StopRecordingMacro(); +} + + +PluginCallback plugin_callbacks[] = +{ + { "editor-notify", (GCallback) &Notification_Handler, FALSE, NULL }, + { "document-close", (GCallback) &on_document_close, FALSE, NULL }, + { NULL, NULL, FALSE, NULL } +}; + + /* handle starting and stopping macro recording */ static void DoMacroRecording(GtkMenuItem *menuitem, gpointer gdata) { - if(RecordingMacro==NULL) - { - /* start recording process, but quit if error, or user cancels */ - if(!InitializeMacroRecord()) - return; + /* can't record if in an empty editor */ + if(!DocumentPresent()) + return;
- /* start actual recording */ - scintilla_send_message(document_get_current()->editor->sci,SCI_STARTRECORD,0,0); - gtk_widget_hide(Record_Macro_menu_item); - gtk_widget_show(Stop_Record_Macro_menu_item); - } - else { - scintilla_send_message(document_get_current()->editor->sci,SCI_STOPRECORD,0,0); - /* Recorded in reverse as more efficient */ - RecordingMacro->MacroEvents=g_slist_reverse(RecordingMacro->MacroEvents); - /* add macro to list */ - AddMacroToList(RecordingMacro); - /* set ready to record new macro (don't free as macro has been saved in macrolist) */ - RecordingMacro=NULL; - gtk_widget_show(Record_Macro_menu_item); - gtk_widget_hide(Stop_Record_Macro_menu_item); - - /* Macros have been changed */ - bMacrosHaveChanged=TRUE; - } + if(RecordingMacro==NULL) + StartRecordingMacro(); + else + StopRecordingMacro(); }
@@ -1214,6 +1327,200 @@ static void Accel_Render_Edited_CallBack(GtkCellRendererAccel *cell,gchar *iter_ }
+/* Get Search Description string with search text and flags at end*/ +static gchar * GetSearchDescription(gint message,gchar *text,gint flags) +{ + return g_strdup_printf(_("Search %s, looking for %s%s%s.%s%s%s%s%s"), + message==SCI_SEARCHNEXT?"forewards":"backwards", + text==NULL?"":""", + text==NULL?"clipboard contents":text, + text==NULL?"":""", + (flags&SCFIND_MATCHCASE)==SCFIND_MATCHCASE?" Match case.":"", + (flags&SCFIND_WHOLEWORD)==SCFIND_WHOLEWORD?" Match whole word.":"", + (flags&SCFIND_WORDSTART)==SCFIND_WORDSTART?" Match start of word.":"", + (flags&SCFIND_REGEXP)==SCFIND_REGEXP?" Search by Regular Expression.":"", + (flags&SCFIND_POSIX)==SCFIND_POSIX?" Regular Expression is POSIX.":""); +} + + +/* handle button presses in the preferences dialog box */ +static void on_search_toggle(GtkToggleButton *cb,gpointer user_data) +{ + GtkEntry *gtke; + GtkLabel *gtkl; + gboolean bUseClipboard; + + /* retreive pointers to entry & label */ + gtke=(GtkEntry*)(g_object_get_data(G_OBJECT(cb),"GeanyMacros_e")); + gtkl=(GtkLabel*)(g_object_get_data(G_OBJECT(cb),"GeanyMacros_l")); + + /* find out what we're searching for */ + bUseClipboard=gtk_toggle_button_get_active(cb); + + /* set entry & label depending on if we're looking for text or not */ + gtk_widget_set_sensitive((GtkWidget*)gtke,!bUseClipboard); + gtk_widget_set_sensitive((GtkWidget*)gtkl,!bUseClipboard); +} + + +/* Handle editing of options for search */ +static void EditSearchOptions(GtkTreeModel *model,GtkTreeIter *iter) +{ + GtkWidget *dialog,*gtke,*hbox,*gtkl; + gchar *cTemp,*cData,*cText,*cTemp2; + gint iReply=GTK_RESPONSE_OK,i; + GtkWidget *vbox,*gtkcb; + GtkWidget *cbA,*cbB,*cbC,*cbD,*cbE,*cbF; + MacroDetailEntry *mde; + gulong flags; + + /* get MacroDetail and data for this line */ + gtk_tree_model_get(model,iter,2,&mde,3,&cData,-1); + + /* make cText point to search text */ + cText=strchr(cData,','); + cText++; + + /* get search flags */ + flags=strtoll(cData,NULL,10); + + /* create dialog box */ + dialog=gtk_dialog_new_with_buttons(_("Search Options:"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT,NULL); + + /* create buttons */ + gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Ok"),GTK_RESPONSE_OK); + gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Cancel"),GTK_RESPONSE_CANCEL); + + /* create box to hold widgets */ + vbox=gtk_vbox_new(FALSE, 6); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),vbox); + gtk_widget_show(vbox); + + /* create combobox to hold search direction */ + gtkcb=gtk_combo_box_new_text(); + gtk_combo_box_append_text((GtkComboBox*)gtkcb,_("Search Forwards")); + gtk_combo_box_append_text((GtkComboBox*)gtkcb,_("Search Backwards")); + gtk_combo_box_set_active((GtkComboBox*)gtkcb,(mde->message==SCI_SEARCHNEXT)?0:1); + gtk_box_pack_start(GTK_BOX(vbox),gtkcb,FALSE,FALSE,2); + gtk_widget_show(gtkcb); + + /* create checkbox to check for search options */ + cbA=gtk_check_button_new_with_label(_("Seach for contents of clipboard")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbA),(*cText)==0); + gtk_box_pack_start(GTK_BOX(vbox),cbA,FALSE,FALSE,2); + /* ensure we monitor for change in this button */ + g_signal_connect(cbA,"toggled",G_CALLBACK(on_search_toggle),dialog); + gtk_widget_show(cbA); + + + /* create box to hold search text entry box, and label */ + hbox=gtk_hbox_new(FALSE,0); + gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,2); + gtk_widget_show(hbox); + + gtkl=gtk_label_new(_("Seach for:")); + gtk_box_pack_start(GTK_BOX(hbox),gtkl,FALSE,FALSE,2); + gtk_widget_show(gtkl); + /* save pointer to label */ + g_object_set_data(G_OBJECT(cbA),"GeanyMacros_l",gtkl); + gtk_widget_set_sensitive((GtkWidget*)gtkl,(*cText)!=0); + + gtke=gtk_entry_new(); + if((*cText)!=0) + gtk_entry_set_text(GTK_ENTRY(gtke),cText); + + gtk_box_pack_start(GTK_BOX(hbox),gtke,FALSE,FALSE,2); + gtk_widget_show(gtke); + /* save pointer to entry */ + g_object_set_data(G_OBJECT(cbA),"GeanyMacros_e",gtke); + gtk_widget_set_sensitive((GtkWidget*)gtke,(*cText)!=0); + + /* create checkbox to check for search options */ + cbB=gtk_check_button_new_with_label(_("Seach is case sensitive")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbB),(flags&SCFIND_MATCHCASE)==SCFIND_MATCHCASE); + gtk_box_pack_start(GTK_BOX(vbox),cbB,FALSE,FALSE,2); + + cbC=gtk_check_button_new_with_label(_("Seach for whole word")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbC),(flags&SCFIND_WHOLEWORD)==SCFIND_WHOLEWORD); + gtk_box_pack_start(GTK_BOX(vbox),cbC,FALSE,FALSE,2); + + cbD=gtk_check_button_new_with_label(_("Seach for start of word")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbD),(flags&SCFIND_WORDSTART)==SCFIND_WORDSTART); + gtk_box_pack_start(GTK_BOX(vbox),cbD,FALSE,FALSE,2); + + cbE=gtk_check_button_new_with_label(_("Seach text is regular expression")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbE),(flags&SCFIND_REGEXP)==SCFIND_REGEXP); + gtk_box_pack_start(GTK_BOX(vbox),cbE,FALSE,FALSE,2); + + cbF=gtk_check_button_new_with_label(_("Seach text is POSIX compatible")); + /* if search text is empty then to seach for clipboard contents */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cbF),(flags&SCFIND_POSIX)==SCFIND_POSIX); + gtk_box_pack_start(GTK_BOX(vbox),cbF,FALSE,FALSE,2); + + gtk_widget_show_all(vbox); + + while(iReply==GTK_RESPONSE_OK) + { + iReply=gtk_dialog_run(GTK_DIALOG(dialog)); + + if(iReply==GTK_RESPONSE_OK) + { + /* handle change in options */ + + /* check search direction 0=foreward, 1=backwards */ + iReply=gtk_combo_box_get_active((GtkComboBox*)gtkcb); + + /* calculate macro detail of relavent detail */ + i=0; + while(MacroDetails[i].message!=SCI_SEARCHNEXT) i++; + mde=(MacroDetailEntry *)(&MacroDetails[i+iReply]); + + /* calculate flags */ + flags=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbB))?SCFIND_MATCHCASE:0; + flags|=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbC))?SCFIND_WHOLEWORD:0; + flags|=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbD))?SCFIND_WORDSTART:0; + flags|=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbE))?SCFIND_REGEXP:0; + flags|=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbF))?SCFIND_POSIX:0; + + /* get search string or NULL if using clipboard */ + cText=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cbA)))? + NULL:(gchar*)gtk_entry_get_text((GtkEntry*)(gtke)); + + /* get new data */ + cData=g_strdup_printf("%lu,%s",flags,(cText==NULL)?"":cText); + + /* get new text */ + cText=GetSearchDescription(mde->message,cText,flags); + + /* get old data for this line */ + gtk_tree_model_get(model,iter,0,&cTemp,3,&cTemp2,-1); + + /* set text and macro detail */ + gtk_list_store_set(GTK_LIST_STORE(model),iter,0,cText,2,mde,3,cData,-1); + + /* free up old text */ + g_free(cTemp); + g_free(cTemp2); + + /* break out of loop */ + break; + } + + } + + /* tidy up */ + gtk_widget_destroy(dialog); +} + + +/* Handle editing of text for SCI_REPLACESEL */ static void EditSCIREPLACESELText(GtkTreeModel *model,GtkTreeIter *iter) { GtkWidget *dialog,*gtke,*hbox,*gtkl; @@ -1286,6 +1593,7 @@ static void combo_edited(GtkCellRendererText *cell,gchar *iter_id,gchar *new_tex MacroDetailEntry *mde; gint i; gchar *cTemp,*cTemp2; + gboolean bNeedButtonUpdate=FALSE;
/* find MacroDetails that has the setting of new setting */ i=0; @@ -1301,16 +1609,35 @@ static void combo_edited(GtkCellRendererText *cell,gchar *iter_id,gchar *new_tex
/* handle freeing of string if needed */ g_free(cTemp); - if(mde->message==SCI_REPLACESEL) + if(mde->message==SCI_REPLACESEL || + mde->message==SCI_SEARCHNEXT || + mde->message==SCI_SEARCHPREV) + { g_free(cTemp2); + bNeedButtonUpdate=TRUE; + } + + /* see what text will have to change into */ + cTemp=(gchar*)(MacroDetails[i].description); + cTemp2=NULL; + if(MacroDetails[i].message==SCI_REPLACESEL) + { + cTemp=g_strdup_printf(_("Insert/replace with """)); + bNeedButtonUpdate=TRUE; + } + else if(MacroDetails[i].message==SCI_SEARCHNEXT || + MacroDetails[i].message==SCI_SEARCHPREV) + { + cTemp=GetSearchDescription(MacroDetails[i].message,NULL,0); + cTemp2=g_strdup("0,"); + bNeedButtonUpdate=TRUE; + }
/* Update the model */ - gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,(MacroDetails[i].message==SCI_REPLACESEL? - g_strdup_printf(_("Insert/replace with """)):MacroDetails[i].description),2, - &(MacroDetails[i]),3,NULL,-1); + gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,cTemp,2,&(MacroDetails[i]),3,cTemp2,-1);
/* check if changing to or from SCI_REPLACESEL and enable/disable edit button as needed */ - if(mde->message==SCI_REPLACESEL || MacroDetails[i].message==SCI_REPLACESEL) + if(bNeedButtonUpdate) g_signal_emit_by_name(gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)),"changed", G_TYPE_NONE); } @@ -1335,21 +1662,23 @@ static void DoEditMacroElementsSelectionChanged(GtkTreeSelection *selection,gpoi gtk_tree_model_get(GTK_TREE_MODEL(model),&iter,2,&mde,-1);
/* find delete button & enable it*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_DELETE); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bD")); gtk_widget_set_sensitive(button,TRUE);
/* find edit text button & enable it if looking at a SCI_REPLACESEL item*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_EDIT); - gtk_widget_set_sensitive(button,mde->message==SCI_REPLACESEL); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bC")); + gtk_widget_set_sensitive(button,mde->message==SCI_REPLACESEL || + mde->message==SCI_SEARCHNEXT || + mde->message==SCI_SEARCHPREV);
/* get copy of iteraton */ iter2=iter; /* if can move to next node then it's not the last. use to set Move down */ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_DOWN); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bB")); gtk_widget_set_sensitive(button,gtk_tree_model_iter_next(GTK_TREE_MODEL(model),&iter2));
/* find Move up button & enable/disable it */ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_UP); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bA")); /* get the path of the current selected line */ tpTemp=gtk_tree_model_get_path(GTK_TREE_MODEL(model),&iter); /* if has previous then can be moved up a line */ @@ -1361,19 +1690,19 @@ static void DoEditMacroElementsSelectionChanged(GtkTreeSelection *selection,gpoi else { /* find delete button & diable it*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_DELETE); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bD")); gtk_widget_set_sensitive(button,FALSE);
/* find edit text button & diable it*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_EDIT); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bC")); gtk_widget_set_sensitive(button,FALSE);
/* find Move up button & diable it*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_UP); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bA")); gtk_widget_set_sensitive(button,FALSE);
/* find Move Down button & diable it*/ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_DOWN); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bB")); gtk_widget_set_sensitive(button,FALSE); }
@@ -1383,7 +1712,7 @@ static void DoEditMacroElementsSelectionChanged(GtkTreeSelection *selection,gpoi /* edit individual existing macro */ static void EditMacroElements(Macro *m) { - GtkWidget *table,*dialog; + GtkWidget *table,*dialog,*button; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeSelection *selection; @@ -1411,26 +1740,43 @@ static void EditMacroElements(Macro *m) { me=(MacroEvent*)(gsl->data); i=0; - while(MacroDetails[i].description!=NULL) { + while(MacroDetails[i].description!=NULL) + { if(MacroDetails[i].message==me->message) break; i++; }
gtk_list_store_append(ls,&iter); /* Acquire an iterator */ /* set text, pointer to macro detail, and any ascociated string */ - gtk_list_store_set(ls,&iter,0,(me->message==SCI_REPLACESEL? - g_strdup_printf(_("Insert/replace with "%s""),(gchar*)(me->lparam)): - MacroDetails[i].description),2,&(MacroDetails[i]),3, - (me->message==SCI_REPLACESEL?g_strdup((gchar*)(me->lparam)):NULL),-1); + cTemp=(gchar*)(MacroDetails[i].description); + cTemp2=NULL; + if(me->message==SCI_REPLACESEL) + { + cTemp=g_strdup_printf(_("Insert/replace with "%s""), + (gchar*)(me->lparam)); + cTemp2=g_strdup((gchar*)(me->lparam)); + } + else if(MacroDetails[i].message==SCI_SEARCHNEXT || + MacroDetails[i].message==SCI_SEARCHPREV) + { + cTemp=GetSearchDescription(MacroDetails[i].message,(gchar*)(me->lparam), + me->wparam); + cTemp2=g_strdup_printf("%lu,%s",me->wparam,((gchar*)(me->lparam)==NULL)? + "":((gchar*)(me->lparam))); + } + + gtk_list_store_set(ls,&iter,0,cTemp,2,&(MacroDetails[i]),3,cTemp2,-1); gsl=g_slist_next(gsl); }
/* create list store for combo renderer */ lsCombo=gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_POINTER); i=0; - while(MacroDetails[i].description!=NULL) { + while(MacroDetails[i].description!=NULL) + { gtk_list_store_append(lsCombo,&iter); - gtk_list_store_set(lsCombo,&iter,0,MacroDetails[i].description,1,&(MacroDetails[i]),-1); + gtk_list_store_set(lsCombo,&iter,0,MacroDetails[i].description,1, + &(MacroDetails[i]),-1); i++; }
@@ -1445,8 +1791,8 @@ static void EditMacroElements(Macro *m) gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(table),GTK_TREE_VIEW_GRID_LINES_BOTH);
/* add column */ - column=gtk_tree_view_column_new_with_attributes(_("Event"),renderer,"text",0,"text-column",1, - NULL); + column=gtk_tree_view_column_new_with_attributes(_("Event"),renderer,"text",0,"text-column" + ,1,NULL); g_signal_connect(renderer,"edited",G_CALLBACK(combo_edited),table); gtk_tree_view_append_column(GTK_TREE_VIEW(table),column);
@@ -1456,23 +1802,27 @@ static void EditMacroElements(Macro *m)
/* add table to dialog */ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),table); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),table,FALSE,FALSE,2); +// gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),table,FALSE,FALSE,2); gtk_widget_show(table);
/* add buttons */ - gtk_dialog_add_button(GTK_DIALOG(dialog),_("Move _Up"),GEANY_MACRO_BUTTON_UP); - gtk_dialog_add_button(GTK_DIALOG(dialog),_("Move Do_wn"),GEANY_MACRO_BUTTON_DOWN); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("Move _Up"),GEANY_MACRO_BUTTON_UP); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bA",button); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("Move Do_wn"),GEANY_MACRO_BUTTON_DOWN); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bB",button); gtk_dialog_add_button(GTK_DIALOG(dialog),_("New _Above"),GEANY_MACRO_BUTTON_ABOVE); gtk_dialog_add_button(GTK_DIALOG(dialog),_("New _Below"),GEANY_MACRO_BUTTON_BELOW); - gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Edit Text"),GEANY_MACRO_BUTTON_EDIT); - gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Delete"),GEANY_MACRO_BUTTON_DELETE); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Edit"),GEANY_MACRO_BUTTON_EDIT); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bC",button); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Delete"),GEANY_MACRO_BUTTON_DELETE); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bD",button); gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Ok"),GEANY_MACRO_BUTTON_APPLY); gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Cancel"),GEANY_MACRO_BUTTON_CANCEL);
/* listen for changes in selection */ selection=gtk_tree_view_get_selection(GTK_TREE_VIEW(table)); - g_signal_connect(G_OBJECT(selection),"changed",G_CALLBACK(DoEditMacroElementsSelectionChanged), - dialog); + g_signal_connect(G_OBJECT(selection),"changed", + G_CALLBACK(DoEditMacroElementsSelectionChanged),dialog);
/* call callback: this will set buttons acordingly */ DoEditMacroElementsSelectionChanged(selection,dialog); @@ -1494,9 +1844,14 @@ static void EditMacroElements(Macro *m) if(i==GEANY_MACRO_BUTTON_DELETE) { /* see if need to free non-static string */ - gtk_tree_model_get(GTK_TREE_MODEL(ls),&iter,0,&cTemp,2,&mde,-1); - if(mde->message==SCI_REPLACESEL) + gtk_tree_model_get(GTK_TREE_MODEL(ls),&iter,0,&cTemp,2,&mde,3,&cTemp2,-1); + if(mde->message==SCI_REPLACESEL || + mde->message==SCI_SEARCHNEXT || + mde->message==SCI_SEARCHPREV) + { g_free(cTemp); + g_free(cTemp2); + }
/* remove element */ gtk_list_store_remove(ls,&iter); @@ -1569,6 +1924,9 @@ static void EditMacroElements(Macro *m) gtk_tree_model_get(GTK_TREE_MODEL(ls),&iter,2,&mde,-1); if(mde->message==SCI_REPLACESEL) EditSCIREPLACESELText(GTK_TREE_MODEL(ls),&iter); + else if(mde->message==SCI_SEARCHNEXT || mde->message==SCI_SEARCHPREV) + EditSearchOptions(GTK_TREE_MODEL(ls),&iter); + }
} //end of commands that require line to be selected @@ -1602,10 +1960,21 @@ static void EditMacroElements(Macro *m)
me->message=mde->message; me->lparam=0; + me->wparam=0;
/* Special handling for text inserting, duplicate inserted string */ if(me->message==SCI_REPLACESEL) - me->lparam=(glong)((cTemp!=NULL)?g_strdup(cTemp):g_strdup_printf("")); + me->lparam=(glong)((cTemp!=NULL)?g_strdup(cTemp):g_strdup("")); + + /* Special handling for search */ + if(me->message==SCI_SEARCHNEXT || me->message==SCI_SEARCHPREV) + { + cTemp2=strchr(cTemp,','); + cTemp2++; + + me->lparam=(glong)(((*cTemp2)==0)?NULL:g_strdup(cTemp2)); + me->wparam=strtoll(cTemp,NULL,10); + }
/* more efficient to create reverse list and reverse it at the end */ m->MacroEvents=g_slist_prepend(m->MacroEvents,me); @@ -1631,7 +2000,8 @@ static void EditMacroElements(Macro *m)
/* free any non-static text */ g_free((void*)(cTemp)); - if(mde->message==SCI_REPLACESEL) + if(mde->message==SCI_REPLACESEL || mde->message==SCI_SEARCHNEXT || + mde->message==SCI_SEARCHPREV) g_free(cTemp2);
/* get next event */ @@ -1661,11 +2031,11 @@ static void DoEditMacroSelectionChanged(GtkTreeSelection *selection,gpointer dat bHasItemSelected=gtk_tree_selection_get_selected(selection,&model,&iter);
/* now set button sensitive or not depending if there is something for them to act on */ - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_RERECORD); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bA")); gtk_widget_set_sensitive(button,bHasItemSelected); - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_EDIT); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bB")); gtk_widget_set_sensitive(button,bHasItemSelected); - button=gtk_dialog_get_widget_for_response(dialog,GEANY_MACRO_BUTTON_DELETE); + button=(GtkWidget*)(g_object_get_data(G_OBJECT(dialog),"GeanyMacros_bC")); gtk_widget_set_sensitive(button,bHasItemSelected); }
@@ -1673,7 +2043,7 @@ static void DoEditMacroSelectionChanged(GtkTreeSelection *selection,gpointer dat /* do editing of existing macros */ static void DoEditMacro(GtkMenuItem *menuitem, gpointer gdata) { - GtkWidget *table,*dialog; + GtkWidget *table,*dialog,*button; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeSelection *selection; @@ -1733,14 +2103,16 @@ static void DoEditMacro(GtkMenuItem *menuitem, gpointer gdata) GTK_SELECTION_SINGLE);
/* add table to dialog */ - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),table); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),table,FALSE,FALSE,2); gtk_widget_show(table);
/* add buttons */ - gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Re-Record"),GEANY_MACRO_BUTTON_RERECORD); - gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Edit"),GEANY_MACRO_BUTTON_EDIT); - gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Delete"),GEANY_MACRO_BUTTON_DELETE); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Re-Record"),GEANY_MACRO_BUTTON_RERECORD); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bA",button); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Edit"),GEANY_MACRO_BUTTON_EDIT); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bB",button); + button=gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Delete"),GEANY_MACRO_BUTTON_DELETE); + g_object_set_data(G_OBJECT(dialog),"GeanyMacros_bC",button); gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Ok"),GEANY_MACRO_BUTTON_CANCEL);
/* listen for changes in selection */ @@ -1783,7 +2155,7 @@ static void DoEditMacro(GtkMenuItem *menuitem, gpointer gdata) }
/* handle re-record macro */ - if(i==GEANY_MACRO_BUTTON_RERECORD && bEditable) + if(i==GEANY_MACRO_BUTTON_RERECORD && bEditable && DocumentPresent()) { m=FindMacroByName(cTemp); /* ensure have empty recording macro */ @@ -1812,7 +2184,7 @@ static void DoEditMacro(GtkMenuItem *menuitem, gpointer gdata) /* Signal that macros have changed (and need to be saved) */ bMacrosHaveChanged=TRUE; } - + /* free memory */ g_free(cTemp); } @@ -1835,7 +2207,7 @@ void plugin_init(GeanyData *data) /* Calculate what shift '0' to '9 will be (£ is above 3 on uk keyboard, but it's # or ~ on us * keyboard.) * there must be an easier way than this of working this out, but I've not figured it out. - * This is needed to play nicely with the Geany Numbered Bookmarks plugin + * This is needed to play nicely with the Geany Numbered Bookmarks plugin */
/* go through '0' to '9', work out hardware keycode, then find out what shift+this keycode
Modified: geanynumberedbookmarks/src/geanynumberedbookmarks.c 81 files changed, 41 insertions(+), 40 deletions(-) =================================================================== @@ -81,7 +81,7 @@ "[FileData]";
/* Definitions for bookmark images */ -static gchar * aszMarkerImage0[] = +static const gchar * aszMarkerImage0[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -102,7 +102,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage1[] = +static const gchar * aszMarkerImage1[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -123,7 +123,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage2[] = +static const gchar * aszMarkerImage2[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -144,7 +144,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage3[] = +static const gchar * aszMarkerImage3[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -165,7 +165,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage4[] = +static const gchar * aszMarkerImage4[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -186,7 +186,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage5[] = +static const gchar * aszMarkerImage5[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -207,7 +207,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage6[] = +static const gchar * aszMarkerImage6[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -228,7 +228,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage7[] = +static const gchar * aszMarkerImage7[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -249,7 +249,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage8[] = +static const gchar * aszMarkerImage8[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -270,7 +270,7 @@ "..B**********B...", "...BBBBBBBBBB...." }; -static gchar * aszMarkerImage9[] = +static const gchar * aszMarkerImage9[] = { "17 14 3 1", /* width height colours characters-per-pixel */ ". c None", @@ -292,7 +292,7 @@ "...BBBBBBBBBB...." };
-static gchar ** aszMarkerImages[]= +static const gchar ** aszMarkerImages[]= { aszMarkerImage0,aszMarkerImage1,aszMarkerImage2,aszMarkerImage3,aszMarkerImage4, aszMarkerImage5,aszMarkerImage6,aszMarkerImage7,aszMarkerImage8,aszMarkerImage9 @@ -463,7 +463,7 @@ static void LoadSettings(void)
/* extract settings */ bCenterWhenGotoBookmark=utils_get_setting_boolean(config,"Settings", - "Center_When_Goto_Bookmark",FALSE); + "Center_When_Goto_Bookmark",FALSE); bRememberFolds=utils_get_setting_boolean(config,"Settings","Remember_Folds",FALSE);
/* extract data about files */ @@ -521,7 +521,7 @@ static void DefineMarkers(ScintillaObject* sci) gint i; for(i=0;i<10;i++) scintilla_send_message(sci,SCI_MARKERDEFINEPIXMAP,i+BOOKMARK_BASE, - (glong)(aszMarkerImages[i])); + (glong)(aszMarkerImages[i])); }
@@ -586,7 +586,8 @@ static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_dat struct stat sBuf; GtkWidget *dialog; gchar *cFoldData=NULL; - gint iBits,iFlags,iBitCounter; + /* keep compiler happy & initialise iBits: will logically be initiated anyway */ + gint iBits=0,iFlags,iBitCounter;
/* ensure have markers set */ CheckEditorSetup(); @@ -595,16 +596,16 @@ static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_dat /* check to see if file has changed since geany last saved it */ fd=GetFileData(doc->file_name); if(stat(doc->file_name,&sBuf)==0 && fd!=NULL && fd->LastChangedTime!=-1 && - fd->LastChangedTime!=sBuf.st_mtime) + fd->LastChangedTime!=sBuf.st_mtime) { /* notify user that file has been changed */ dialog=gtk_message_dialog_new(GTK_WINDOW(geany->main_widgets->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_NONE, - _("'%s' has been edited since it was last saved by geany. Marker positions may \ -be unreliable and will not be loaded.\nPress Ignore to try an load markers anyway."), - doc->file_name); + GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR, + GTK_BUTTONS_NONE, + _("'%s' has been edited since it was last saved by g\ + eany. Marker positions may be unreliable and will \ + not be loaded.\nPress Ignore to try an load marker\ + s anyway."),doc->file_name); gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Okay"),GTK_RESPONSE_OK); gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Ignore"),GTK_RESPONSE_REJECT); l=gtk_dialog_run(GTK_DIALOG(dialog)); @@ -624,9 +625,9 @@ static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_dat if(fd->pcFolding==NULL || bRememberFolds==FALSE) break;
- cFoldData=fd->pcFolding; + cFoldData=fd->pcFolding;
- /* first ensure fold positions exist */ + /* first ensure fold positions exist */ scintilla_send_message(sci,SCI_COLOURISE,0,-1);
iLineCount=scintilla_send_message(sci,SCI_GETLINECOUNT,0,0); @@ -637,14 +638,14 @@ static void on_document_open(GObject *obj, GeanyDocument *doc, gpointer user_dat iFlags=scintilla_send_message(sci,SCI_GETFOLDLEVEL,i,0); /* ignore non-folding lines */ if((iFlags & SC_FOLDLEVELHEADERFLAG)==0) - continue; + continue;
- /* get next 6 fold states if needed */ + /* get next 6 fold states if needed */ if(iBitCounter==6) { - iBitCounter=0; - iBits=base64_char_to_int[(gint)(*cFoldData)]; - cFoldData++; + iBitCounter=0; + iBits=base64_char_to_int[(gint)(*cFoldData)]; + cFoldData++; }
/* set fold if needed */ @@ -715,8 +716,8 @@ static void on_document_save(GObject *obj, GeanyDocument *doc, gpointer user_dat if(iBitCounter!=0) { guiFold=(guint8)base64_int_to_char[guiFold]; - g_byte_array_append(gbaFoldData,&guiFold,1); - } + g_byte_array_append(gbaFoldData,&guiFold,1); + }
/* transfer data to text string */ fdTemp->pcFolding=g_strndup((gchar*)(gbaFoldData->data),gbaFoldData->len); @@ -745,7 +746,7 @@ static void on_document_save(GObject *obj, GeanyDocument *doc, gpointer user_dat static gint GetLine(ScintillaObject* sci) { return scintilla_send_message(sci,SCI_LINEFROMPOSITION, - scintilla_send_message(sci,SCI_GETCURRENTPOS,10,0),0); + scintilla_send_message(sci,SCI_GETCURRENTPOS,10,0),0); }
@@ -765,7 +766,7 @@ static void on_configure_response(GtkDialog *dialog, gint response, gpointer use /* first see if settings are going to change */ bSettingsHaveChanged=(bRememberFolds!=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb1))); bSettingsHaveChanged|=(bCenterWhenGotoBookmark!=gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(cb2))); + GTK_TOGGLE_BUTTON(cb2)));
/* set new settings settings */ bRememberFolds=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb1)); @@ -811,11 +812,10 @@ void plugin_help(void) GtkWidget *dialog,*label,*scroll;
/* create dialog box */ - dialog=gtk_dialog_new_with_buttons(_("Numbered Bookmarks help"), - GTK_WINDOW(geany->main_widgets->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK,GTK_RESPONSE_ACCEPT, - NULL); + dialog=gtk_dialog_new_with_buttons(_("Numbered Bookmarks help"), + GTK_WINDOW(geany->main_widgets->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,NULL);
/* create label */ label=gtk_label_new( @@ -842,7 +842,7 @@ void plugin_help(void) /* create scrolled window to display label */ scroll=gtk_scrolled_window_new(NULL,NULL); gtk_scrolled_window_set_policy((GtkScrolledWindow*)scroll,GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); + GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport((GtkScrolledWindow*)scroll,label);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),scroll); @@ -882,6 +882,7 @@ static void GotoBookMark(gint iBookMark) /* make sure view is not beyond start or end of document */ if(iLine+iLinesVisible>iLineCount) iLine=iLineCount-iLinesVisible; + if(iLine<0) iLine=0;
@@ -1019,7 +1020,7 @@ void plugin_init(GeanyData *data)
/* set key press monitor handle */ key_release_signal_id=g_signal_connect(geany->main_widgets->window,"key-release-event", - G_CALLBACK(Key_Released_CallBack),NULL); + G_CALLBACK(Key_Released_CallBack),NULL); }
@@ -1042,7 +1043,7 @@ void plugin_cleanup(void) if(documents[i]->is_valid) { sci=documents[i]->editor->sci; for(k=0;k<9;k++) - scintilla_send_message(sci,SCI_MARKERDELETEALL,BOOKMARK_BASE+k,0); + scintilla_send_message(sci,SCI_MARKERDELETEALL,BOOKMARK_BASE+k,0);
}
Modified: po/POTFILES.in 40 files changed, 39 insertions(+), 1 deletions(-) =================================================================== @@ -50,9 +50,47 @@ debugger/src/atree.c devhelp/src/dhp.h devhelp/src/dhp-object.c devhelp/src/dhp-plugin.c -devhelp/src/dhp-codesearch.c devhelp/src/dhp-manpages.c devhelp/src/dhp-settings.c +# bundled libdevhelp2 +devhelp/devhelp/dh-assistant.c +devhelp/devhelp/dh-assistant.h +devhelp/devhelp/dh-assistant-view.c +devhelp/devhelp/dh-assistant-view.h +devhelp/devhelp/dh-base.c +devhelp/devhelp/dh-base.h +devhelp/devhelp/dh-book.c +devhelp/devhelp/dh-book.h +devhelp/devhelp/dh-book-manager.c +devhelp/devhelp/dh-book-manager.h +devhelp/devhelp/dh-book-tree.c +devhelp/devhelp/dh-book-tree.h +devhelp/devhelp/dh-enum-types.c +devhelp/devhelp/dh-enum-types.h +devhelp/devhelp/dh-error.c +devhelp/devhelp/dh-error.h +devhelp/devhelp/dh-keyword-model.c +devhelp/devhelp/dh-keyword-model.h +devhelp/devhelp/dh-link.c +devhelp/devhelp/dh-link.h +devhelp/devhelp/dh-marshal.c +devhelp/devhelp/dh-marshal.h +devhelp/devhelp/dh-parser.c +devhelp/devhelp/dh-parser.h +devhelp/devhelp/dh-preferences.c +devhelp/devhelp/dh-preferences.h +devhelp/devhelp/dh-search.c +devhelp/devhelp/dh-search.h +devhelp/devhelp/dh-util.c +devhelp/devhelp/dh-util.h +devhelp/devhelp/dh-window.c +devhelp/devhelp/dh-window.h +devhelp/devhelp/eggfindbar.c +devhelp/devhelp/eggfindbar.h +devhelp/devhelp/ige-conf.c +devhelp/devhelp/ige-conf-gconf.c +devhelp/devhelp/ige-conf.h +devhelp/devhelp/ige-conf-private.h
# geanydoc geanydoc/tests/unittests.c
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org