static void do_rectangle_operation(EditState *s, const char *command) { if (!strcmp(command, "kill")) { rectangle_cut(s); } else if (!strcmp(command, "yank")) { put_status(s, "Rectangle yank not supported!"); } else if (!strcmp(command, "insert")) { minibuffer_edit(NULL, "String to insert: ", NULL, NULL, rectangle_insert_query, (void *)s); } else { put_status(s, "%s command not supported", command); } }
static void do_latex(EditState *e, const char *cmd) { char buf[1024]; int i; char *p, *f; char *bname; /* strip extension from filename, find the last dot after the last * slash (ie, the last dot in the filename) */ f = strrchr(e->b->filename, '/'); if(f) f++; else f = e->b->filename; p = strrchr(f, '.'); if(p) { int len = p - e->b->filename; bname = (char *)malloc(len + 1); pstrncpy(bname, len + 1, e->b->filename, len); } else { bname = strdup(e->b->filename); } if(!cmd || cmd[0] == '\0') strcpy(buf, "LaTeX"); else strcpy(buf, cmd); /* check what command to run */ for(i = 0; latex_funcs[i].name; i++) { if(strcasecmp(buf, latex_funcs[i].name) == 0) { /* pass the EditState through to latex_cmd_run() */ latex_funcs[i].es = e; /* construct the command line to run */ snprintf(buf, sizeof(buf), latex_funcs[i].fmt, bname, bname); if(latex_funcs[i].ask) { char prompt[128]; snprintf(prompt, sizeof(prompt), "%s command: ", latex_funcs[i].name); minibuffer_edit(buf, prompt, &latex_funcs[i].history, NULL /* completion */, latex_cmd_run, (void *)&latex_funcs[i]); } else { latex_cmd_run((void *)&latex_funcs[i], buf); } break; } } if(latex_funcs[i].name == 0) put_status(e, "%s: No match", buf); free(bname); }