home *** CD-ROM | disk | FTP | other *** search
- /*
- * chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
- *
- * scrmisc.c Collection of curses screen misc stuff
- */
-
- #include <curses.h>
- #include "variables.h"
- #include "windows.h"
-
- /* The SPACING define is for spacing the transcripts. This spacing technique
- * will USUALLY work for most print queues WITHOUT end-of-page form-feeding,
- * meaning the print command doesn't care about upper and lower margins. If
- * so, a lower value may be needed. */
- #define SPACING 4
-
- menu(str)
- char *str;
- {
- wstandout(mn);
- mvwaddstr(mn, 0, (40 - (strlen(str) / 2)), str);
- wstandend(mn);
- wrefresh(mn);
- }
-
- /*
- * bot(str)
- * input: str - char - string to print on bottom
- * output: curses only
- *
- * purpose: Take ''str'' and put it on ''btm'' (window)
- */
- bot(strn)
- char *strn;
- {
- wclear(btm); mvwaddstr(btm, 0, 0, strn); wrefresh(btm);
- }
-
- /*
- * spc() - no input
- *
- * purpose: To prompt the user that there is more..
- */
- spc()
- {
- wclear(btm); mvwaddstr(btm, 0, 0, "<< Press SPACE BAR to continue >>");
- wrefresh(btm);
- cur = btm; xp = 33; yp = 1;
- noecho(); crmode();
- getchar();
- wclear(btm);
- wrefresh(btm);
- }
-
- int needsit(win)
- WINDOW *win;
- {
- int y, x;
-
- for (y = 0; y < win->_maxy; y++) {
- for (x = 0; x < win->_maxx; x++)
- if (mvwinch(win, y, x) != ' ')
- return(1);
- }
- return(0);
- }
-
- void help(num)
- int num;
- {
- FILE *fp;
- char str[60];
- int line, i;
-
- hlp = newwin(16, 62, 4, 8);
- wrefresh(hlp);
-
- if ((fp = fopen(HELPFILE, "r")) == NULL) {
- mvwaddstr(hlp, 7, 1, "The HELPFILE is not available.");
- mvwaddstr(hlp, 8, 1, "Contact a chemtab administrator.");
- sleep(5);
- delwin(hlp);
- goto clean;
- }
-
- line = 0;
- for (;;) {
- fgets(str, 60, fp);
- if (str[0] == '_')
- if (++line == num)
- break;
- }
-
- for (i = 1; i < 15; i++) {
- if (fgets(str, 60, fp) == NULL) break;
- if (str[0] == '_') break;
- mvwaddstr(hlp, i, 2, str);
- }
-
- box(hlp, '|', '-');
- clean: wstandout(hlp); mvwaddstr(hlp, 15, 15, "Press <<RETURN>> to continue...");
- wrefresh(hlp);
- wstandend(hlp);
- cur = hlp; xp = 46; yp = 15;
- noecho();
- gets(str);
- wclear(hlp); wrefresh(hlp);
- delwin(hlp);
- hlp = NULL;
- if (needsit(stdscr)) { touchwin(stdscr); wrefresh(stdscr); }
- if (needsit(graph)) { touchwin(graph); wrefresh(graph); }
- if (needsit(mn)) { touchwin(mn); wrefresh(mn); }
- if (needsit(srt)) { touchwin(srt); wrefresh(srt); }
- if (needsit(btm)) { touchwin(btm); wrefresh(btm); }
- }
-
- capture(win, f, z)
- WINDOW *win;
- int f, z;
- {
- char c;
- int i, j, icn = 0; /* Internal count */
- if (!trans)
- return(1);
-
- for (;;) {
- l22: wclear(btm); mvwaddstr(btm, 0, 0, "Would you like this on your transcript? ");
- wrefresh(btm);
- cur = btm; xp = 41; yp = 0;
- noecho(); crmode();
- c = wgetch(btm);
- if (c == 'y') break;
- if (c == '?') { help(22); goto l22; }
- else if (c == 'n') return(1);
- }
-
- if (!z) {
- for (i = 0; i < SPACING; i++) {
- fputc('\n', fp);
- icn++;
- }
- } else {
- for (i = 0; i < SPACING-2; i++) {
- fputc('\n', fp);
- icn++;
- }
- fprintf(fp, "Your selection characteristics are listed on the next line.\n");
- icn++;
- for (i = 0; i < 3; i++) {
- if (dosort[i].wch != 0) {
- icn++;
- fprintf(fp, "%s ", sopts[dosort[i].wch].chst);
- switch(dosort[i].sgn) {
- case EQUAL: fprintf(fp, "= "); break;
- case GREATER: fprintf(fp, "> "); break;
- case CLOSE: fprintf(fp, "~ "); break;
- default: fprintf(fp, "< ");
- }
- fprintf(fp, "%4.*f ", sopts[dosort[i].wch].dnum, dosort[i].amt);
- }
- }
- }
- fputc('\n', fp);
- for (i = 0; i < 23; i++) {
- if (!f)
- fprintf(fp, " ");
- for (j = 0; j < 80; j++) {
- wmove(graph, i, j);
- fputc(winch(graph), fp);
- }
- fputc('\n', fp);
- }
- for (i = 0; i < SPACING-2; i++)
- fputc('\n', fp);
-
- fflush(fp);
- return(1);
- }
-
- version()
- {
- clear(); refresh();
-
- standout();
- mvaddstr(0, 34, "Chemtab V2.01");
- standend();
- mvaddstr(2, 0, "Element data (text): ");
- printw("%s", PERTABLE);
- mvaddstr(3, 0, "Element table (binary): ");
- printw("%s", BINTABLE);
- mvaddstr(4, 0, "Periodic table (text): ");
- printw("%s", TABLE);
- mvaddstr(5, 0, "Periodic table (graphic): ");
- printw("%s_graphic", TABLE);
- mvaddstr(6, 0, "Online help file (text): ");
- printw("%s", HELPFILE);
- mvaddstr(7, 0, "Close value file (text): ");
- printw("%s", CLOSEFILE);
- standout();
- mvaddstr(9, 0, "The above files must be properly defined for the program to run");
- mvaddstr(10, 0, "The files below are optional definitions");
- standend();
- #ifdef USERSHELL
- mvaddstr(12, 0, "Job stopping is enabled.");
- #else
- mvaddstr(12, 0, "Job stopping is disabled.");
- #endif USERSHELL
-
- #ifdef PRINTER
- mvaddstr(13, 0, "Printing is enabled through the ");
- printw("%s ", PRINTER);
- printw("command.");
- #else
- mvaddstr(13, 0, "Printing is disabled.");
- #endif PRINTER
-
- #ifdef TRANSCRIPT
- mvaddstr(14, 0, "User logs are kept in ");
- printw("%s.", TRANSCRIPT);
- #else
- mvaddstr(14, 0, "User logs are disabled.");
- #endif TRANSCRIPT
-
- #ifdef ReGIS
- mvaddstr(15, 0, "ReGIS graphics module is installed.");
- #else
- mvaddstr(15, 0, "ReGIS graphics module is not installed.");
- #endif ReGIS
-
- refresh();
- spc();
- clear(); refresh();
- }
-