Written: 1994, 1996 Janne Kukonlehto
1997 Norbert Warmuth
1996 Miguel de Icaza
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par);
#define tcallback (callback_fn) tree_callback
-/* "$Id: tree.c,v 1.1 2001/12/30 09:55:21 sedwards Exp $" */
+/* "$Id$" */
/* Returns number of common characters */
static inline int str_common (char *s1, char *s2)
/etc.old/X11
/etc.old/rc.d
/usr
-
- i.e. the required collating sequence when comparing two directory names is
+
+ i.e. the required collating sequence when comparing two directory names is
'\0' < PATH_SEP < all-other-characters-in-encoding-order
-
+
Since strcmp doesn't fulfil this requirement we use pathcmp when
- inserting directory names into the list. The meaning of the return value
- of pathcmp and strcmp are the same (an integer less than, equal to, or
- greater than zero if p1 is found to be less than, to match, or be greater
+ inserting directory names into the list. The meaning of the return value
+ of pathcmp and strcmp are the same (an integer less than, equal to, or
+ greater than zero if p1 is found to be less than, to match, or be greater
than p2.
*/
int
for ( ;*p1 == *p2; p1++, p2++)
if (*p1 == '\0' )
return 0;
-
+
if (*p1 == '\0')
return -1;
if (*p2 == '\0')
if (!tree)
return 0;
-
+
if (tree->tree_last && tree->tree_last->next)
abort ();
#if 0
old = current;
current = current->next;
}
-
+
if (flag == 0)
return current; /* Already in the list */
if (name [0] == PATH_SEP && name [1] == 0)
return;
/* Miguel Ugly hack end */
-
+
base = whereis (tree, name);
if (!base)
return; /* Doesn't exist */
tree = (WTree *) find_widget_type (current_dlg, tcallback);
if (!tree)
return;
-
+
/* Search for the start of subdirectories */
mc_get_current_wd (tree->check_name, MC_MAXPATHLEN);
tree->check_start = NULL;
current = tree->check_start;
while (current && (flag = pathcmp (current->name, name)) < 0)
current = current->next;
-
+
if (flag != 0)
/* Doesn't exist -> add it */
current = tree_add_entry (tree, name);
tree = (WTree *) find_widget_type (current_dlg, tcallback);
if (!tree)
return;
-
+
/* Check delete marks and delete if found */
len = strlen (tree->check_name);
file = fopen (filename, "r");
free (filename);
}
-
+
if (file){
/* File open -> read contents */
oldname [0] = 0;
}
#ifdef OS2_NT
/* .ado: Drives for NT and OS/2 */
- if ((len > 2) &&
- isalpha(name[0]) &&
- (name[1] == ':') &&
+ if ((len > 2) &&
+ isalpha(name[0]) &&
+ (name[1] == ':') &&
(name[2] == '\\')) {
tree_add_entry (tree, name);
strcpy (oldname, name);
line = tree_lines+2;
} else
line = tree_lines+1;
-
+
widget_move (&tree->widget, line, 1);
hline (' ', tree_cols);
widget_move (&tree->widget, line, 1);
-
+
if (tree->searching){
/* Show search string */
attrset (TREE_NORMALC);
attrset (FOCUSC);
addch (PATH_SEP);
-
+
addstr (name_trunc (tree->search_buffer, tree_cols-2));
addch (' ');
attrset (FOCUSC);
tree->topdiff = 0;
}
current = tree->selected_ptr;
-
+
/* Calculate the directory which is to be shown on the topmost line */
if (tree_navigation_flag){
i = 0;
if (!current)
continue;
-
+
tree->tree_shown [i] = current;
if (current->sublevel == topsublevel){
addch (ACS_LTEE);
addch (ACS_HLINE);
noacs ();
-
+
if (tree->active && current == tree->selected_ptr)
/* Selected directory -> change color */
if (!use_colors && !tree->is_panel)
tree_cols - 2 - 4 - 3 * j));
}
addch (' ');
-
+
/* Return to normal color */
attrset (TREE_NORMALC);
{
tree_entry *current;
int j = 0;
-
+
if (tree_navigation_flag){
current = tree->selected_ptr;
while (j < i && current->prev
{
tree_entry *current;
tree_entry *old;
-
+
if (!tree->selected_ptr)
return 0;
old = tree->selected_ptr;
if (tree->is_panel)
event->y--;
-
+
event->y--;
if (!tree->active)
if (!search_tree (tree, tree->search_buffer))
tree->search_buffer [--l] = 0;
-
+
show_tree (tree);
maybe_chdir (tree);
}
if (!tree->selected_ptr || !mc_get_current_wd (old_dir, MC_MAXPATHLEN) ||
mc_chdir (tree->selected_ptr->name))
return;
-
+
start_tree_check (tree);
dirp = opendir (".");
if (dirp){
static int move_left (WTree *tree)
{
int v;
-
+
if (tree_navigation_flag){
v = tree_move_to_parent (tree);
show_tree (tree);
int i;
if (tree->searching){
-
+
if (tree->selected_ptr == tree->tree_last)
tree_move_to_top(tree);
else {
- /* set navigation mode temporarily to 'Static' because in
+ /* set navigation mode temporarily to 'Static' because in
* dynamic navigation mode tree_move_forward will not move
* to a lower sublevel if necessary (sequent searches must
* start with the directory followed the last found directory)
- */
+ */
i = tree_navigation_flag;
tree_navigation_flag = 0;
tree_move_forward (tree, 1);
if (tree->is_panel)
draw_double_box (h, tree->widget.y, tree->widget.x, tree->widget.lines,
tree->widget.cols);
-
+
if (show_mini_info && tree->is_panel){
widget_move (tree, tlines (tree) + 1, 1);
hline (ACS_HLINE, tree->widget.cols - 2);
case WIDGET_FOCUS:
tree->active = 1;
define_label (h, (Widget *)tree, 1, _("Help"), (voidfn) tree_help_cmd);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
2, _("Rescan"), (buttonbarfn)tree_rescan_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
3, _("Forget"), (buttonbarfn)tree_forget_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
5, _("Copy"), (buttonbarfn) tree_copy_cmd, tree);
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
6, _("RenMov"), (buttonbarfn) tree_move_cmd, tree);
#if 0
/* FIXME: mkdir is currently defunct */
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
7, _("Mkdir"), (buttonbarfn) tree_mkdir_cmd, tree);
#else
define_label (h, (Widget *)tree, 7, "", 0);
#endif
- define_label_data (h, (Widget *)tree,
+ define_label_data (h, (Widget *)tree,
8, _("Rmdir"), (buttonbarfn) tree_rmdir_cmd, tree);
set_navig_label (h);
redraw_labels (h, (Widget *)tree);
-
+
/* FIXME: Should find a better way of only displaying the
- currently selected item */
+ currently selected item */
show_tree (tree);
return 1;
tree->searching = 0;
tree->done = 0;
tree->active = 0;
-
+
/* We do not want to keep the cursor */
widget_want_cursor (tree->widget, 0);
load_tree (tree);
{
char *p, *q;
int result;
-
+
if (!mc_mkdir (s, mode))
return 0;
free (p);
if (!(result = my_mkdir_rec (q, mode))) {
result = mc_mkdir (s, mode);
- }
+ }
free (q);
return result;
}
int my_mkdir (char *s, mode_t mode)
{
int result;
-#if FIXME
+#if FIXME
WTree *tree = 0;
-#endif
+#endif
result = mc_mkdir (s, mode);
#ifdef OS2_NT
#endif
if (result) {
char *p = vfs_canon (s);
-
+
result = my_mkdir_rec (p, mode);
free (p);
}
int my_rmdir (char *s)
{
int result;
-#if FIXME
+#if FIXME
WTree *tree = 0;
-#endif
+#endif
/* FIXME: Should receive a Wtree! */
result = mc_rmdir (s);