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
This commit is contained in:
parent
6b3b7fe55a
commit
852a4dbb50
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
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>
|
||||
|
||||
* src/keybindings.c, src/editor.c, src/editor.h:
|
||||
|
@ -1054,41 +1054,14 @@ void
|
||||
on_goto_tag_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
|
||||
gint type;
|
||||
TMTag *tmtag;
|
||||
gboolean definition = (menuitem ==
|
||||
GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")));
|
||||
document *doc = document_get_current();
|
||||
|
||||
// goto tag definition: all except prototypes / forward declarations / externs
|
||||
if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")))
|
||||
type = tm_tag_max_t - forward_types;
|
||||
else
|
||||
type = forward_types;
|
||||
g_return_if_fail(doc);
|
||||
|
||||
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,
|
||||
tmtag->atts.entry.line);
|
||||
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);
|
||||
sci_set_current_position(doc->sci, editor_info.click_pos, FALSE);
|
||||
symbols_goto_tag(editor_info.current_word, definition);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "build.h"
|
||||
#include "tools.h"
|
||||
#include "navqueue.h"
|
||||
#include "symbols.h"
|
||||
|
||||
|
||||
const gboolean swap_alt_tab_order = FALSE;
|
||||
@ -942,12 +943,10 @@ static void cb_func_current_word(guint key_id)
|
||||
on_find_usage1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_POPUP_GOTOTAGDEFINITION:
|
||||
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
|
||||
"goto_tag_definition1")), NULL);
|
||||
symbols_goto_tag(editor_info.current_word, TRUE);
|
||||
break;
|
||||
case GEANY_KEYS_POPUP_GOTOTAGDECLARATION:
|
||||
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
|
||||
"goto_tag_declaration1")), NULL);
|
||||
symbols_goto_tag(editor_info.current_word, FALSE);
|
||||
break;
|
||||
case GEANY_KEYS_POPUP_CONTEXTACTION:
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
void navqueue_new_position(gchar *tm_filename, gint line)
|
||||
static void add_new_position(gchar *tm_filename, gint line)
|
||||
{
|
||||
filepos *npos;
|
||||
guint i;
|
||||
@ -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.
|
||||
* 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();
|
||||
|
||||
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_list[new_idx].tm_file, FALSE);
|
||||
g_return_val_if_fail(line >= 1, FALSE);
|
||||
|
||||
// first add old file as old position
|
||||
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
navqueue_new_position(doc_list[new_idx].tm_file->file_name, line);
|
||||
return TRUE;
|
||||
add_new_position(doc_list[new_idx].tm_file->file_name, line);
|
||||
return utils_goto_line(new_idx, line);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,10 +30,7 @@ void navqueue_init();
|
||||
void navqueue_free();
|
||||
|
||||
|
||||
void navqueue_new_position(gchar *tm_filename, gint line);
|
||||
|
||||
gboolean navqueue_append(gint new_idx, gint line);
|
||||
|
||||
gboolean navqueue_goto_line(gint new_idx, gint line);
|
||||
|
||||
void navqueue_go_back();
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "msgwindow.h"
|
||||
#include "treeviews.h"
|
||||
#include "main.h"
|
||||
#include "navqueue.h"
|
||||
#include "ui_utils.h"
|
||||
|
||||
|
||||
const guint TM_GLOBAL_TYPE_MASK =
|
||||
@ -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;
|
||||
const GPtrArray *tags;
|
||||
@ -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);
|
||||
|
||||
GString *symbols_get_macro_list();
|
||||
|
||||
TMTag *symbols_find_in_workspace(const gchar *tag_name, gint type);
|
||||
|
||||
const gchar **symbols_get_html_entities();
|
||||
|
||||
void symbols_finalize();
|
||||
@ -50,4 +48,6 @@ gint symbols_generate_global_tags(gint argc, gchar **argv);
|
||||
|
||||
void symbols_show_load_tags_dialog();
|
||||
|
||||
gboolean symbols_goto_tag(const gchar *name, gboolean definition);
|
||||
|
||||
#endif
|
||||
|
@ -544,8 +544,7 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
navqueue_append(idx, line);
|
||||
utils_goto_line(idx, line);
|
||||
navqueue_goto_line(idx, line);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user