Kaydet (Commit) 852a4dbb authored tarafından Nick Treleaven's avatar Nick Treleaven

Fix bug when using Navigate backwards after using the keyboard to

set the cursor position on the current word.
Add symbols_goto_tag().
Replace navqueue_append() with navqueue_goto_line().


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1900 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 6b3b7fe5
2007-09-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/navqueue.c, src/navqueue.h, src/treeviews.c,
src/callbacks.c, src/symbols.c, src/symbols.h:
Fix bug when using Navigate backwards after using the keyboard to
set the cursor position on the current word.
Add symbols_goto_tag().
Replace navqueue_append() with navqueue_goto_line().
2007-09-24 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2007-09-24 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/editor.c, src/editor.h: * src/keybindings.c, src/editor.c, src/editor.h:
......
...@@ -1054,41 +1054,14 @@ void ...@@ -1054,41 +1054,14 @@ void
on_goto_tag_activate (GtkMenuItem *menuitem, on_goto_tag_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t; gboolean definition = (menuitem ==
gint type; GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")));
TMTag *tmtag; document *doc = document_get_current();
// goto tag definition: all except prototypes / forward declarations / externs g_return_if_fail(doc);
if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")))
type = tm_tag_max_t - forward_types;
else
type = forward_types;
tmtag = symbols_find_in_workspace(editor_info.current_word, type);
if (tmtag != NULL)
{
gint old_idx = document_get_cur_idx(); // get idx before switching the file
if (utils_goto_file_line(
tmtag->atts.entry.file->work_object.file_name,
TRUE, tmtag->atts.entry.line))
{
// first add old file as old position
if (doc_list[old_idx].tm_file)
navqueue_new_position(doc_list[old_idx].tm_file->file_name,
sci_get_line_from_position(doc_list[old_idx].sci, editor_info.click_pos) + 1);
navqueue_new_position(tmtag->atts.entry.file->work_object.file_name, sci_set_current_position(doc->sci, editor_info.click_pos, FALSE);
tmtag->atts.entry.line); symbols_goto_tag(editor_info.current_word, definition);
return;
}
}
// if we are here, there was no match and we are beeping ;-)
utils_beep();
if (type == forward_types)
ui_set_statusbar(_("Forward declaration \"%s\" not found."), editor_info.current_word);
else
ui_set_statusbar(_("Definition of \"%s\" not found."), editor_info.current_word);
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "build.h" #include "build.h"
#include "tools.h" #include "tools.h"
#include "navqueue.h" #include "navqueue.h"
#include "symbols.h"
const gboolean swap_alt_tab_order = FALSE; const gboolean swap_alt_tab_order = FALSE;
...@@ -942,12 +943,10 @@ static void cb_func_current_word(guint key_id) ...@@ -942,12 +943,10 @@ static void cb_func_current_word(guint key_id)
on_find_usage1_activate(NULL, NULL); on_find_usage1_activate(NULL, NULL);
break; break;
case GEANY_KEYS_POPUP_GOTOTAGDEFINITION: case GEANY_KEYS_POPUP_GOTOTAGDEFINITION:
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu, symbols_goto_tag(editor_info.current_word, TRUE);
"goto_tag_definition1")), NULL);
break; break;
case GEANY_KEYS_POPUP_GOTOTAGDECLARATION: case GEANY_KEYS_POPUP_GOTOTAGDECLARATION:
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu, symbols_goto_tag(editor_info.current_word, FALSE);
"goto_tag_declaration1")), NULL);
break; break;
case GEANY_KEYS_POPUP_CONTEXTACTION: case GEANY_KEYS_POPUP_CONTEXTACTION:
on_context_action1_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu, on_context_action1_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
......
...@@ -106,7 +106,7 @@ queue_pos_matches(guint queue_pos, const gchar *fname, gint line) ...@@ -106,7 +106,7 @@ queue_pos_matches(guint queue_pos, const gchar *fname, gint line)
} }
void navqueue_new_position(gchar *tm_filename, gint line) static void add_new_position(gchar *tm_filename, gint line)
{ {
filepos *npos; filepos *npos;
guint i; guint i;
...@@ -135,12 +135,13 @@ void navqueue_new_position(gchar *tm_filename, gint line) ...@@ -135,12 +135,13 @@ void navqueue_new_position(gchar *tm_filename, gint line)
/* Adds the current document position to the queue before adding the new position. /* Adds the current document position to the queue before adding the new position.
* line is counted with 1 as the first line, not 0. */ * line is counted with 1 as the first line, not 0. */
gboolean navqueue_append(gint new_idx, gint line) gboolean navqueue_goto_line(gint new_idx, gint line)
{ {
gint old_idx = document_get_cur_idx(); gint old_idx = document_get_cur_idx();
g_return_val_if_fail(DOC_IDX_VALID(old_idx), FALSE); g_return_val_if_fail(DOC_IDX_VALID(old_idx), FALSE);
g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE); g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE);
g_return_val_if_fail(doc_list[new_idx].tm_file, FALSE);
g_return_val_if_fail(line >= 1, FALSE); g_return_val_if_fail(line >= 1, FALSE);
// first add old file as old position // first add old file as old position
...@@ -148,13 +149,11 @@ gboolean navqueue_append(gint new_idx, gint line) ...@@ -148,13 +149,11 @@ gboolean navqueue_append(gint new_idx, gint line)
{ {
gint cur_line = sci_get_current_line(doc_list[old_idx].sci, -1); gint cur_line = sci_get_current_line(doc_list[old_idx].sci, -1);
navqueue_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1); add_new_position(doc_list[old_idx].tm_file->file_name, cur_line + 1);
} }
g_return_val_if_fail(doc_list[new_idx].tm_file, FALSE); add_new_position(doc_list[new_idx].tm_file->file_name, line);
return utils_goto_line(new_idx, line);
navqueue_new_position(doc_list[new_idx].tm_file->file_name, line);
return TRUE;
} }
......
...@@ -30,10 +30,7 @@ void navqueue_init(); ...@@ -30,10 +30,7 @@ void navqueue_init();
void navqueue_free(); void navqueue_free();
void navqueue_new_position(gchar *tm_filename, gint line); gboolean navqueue_goto_line(gint new_idx, gint line);
gboolean navqueue_append(gint new_idx, gint line);
void navqueue_go_back(); void navqueue_go_back();
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "msgwindow.h" #include "msgwindow.h"
#include "treeviews.h" #include "treeviews.h"
#include "main.h" #include "main.h"
#include "navqueue.h"
#include "ui_utils.h"
const guint TM_GLOBAL_TYPE_MASK = const guint TM_GLOBAL_TYPE_MASK =
...@@ -255,7 +257,7 @@ symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name) ...@@ -255,7 +257,7 @@ symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
} }
TMTag *symbols_find_in_workspace(const gchar *tag_name, gint type) static TMTag *find_workspace_tag(const gchar *tag_name, gint type)
{ {
guint j; guint j;
const GPtrArray *tags; const GPtrArray *tags;
...@@ -1035,3 +1037,31 @@ static void load_user_tags(filetype_id ft_id) ...@@ -1035,3 +1037,31 @@ static void load_user_tags(filetype_id ft_id)
} }
gboolean symbols_goto_tag(const gchar *name, gboolean definition)
{
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
gint type;
TMTag *tmtag;
// goto tag definition: all except prototypes / forward declarations / externs
type = (definition) ? tm_tag_max_t - forward_types : forward_types;
tmtag = find_workspace_tag(name, type);
if (tmtag != NULL)
{
gint new_idx = document_find_by_filename(
tmtag->atts.entry.file->work_object.file_name, TRUE);
if (navqueue_goto_line(new_idx, tmtag->atts.entry.line))
return TRUE;
}
// if we are here, there was no match and we are beeping ;-)
utils_beep();
if (type == forward_types)
ui_set_statusbar(_("Forward declaration \"%s\" not found."), name);
else
ui_set_statusbar(_("Definition of \"%s\" not found."), name);
return FALSE;
}
...@@ -38,8 +38,6 @@ const GList *symbols_get_tag_list(gint idx, guint tag_types); ...@@ -38,8 +38,6 @@ const GList *symbols_get_tag_list(gint idx, guint tag_types);
GString *symbols_get_macro_list(); GString *symbols_get_macro_list();
TMTag *symbols_find_in_workspace(const gchar *tag_name, gint type);
const gchar **symbols_get_html_entities(); const gchar **symbols_get_html_entities();
void symbols_finalize(); void symbols_finalize();
...@@ -50,4 +48,6 @@ gint symbols_generate_global_tags(gint argc, gchar **argv); ...@@ -50,4 +48,6 @@ gint symbols_generate_global_tags(gint argc, gchar **argv);
void symbols_show_load_tags_dialog(); void symbols_show_load_tags_dialog();
gboolean symbols_goto_tag(const gchar *name, gboolean definition);
#endif #endif
...@@ -544,8 +544,7 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection) ...@@ -544,8 +544,7 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
{ {
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
navqueue_append(idx, line); navqueue_goto_line(idx, line);
utils_goto_line(idx, line);
} }
} }
return FALSE; return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment