示例#1
0
static void
view_redo (WDiff *view)
{
    int rv;
    if (quick_dialog(&diffopt) != B_CANCEL) {
	view_fini(view, 0);
	mc_setctl (view->file[0], VFS_SETCTL_STALE_DATA, NULL);
	mc_setctl (view->file[1], VFS_SETCTL_STALE_DATA, NULL);
	rv = redo_diff(view, REINIT_OPEN | REINIT_READ_LEFT | REINIT_READ_RIGHT);
	if (rv < 0) {
	    view->view_quit = 1;
	}
    }
}
示例#2
0
文件: args.c 项目: idispatch/mc
gboolean
mc_setup_by_args (int argc, char **argv, GError ** mcerror)
{
    const char *base;
    char *tmp;

    mc_return_val_if_error (mcerror, FALSE);

    if (mc_args__force_colors)
        mc_global.tty.disable_colors = FALSE;

#ifdef ENABLE_SUBSHELL
    if (mc_args__nouse_subshell)
        mc_global.tty.use_subshell = FALSE;
#endif /* ENABLE_SUBSHELL */

#ifdef ENABLE_VFS_SMB
    if (mc_args__debug_level != 0)
        smbfs_set_debug (mc_args__debug_level);
#endif /* ENABLE_VFS_SMB */

    if (mc_args__netfs_logfile != NULL)
    {
        vfs_path_t *vpath;
#ifdef ENABLE_VFS_FTP
        vpath = vfs_path_from_str ("ftp://");
        mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
        vfs_path_free (vpath);
#endif /* ENABLE_VFS_FTP */
#ifdef ENABLE_VFS_SMB
        vpath = vfs_path_from_str ("smb://");
        mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
        vfs_path_free (vpath);
#endif /* ENABLE_VFS_SMB */
        (void) vpath;
    }

    base = x_basename (argv[0]);
    tmp = (argc > 0) ? argv[1] : NULL;

    if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
    {
        /* mce* or vi is link to mc */
        mc_global.mc_run_mode = MC_RUN_EDITOR;
    }
    else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
    {
        /* mcv* or view is link to mc */
        mc_global.mc_run_mode = MC_RUN_VIEWER;
    }
#ifdef USE_DIFF_VIEW
    else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
    {
        /* mcd* or diff is link to mc */
        mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
    }
#endif /* USE_DIFF_VIEW */

    switch (mc_global.mc_run_mode)
    {
    case MC_RUN_EDITOR:
        mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
        break;

    case MC_RUN_VIEWER:
        if (tmp == NULL)
        {
            mc_propagate_error (mcerror, 0, "%s\n", _("No arguments given to the viewer."));
            return FALSE;
        }

        mc_run_param0 = g_strdup (tmp);
        break;

#ifdef USE_DIFF_VIEW
    case MC_RUN_DIFFVIEWER:
        if (argc < 3)
        {
            mc_propagate_error (mcerror, 0, "%s\n",
                                _("Two files are required to envoke the diffviewer."));
            return FALSE;
        }
        /* fallthrough */
#endif /* USE_DIFF_VIEW */

    case MC_RUN_FULL:
    default:
        /* set the current dir and the other dir for filemanager,
           or two files for diff viewer */
        if (tmp != NULL)
        {
            mc_run_param0 = g_strdup (tmp);
            tmp = (argc > 1) ? argv[2] : NULL;
            if (tmp != NULL)
                mc_run_param1 = g_strdup (tmp);
        }
        break;
    }

    return TRUE;
}
示例#3
0
文件: args.c 项目: djwisdom/mc
gboolean
mc_setup_by_args (int argc, char **argv, GError ** error)
{
    const char *base;
    char *tmp;

    if (mc_args__force_colors)
        mc_global.tty.disable_colors = FALSE;

#ifdef HAVE_SUBSHELL_SUPPORT
    if (mc_args__nouse_subshell)
        mc_global.tty.use_subshell = FALSE;
#endif /* HAVE_SUBSHELL_SUPPORT */

#ifdef ENABLE_VFS_SMB
    if (mc_args__debug_level != 0)
        smbfs_set_debug (mc_args__debug_level);
#endif /* ENABLE_VFS_SMB */

    if (mc_args__netfs_logfile != NULL)
    {
        vfs_path_t *vpath;
#ifdef ENABLE_VFS_FTP
        vpath = vfs_path_from_str ("ftp://");
        mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
        vfs_path_free (vpath);
#endif /* ENABLE_VFS_FTP */
#ifdef ENABLE_VFS_SMB
        vpath = vfs_path_from_str ("smb://");
        mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
        vfs_path_free (vpath);
#endif /* ENABLE_VFS_SMB */
        (void) vpath;
    }

    base = x_basename (argv[0]);
    tmp = (argc > 0) ? argv[1] : NULL;

    if (strncmp (base, "mce", 3) == 0 || strcmp (base, "vi") == 0)
    {
        /* mce* or vi is link to mc */

        mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
        mc_global.mc_run_mode = MC_RUN_EDITOR;
    }
    else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
    {
        /* mcv* or view is link to mc */

        if (tmp != NULL)
            mc_run_param0 = g_strdup (tmp);
        else
        {
            *error = g_error_new (MC_ERROR, 0, "%s\n", _("No arguments given to the viewer."));
            return FALSE;
        }
        mc_global.mc_run_mode = MC_RUN_VIEWER;
    }
#ifdef USE_DIFF_VIEW
    else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
    {
        /* mcd* or diff is link to mc */

        if (argc < 3)
        {
            *error = g_error_new (MC_ERROR, 0, "%s\n",
                                  _("Two files are required to evoke the diffviewer."));
            return FALSE;
        }

        if (tmp != NULL)
        {
            mc_run_param0 = g_strdup (tmp);
            tmp = (argc > 1) ? argv[2] : NULL;
            if (tmp != NULL)
                mc_run_param1 = g_strdup (tmp);
            mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
        }
    }
#endif /* USE_DIFF_VIEW */
    else
    {
        /* MC is run as mc */

        switch (mc_global.mc_run_mode)
        {
        case MC_RUN_EDITOR:
            mc_run_param0 = parse_mcedit_arguments (argc - 1, &argv[1]);
            break;

        case MC_RUN_VIEWER:
            /* mc_run_param0 is set up in parse_mc_v_argument() */
            break;

        case MC_RUN_DIFFVIEWER:
            /* not implemented yet */
            break;

        case MC_RUN_FULL:
        default:
            /* sets the current dir and the other dir */
            if (tmp != NULL)
            {
                mc_run_param0 = g_strdup (tmp);
                tmp = (argc > 1) ? argv[2] : NULL;
                if (tmp != NULL)
                    mc_run_param1 = g_strdup (tmp);
            }
            mc_global.mc_run_mode = MC_RUN_FULL;
            break;
        }
    }

    return TRUE;
}