home *** CD-ROM | disk | FTP | other *** search
- /*
- * This software is Copyright 1988 by Radical Eye Software.
- * All Rights Reserved.
- */
- /*
- * dviamiga.c of dviamiga software package.
- *
- * This is a preliminary main routine.
- */
- #include "structures.h"
- #include <string.h>
- /*
- * Our globals:
- */
- TeXfontdesctype *TeXfonts[256] ; /* font pointers */
- TeXfontdesctype *TeXfontlist ;
- fontdesctype *fontlist = NULL ; /* list of resident fonts */
- Boolean landscape = 0 ; /* are we in landscape? */
- FILE *dvifile, *pkfile ; /* files for input and output */
- integer curpos ; /* dvi file position */
- integer thispage ; /* where this page is */
- integer rthispage ;
- integer prevpage ; /* previous page */
- integer pagenum, seq ; /* page number */
- real conv, pxlconv ; /* to pixel conversion factors */
- integer iconv ; /* integer to pixel conversion factor */
- real vconv ; /* these are for the half mode */
- integer viconv ;
- real alpha ; /* conversion ratio, DVI unit per TFM unit */
- integer mag ; /* the magnification of this document */
- real screendpi = 100.0 ; /* current screen resolution */
- shalfword hh, vv ; /* current pixel position */
- shalfword fnt ; /* current font (0-255) */
- fontdesctype *curfnt ; /* current font (pointer) */
- char *resident ; /* where to find configuration info */
- char *tfmpath ; /* where to find tfm info */
- char *inputspath ; /* where to find input files */
- char *configpath ;
- char *headerpath ;
- char defaultfont[256] ; /* the default font name, size */
- frametype frames[MAXFRAME] ; /* stack for virtual fonts */
- quarterword *virpos ; /* current position in virtual character packet */
- quarterword *virlim ; /* final byte in virtual character packet */
- fontmaptype *ffont ; /* first font in current frame */
- char *vfpath ; /* pointer to directories for vf files */
- char *pkpath ; /* where to find pk info */
- shalfword hhoffset, vvoffset ; /* the horizontal and vertical off */
- shalfword hhmin, hhmax, vvmin, vvmax ; /* the borders of the screen */
- real hsize = 8.5, vsize = 11.0, hmarg = 1.0, vmarg = 1.0 ;
- /* the page and margin size */
- real defhsize = 8.5, defvsize = 11.0, defhmarg = 1.0, defvmarg = 1.0 ;
- shalfword hhsize, vvsize, hhmarg, vvmarg ;
- shalfword rhhsize, rvvsize, rhhmarg, rvvmarg ;
- shalfword hbody, vbody, hpos, vpos ;
- integer hpot = 32768, vpot = 0 ;
- shalfword vscreen = 380 ; /* screen size vertical */
- shalfword vwindow, vwindowheight, hwindow, hwindowwidth ;
- integer dvimag, num, den ; /* sizes from dvi file */
- integer memalloc = 0 ;
- integer numalloc = 0 ;
- Boolean pageinterrupted = 0 ;
- integer messagebit ; /* the bit to wait for on IDCMP */
- real possibmag[] = { /* possible screen dots per inch */
- 33.4898, /* this one is writeable */
- 16.1506, 17.6921, 19.3807, 21.2305, 23.2568,
- 25.4766, 27.9082, 30.5719, 33.4898, 36.6862,
- 40.1878, 44.0235, 48.2253, 52.8282,
- 57.8704, 63.3938, 69.4444, 76.0726, 83.3333,
- 91.2871, 100.0000, 109.5445, 120.0000, 131.4534,
- 144.0000, 157.7441, 172.8000, 189.2929, 300.0000,
- 400.0000, 0.0000 } ;
- int existsize100[] = { 0, 69, 76, 83, 91, 100, 110, 120,
- 131, 144, 158, 173, 189, 207, 227, 249, 273, 299, 327, 358, 393,
- 430, 471, 516, 565, 619, 678, 743, 814, 892, 977, 1070, 32767 } ;
- int existsize300[] = { 0, 300, 329, 360, 432, 518, 622, 746, 896,
- 1075, 1290, 1548, 32767 } ;
- int existsize400[] = { 0, 400, 438, 480, 576, 691, 829, 995, 1194,
- 1433, 1720, 2064, 32767 } ;
- int *existsize = existsize100 ;
- real userdpi[] = { 91.2871, 120.0000 } ;
- int debugon = 0 ;
- int paranoia = 0 ;
- Boolean borderson = 1 ;
- Boolean dualpage = 0 ;
- Boolean orientationset = 0 ;
- Boolean reopenscreen = 0 ;
- shalfword vscreenheight = 400 ;
- Boolean interlaceon = 1 ;
- int first ;
- int x, y ;
- int tracking ;
- Boolean zoomed = 0 ;
- Boolean mocked = 0 ;
- char realname[200] ;
- char safebuf[200], filenamebuf[200] ;
- int redrawbars = 0 ;
- int turnitoff = 0 ;
- int nloc ;
- integer spage, sno ;
- Boolean redrawpage ;
- int rowsize, colsize ;
- Boolean autofront=1, autoactivate ;
- int actualdpi = 100 ;
- extern char pagebuf[] ;
- extern Boolean usersetsizes ;
- extern char defaulttitle[] ;
- extern char safebuf[] ;
- /*
- * The external routines we call:
- */
- extern void dopage() ;
- extern void initialize() ;
- extern shalfword skipnop() ;
- extern void skipover() ;
- extern Boolean seekpage() ;
- extern void exit() ;
- extern void recalculate() ;
- extern int NXAlert() ;
- extern int NXRunAlertPanel() ;
- extern int NXGetAlertPanel() ;
- extern void TPSbop(), TPSeop() ;
- extern void texflush() ;
- extern void display() ;
- int dviOpenFile() ;
- extern void writeconsole() ;
- /*
- * Pops and deletes an alert panel to get around a bug.
- */
- void fixalertbug() {
- #ifdef BADKLUDGE
- NXRunAlertPanel("Howdy!", "This is TeXview 0.0\nCopyright 1989 Radical Eye Software\nAll Rights Reserved",
- NULL, NULL, NULL) ;
- #endif
- }
- /*
- * error is called on all errors. It prints the message, and exits
- * if the error starts with !.
- */
- char temperrorbuf[80] ;
- extern char lastfile[] ;
- Boolean erroronscreen = 0 ;
- void error(s)
- register char *s ;
- {
- fflush(stdout) ;
- writeconsole(s) ;
- NXRunAlertPanel(NULL, s, "OK", NULL, NULL) ;
- if (*s=='!') {
- if (lastfile[0])
- NXRunAlertPanel(NULL, "Last font was %s\n", "OK", NULL, NULL, lastfile) ; /* jvc */
- exit(1) ;
- }
- }
- /*
- * Our main routine will get a file name from the command line. First,
- * a routine to check if we need to quit.
- */
- int checkformessage() {
- return(0) ;
- }
- int gargc ;
- void more_main (argc, argv)
- int argc ;
- char *argv[] ;
- {
- if (argc > 1 && argv[1][0]=='-' && argv[1][1]=='d') {
- if (argv[1][2] <= '9' && argv[1][2] >= '0')
- debugon = argv[1][2] - '0' ;
- else
- debugon = 1 ;
- argc-- ; argv++ ;
- }
- while (argc > 1 && argv[1][0]=='-') {
- argc-- ; argv++ ;
- }
- screendpi = userdpi[zoomed] ;
- dvifile = NULL ;
- usersetsizes = 0 ;
- hsize = 8.5 ;
- vsize = 11.0 ;
- hmarg = 1.0 ;
- vmarg = 1.0 ;
- gargc = argc ;
- initialize() ;
- curpos = 0 ;
- recalculate() ;
- if (argc > 1) {
- char *p, *last ;
- last = 0 ;
- strcpy(realname, argv[1]) ;
- for (p=realname; *p; p++)
- if (*p == '.')
- last = p ;
- else if (*p == '/')
- last = 0 ;
- if (last == 0)
- strcat(realname, ".dvi") ;
- if (dviOpenFile(realname) == 1)
- display() ;
- } else
- display() ;
- }
- /*
- * This is where we fix the environment variable problem
- * caused by the fact that the WorkSpace environment
- * doesn't get environment variables.
- */
- #undef getenv
- char *getenv(), *malloc() ;
- char *mgetenv(s)
- char *s ;
- {
- static int envinit = 0 ;
- static struct envpair {
- struct envpair *next ;
- char *name, *val ;
- char s[1] ;
- } *envbase = 0 ;
- char inbuf[1000] ;
- char *p ;
- struct envpair *tp ;
-
- if (envinit == 0) {
- FILE *f = popen("csh -c printenv", "r") ;
- if (f) {
- while (fgets(inbuf, 1000, f))
- if (strlen(inbuf) > 3) {
- inbuf[strlen(inbuf)-1] = 0 ;
- for (p=inbuf; *p && *p != '='; p++) ;
- if (*p == '=') {
- tp = (struct envpair *)
- malloc(sizeof(struct envpair) + strlen(inbuf)) ;
- tp->next = envbase ;
- strcpy(tp->s, inbuf) ;
- p = tp->s + (p - inbuf) ;
- tp->name = tp->s ;
- tp->val = p + 1 ;
- *p = 0 ;
- envbase = tp ;
- }
- }
- pclose(f) ;
- }
- envinit = 1 ;
- }
- p = getenv(s) ;
- if (p)
- return p ;
- for (tp = envbase; tp; tp = tp->next)
- if (strcmp(s, tp->name)==0)
- return tp->val ;
- return 0 ;
- }
-