From 1b017c668f676ccaf0c6be5bc7ee39a49a58a5ee Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 13 Nov 2002 08:21:45 +0000 Subject: [PATCH] * cmd.c (do_view_cmd): Don't take WPanel argument - always use the current panel. (view_cmd): Likewise. (view_file_cmd): Likewise. (view_simple_cmd): Likewise. (filtered_view_cmd): Likewise. (filtered_view_cmd_cpanel): Remove. (view_panel_cmd): Likewise. --- src/ChangeLog | 11 +++++++++ src/cmd.c | 66 ++++++++++++++++++++++++++------------------------- src/cmd.h | 14 +++++------ src/main.c | 3 ++- src/screen.c | 2 +- 5 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6e0bb1591..a2ed4aeae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2002-11-13 Pavel Roskin + + * cmd.c (do_view_cmd): Don't take WPanel argument - always use + the current panel. + (view_cmd): Likewise. + (view_file_cmd): Likewise. + (view_simple_cmd): Likewise. + (filtered_view_cmd): Likewise. + (filtered_view_cmd_cpanel): Remove. + (view_panel_cmd): Likewise. + 2002-11-12 Pavel Roskin * chmod.c (init_chmod): Make static. diff --git a/src/cmd.c b/src/cmd.c index 2448d9e7b..05859ae75 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -213,72 +213,84 @@ static int scan_for_file (WPanel *panel, int idx, int direction) return i; } -/* do_view: Invoked as the F3/F13 key. */ +/* + * Run viewer (internal or external) on the currently selected file. + * If normal is 1, force internal viewer and raw mode (used for F13). + */ static void -do_view_cmd (WPanel *panel, int normal) +do_view_cmd (int normal) { int dir, file_idx; - panel = get_a_panel (panel); /* Directories are viewed by changing to them */ - if (S_ISDIR (selection (panel)->buf.st_mode) - || link_isdir (selection (panel))) { - if (confirm_view_dir && (panel->marked || panel->dirs_marked)) { + if (S_ISDIR (selection (cpanel)->buf.st_mode) + || link_isdir (selection (cpanel))) { + if (confirm_view_dir && (cpanel->marked || cpanel->dirs_marked)) { if (query_dialog (_(" Confirmation "), _("Files tagged, want to cd?"), 0, 2, _("&Yes"), _("&No")) != 0) { return; } } - if (!do_cd (selection (panel)->fname, cd_exact)) + if (!do_cd (selection (cpanel)->fname, cd_exact)) message (1, MSG_ERROR, _("Could not change directory")); return; } - file_idx = panel->selected; + file_idx = cpanel->selected; while (1) { char *filename; - filename = panel->dir.list[file_idx].fname; + filename = cpanel->dir.list[file_idx].fname; dir = view_file (filename, normal, use_internal_view); if (dir == 0) break; - file_idx = scan_for_file (panel, file_idx, dir); + file_idx = scan_for_file (cpanel, file_idx, dir); } } -void view_cmd (WPanel *panel) +/* Run user's preferred viewer on the currently selected file */ +void +view_cmd (void) { - do_view_cmd (panel, 0); + do_view_cmd (0); } -void view_file_cmd (WPanel *panel) +/* Ask for file and run user's preferred viewer on it */ +void +view_file_cmd (void) { char *filename; - panel = get_a_panel (panel); - filename = input_dialog (_(" View file "), _(" Filename:"), selection (panel)->fname); - if (!filename) return; + filename = + input_dialog (_(" View file "), _(" Filename:"), + selection (cpanel)->fname); + if (!filename) + return; view_file (filename, 0, use_internal_view); g_free (filename); } -void view_simple_cmd (WPanel *panel) +/* Run plain internal viewer on the currently selected file */ +void +view_simple_cmd (void) { - do_view_cmd (panel, 1); + do_view_cmd (1); } -void filtered_view_cmd (WPanel *panel) +void +filtered_view_cmd (void) { char *command; - panel = get_a_panel (panel); - command = input_dialog (_(" Filtered view "), _(" Filter command and arguments:"), - selection (panel)->fname); + command = + input_dialog (_(" Filtered view "), + _(" Filter command and arguments:"), + selection (cpanel)->fname); if (!command) return; @@ -287,11 +299,6 @@ void filtered_view_cmd (WPanel *panel) g_free (command); } -void filtered_view_cmd_cpanel (void) -{ - filtered_view_cmd (cpanel); -} - void do_edit_at_line (const char *what, int start_line) { static char *editor = 0; @@ -1150,11 +1157,6 @@ void help_cmd (void) interactive_display (NULL, "[main]"); } -void view_panel_cmd (void) -{ - view_cmd (cpanel); -} - void edit_panel_cmd (void) { edit_cmd (cpanel); diff --git a/src/cmd.h b/src/cmd.h index f96088f47..660b2cc5e 100644 --- a/src/cmd.h +++ b/src/cmd.h @@ -13,11 +13,10 @@ void dirsizes_cmd (void); int view_file_at_line (char *filename, int plain_view, int internal, int start_line); int view_file (char *filename, int normal, int internal); -void view_cmd (WPanel *panel); -void view_file_cmd (WPanel *panel); -void view_simple_cmd (WPanel *panel); -void filtered_view_cmd (WPanel *panel); -void filtered_view_cmd_cpanel (void); +void view_cmd (void); +void view_file_cmd (void); +void view_simple_cmd (void); +void filtered_view_cmd (void); void do_edit (const char *what); void do_edit_at_line (const char *what, int start_line); void edit_cmd (WPanel *panel); @@ -37,7 +36,6 @@ void set_panel_filter (WPanel *panel); void set_panel_filter_to (WPanel *p, char *allocated_filter_string); void reread_cmd (void); void do_re_sort (WPanel *panel); -void quick_view_cmd (void); void tree_view_cmd (void); void ext_cmd (void); void menu_edit_cmd (int select); @@ -59,7 +57,6 @@ void swap_cmd (void); void view_other_cmd (void); void mkdir_panel_cmd (void); void edit_panel_cmd (void); -void view_panel_cmd (void); void quick_cd_cmd (void); void save_setup_cmd (void); char *get_random_hint (void); @@ -77,7 +74,8 @@ void quick_cmd_no_menu (void); void info_cmd_no_menu (void); void quick_view_cmd (void); void toggle_listing_cmd (void); -void configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user, char *status); +void configure_panel_listing (WPanel * p, int view_type, int use_msformat, + char *user, char *status); #ifdef USE_INTERNAL_EDIT extern int edit (const char *file, int line); diff --git a/src/main.c b/src/main.c index 0f8fca60b..cc6ef971f 100644 --- a/src/main.c +++ b/src/main.c @@ -1479,8 +1479,9 @@ static const key_map default_map[] = { /* Suspend */ {XCTRL ('z'), suspend_cmd}, + /* The filtered view command */ - {ALT ('!'), filtered_view_cmd_cpanel}, + {ALT ('!'), filtered_view_cmd}, /* Find file */ {ALT ('?'), find_cmd}, diff --git a/src/screen.c b/src/screen.c index 71f01b784..d5037ba2f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2181,7 +2181,7 @@ panel_callback (WPanel *panel, int msg, int par) define_label (h, 1, _("Help"), help_cmd); define_label (h, 2, _("Menu"), user_file_menu_cmd); - define_label (h, 3, _("View"), view_panel_cmd); + define_label (h, 3, _("View"), view_cmd); define_label (h, 4, _("Edit"), edit_panel_cmd); define_label (h, 5, _("Copy"), copy_cmd); define_label (h, 6, _("RenMov"), ren_cmd);