mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
add recursive search file TAGS
This commit is contained in:
parent
20c769b063
commit
351f42ac24
@ -46,6 +46,7 @@
|
|||||||
#include "editcmddef.h"
|
#include "editcmddef.h"
|
||||||
#include "edit-widget.h"
|
#include "edit-widget.h"
|
||||||
#include "etags.h"
|
#include "etags.h"
|
||||||
|
#include "../src/panel.h"
|
||||||
|
|
||||||
#include "../src/color.h" /* dialog_colors */
|
#include "../src/color.h" /* dialog_colors */
|
||||||
#include "../src/tty.h" /* LINES */
|
#include "../src/tty.h" /* LINES */
|
||||||
@ -3095,7 +3096,7 @@ edit_select_definition_dialog (WEdit * edit, int max_len, int word_len,
|
|||||||
edit_history_moveto[edit_stack_iterator].filename = g_strdup(edit->filename);
|
edit_history_moveto[edit_stack_iterator].filename = g_strdup(edit->filename);
|
||||||
edit_history_moveto[edit_stack_iterator].line = edit->start_line + edit->curs_row + 1;
|
edit_history_moveto[edit_stack_iterator].line = edit->start_line + edit->curs_row + 1;
|
||||||
edit_stack_iterator++;
|
edit_stack_iterator++;
|
||||||
mc_log("%s:%i iterator=%i\n", curr_def->filename, curr_def->line, edit_stack_iterator);
|
// mc_log("%s:%i iterator=%i\n", curr_def->filename, curr_def->line, edit_stack_iterator);
|
||||||
g_free( edit_history_moveto[edit_stack_iterator].filename );
|
g_free( edit_history_moveto[edit_stack_iterator].filename );
|
||||||
edit_history_moveto[edit_stack_iterator].filename = g_strdup(curr_def->filename);
|
edit_history_moveto[edit_stack_iterator].filename = g_strdup(curr_def->filename);
|
||||||
edit_history_moveto[edit_stack_iterator].line = curr_def->line;
|
edit_history_moveto[edit_stack_iterator].line = curr_def->line;
|
||||||
@ -3120,8 +3121,14 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
|||||||
{
|
{
|
||||||
int word_len = 0, num_def = 0, max_len;
|
int word_len = 0, num_def = 0, max_len;
|
||||||
long word_start = 0;
|
long word_start = 0;
|
||||||
|
int len = 0;
|
||||||
unsigned char *bufpos;
|
unsigned char *bufpos;
|
||||||
char *match_expr;
|
char *match_expr;
|
||||||
|
char *path = NULL;
|
||||||
|
char *ptr = NULL;
|
||||||
|
char *tagfile = NULL;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
struct def_hash_type def_hash[MAX_DEFINITIONS];
|
struct def_hash_type def_hash[MAX_DEFINITIONS];
|
||||||
|
|
||||||
for ( int i = 0; i < MAX_DEFINITIONS; i++) {
|
for ( int i = 0; i < MAX_DEFINITIONS; i++) {
|
||||||
@ -3138,9 +3145,29 @@ edit_get_match_keyword_cmd (WEdit *edit)
|
|||||||
[word_start & M_EDIT_BUF_SIZE];
|
[word_start & M_EDIT_BUF_SIZE];
|
||||||
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
|
match_expr = g_strdup_printf ("%.*s", word_len, bufpos);
|
||||||
|
|
||||||
mc_log("%s \n", match_expr);
|
path = g_strdup_printf ("%s/", current_panel->cwd);
|
||||||
|
mc_log("%s\n", path);
|
||||||
|
len = strlen(path);
|
||||||
|
ptr = path + len;
|
||||||
|
|
||||||
set_def_hash("TAGS", match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
while ( ptr != path ) {
|
||||||
|
if ( *ptr == '/' ) {
|
||||||
|
path[len] = '\0';
|
||||||
|
g_free (tagfile);
|
||||||
|
tagfile = g_strdup_printf ("%s/TAGS", path);
|
||||||
|
mc_log("%s\n",tagfile);
|
||||||
|
f = fopen (tagfile, "r");
|
||||||
|
if ( f ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr--;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_def_hash(tagfile, path, match_expr, (struct def_hash_type *) &def_hash, &num_def);
|
||||||
|
g_free (path);
|
||||||
|
g_free (tagfile);
|
||||||
max_len = 50;
|
max_len = 50;
|
||||||
word_len = 0;
|
word_len = 0;
|
||||||
if ( num_def > 0 ) {
|
if ( num_def > 0 ) {
|
||||||
|
15
edit/etags.c
15
edit/etags.c
@ -25,7 +25,7 @@ long get_pos_from(char *str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash, int *num)
|
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
static char buf[4048];
|
static char buf[4048];
|
||||||
@ -35,12 +35,13 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
|||||||
int i;
|
int i;
|
||||||
if (!f)
|
if (!f)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
len = strlen( match_func );
|
len = strlen( match_func );
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
char *fullpath = NULL;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
long line;
|
long line;
|
||||||
enum {start, in_filename, in_define} state=start;
|
enum {start, in_filename, in_define} state = start;
|
||||||
|
|
||||||
while (fgets (buf, sizeof (buf), f)) {
|
while (fgets (buf, sizeof (buf), f)) {
|
||||||
|
|
||||||
@ -52,9 +53,7 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
|||||||
break;
|
break;
|
||||||
case in_filename:
|
case in_filename:
|
||||||
pos = strcspn(buf, ",");
|
pos = strcspn(buf, ",");
|
||||||
if ( filename ) {
|
g_free(filename);
|
||||||
g_free(filename);
|
|
||||||
}
|
|
||||||
filename = malloc(pos + 2);
|
filename = malloc(pos + 2);
|
||||||
g_strlcpy ( filename, (char *)buf, pos + 1 );
|
g_strlcpy ( filename, (char *)buf, pos + 1 );
|
||||||
state = in_define;
|
state = in_define;
|
||||||
@ -73,7 +72,9 @@ int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash
|
|||||||
state = start;
|
state = start;
|
||||||
if ( *num < MAX_DEFINITIONS ) {
|
if ( *num < MAX_DEFINITIONS ) {
|
||||||
def_hash[*num].filename_len = strlen(filename);
|
def_hash[*num].filename_len = strlen(filename);
|
||||||
def_hash[*num].filename = g_strdup(filename);
|
fullpath = g_strdup_printf("%s/%s",start_path, filename);
|
||||||
|
def_hash[*num].filename = g_strdup(fullpath);
|
||||||
|
g_free(fullpath);
|
||||||
def_hash[*num].line = line;
|
def_hash[*num].line = line;
|
||||||
(*num)++;
|
(*num)++;
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,4 @@ struct def_hash_type {
|
|||||||
long line;
|
long line;
|
||||||
};
|
};
|
||||||
long get_pos_from(char *str);
|
long get_pos_from(char *str);
|
||||||
int set_def_hash(char *tagfile, char *match_func, struct def_hash_type *def_hash, int *num);
|
int set_def_hash(char *tagfile, char *start_path, char *match_func, struct def_hash_type *def_hash, int *num);
|
||||||
|
Loading…
Reference in New Issue
Block a user