home *** CD-ROM | disk | FTP | other *** search
- /*
- * Routines to read and copy the virtual screen image file.
- */
-
- #define MAX_COL 128
-
- #include <stdio.h>
- #include <curses.h>
- #include "param.h"
- #include "status.h"
-
- /*
- * Do a screen dump. Actually, the screen is already dumped, all we
- * do is copy the file.
- */
-
- void
- screen_dump()
- {
- FILE *fp_in, *fp_out;
- char buf[MAX_COL+2];
- void error_win();
- /* not guaranteed to exist yet */
- if (!(fp_in = fopen(status->vs_path, "r")))
- return;
- /* open for append */
- if (!(fp_out = fopen(param->dumpfile, "a"))) {
- fclose(fp_in);
- sprintf(buf, "'%s' for write", param->dumpfile);
- error_win(0, "Can't open screen dump file", buf);
- return;
- }
- /* skip the x, y coordinates */
- fgets(buf, 10, fp_in);
-
- while (fgets(buf, MAX_COL+2, fp_in) != NULL)
- fputs(buf, fp_out);
-
- fclose(fp_in);
- fclose(fp_out);
-
- return;
- }
-
- /*
- * Read the virtual screen file and paint its contents to the
- * stdscr with curses. Leave the cursor where it belongs.
- */
-
- void
- load_vs()
- {
- FILE *fp;
- int row, col, i;
- char buf[MAX_COL+2];
- /* not guaranteed to exist yet */
- if (!(fp = fopen(status->vs_path, "r")))
- return;
- /* get the x, y coordinates */
- fgets(buf, 10, fp);
- sscanf(buf, "%d,%d\n", &row, &col);
-
- clearok(stdscr, TRUE);
- i = 0;
- while (fgets(buf, MAX_COL+2, fp) != NULL) {
- buf[COLS] = NULL;
- mvaddstr(i++, 0, buf);
- }
- move(row, col);
- refresh();
- clearok(stdscr, FALSE);
-
- fclose(fp);
- return;
- }
-