static void dropconsole(control m, char *fn) { char *p, local[MAX_PATH]; p = Rf_strrchr(fn, '.'); if(p) { /* OK even in MBCS */ if(stricmp(p+1, "R") == 0) { if(ConsoleAcceptCmd) { double_backslashes(fn, local); snprintf(cmd, 1024, "source(\"%s\")", local); consolecmd(RConsole, cmd); } /* OK even in MBCS */ } else if(stricmp(p+1, "RData") == 0 || stricmp(p+1, "rda")) { if(ConsoleAcceptCmd) { double_backslashes(fn, local); snprintf(cmd, 1024, "load(\"%s\")", local); consolecmd(RConsole, cmd); } } return; } askok(G_("Can only drag-and-drop .R, .RData and .rda files")); }
static void menupkgload(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)\nif(nchar(pkg)) library(pkg, character.only=TRUE)})"); /* show(RConsole); */ }
static void menuhelpstart(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "help.start()"); /* show(RConsole); internal_shellexec("doc\\html\\index.html"); */ }
static void menurm(control m) { if (!ConsoleAcceptCmd) return; if (askyesno(G_("Are you sure?")) == YES) consolecmd(RConsole, "rm(list=ls(all=TRUE))"); else show(RConsole); }
static void editorrunline(textbox t) { int length = getlinelength(t); /* return character num */ char *line = malloc(length * sizeof(WCHAR) + 2); /* Extra space for null and word length in getcurrentline */ memset(line, 0, length * sizeof(WCHAR) + 2); getcurrentline(t, line, length); consolecmd(RConsole, line); free(line); scrollcaret(t, 1); show(t); }
static void menusearchRsite(control m) { char *s; static char olds[256] = ""; if (!ConsoleAcceptCmd) return; s = askstring(G_("Search for words in help list archives and documentation"), olds); if (s && strlen(s)) { snprintf(cmd, 1024, "RSiteSearch(\"%s\")", s); if (strlen(s) > 255) s[255] = '\0'; strcpy(olds, s); consolecmd(RConsole, cmd); } else show(RConsole); }
static void menuhelpsearch(control m) { char *s; static char olds[256] = ""; if (!ConsoleAcceptCmd) return; s = askstring(G_("Search help"), olds); if (s && strlen(s)) { snprintf(cmd, 1024, "help.search(\"%s\")", s); if (strlen(s) > 255) s[255] = '\0'; strcpy(olds, s); consolecmd(RConsole, cmd); } else show(RConsole); }
static void menuloadimage(control m) { wchar_t *fn; char s[MAX_PATH]; if (!ConsoleAcceptCmd) return; setuserfilterW(L"R images (*.RData)\0*.RData\0R images - old extension (*.rda)\0*.rda\0All files (*.*)\0*.*\0\0"); fn = askfilenameW(G_("Select image to load"), ""); if (fn) { quote_fn(fn, s); snprintf(cmd, 1024, "load(\"%s\")", s); consolecmd(RConsole, cmd); } else show(RConsole); }
static void menusource(control m) { wchar_t *fn; char local[MAX_PATH]; if (!ConsoleAcceptCmd) return; setuserfilterW(L"R files (*.R)\0*.R\0S files (*.q, *.ssc, *.S)\0*.q;*.ssc;*.S\0All files (*.*)\0*.*\0\0"); fn = askfilenameW(G_("Select file to source"), ""); if (fn) { quote_fn(fn, local); snprintf(cmd, 1024, "source(\"%s\")", local); consolecmd(RConsole, cmd); } else show(RConsole); }
static void menuapropos(control m) { char *s; static char olds[256] = ""; if (!ConsoleAcceptCmd) return; s = askstring(G_("Apropos"), olds); /* show(RConsole); */ if (s) { snprintf(cmd, 1024, "apropos(\"%s\")", s); if (strlen(s) > 255) s[255] = '\0'; strcpy(olds, s); consolecmd(RConsole, cmd); } else show(RConsole); }
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); }
static void menufncomplete(control m) { char cmd[200], *c0; if(ischecked(mfncomplete)) { c0 = "FALSE"; uncheck(mfncomplete); filename_completion_on = 0; } else { c0 = "TRUE"; check(mfncomplete); filename_completion_on = 1; } snprintf(cmd, 200, "utils::rc.settings(files=%s)", c0); consolecmd(RConsole, cmd); }
static void menude(control m) { char *s; SEXP var; if (!ConsoleAcceptCmd) return; s = askstring(G_("Name of data frame or matrix"), ""); if(s) { var = findVar(install(s), R_GlobalEnv); if (var != R_UnboundValue) { snprintf(cmd, 1024,"fix(%s)", s); consolecmd(RConsole, cmd); } else { snprintf(cmd, 1024, G_("'%s' cannot be found"), s); askok(cmd); } } /* show(RConsole); */ }
static void menusearch(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "search()"); /* show(RConsole); */ }
static void menudisplay(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole,"local({fn<-choose.files(filters=Filters[c('R','txt','All'),],index=4)\nfile.show(fn,header=fn,title='')})"); }
static void menupkgcranmirror(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "chooseCRANmirror()"); }
static void menupkgupdate(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "update.packages(ask='graphics',checkBuilt=TRUE)"); /* show(RConsole); */ }
static void menurestoregroup(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils::arrangeWindows(action='restore')"); }
static void menutilevert(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils::arrangeWindows(action='vertical')"); }
static void menucascade(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils::arrangeWindows(action='cascade')"); }
void Rconsolecmd(char *cmd) { consolecmd(RConsole, cmd); }
static void menuCRAN(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils:::menuShowCRAN()"); }
static void menupkgrepos(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "setRepositories()"); }
static void menupkginstalllocal(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils:::menuInstallLocal()"); }
static void menupkginstallpkgs(control m) { if (!ConsoleAcceptCmd) return; consolecmd(RConsole, "utils:::menuInstallPkgs()"); /* show(RConsole); */ }
static void closeconsole(control m) { consolecmd(RConsole, "q()"); // R_CleanUp(SA_DEFAULT, 0, 1); }