int Curses_getch(int with_echo) { char achar; int c; int kill; if (!inited) return 0; kill = 0; while (1) { c = getch() & 0177; if (c == interrupt_char) { if (kill++ >= 3) { End_curses(); exit(0); } continue; } kill = 0; if (c != 18) break; Curses_replot_screen(); } if (with_echo) { achar = c; addch(achar); refresh(); } return c; }
static Window *make_window(int top, int bottom, int left, int right) { Window *window; if (top < 0 || bottom >= LINES || left < 0 || right >= COLS || bottom - top <= 1 || right - left <= 1) { End_curses(); G_warning(_("make_window(%d,%d,%d,%d): illegal screen values."), top, bottom, left, right); G_sleep(3); exit(1); } window = (Window *) G_malloc(sizeof(Window)); window->top = top; window->bottom = bottom; window->left = left; window->right = right; Curses_clear_window(window); return window; }
int call(int (*function) (), char *msg) { int pid; int w, status; char i_msg[80]; /* * build interrupt msg */ sprintf(i_msg, "Hit %s %s\n", G_unctrl(interrupt_char), msg); /* * make sure all graphics have gotten to the monitor */ R_stabilize(); /* fork to create child */ pid = fork(); if (pid < 0) { End_curses(); perror("Can't fork"); exit(1); } /* parent just waits for child */ Curses_allow_interrupts(1); if (pid) { Curses_write_window(PROMPT_WINDOW, 1, 1, i_msg); while ((w = wait(&status)) != pid && w != -1) ; Curses_allow_interrupts(0); Curses_write_window(PROMPT_WINDOW, 1, 1, "\n"); } /* child turns on interrupts and calls the function */ else { signal(SIGINT, SIG_DFL); (*function) (); exit(0); } return 0; }
int quit(int n) { char command[1024]; End_curses(); R_close_driver(); if (use_digitizer) { sprintf(command, "%s/etc/geo.unlock %s", G_gisbase(), digit_points); system(command); } unlink(tempfile1); unlink(tempfile2); unlink(cell_list); unlink(group_list); unlink(vect_list); unlink(digit_points); unlink(digit_results); system("d.frame -e"); exit(n); }