Temporarry commit. Fixed completion in browse by directoryes.
Not fixed completion by commands (fail if command in $PATH contain space)
Этот коммит содержится в:
родитель
26c9d6d107
Коммит
a419b71b6e
@ -74,6 +74,7 @@ filename_completion_function (char *text, int state)
|
|||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (users_dirname);
|
g_free (users_dirname);
|
||||||
|
|
||||||
|
text = unescape_string(text);
|
||||||
if ((*text) && (temp = strrchr (text, PATH_SEP))){
|
if ((*text) && (temp = strrchr (text, PATH_SEP))){
|
||||||
filename = g_strdup (++temp);
|
filename = g_strdup (++temp);
|
||||||
dirname = g_strndup (text, temp - text);
|
dirname = g_strndup (text, temp - text);
|
||||||
@ -81,6 +82,7 @@ filename_completion_function (char *text, int state)
|
|||||||
dirname = g_strdup (".");
|
dirname = g_strdup (".");
|
||||||
filename = g_strdup (text);
|
filename = g_strdup (text);
|
||||||
}
|
}
|
||||||
|
mhl_mem_free(text);
|
||||||
|
|
||||||
/* We aren't done yet. We also support the "~user" syntax. */
|
/* We aren't done yet. We also support the "~user" syntax. */
|
||||||
|
|
||||||
@ -122,6 +124,9 @@ filename_completion_function (char *text, int state)
|
|||||||
strcat (tmp, PATH_SEP_STR);
|
strcat (tmp, PATH_SEP_STR);
|
||||||
strcat (tmp, entry->d_name);
|
strcat (tmp, entry->d_name);
|
||||||
canonicalize_pathname (tmp);
|
canonicalize_pathname (tmp);
|
||||||
|
if (! strncmp(dirname,"/home", 5)){
|
||||||
|
mc_log2("'%s' -> '%s'\n",entry->d_name, tmp);
|
||||||
|
}
|
||||||
/* Unix version */
|
/* Unix version */
|
||||||
if (!mc_stat (tmp, &tempstat)){
|
if (!mc_stat (tmp, &tempstat)){
|
||||||
uid_t my_uid = getuid ();
|
uid_t my_uid = getuid ();
|
||||||
@ -195,6 +200,7 @@ username_completion_function (char *text, int state)
|
|||||||
static struct passwd *entry;
|
static struct passwd *entry;
|
||||||
static int userlen;
|
static int userlen;
|
||||||
|
|
||||||
|
if (text[0] == '\\' && text[1] == '~') text++;
|
||||||
if (!state){ /* Initialization stuff */
|
if (!state){ /* Initialization stuff */
|
||||||
setpwent ();
|
setpwent ();
|
||||||
userlen = strlen (text + 1);
|
userlen = strlen (text + 1);
|
||||||
@ -646,8 +652,15 @@ try_complete (char *text, int *start, int *end, int flags)
|
|||||||
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
|
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
|
||||||
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)){
|
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)){
|
||||||
i = *start - 1;
|
i = *start - 1;
|
||||||
while (i > -1 && (text[i] == ' ' || text[i] == '\t'))
|
for (i = *start - 1; i > -1; i--) {
|
||||||
i--;
|
if (text[i] == ' ' || text[i] == '\t'){
|
||||||
|
if (i == 0 ) continue;
|
||||||
|
if (text[i-1] == '\\') {
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
in_command_position++;
|
in_command_position++;
|
||||||
else if (strchr (command_separator_chars, text[i])){
|
else if (strchr (command_separator_chars, text[i])){
|
||||||
@ -723,10 +736,24 @@ try_complete (char *text, int *start, int *end, int flags)
|
|||||||
ignore_filenames = 0;
|
ignore_filenames = 0;
|
||||||
if (!matches && is_cd && *word != PATH_SEP && *word != '~'){
|
if (!matches && is_cd && *word != PATH_SEP && *word != '~'){
|
||||||
char *p, *q = text + *start;
|
char *p, *q = text + *start;
|
||||||
|
|
||||||
for (p = text; *p && p < q && (*p == ' ' || *p == '\t'); p++);
|
for (p = text; *p && p < q; p++){
|
||||||
|
if (*p == ' ' || *p == '\t') {
|
||||||
|
if (p == text) continue;
|
||||||
|
if (*(p-1) == '\\') {
|
||||||
|
p--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!strncmp (p, "cd", 2))
|
if (!strncmp (p, "cd", 2))
|
||||||
for (p += 2; *p && p < q && (*p == ' ' || *p == '\t'); p++);
|
for (p += 2; *p && p < q && (*p == ' ' || *p == '\t'); p++){
|
||||||
|
if (p == text) continue;
|
||||||
|
if (*(p-1) == '\\') {
|
||||||
|
p--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p == q){
|
if (p == q){
|
||||||
char * const cdpath_ref = g_strdup (getenv ("CDPATH"));
|
char * const cdpath_ref = g_strdup (getenv ("CDPATH"));
|
||||||
char *cdpath = cdpath_ref;
|
char *cdpath = cdpath_ref;
|
||||||
@ -920,8 +947,12 @@ complete_engine (WInput *in, int what_to_do)
|
|||||||
if (!in->completions){
|
if (!in->completions){
|
||||||
end = in->point;
|
end = in->point;
|
||||||
for (start = end ? end - 1 : 0; start > -1; start--)
|
for (start = end ? end - 1 : 0; start > -1; start--)
|
||||||
if (strchr (" \t;|<>", in->buffer [start]))
|
if (strchr (" \t;|<>", in->buffer [start])){
|
||||||
break;
|
if (start > 0 && in->buffer [start-1] == '\\')
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (start < end)
|
if (start < end)
|
||||||
start++;
|
start++;
|
||||||
in->completions = try_complete (in->buffer, &start, &end, in->completion_flags);
|
in->completions = try_complete (in->buffer, &start, &end, in->completion_flags);
|
||||||
@ -936,7 +967,7 @@ complete_engine (WInput *in, int what_to_do)
|
|||||||
free_completions (in);
|
free_completions (in);
|
||||||
} else
|
} else
|
||||||
beep ();
|
beep ();
|
||||||
//mhl_mem_free(complete);
|
mhl_mem_free(complete);
|
||||||
}
|
}
|
||||||
if ((what_to_do & DO_QUERY) && in->completions && in->completions [1]) {
|
if ((what_to_do & DO_QUERY) && in->completions && in->completions [1]) {
|
||||||
int maxlen = 0, i, count = 0;
|
int maxlen = 0, i, count = 0;
|
||||||
@ -945,10 +976,13 @@ complete_engine (WInput *in, int what_to_do)
|
|||||||
char **p, *q;
|
char **p, *q;
|
||||||
Dlg_head *query_dlg;
|
Dlg_head *query_dlg;
|
||||||
WListbox *query_list;
|
WListbox *query_list;
|
||||||
|
|
||||||
for (p=in->completions + 1; *p; count++, p++) {
|
for (p=in->completions + 1; *p; count++, p++) {
|
||||||
if ((i = strlen (*p)) > maxlen)
|
q = *p;
|
||||||
maxlen = i;
|
*p = escape_string(*p);
|
||||||
|
mhl_mem_free(q);
|
||||||
|
if ((i = strlen (*p)) > maxlen)
|
||||||
|
maxlen = i;
|
||||||
}
|
}
|
||||||
start_x = in->widget.x;
|
start_x = in->widget.x;
|
||||||
start_y = in->widget.y;
|
start_y = in->widget.y;
|
||||||
|
@ -68,3 +68,19 @@ mc_log(const char *fmt, ...)
|
|||||||
g_free(logfilename);
|
g_free(logfilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mc_log2(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
FILE *f;
|
||||||
|
char *logfilename;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
logfilename = g_strdup_printf("%s/.mc/log2", home_dir);
|
||||||
|
if ((f = fopen(logfilename, "a")) != NULL) {
|
||||||
|
(void)vfprintf(f, fmt, args);
|
||||||
|
(void)fclose(f);
|
||||||
|
}
|
||||||
|
g_free(logfilename);
|
||||||
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user