Mon Mar 30 20:02:49 1998 Paul Sheer <psheer@obsidian.co.za>
* main.c, screen.c, dirhist.c, dirhist.h, main.h, widget.c, main.h and others?: Directory history added. The previous directory history code was removed. The directory history now loads and saves using the same routines as the input widget. The keys meta-y, and meta-u are used to go backward and forward through the history. The buttons to the right and left of the current directory display on the panel can be used as well. The v button brings up a history, but no key is assigned to this. Discussion as to correct color and shape of these buttons is open. show_hist() in widget.c is made generic to be called for any widget. Help pages still needed to be added for the directory history.
Этот коммит содержится в:
родитель
60c595aa91
Коммит
e249fcde42
@ -26,6 +26,21 @@ Sat Mar 28 13:18:36 1998 Alex Tkachenko <alex@bcs.zp.ua>
|
||||
* src/screen.c: (repaint_file) last patches to format_file() in the
|
||||
same file broke appearance of panels in brief mode -- fixed.
|
||||
|
||||
Mon Mar 30 20:02:49 1998 Paul Sheer <psheer@obsidian.co.za>
|
||||
|
||||
* main.c, screen.c, dirhist.c, dirhist.h, main.h, widget.c,
|
||||
main.h and others?: Directory history added. The previous
|
||||
directory history code was removed. The directory history now
|
||||
loads and saves using the same routines as the input widget. The
|
||||
keys meta-y, and meta-u are used to go backward and forward
|
||||
through the history. The buttons to the right and left of the
|
||||
current directory display on the panel can be used as well. The
|
||||
v button brings up a history, but no key is assigned to this.
|
||||
Discussion as to correct color and shape of these buttons is
|
||||
open. show_hist() in widget.c is made generic to be called for
|
||||
any widget. Help pages still needed to be added for the
|
||||
directory history.
|
||||
|
||||
Wed Mar 25 19:05:31 1998 Norbert Warmuth <k3190@fh-sw.de>
|
||||
|
||||
* view.c (view_done): Set monitor off before deleting the view
|
||||
|
@ -21,7 +21,7 @@ SRCS = dir.c util.c main.c screen.c dialog.c key.c menu.c\
|
||||
wtools.c cons.handler.c chown.c subshell.c terms.c boxes.c \
|
||||
hotlist.c achown.c layout.c fsusage.c mountlist.c regex.c \
|
||||
complete.c slint.c command.c cmd.c panelize.c learn.c \
|
||||
listmode.c utilunix.c background.c dirhist.c rxvt.c popt.c \
|
||||
listmode.c utilunix.c background.c rxvt.c popt.c \
|
||||
text.c
|
||||
|
||||
HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
|
||||
@ -31,7 +31,7 @@ HDRS = color.h file.h mouse.h user.h dialog.h find.h main.h \
|
||||
subshell.h view.h setup.h key.h ext.h boxes.h \
|
||||
hotlist.h layout.h fsusage.h mountlist.h regex.h complete.h \
|
||||
myslang.h command.h cmd.h tty.h fs.h panelize.h achown.h \
|
||||
learn.h listmode.h features.inc background.h dirhist.h \
|
||||
learn.h listmode.h features.inc background.h \
|
||||
x.h popt.h textconf.h i18n.h
|
||||
|
||||
OBJS = dir.o util.o screen.o dialog.o key.o menu.o\
|
||||
@ -42,7 +42,7 @@ OBJS = dir.o util.o screen.o dialog.o key.o menu.o\
|
||||
hotlist.o achown.o layout.o fsusage.o mountlist.o \
|
||||
@XCURSES@ @REGEX_O@ complete.o slint.o command.o \
|
||||
cmd.o main.o panelize.o learn.o listmode.o utilunix.o \
|
||||
background.o dirhist.o rxvt.o popt.o text.o
|
||||
background.o rxvt.o popt.o text.o
|
||||
|
||||
#
|
||||
# Distribution variables
|
||||
|
72
src/main.c
72
src/main.c
@ -111,7 +111,6 @@
|
||||
#endif
|
||||
#include "listmode.h"
|
||||
#include "background.h"
|
||||
#include "dirhist.h"
|
||||
#include "ext.h" /* For flush_extension_file() */
|
||||
|
||||
/* Listbox for the command history feature */
|
||||
@ -906,6 +905,70 @@ subshell_chdir (char *directory)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
directory_history_add (WPanel * panel, char *s)
|
||||
{
|
||||
if (!panel->dir_history) {
|
||||
panel->dir_history = malloc (sizeof (Hist));
|
||||
memset (panel->dir_history, 0, sizeof (Hist));
|
||||
panel->dir_history->text = strdup (s);
|
||||
return;
|
||||
}
|
||||
if (!strcmp (panel->dir_history->text, s))
|
||||
return;
|
||||
if (panel->dir_history->next) {
|
||||
if (panel->dir_history->next->text) {
|
||||
free (panel->dir_history->next->text);
|
||||
panel->dir_history->next->text = 0;
|
||||
}
|
||||
} else {
|
||||
panel->dir_history->next = malloc (sizeof (Hist));
|
||||
memset (panel->dir_history->next, 0, sizeof (Hist));
|
||||
panel->dir_history->next->prev = panel->dir_history;
|
||||
}
|
||||
panel->dir_history = panel->dir_history->next;
|
||||
panel->dir_history->text = strdup (s);
|
||||
}
|
||||
|
||||
int do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type);
|
||||
|
||||
void
|
||||
directory_history_next (WPanel * panel)
|
||||
{
|
||||
if (!panel->dir_history->next)
|
||||
return;
|
||||
if (do_panel_cd (panel, panel->dir_history->next->text, cd_exact))
|
||||
panel->dir_history = panel->dir_history->next;
|
||||
}
|
||||
|
||||
void
|
||||
directory_history_prev (WPanel * panel)
|
||||
{
|
||||
if (!panel->dir_history->prev)
|
||||
return;
|
||||
if (do_panel_cd (panel, panel->dir_history->prev->text, cd_exact))
|
||||
panel->dir_history = panel->dir_history->prev;
|
||||
}
|
||||
|
||||
void
|
||||
directory_history_list (WPanel * panel)
|
||||
{
|
||||
char *s;
|
||||
/* must be at least two to show a history */
|
||||
if (panel->dir_history) {
|
||||
if (panel->dir_history->prev || panel->dir_history->next) {
|
||||
s = show_hist (panel->dir_history, panel->widget.x, panel->widget.y);
|
||||
if (s) {
|
||||
int r;
|
||||
r = do_panel_cd (panel, s, cd_exact);
|
||||
if (r)
|
||||
directory_history_add (panel, panel->cwd);
|
||||
free (s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Changes the current panel directory */
|
||||
int
|
||||
do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
|
||||
@ -939,7 +1002,6 @@ do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
|
||||
}
|
||||
|
||||
/* Success: save previous directory, shutdown status of previous dir */
|
||||
directory_history_add (olddir);
|
||||
strcpy (panel->lwd, olddir);
|
||||
free_completions (input_w (cmdline));
|
||||
|
||||
@ -974,7 +1036,11 @@ do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
|
||||
int
|
||||
do_cd (char *new_dir, enum cd_enum exact)
|
||||
{
|
||||
return do_panel_cd (cpanel, new_dir, exact);
|
||||
int r;
|
||||
r = do_panel_cd (cpanel, new_dir, exact);
|
||||
if (r)
|
||||
directory_history_add (cpanel, cpanel->cwd);
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
|
@ -128,6 +128,8 @@ void outrefresh_screen (void);
|
||||
void suspend_cmd (void);
|
||||
void do_update_prompt (void);
|
||||
|
||||
|
||||
|
||||
extern char control_file [];
|
||||
extern char *shell;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "dir.h" /* file_entry */
|
||||
#include "dlg.h"
|
||||
#include "widget.h" /* for history loading and saving */
|
||||
|
||||
#define LIST_TYPES 4
|
||||
|
||||
@ -68,6 +69,8 @@ typedef struct {
|
||||
int active; /* If panel is currently selected */
|
||||
char cwd [MC_MAXPATHLEN];/* Current Working Directory */
|
||||
char lwd [MC_MAXPATHLEN];/* Last Working Directory */
|
||||
Hist *dir_history; /* directory history */
|
||||
char *hist_name; /* directory history name for history file */
|
||||
int count; /* Number of files in dir structure */
|
||||
int marked; /* Count of marked files */
|
||||
int dirs_marked; /* Count of marked directories */
|
||||
|
54
src/screen.c
54
src/screen.c
@ -744,10 +744,16 @@ show_dir (WPanel *panel)
|
||||
if (panel->active)
|
||||
attrset (REVERSE_COLOR);
|
||||
|
||||
widget_move (&panel->widget, 0, 1);
|
||||
widget_move (&panel->widget, 0, 3);
|
||||
|
||||
trim (strip_home_and_password (panel->cwd), tmp, panel->widget.cols-5);
|
||||
trim (strip_home_and_password (panel->cwd), tmp, panel->widget.cols-7);
|
||||
addstr (tmp);
|
||||
widget_move (&panel->widget, 0, 1);
|
||||
addstr ("<");
|
||||
widget_move (&panel->widget, 0, panel->widget.cols-2);
|
||||
addstr (">");
|
||||
widget_move (&panel->widget, 0, panel->widget.cols-3);
|
||||
addstr ("v");
|
||||
|
||||
if (panel->active)
|
||||
standend ();
|
||||
@ -892,12 +898,28 @@ static void
|
||||
panel_destroy (WPanel *p)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
char *name = panel_save_name (p);
|
||||
|
||||
panel_save_setup (p, name);
|
||||
clean_dir (&p->dir, p->count);
|
||||
|
||||
/* save and clean history */
|
||||
if (p->dir_history){
|
||||
Hist *current, *old;
|
||||
history_put (p->hist_name, p->dir_history);
|
||||
current = p->dir_history;
|
||||
while (current->next)
|
||||
current = current->next;
|
||||
while (current){
|
||||
old = current;
|
||||
current = current->prev;
|
||||
free (old->text);
|
||||
free (old);
|
||||
}
|
||||
}
|
||||
free (p->hist_name);
|
||||
|
||||
delete_format (p->format);
|
||||
delete_format (p->status_format);
|
||||
|
||||
@ -916,6 +938,7 @@ panel_format_modified (WPanel *panel)
|
||||
x_reset_sort_labels (panel);
|
||||
}
|
||||
|
||||
void directory_history_add (WPanel * panel, char *s);
|
||||
|
||||
/* Panel creation */
|
||||
/* The parameter specifies the name of the panel for setup retieving */
|
||||
@ -940,6 +963,10 @@ panel_new (char *panel_name)
|
||||
mc_get_current_wd (panel->cwd, sizeof (panel->cwd)-2);
|
||||
strcpy (panel->lwd, ".");
|
||||
|
||||
panel->hist_name = copy_strings ("Dir Hist ", panel_name, 0);
|
||||
panel->dir_history = history_get (panel->hist_name);
|
||||
directory_history_add (panel, panel->cwd);
|
||||
|
||||
panel->dir.list = (file_entry *) malloc (MIN_FILES * sizeof (file_entry));
|
||||
panel->dir.size = MIN_FILES;
|
||||
panel->active = 0;
|
||||
@ -2024,6 +2051,10 @@ chdir_to_readlink (WPanel *panel)
|
||||
}
|
||||
}
|
||||
|
||||
void directory_history_next (WPanel * panel);
|
||||
void directory_history_prev (WPanel * panel);
|
||||
void directory_history_list (WPanel * panel);
|
||||
|
||||
static key_map panel_keymap [] = {
|
||||
{ KEY_DOWN, move_down },
|
||||
{ KEY_UP, move_up },
|
||||
@ -2063,6 +2094,8 @@ static key_map panel_keymap [] = {
|
||||
{ ALT('l'), chdir_to_readlink },
|
||||
{ KEY_F(13), view_simple_cmd },
|
||||
{ KEY_F(14), edit_cmd_new },
|
||||
{ ALT('y'), directory_history_prev },
|
||||
{ ALT('u'), directory_history_next },
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
{ '+', select_cmd },
|
||||
@ -2321,6 +2354,21 @@ panel_event (Gpm_Event *event, WPanel *panel)
|
||||
int my_index;
|
||||
extern void change_panel (void);
|
||||
|
||||
if (event->type & GPM_DOWN && event->x == 1 + 1 && event->y == 0 + 1) {
|
||||
directory_history_prev (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 2 + 1 && event->y == 0 + 1) {
|
||||
directory_history_next (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 3 + 1 && event->y == 0 + 1) {
|
||||
directory_history_list (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
event->y -= 2;
|
||||
if ((event->type & (GPM_DOWN|GPM_DRAG))){
|
||||
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "menu.h" /* menubar_visible declaration */
|
||||
#include "win.h" /* lookup_key */
|
||||
#include "cmd.h"
|
||||
#include "dirhist.h" /* Directory history routines */
|
||||
#include "x.h"
|
||||
|
||||
#include "../vfs/vfs.h"
|
||||
@ -346,7 +345,7 @@ void save_setup (void)
|
||||
save_hotlist ();
|
||||
save_panelize ();
|
||||
save_panel_types ();
|
||||
directory_history_save ();
|
||||
/* directory_history_save (); */
|
||||
|
||||
#ifdef USE_VFS
|
||||
#ifdef USE_NETCODE
|
||||
@ -518,7 +517,7 @@ void load_setup (void)
|
||||
color_terminal_string, sizeof (color_terminal_string));
|
||||
|
||||
/* Load the directory history */
|
||||
directory_history_load ();
|
||||
/* directory_history_load (); */
|
||||
/* Remove the temporal entries */
|
||||
profile_clean_section ("Temporal:New Left Panel", profile_name);
|
||||
profile_clean_section ("Temporal:New Right Panel", profile_name);
|
||||
@ -549,7 +548,7 @@ void done_setup (void)
|
||||
free (profile_name);
|
||||
done_hotlist ();
|
||||
done_panelize ();
|
||||
directory_history_free ();
|
||||
/* directory_history_free (); */
|
||||
}
|
||||
|
||||
void load_keys_from_section (char *terminal, char *profile_name)
|
||||
|
30
src/widget.c
30
src/widget.c
@ -975,18 +975,18 @@ int history_callback (Dlg_head * h, int Par, int Msg)
|
||||
|
||||
static inline int listbox_fwd (WListbox *l);
|
||||
|
||||
static void show_hist (WInput * in)
|
||||
char *show_hist (Hist *history, int widget_x, int widget_y)
|
||||
{
|
||||
Hist *hi, *z;
|
||||
int maxlen = strlen(history_title), i, count = 0;
|
||||
int x, y, w, h;
|
||||
char *q;
|
||||
char *q, *r = 0;
|
||||
Dlg_head *query_dlg;
|
||||
WListbox *query_list;
|
||||
|
||||
z = in->history;
|
||||
z = history;
|
||||
if (!z)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
while (z->prev) /* goto first */
|
||||
z = z->prev;
|
||||
@ -998,7 +998,7 @@ static void show_hist (WInput * in)
|
||||
hi = hi->next;
|
||||
}
|
||||
|
||||
y = in->widget.y;
|
||||
y = widget_y;
|
||||
h = count + 2;
|
||||
if (h <= y || y > LINES - 6)
|
||||
{
|
||||
@ -1011,7 +1011,7 @@ static void show_hist (WInput * in)
|
||||
h = min(h, LINES - y);
|
||||
}
|
||||
|
||||
x = in->widget.x - 2;
|
||||
x = widget_x - 2;
|
||||
if ((w = maxlen + 4) + x > COLS)
|
||||
{
|
||||
w = min(w,COLS);
|
||||
@ -1023,7 +1023,7 @@ static void show_hist (WInput * in)
|
||||
query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL);
|
||||
add_widget (query_dlg, query_list);
|
||||
hi = z;
|
||||
if (y < in->widget.y) {
|
||||
if (y < widget_y) {
|
||||
while (hi) { /* traverse */
|
||||
listbox_add_item (query_list, 0, 0, hi->text, NULL);
|
||||
hi = hi->next;
|
||||
@ -1042,11 +1042,21 @@ static void show_hist (WInput * in)
|
||||
if (query_dlg->ret_value != B_CANCEL) {
|
||||
listbox_get_current (query_list, &q, NULL);
|
||||
if (q)
|
||||
assign_text (in, q);
|
||||
r = strdup (q);
|
||||
}
|
||||
destroy_dlg (query_dlg);
|
||||
return r;
|
||||
}
|
||||
|
||||
static void do_show_hist (WInput * in)
|
||||
{
|
||||
char *r;
|
||||
r = show_hist (in->history, in->widget.x, in->widget.y);
|
||||
if (r) {
|
||||
assign_text (in, r);
|
||||
free (r);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} history display */
|
||||
|
||||
@ -1459,7 +1469,7 @@ static struct {
|
||||
/* History */
|
||||
{ ALT('p'), hist_prev },
|
||||
{ ALT('n'), hist_next },
|
||||
{ ALT('h'), show_hist },
|
||||
{ ALT('h'), do_show_hist },
|
||||
|
||||
/* Completion */
|
||||
{ ALT('\t'), complete },
|
||||
@ -1613,7 +1623,7 @@ input_event (Gpm_Event *event, WInput *in)
|
||||
dlg_select_widget (in->widget.parent, in);
|
||||
|
||||
if (event->x >= in->field_len - HISTORY_BUTTON_WIDTH + 1 && should_show_history_button (in)) {
|
||||
show_hist (in);
|
||||
do_show_hist (in);
|
||||
update_input (in);
|
||||
} else {
|
||||
in->point = strlen (in->buffer);
|
||||
|
@ -61,6 +61,10 @@ typedef struct hist_entry {
|
||||
char *text;
|
||||
} Hist;
|
||||
|
||||
Hist *history_get (char *input_name);
|
||||
void history_put (char *input_name, Hist *h);
|
||||
char *show_hist (Hist *history, int widget_y, int widget_x);
|
||||
|
||||
typedef struct {
|
||||
Widget widget;
|
||||
int point; /* cursor position in the input line */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user