mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-04 07:01:30 +03:00
Clean up stuff that is not used anymore.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
c83c3f7052
commit
c1f2a8ac49
@ -120,34 +120,6 @@ static const char *machine_str = N_("Enter machine name (F1 for details):");
|
||||
#endif /* ENABLE_VFS_NET */
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** scan_for_file (panel, idx, direction)
|
||||
*
|
||||
* Inputs:
|
||||
* panel: pointer to the panel on which we operate
|
||||
* idx: starting file.
|
||||
* direction: 1, or -1
|
||||
*/
|
||||
|
||||
static int
|
||||
scan_for_file (WPanel * panel, int idx, int direction)
|
||||
{
|
||||
int i = idx + direction;
|
||||
|
||||
while (i != idx)
|
||||
{
|
||||
if (i < 0)
|
||||
i = panel->count - 1;
|
||||
if (i == panel->count)
|
||||
i = 0;
|
||||
if (!S_ISDIR (panel->dir.list[i].st.st_mode))
|
||||
return i;
|
||||
i += direction;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Run viewer (internal or external) on the currently selected file.
|
||||
@ -178,21 +150,12 @@ do_view_cmd (gboolean normal)
|
||||
else
|
||||
{
|
||||
int file_idx;
|
||||
vfs_path_t *filename_vpath;
|
||||
|
||||
file_idx = current_panel->selected;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
vfs_path_t *filename_vpath;
|
||||
int dir;
|
||||
|
||||
filename_vpath = vfs_path_from_str (current_panel->dir.list[file_idx].fname);
|
||||
dir = view_file (filename_vpath, normal, use_internal_view);
|
||||
vfs_path_free (filename_vpath);
|
||||
if (dir == 0)
|
||||
break;
|
||||
file_idx = scan_for_file (current_panel, file_idx, dir);
|
||||
}
|
||||
filename_vpath = vfs_path_from_str (current_panel->dir.list[file_idx].fname);
|
||||
view_file (filename_vpath, normal, use_internal_view);
|
||||
vfs_path_free (filename_vpath);
|
||||
}
|
||||
|
||||
repaint_screen ();
|
||||
@ -636,11 +599,11 @@ set_basic_panel_listing_to (int panel_index, int listing_mode)
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
gboolean
|
||||
view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int internal, int start_line)
|
||||
{
|
||||
static const char *viewer = NULL;
|
||||
int move_dir = 0;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
if (plain_view)
|
||||
{
|
||||
@ -661,17 +624,7 @@ view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int intern
|
||||
mcview_default_nroff_flag = 0;
|
||||
mcview_default_magic_flag = 0;
|
||||
|
||||
switch (mcview_viewer (NULL, filename_vpath, start_line))
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
move_dir = 0;
|
||||
}
|
||||
ret = mcview_viewer (NULL, filename_vpath, start_line);
|
||||
|
||||
if (changed_hex_mode && !mcview_altered_hex_mode)
|
||||
mcview_default_hex_mode = 1;
|
||||
@ -691,20 +644,10 @@ view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int intern
|
||||
else
|
||||
strcpy (view_entry, "View");
|
||||
|
||||
if (regex_command (filename_vpath, view_entry, &move_dir) == 0)
|
||||
ret = (regex_command (filename_vpath, view_entry) == 0);
|
||||
if (ret)
|
||||
{
|
||||
switch (mcview_viewer (NULL, filename_vpath, start_line))
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
move_dir = 0;
|
||||
}
|
||||
|
||||
ret = mcview_viewer (NULL, filename_vpath, start_line);
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
}
|
||||
@ -722,7 +665,7 @@ view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int intern
|
||||
execute_with_vfs_arg (viewer, filename_vpath);
|
||||
}
|
||||
|
||||
return move_dir;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -735,7 +678,7 @@ view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int intern
|
||||
* internal: If set uses the internal viewer, otherwise an external viewer.
|
||||
*/
|
||||
|
||||
int
|
||||
gboolean
|
||||
view_file (const vfs_path_t * filename_vpath, int plain_view, int internal)
|
||||
{
|
||||
return view_file_at_line (filename_vpath, plain_view, internal, 0);
|
||||
@ -849,7 +792,7 @@ edit_cmd (void)
|
||||
vfs_path_t *fname;
|
||||
|
||||
fname = vfs_path_from_str (selection (current_panel)->fname);
|
||||
if (regex_command (fname, "Edit", NULL) == 0)
|
||||
if (regex_command (fname, "Edit") == 0)
|
||||
do_edit (fname);
|
||||
vfs_path_free (fname);
|
||||
}
|
||||
@ -863,7 +806,7 @@ edit_cmd_force_internal (void)
|
||||
vfs_path_t *fname;
|
||||
|
||||
fname = vfs_path_from_str (selection (current_panel)->fname);
|
||||
if (regex_command (fname, "Edit", NULL) == 0)
|
||||
if (regex_command (fname, "Edit") == 0)
|
||||
do_edit_at_line (fname, TRUE, 0);
|
||||
vfs_path_free (fname);
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ void help_cmd (void);
|
||||
void smart_dirsize_cmd (void);
|
||||
void single_dirsize_cmd (void);
|
||||
void dirsizes_cmd (void);
|
||||
int view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int internal,
|
||||
int start_line);
|
||||
int view_file (const vfs_path_t * filename_vpath, int normal, int internal);
|
||||
gboolean view_file_at_line (const vfs_path_t * filename_vpath, int plain_view, int internal,
|
||||
int start_line);
|
||||
gboolean view_file (const vfs_path_t * filename_vpath, int normal, int internal);
|
||||
void view_cmd (void);
|
||||
void view_file_cmd (void);
|
||||
void view_raw_cmd (void);
|
||||
|
@ -313,10 +313,9 @@ exec_make_shell_string (const char *lc_data, vfs_path_t * filename_vpath)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
exec_extension_view (char *cmd, vfs_path_t * filename_vpath, int *move_dir, int start_line,
|
||||
exec_extension_view (char *cmd, vfs_path_t * filename_vpath, int start_line,
|
||||
vfs_path_t * temp_file_name_vpath)
|
||||
{
|
||||
mcview_ret_t ret;
|
||||
int def_hex_mode = mcview_default_hex_mode, changed_hex_mode = 0;
|
||||
int def_nroff_flag = mcview_default_nroff_flag, changed_nroff_flag = 0;
|
||||
|
||||
@ -332,24 +331,11 @@ exec_extension_view (char *cmd, vfs_path_t * filename_vpath, int *move_dir, int
|
||||
*/
|
||||
if (written_nonspace)
|
||||
{
|
||||
ret = mcview_viewer (cmd, filename_vpath, start_line);
|
||||
mcview_viewer (cmd, filename_vpath, start_line);
|
||||
mc_unlink (temp_file_name_vpath);
|
||||
}
|
||||
else
|
||||
ret = mcview_viewer (NULL, filename_vpath, start_line);
|
||||
|
||||
if (move_dir != NULL)
|
||||
switch (ret)
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
*move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
*move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
*move_dir = 0;
|
||||
}
|
||||
mcview_viewer (NULL, filename_vpath, start_line);
|
||||
|
||||
if (changed_hex_mode && !mcview_altered_hex_mode)
|
||||
mcview_default_hex_mode = def_hex_mode;
|
||||
@ -388,7 +374,7 @@ exec_extension_cd (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line)
|
||||
exec_extension (const char *filename, const char *lc_data, int start_line)
|
||||
{
|
||||
char *shell_string, *export_variables;
|
||||
vfs_path_t *temp_file_name_vpath = NULL;
|
||||
@ -487,7 +473,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
||||
}
|
||||
|
||||
if (run_view)
|
||||
exec_extension_view (cmd, filename_vpath, move_dir, start_line, temp_file_name_vpath);
|
||||
exec_extension_view (cmd, filename_vpath, start_line, temp_file_name_vpath);
|
||||
else
|
||||
{
|
||||
shell_execute (cmd, EXECUTE_INTERNAL);
|
||||
@ -736,7 +722,7 @@ flush_extension_file (void)
|
||||
*/
|
||||
|
||||
int
|
||||
regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_dir)
|
||||
regex_command (const vfs_path_t * filename_vpath, const char *action)
|
||||
{
|
||||
char *filename, *p, *q, *r, c;
|
||||
size_t file_len;
|
||||
@ -957,7 +943,7 @@ regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_
|
||||
*/
|
||||
if (p < q)
|
||||
{
|
||||
exec_extension (filename, r + 1, move_dir, view_at_line_number);
|
||||
exec_extension (filename, r + 1, view_at_line_number);
|
||||
ret = 1;
|
||||
}
|
||||
break;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_dir);
|
||||
int regex_command (const vfs_path_t * filename_vpath, const char *action);
|
||||
|
||||
/* Call it after the user has edited the mc.ext file,
|
||||
* to flush the cached mc.ext file
|
||||
|
@ -997,9 +997,8 @@ mc_maybe_editor_or_viewer (void)
|
||||
if (mc_run_param0 != NULL && *mc_run_param0 != '\0')
|
||||
vpath = prepend_cwd_on_local (mc_run_param0);
|
||||
|
||||
view_file (vpath, 0, 1);
|
||||
ret = view_file (vpath, 0, 1);
|
||||
vfs_path_free (vpath);
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
#ifdef USE_DIFF_VIEW
|
||||
|
@ -2561,7 +2561,7 @@ do_enter_on_file_entry (file_entry * fe)
|
||||
full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, NULL);
|
||||
|
||||
/* Try associated command */
|
||||
if (regex_command (full_name_vpath, "Open", NULL) != 0)
|
||||
if (regex_command (full_name_vpath, "Open") != 0)
|
||||
{
|
||||
vfs_path_free (full_name_vpath);
|
||||
return 1;
|
||||
|
@ -164,12 +164,6 @@ typedef struct mcview_struct
|
||||
int marker; /* mark to use */
|
||||
off_t marks[10]; /* 10 marks: 0..9 */
|
||||
|
||||
int move_dir; /* return value from widget:
|
||||
* 0 do nothing
|
||||
* -1 view previous file
|
||||
* 1 view next file
|
||||
*/
|
||||
|
||||
off_t update_steps; /* The number of bytes between percent
|
||||
* increments */
|
||||
off_t update_activate; /* Last point where we updated the status */
|
||||
|
@ -231,7 +231,6 @@ mcview_init (mcview_t * view)
|
||||
for (i = 0; i < sizeof (view->marks) / sizeof (view->marks[0]); i++)
|
||||
view->marks[i] = 0;
|
||||
|
||||
view->move_dir = 0;
|
||||
view->update_steps = 0;
|
||||
view->update_activate = 0;
|
||||
|
||||
|
@ -230,13 +230,12 @@ mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** Real view only */
|
||||
|
||||
mcview_ret_t
|
||||
gboolean
|
||||
mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_line)
|
||||
{
|
||||
gboolean succeeded;
|
||||
mcview_t *lc_mcview;
|
||||
Dlg_head *view_dlg;
|
||||
mcview_ret_t ret;
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
view_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback, NULL,
|
||||
@ -258,22 +257,14 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
|
||||
}
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
run_dlg (view_dlg);
|
||||
|
||||
ret = lc_mcview->move_dir == 0 ? MCVIEW_EXIT_OK :
|
||||
lc_mcview->move_dir > 0 ? MCVIEW_WANT_NEXT : MCVIEW_WANT_PREV;
|
||||
}
|
||||
else
|
||||
{
|
||||
view_dlg->state = DLG_CLOSED;
|
||||
ret = MCVIEW_EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (view_dlg->state == DLG_CLOSED)
|
||||
destroy_dlg (view_dlg);
|
||||
|
||||
return ret;
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
/* {{{ Miscellaneous functions }}} */
|
||||
|
@ -11,14 +11,6 @@
|
||||
|
||||
struct mcview_struct;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MCVIEW_EXIT_FAILURE = -1,
|
||||
MCVIEW_EXIT_OK = 0,
|
||||
MCVIEW_WANT_NEXT,
|
||||
MCVIEW_WANT_PREV
|
||||
} mcview_ret_t;
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -50,8 +42,8 @@ extern struct mcview_struct *mcview_new (int y, int x, int lines, int cols, gboo
|
||||
/* Shows {file} or the output of {command} in the internal viewer,
|
||||
* starting in line {start_line}.
|
||||
*/
|
||||
extern mcview_ret_t mcview_viewer (const char *command, const vfs_path_t * file_vpath,
|
||||
int start_line);
|
||||
extern gboolean mcview_viewer (const char *command, const vfs_path_t * file_vpath,
|
||||
int start_line);
|
||||
|
||||
extern gboolean mcview_load (struct mcview_struct *, const char *, const char *, int);
|
||||
|
||||
|
@ -180,11 +180,10 @@ do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse,
|
||||
}
|
||||
|
||||
int
|
||||
regex_command (const vfs_path_t *filename, const char *action, int *move_dir)
|
||||
regex_command (const vfs_path_t *filename, const char *action)
|
||||
{
|
||||
(void) filename;
|
||||
(void) action;
|
||||
(void) move_dir;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user