Beispiel #1
0
static void menusaveimage(control m)
{
    wchar_t *fn;
    char s[MAX_PATH];

    if (!ConsoleAcceptCmd) return;
    setuserfilterW(L"R images (*.RData)\0*.RData\0All files (*.*)\0*.*\0\0");
    fn = askfilesaveW(G_("Save image in"), ".RData");
    if (fn) {
	quote_fn(fn, s);
	if (!strcmp(&s[strlen(s) - 2], ".*")) s[strlen(s) - 2] = '\0';
	snprintf(cmd, 1024, "save.image(\"%s\")", s);
	consolecmd(RConsole, cmd);
    } else show(RConsole);
}
Beispiel #2
0
static void editorsaveas(editor c)
{
    textbox t = getdata(c);
    EditorData p = getdata(t);
    wchar_t *wname;

    setuserfilterW(L"R files (*.R)\0*.R\0S files (*.q, *.ssc, *.S)\0*.q;*.ssc;*.S\0All files (*.*)\0*.*\0\0");
    wname = askfilesaveW(G_("Save script as"), "");
    if (wname) {
	char name[4*MAX_PATH+1];
	wcstoutf8(name, wname, MAX_PATH);
	/* now check if it has an extension */
	char *q = strchr(name, '.');
	if(!q) strncat(name, ".R", 4*MAX_PATH);
	editor_save_file(c, name, CE_UTF8);
	p->file = 1;
	reEnc2(name, p->filename, MAX_PATH+1, CE_UTF8, CE_NATIVE, 3);
	gsetmodified(t, 0);
	editor_set_title(c, p->filename);
    }
    show(c);
}