/* panel.c -- The panels management file. */
/* Copyright (C) 1993-1999 Free Software Foundation, Inc.
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, 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Written by Tudor Hulubei and Andrei Pitis. */
/* $Id: panel.c,v 1.29 2000/03/10 18:39:27 tudor Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else /* !HAVE_STDLIB_H */
#include "ansi_stdlib.h"
#endif /* !HAVE_STDLIB_H */
#include <sys/types.h>
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#include <ctype.h>
#include "file.h"
#ifdef HAVE_VALUES_H
#include <values.h>
#endif /* HAVE_VALUES_H */
#include <limits.h>
#ifndef INT_MAX
/* The actual value doesn't matter too much... */
#define INT_MAX 32767
#endif /* INT_MAX */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include "xtime.h"
#include <errno.h>
/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
#if !defined (errno)
extern int errno;
#endif /* !errno */
/* Get the statfs() prototipe from sys/vfs.h. */
#ifdef HAVE_LINUX
#include <sys/vfs.h>
#endif /* HAVE_LINUX */
#include <assert.h>
#include "stdc.h"
#include "xstring.h"
#include "xmalloc.h"
#include "xio.h"
#include "xid.h"
#include "fsusage.h"
#include "window.h"
#include "status.h"
#include "signals.h"
#include "tty.h"
#include "inputline.h"
#include "panel.h"
#include "tilde.h"
#include "fnmatch.h"
#include "configure.h"
#include "system.h"
#include "misc.h"
#include "stat.h"
extern int AnsiColors;
extern int TypeSensitivity;
char rights[16] = "-rwxrwxrwx";
#define FILE_DISPLAY_MODES 6
char *FileDisplayMode[FILE_DISPLAY_MODES] =
{
"OwnerGroup",
"DateTime",
"Size",
"Mode",
"FullName",
"All",
};
#define FILE_SORT_METHODS 9
char *FileSortMethod[FILE_SORT_METHODS] =
{
"Name",
"Extension",
"Size",
"Date",
"Mode",
"OwnerId",
"GroupId",
"OwnerName",
"GroupName",
};
#define PANEL_FIELDS 20
static char *PanelFields[PANEL_FIELDS] =
{
"PanelFrame",
"PanelBackground",
"PanelThumbForeground",
"PanelThumbBackground",
"PanelThumbBrightness",
"PanelSelectedFile",
"PanelSelectedFileBrightness",
"PanelNotSelectedFile",
"PanelNotSelectedFileBrightness",
"PanelCurrentSelectedFile",
"PanelCurrentNotSelectedFile",
"PanelCurrentFile",
"PanelPath",
"PanelPathBrightness",
"PanelDeviceFreeSpace",
"PanelDeviceFreeSpaceBrightness",
"PanelFileInfo",
"PanelFileInfoBrightness",
"PanelFilesInfo",
"PanelFilesInfoBrightness",
};
#ifdef HAVE_LINUX
static int PanelColors[PANEL_FIELDS] =
{
WHITE, BLUE, BLACK, WHITE, OFF, YELLOW, ON, WHITE, ON, YELLOW,
WHITE, CYAN, RED, OFF, RED, OFF, RED, OFF, BLACK, OFF,
};
#else /* !HAVE_LINUX */
static int PanelColors[PANEL_FIELDS] =
{
WHITE, BLACK, BLACK, WHITE, OFF, WHITE, ON, WHITE, OFF, WHITE,
BLACK, WHITE, BLACK, OFF, BLACK, OFF, BLACK, OFF, BLACK, OFF
};
#endif /* !HAVE_LINUX */
#define PanelFrame PanelColors[0]
#define PanelBackground PanelColors[1]
#define PanelThumbForeground PanelColors[2]
#define PanelThumbBackground PanelColors[3]
#define PanelThumbBrightness PanelColors[4]
#define PanelSelectedFile PanelColors[5]
#define PanelSelectedFileBrightness PanelColors[6]
#define PanelNotSelectedFile PanelColors[7]
#define PanelNotSelectedFileBrightness PanelColors[8]
#define PanelCurrentSelectedFile PanelColors[9]
#define PanelCurrentNotSelectedFile PanelColors[10]
#define PanelCurrentFile PanelColors[11]
#define PanelPath PanelColors[12]
#define PanelPathBrightness PanelColors[13]
#define PanelDeviceFreeSpace PanelColors[14]
#define PanelDeviceFreeSpaceBrightness PanelColors[15]
#define PanelFileInfo PanelColors[16]
#define PanelFileInfoBrightness PanelColors[17]
#define PanelFilesInfo PanelColors[18]
#define PanelFilesInfoBrightness PanelColors[19]
char *panel_il_message[] =
{
"Wait, reading directory...",
"Wait, copying file...",
"Wait, copying file(s)...",
"Wait, copying directory...",
"Wait, deleting directory...",
"Wait, deleting file(s)...",
"Wait, moving file...",
"Wait, moving file(s)...",
"Wait, moving directory...",
"Wait, comparing directories...",
"Wait, comparing files...",
"Wait, renaming file(s)...",
};
#define PANEL_READ_DIR_MSG panel_il_message[ 0]
#define PANEL_COPY_FILE_MSG panel_il_message[ 1]
#define PANEL_COPY_FILES_MSG panel_il_message[ 2]
#define PANEL_COPY_DIR_MSG panel_il_message[ 3]
#define PANEL_DELETE_DIR_MSG panel_il_message[ 4]
#define PANEL_DELETE_FILES_MSG panel_il_message[ 5]
#define PANEL_MOVE_FILE_MSG panel_il_message[ 6]
#define PANEL_MOVE_FILES_MSG panel_il_message[ 7]
#define PANEL_MOVE_DIR_MSG panel_il_message[ 8]
#define PANEL_COMPARE_DIR_MSG panel_il_message[ 9]
#define PANEL_COMPARE_FILES_MSG panel_il_message[10]
#define PANEL_RENAME_FILES_MSG panel_il_message[11]
/* Some useful isearch stack management functions. */
#define STACK_PUSH(__entry__, __length__) \
{ \
isearch_t current_isearch; \
\
current_isearch.entry = __entry__; \
current_isearch.length = __length__; \
\
xstack_push(this->isearch_stack, ¤t_isearch); \
}
#define STACK_POP(__entry__, __length__) \
{ \
isearch_t tmp_isearch; \
\
xstack_pop(this->isearch_stack, &tmp_isearch); \
\
__entry__ = tmp_isearch.entry; \
__length__ = tmp_isearch.length; \
}
#define STACK_PREVIEW(__entry__, __length__) \
{ \
isearch_t tmp_isearch; \
\
xstack_preview(this->isearch_stack, &tmp_isearch, 1); \
\
__entry__ = tmp_isearch.entry; \
__length__ = tmp_isearch.length; \
}
/* Is the current directory the root directory? */
#define rootdir() (this->path[0] == '/' && this->path[1] == '\0')
static int StartupFileDisplayMode;
static int StartupFileSortMethod;
static int StartupScrollStep;
static int CurrentSortMethod;
static int LeadingDotMatch = OFF;
static int InfoDisplay = OFF;
static char nice_try[] = "Nice try, maybe later... :-)";
extern void fatal PROTO ((char *));
extern void panel_update_entry PROTO ((panel_t *, int));
extern char il_read_char PROTO ((char *, char *, int));
extern char *il_read_line PROTO ((char *, char **, char *, xstack_t *));
static xstack_t *copy_history;
static xstack_t *move_history;
static xstack_t *mkdir_history;
static void
xchg(a, b)
int *a, *b;
{
int tmp = *a;
*a = *b;
*b = tmp;
}
/*
* Initialize the panel data structures. Read the necessar
评论13
最新资源