SEXP winDialog(SEXP call, SEXP op, SEXP args, SEXP env) { SEXP message; const char * type; int res=YES; args = CDR(args); type = translateChar(STRING_ELT(CAR(args), 0)); message = CADR(args); if(!isString(message) || length(message) != 1 || strlen(translateChar(STRING_ELT(message, 0))) > 255) error(_("invalid '%s' argument"), "message"); if (strcmp(type, "ok") == 0) { askok(translateChar(STRING_ELT(message, 0))); res = 10; } else if (strcmp(type, "okcancel") == 0) { res = askokcancel(translateChar(STRING_ELT(message, 0))); if(res == YES) res = 2; } else if (strcmp(type, "yesno") == 0) { res = askyesno(translateChar(STRING_ELT(message, 0))); } else if (strcmp(type, "yesnocancel") == 0) { res = askyesnocancel(translateChar(STRING_ELT(message, 0))); } else errorcall(call, _("unknown type")); return ScalarInteger(res); }
int editorchecksave(editor c) { textbox t = getdata(c); EditorData p = getdata(t); int save; char buf[EDITORMAXTITLE + 100]; if (ggetmodified(t)) { snprintf(buf, EDITORMAXTITLE + 100, "\"%s\" has been modified. Do you want to save the changes?", (p->title ? p->title : "Untitled")); save = askyesnocancel(buf); switch (save) { case YES: editorsave(c); break; case NO: break; case CANCEL: return 1; } } return 0; }