comparison src/ui_tabcomp.c @ 1382:31a747f9d268

Fix tab completion when entering "/et[TAB]" it was changed to "et", this is fixed.
author zas_
date Fri, 06 Mar 2009 11:42:25 +0000
parents 2c2f86e30f6c
children b4e6fee484f7
comparison
equal deleted inserted replaced
1381:94eb664a7da1 1382:31a747f9d268
384 else 384 else
385 { 385 {
386 entry_dir = g_strdup(entry_text); 386 entry_dir = g_strdup(entry_text);
387 } 387 }
388 388
389 entry_file = filename_from_path(entry_text);
390
391 if (isfile(entry_dir)) 389 if (isfile(entry_dir))
392 { 390 {
393 if (home_exp) 391 if (home_exp)
394 { 392 {
395 gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir); 393 gtk_entry_set_text(GTK_ENTRY(td->entry), entry_dir);
396 gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(entry_dir)); 394 gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(entry_dir));
397 } 395 }
398 g_free(entry_dir); 396 g_free(entry_dir);
399 return home_exp; 397 return home_exp;
400 } 398 }
399
400 entry_file = filename_from_path(entry_text);
401 401
402 if (isdir(entry_dir) && strcmp(entry_file, ".") != 0 && strcmp(entry_file, "..") != 0) 402 if (isdir(entry_dir) && strcmp(entry_file, ".") != 0 && strcmp(entry_file, "..") != 0)
403 { 403 {
404 ptr = entry_dir + strlen(entry_dir) - 1; 404 ptr = entry_dir + strlen(entry_dir) - 1;
405 if (ptr[0] == G_DIR_SEPARATOR) 405 if (ptr[0] == G_DIR_SEPARATOR)
453 } 453 }
454 454
455 ptr = (gchar *)filename_from_path(entry_dir); 455 ptr = (gchar *)filename_from_path(entry_dir);
456 if (ptr > entry_dir) ptr--; 456 if (ptr > entry_dir) ptr--;
457 ptr[0] = '\0'; 457 ptr[0] = '\0';
458 458
459 if (strlen(entry_dir) == 0) 459 if (strlen(entry_dir) == 0)
460 { 460 {
461 g_free(entry_dir); 461 g_free(entry_dir);
462 entry_dir = g_strdup(G_DIR_SEPARATOR_S); /* FIXME: win32 */ 462 entry_dir = g_strdup(G_DIR_SEPARATOR_S); /* FIXME: win32 */
463 } 463 }
470 470
471 if (!td->dir_path || !td->file_list || strcmp(td->dir_path, entry_dir) != 0) 471 if (!td->dir_path || !td->file_list || strcmp(td->dir_path, entry_dir) != 0)
472 { 472 {
473 tab_completion_read_dir(td, entry_dir); 473 tab_completion_read_dir(td, entry_dir);
474 } 474 }
475
476 if (strcmp(entry_dir, G_DIR_SEPARATOR_S) == 0) entry_dir[0] = '\0'; /* FIXME: win32 */
477 475
478 list = td->file_list; 476 list = td->file_list;
479 while (list) 477 while (list)
480 { 478 {
481 gchar *file = list->data; 479 gchar *file = list->data;
492 { 490 {
493 gchar *file = poss->data; 491 gchar *file = poss->data;
494 gchar *buf; 492 gchar *buf;
495 493
496 buf = g_build_filename(entry_dir, file, NULL); 494 buf = g_build_filename(entry_dir, file, NULL);
497
498 if (isdir(buf))
499 {
500 gchar *tmp = g_strconcat(buf, G_DIR_SEPARATOR_S, NULL);
501 g_free(buf);
502 buf = tmp;
503 }
504 gtk_entry_set_text(GTK_ENTRY(td->entry), buf); 495 gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
505 gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf)); 496 gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
506 g_free(buf); 497 g_free(buf);
507 g_list_free(poss); 498 g_list_free(poss);
508 g_free(entry_dir); 499 g_free(entry_dir);