home *** CD-ROM | disk | FTP | other *** search
- /*
- * chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
- *
- * ptabl.c Print the Periodic Table with sorted elements in place
- */
-
- #include <curses.h>
- #include "windows.h"
- #include <stdio.h>
- #include "variables.h"
- #include "tune.h"
- #include "element.h"
- #include <signal.h>
-
- extern int stop();
-
- /* helps to print out where the elements go */
- int horz[10] = { 0, 2, 4, 6, 8, 10, 12, 14, 18, 20 };
-
- /*
- * ptabl() - no input
- *
- * purpose: To print the periodic table then fill in spaces with
- * appropriate ''selected'' elements.
- */
- ptabl()
- {
- struct elem *tmp;
- FILE *fd; /* Periodic table is in a file */
- char foo[80]; /* And we need to read it into something */
- int z, i, n, ics; /* element number reference */
-
- if (gtot == -1) {
- mvwaddstr(mn, 15, 0, "Please choose some selection characteristics before you do this.");
- wrefresh(mn);
- sleep(2);
- wmove(mn, 15, 0); wclrtoeol(mn);
- return(0);
- }
-
- strcpy(foo, TABLE);
-
- wclear(mn); wrefresh(mn);
- clear(); refresh();
- l16: mvwaddstr(btm, 0, 0, "VT100 alternate graphic set (if yes, no transcript of this table) ");
- wrefresh(btm);
- cur = btm; xp = 65; yp = 0;
- noecho(); crmode();
- switch(getchar()) {
- case '?': help(16); goto l16;
- case 'y':
- case 'Y':
- #ifdef USERSHELL
- signal(SIGTSTP, SIG_IGN);
- #endif USERSHELL
- strcat(foo, "_graphic"); ics = 1; break;
- default: ics = 0; break;
- }
- if ((fd = fopen(foo, "r")) == NULL) {
- bot("Cannot open periodic table.. sorry..");
- sleep(3);
- return(0);
- }
- if (ics) printf("\033(0"); /* on graphics */
- for (i = 0; i < 22; i++) { /* read in the table */
- fgets(foo, 80, fd);
- mvwaddstr(graph, i, 0, foo);
- wrefresh(graph);
- } /* and output to WINDOW *graph */
- fclose(fd);
- if (ics) printf("\033(B");
- tablsort(); /* Put characteristics on screen */
- if (ics) printf("\033(0"); fflush(stdout);
- for (i = 1; i < gtot+1; i++) { /* format and print element sym. */
- n = sub1[i];
- for (tmp = e; n != tmp->anum; tmp = tmp->next) ;
- if (tmp->anum > 56 && tmp->anum < 72)
- wmove(graph, horz[8], (13 + ((tmp->fam - 1) * 3)));
- else if (tmp->anum > 88 && tmp->anum < 104)
- wmove(graph, horz[9], (13 + ((tmp->fam - 1) * 3)));
- else if (tmp->anum > 103 && tmp->anum < 111)
- wmove(graph, horz[tmp->row], (1 + ((tmp->fam - 1) * 3) - (104 - tmp->anum)));
- else
- wmove(graph, horz[tmp->row], (1 + ((tmp->fam - 1) * 3)));
-
- wrefresh(graph);
- wstandout(graph);
- if (ics) { /* I realize the slowness... */
- printf("\033(B"); fflush(stdout);
- wprintw(graph, "%2s", tmp->sym);
- wrefresh(graph);
- printf("\033(0"); fflush(stdout);
- } else
- wprintw(graph, "%2s", tmp->sym);
- wrefresh(graph);
- wstandend(graph);
- }
- if (ics) printf("\033(B");
- wrefresh(graph);
- if (!ics) capture(graph, 0, 0);
- spc();
- wclear(graph); wrefresh(graph);
- clear();
- refresh();
- #ifdef USERSHELL
- signal(SIGTSTP, stop);
- #endif USERSHELL
- return(0);
- }
-