home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / gnuplot / part21 < prev    next >
Encoding:
Text File  |  1993-10-22  |  80.4 KB  |  3,009 lines

  1. Newsgroups: comp.sources.misc
  2. From: woo@playfair.stanford.edu ("Alexander Woo")
  3. Subject: v40i033:  gnuplot - interactive function plotting utility, Part21/33
  4. Message-ID: <1993Oct22.163758.24512@sparky.sterling.com>
  5. X-Md4-Signature: b4859a3bdea5805ff394ac5b3cae1a93
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 22 Oct 1993 16:37:58 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: woo@playfair.stanford.edu ("Alexander Woo")
  12. Posting-number: Volume 40, Issue 33
  13. Archive-name: gnuplot/part21
  14. Environment: UNIX, MS-DOS, VMS
  15. Supersedes: gnuplot3: Volume 24, Issue 23-48
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  gnuplot/corgraph.asm gnuplot/docs/doc2ipf.c
  22. #   gnuplot/os2/dialogs.c gnuplot/term/epson.trm gnuplot/term/hpgl.trm
  23. #   gnuplot/term/unixpc.trm
  24. # Wrapped by kent@sparky on Wed Oct 20 17:14:54 1993
  25. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 21 (of 33)."'
  28. if test -f 'gnuplot/corgraph.asm' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'gnuplot/corgraph.asm'\"
  30. else
  31.   echo shar: Extracting \"'gnuplot/corgraph.asm'\" \(2272 characters\)
  32.   sed "s/^X//" >'gnuplot/corgraph.asm' <<'END_OF_FILE'
  33. XTITLE    Corona graphics module
  34. X;    Colin Kelley
  35. X;    January 1987
  36. X
  37. Xinclude header.mac
  38. X
  39. Xif1
  40. Xinclude lineproc.mac
  41. Xendif
  42. X
  43. X
  44. X_text    segment
  45. X
  46. Xpublic    _GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask
  47. X
  48. Xcorpixel proc near
  49. X    ror word ptr linemask,1
  50. X    jc cont
  51. X    ret
  52. Xcont:    push bp
  53. X    mov bp,sp
  54. X    push ax
  55. X    push bx
  56. X    push cx
  57. X    mov es,ScSeg
  58. X    shl bx,1            ; y
  59. X    mov bx,word ptr LookUp[bx] ; bx has y mem address
  60. X    mov cl,al            ; x
  61. X    and cl,7
  62. X    shr ax,1
  63. X    shr ax,1
  64. X    shr ax,1            ; ax /= 8
  65. X    add bx,ax
  66. X    mov al,1
  67. X    shl al,cl            ; al contains bit mask
  68. X    or byte ptr es:[bx],al
  69. X    pop cx
  70. X    pop bx
  71. X    pop ax
  72. X    pop bp
  73. X    ret
  74. X
  75. Xlineproc _Cor_line, corpixel
  76. X
  77. Xbeginproc _GrInit
  78. X    push bp
  79. X    mov bp,sp
  80. X    push di
  81. X    mov ax, [bp+X]            ; screen number (0 - 7)
  82. X    mov cl,11
  83. X    shl ax,cl            ; multiply by 2048 to get segment
  84. X    mov ScSeg,ax            ; save segment for later
  85. X    push ax
  86. X    mov es, ax
  87. X    xor ax,ax
  88. X    mov di,ax
  89. X    mov cx, 4000h
  90. X    cld
  91. X    rep stosw
  92. X    pop cx
  93. X    call near ptr GrAddr
  94. X    mov ax,es
  95. X    pop di
  96. X    pop bp
  97. X    ret
  98. X_GrInit    endp
  99. X
  100. Xbeginproc _GrReset
  101. X    mov cx, 0
  102. X    call near ptr GrAddr
  103. X    ret
  104. X_GrReset endp
  105. X
  106. XGrAddr    proc near
  107. X    mov dx,3b4h            ; address of 6845
  108. X    mov al,0ch            ; register 12
  109. X    out dx,al
  110. X    inc dx
  111. X    mov al,ch            ; Graphics Segment High
  112. X    out dx,al
  113. X    dec dx
  114. X    mov al,0dh            ; register 13
  115. X    out dx,al
  116. X    mov al,cl            ; Graphics Segment Low
  117. X    inc dx
  118. X    out dx,al
  119. X    ret
  120. XGrAddr    endp
  121. X
  122. Xbeginproc _GrOnly
  123. X    mov dx,3b8h
  124. X    mov al,0a0h
  125. X    out dx,al
  126. X    ret
  127. X_GrOnly    endp
  128. X
  129. Xbeginproc _TxOnly
  130. X    mov dx,3b8h
  131. X    mov al,28h
  132. X    out dx,al
  133. X    ret
  134. X_TxOnly    endp
  135. X
  136. Xbeginproc _GrandTx
  137. X    mov dx,3b8h
  138. X    mov al,0a8h
  139. X    out dx,al
  140. X    ret
  141. X_GrandTx endp
  142. X
  143. Xbeginproc _Cor_mask
  144. X    push bp
  145. X    mov bp,sp
  146. X    mov ax,[bp+x]            ; mask
  147. X    mov linemask,ax
  148. X    pop bp
  149. X    ret
  150. X_Cor_mask endp
  151. X
  152. Xcorpixel endp
  153. X
  154. X_text    ends
  155. X
  156. X_data    segment
  157. Xlinemask dw -1
  158. XScSeg    dw 0
  159. X_data    ends
  160. X
  161. Xconst    segment
  162. X
  163. XK    equ 1024
  164. X
  165. Xmem_mac    MACRO x
  166. X    dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
  167. X    dw 18*K+x,20*K+x,22*K+x,24*K+x
  168. X    ENDM
  169. XLookUp    equ $
  170. X    mem_mac 0
  171. X    mem_mac 80
  172. X    mem_mac (80*2)
  173. X    mem_mac (80*3)
  174. X    mem_mac (80*4)
  175. X    mem_mac (80*5)
  176. X    mem_mac (80*6)
  177. X    mem_mac (80*7)
  178. X    mem_mac (80*8)
  179. X    mem_mac (80*9)
  180. X    mem_mac (80*10)
  181. X    mem_mac (80*11)
  182. X    mem_mac (80*12)
  183. X    mem_mac (80*13)
  184. X    mem_mac (80*14)
  185. X    mem_mac (80*15)
  186. X    mem_mac (80*16)
  187. X    mem_mac (80*17)
  188. X    mem_mac (80*18)
  189. X    mem_mac (80*19)
  190. X    mem_mac (80*20)
  191. X    mem_mac (80*21)
  192. X    mem_mac (80*22)
  193. X    mem_mac (80*23)
  194. X    mem_mac (80*24)
  195. X
  196. Xconst    ends
  197. X
  198. X    end
  199. END_OF_FILE
  200.   if test 2272 -ne `wc -c <'gnuplot/corgraph.asm'`; then
  201.     echo shar: \"'gnuplot/corgraph.asm'\" unpacked with wrong size!
  202.   fi
  203.   # end of 'gnuplot/corgraph.asm'
  204. fi
  205. if test -f 'gnuplot/docs/doc2ipf.c' -a "${1}" != "-c" ; then 
  206.   echo shar: Will not clobber existing file \"'gnuplot/docs/doc2ipf.c'\"
  207. else
  208.   echo shar: Extracting \"'gnuplot/docs/doc2ipf.c'\" \(15131 characters\)
  209.   sed "s/^X//" >'gnuplot/docs/doc2ipf.c' <<'END_OF_FILE'
  210. X#ifndef lint
  211. Xstatic char *RCSid = "$Id: doc2ipf.c%v 3.50 1993/07/09 05:35:24 woo Exp $";
  212. X#endif
  213. X
  214. X/*
  215. X * doc2ipf.c  -- program to convert Gnuplot .DOC format to OS/2
  216. X * ipfc  (.inf/.hlp) format.
  217. X *
  218. X * Modified by Roger Fearick from doc2rtf by M Castro 
  219. X *
  220. X * usage:  doc2ipf gnuplot.doc gnuplot.itl
  221. X *
  222. X */
  223. X
  224. X/* note that tables must begin in at least the second column to */
  225. X/* be formatted correctly and tabs are forbidden */
  226. X
  227. X#include <stdio.h>
  228. X#include <ctype.h>
  229. X#include <string.h>
  230. X#include <stdlib.h>
  231. X#include <malloc.h>
  232. X
  233. X#define MAX_LINE_LEN    1024
  234. X#define TRUE 1
  235. X#define FALSE 0
  236. X
  237. Xstruct LIST
  238. X{
  239. X    int level;
  240. X    int line;
  241. X    char *string;
  242. X    struct LIST *next;
  243. X    };
  244. X
  245. Xstruct LIST *list = NULL;
  246. Xstruct LIST *head = NULL;
  247. X
  248. Xstruct LIST *keylist = NULL;
  249. Xstruct LIST *keyhead = NULL;
  250. X
  251. Xstruct TABENTRY { /* may have 3 column tables */
  252. X        struct TABENTRY *next ;
  253. X        char col[3][256] ;
  254. X        } ;
  255. X
  256. Xstruct TABENTRY table = {NULL} ;
  257. Xstruct TABENTRY *tableins = &table ;
  258. Xint tablecols = 0 ;
  259. Xint tablewidth[3] = {0,0,0} ;        
  260. Xint tablelines = 0 ;
  261. X
  262. Xint debug = FALSE;
  263. X
  264. Xvoid parse();
  265. Xvoid refs();
  266. Xvoid convert();
  267. Xvoid process_line();
  268. Xint lookup();
  269. X
  270. Xmain(argc,argv)
  271. Xint argc;
  272. Xchar **argv;
  273. X{
  274. XFILE * infile;
  275. XFILE * outfile;
  276. X    if (argc==4 && argv[3][0]=='-' && argv[3][1]=='d')
  277. X        debug = TRUE;
  278. X
  279. X    if (argc != 3 && !debug) {
  280. X        fprintf(stderr,"Usage: %s infile outfile\n", argv[0]);
  281. X        return(1);
  282. X    }
  283. X    if ( (infile = fopen(argv[1],"r")) == (FILE *)NULL) {
  284. X        fprintf(stderr,"%s: Can't open %s for reading\n",
  285. X            argv[0], argv[1]);
  286. X        return(1);
  287. X    }
  288. X    if ( (outfile = fopen(argv[2],"w")) == (FILE *)NULL) {
  289. X        fprintf(stderr,"%s: Can't open %s for writing\n",
  290. X            argv[0], argv[2]);
  291. X    }
  292. X    parse(infile);
  293. X    convert(infile,outfile);
  294. X    return(0);
  295. X}
  296. X
  297. X/* scan the file and build a list of line numbers where particular levels are */
  298. Xvoid parse(a)
  299. XFILE *a;
  300. X{
  301. X    static char line[MAX_LINE_LEN];
  302. X    char *c;
  303. X    int lineno=0;
  304. X    int lastline=0;
  305. X
  306. X    while (fgets(line,MAX_LINE_LEN,a)) 
  307. X    {
  308. X    lineno++;
  309. X    if (isdigit(line[0]))
  310. X    {
  311. X        if (list == NULL)    
  312. X            head = (list = (struct LIST *) malloc(sizeof(struct LIST)));
  313. X        else
  314. X            list = (list->next = (struct LIST *) malloc(sizeof(struct LIST)));
  315. X        list->line = lastline = lineno;
  316. X        list->level = line[0] - '0';
  317. X        list->string = (char *) malloc (strlen(line)+1);
  318. X        c = strtok(&(line[1]),"\n");
  319. X        strcpy(list->string, c);
  320. X        list->next = NULL;
  321. X    }
  322. X    if (line[0]=='?')
  323. X    {
  324. X        if (keylist == NULL)    
  325. X            keyhead = (keylist = (struct LIST *) malloc(sizeof(struct LIST)));
  326. X        else
  327. X            keylist = (keylist->next = (struct LIST *) malloc(sizeof(struct LIST)));
  328. X        keylist->line = lastline;
  329. X        keylist->level = line[0] - '0';
  330. X        c = strtok(&(line[1]),"\n");
  331. X        if( c == NULL || *c == '\0' ) c = list->string ;
  332. X        keylist->string = (char *) malloc (strlen(c)+1);
  333. X        strcpy(keylist->string, c);
  334. X        keylist->next = NULL;
  335. X    }
  336. X    }
  337. X    rewind(a);
  338. X    }
  339. X
  340. X/* look up an in text reference */
  341. Xint
  342. Xlookup(s)
  343. Xchar *s;
  344. X{
  345. X    char *c;
  346. X    char tokstr[MAX_LINE_LEN];
  347. X    char *match; 
  348. X    int l;
  349. X
  350. X    strcpy(tokstr, s);
  351. X
  352. X    /* first try the ? keyword entries */
  353. X    keylist = keyhead;
  354. X    while (keylist != NULL)
  355. X    {
  356. X        c = keylist->string;
  357. X        while (isspace(*c)) c++;
  358. X        if (!strcmp(s, c)) return(keylist->line);
  359. X        keylist = keylist->next;
  360. X        }
  361. X
  362. X    /* then try titles */
  363. X    match = strtok(tokstr, " \n\t");
  364. X    l = 0; /* level */
  365. X    
  366. X    list = head;
  367. X    while (list != NULL)
  368. X    {
  369. X        c = list->string;
  370. X        while (isspace(*c)) c++;
  371. X        if (!strcmp(match, c)) 
  372. X        {
  373. X            l = list->level;
  374. X            match = strtok(NULL, "\n\t ");
  375. X            if (match == NULL)
  376. X            {
  377. X                return(list->line);
  378. X                }
  379. X            }
  380. X        if (l > list->level)
  381. X            break;
  382. X        list = list->next;
  383. X        }
  384. X    return(-1);
  385. X    }
  386. X
  387. X/* search through the list to find any references */
  388. Xvoid
  389. Xrefs(l, f)
  390. Xint l;
  391. XFILE *f;
  392. X{
  393. X    int curlevel;
  394. X    char str[MAX_LINE_LEN];
  395. X    char *c;
  396. X
  397. X    /* find current line */
  398. X    list = head;
  399. X    while (list->line != l)
  400. X        list = list->next;
  401. X    curlevel = list->level;
  402. X    list = list->next;        /* look at next element before going on */
  403. X    while (list != NULL)
  404. X    {
  405. X        /* we are onto the next topic so stop */
  406. X        if (list->level == curlevel)
  407. X            break;
  408. X        /* these are the next topics down the list */
  409. X        if (list->level == curlevel+1)
  410. X        {
  411. X            c = list->string;
  412. X            }
  413. X        list = list->next;
  414. X        }
  415. X    }
  416. X
  417. Xvoid
  418. Xconvert(a,b)
  419. X    FILE *a,*b;
  420. X{
  421. X    static char line[MAX_LINE_LEN];
  422. X    
  423. X    /* generate rtf header */
  424. X    fprintf(b,":userdoc.\n:prolog.\n");
  425. X    fprintf(b,":title.GNUPLOT\n");
  426. X    fprintf(b,":docprof toc=1234.\n:eprolog.\n");
  427. X
  428. X    /* process each line of the file */
  429. X        while (fgets(line,MAX_LINE_LEN,a)) {
  430. X       process_line(line, b);
  431. X       }
  432. X
  433. X    /* close final page and generate trailer */
  434. X    fprintf(b,"\n:euserdoc.\n");
  435. X}
  436. X
  437. Xvoid
  438. Xprocess_line(line, b)
  439. X    char *line;
  440. X    FILE *b;
  441. X{
  442. X    static int line_count = 0;
  443. X    static char line2[MAX_LINE_LEN];
  444. X    static int last_line;
  445. X    char hyplink1[64] ;
  446. X    char *pt, *tablerow ;
  447. X    int i;
  448. X    int j;
  449. X    static int startpage = 1;
  450. X    char str[MAX_LINE_LEN];
  451. X    char topic[MAX_LINE_LEN];
  452. X    int k, l;
  453. X    static int tabl=0;
  454. X    static int para=0;
  455. X    static int inquote = FALSE;
  456. X    static int inref = FALSE;
  457. X    static int intable = FALSE ; 
  458. X    static int intablebut = FALSE ;
  459. X    static FILE *bo= NULL, *bt = NULL ;
  460. X
  461. X    line_count++;
  462. X
  463. X    if( bo == NULL ) bo = b ;
  464. X    i = 0;
  465. X    j = 0;
  466. X    while (line[i] != NULL)
  467. X    {
  468. X        switch(line[i])
  469. X        {
  470. X            case '$':
  471. X                if( intable && line[0] == '%' ) {                                    
  472. X                   ++i ;
  473. X                   if( line[i+1]=='$'|| line[i]=='x' || line[i]=='|'){
  474. X                      while ( line[i] != '$' ) line2[j++]=line[i++] ;
  475. X                      --j;
  476. X                      }
  477. X                   else {
  478. X                       while( line[i] != '$' ) i++ ;
  479. X                       if( line[i+1]==',' ) i++ ;
  480. X                       if( line[i+1]==' ' ) i++ ;
  481. X                       line2[j]=line[++i] ;
  482. X                       }
  483. X                   }
  484. X                break ;
  485. X            case ':':
  486. X                strcpy( &line2[j], "&colon." ) ;
  487. X                j += strlen( "&colon." ) - 1 ;
  488. X                break ;
  489. X
  490. X            case '&':
  491. X                strcpy( &line2[j], "&." ) ;
  492. X                j += strlen( "&." ) - 1 ;
  493. X                break ;
  494. X                                
  495. X            case '\r':
  496. X            case '\n':
  497. X                break;
  498. X            case '`':    /* backquotes mean boldface or link */
  499. X                if ((!inref) && (!inquote))
  500. X                {
  501. X                    k=i+1;    /* index into current string */
  502. X                    l=0;    /* index into topic string */
  503. X                    while ((line[k] != '`') && (line[k] != NULL))
  504. X                    {
  505. X                        topic[l] = line[k];
  506. X                        k++;
  507. X                        l++;
  508. X                        }
  509. X                    topic[l] = NULL;
  510. X                    k = lookup(topic);
  511. X                    if (k > 0)
  512. X                    {
  513. X                        sprintf( hyplink1, ":link reftype=hd res=%d.", k ) ;
  514. X                        strcpy( line2+j, hyplink1 ) ;
  515. X                        j += strlen( hyplink1 )-1 ;
  516. X                        
  517. X                        inref = k;
  518. X                        }
  519. X                    else
  520. X                    {
  521. X                        if (debug)
  522. X                            fprintf(stderr,"Can't make link for \042%s\042 on line %d\n",topic,line_count);
  523. X                        line2[j++] = ':';
  524. X                        line2[j++] = 'h';
  525. X                        line2[j++] = 'p';
  526. X                        line2[j++] = '2';
  527. X                        line2[j] = '.';
  528. X                        inquote = TRUE;
  529. X                        }
  530. X                    }
  531. X                else
  532. X                {
  533. X                    if (inquote && inref)
  534. X                        fprintf(stderr, "Warning: Reference Quote conflict line %d\n", line_count);
  535. X                    if (inquote)
  536. X                    {
  537. X                        line2[j++] = ':';
  538. X                        line2[j++] = 'e';
  539. X                        line2[j++] = 'h';
  540. X                        line2[j++] = 'p';
  541. X                        line2[j++] = '2';
  542. X                        line2[j] = '.';
  543. X                        inquote = FALSE;
  544. X                        }
  545. X                    if (inref)
  546. X                    {
  547. X                        /* must be inref */
  548. X                        line2[j++] = ':';
  549. X                        line2[j++] = 'e';
  550. X                        line2[j++] = 'l';
  551. X                        line2[j++] = 'i';
  552. X                        line2[j++] = 'n';
  553. X                        line2[j++] = 'k';
  554. X                        line2[j] = '.';
  555. X                        inref = 0;
  556. X                        }
  557. X                }
  558. X                break;
  559. X            default:
  560. X                line2[j] = line[i];
  561. X            }
  562. X        i++;
  563. X        j++;
  564. X        line2[j] = NULL;
  565. X        }
  566. X
  567. X    i = 1;
  568. X
  569. X    switch(line[0]) {        /* control character */
  570. X       case '?': {            /* interactive help entry */
  571. X                if( intable ) intablebut = TRUE ;
  572. X               break;
  573. X       }
  574. X       case '@': {            /* start/end table */
  575. X                  intable = !intable ;  
  576. X                  if( intable ) {
  577. X                    tablelines = 0;
  578. X                    tablecols = 0 ;
  579. X                    tableins = &table ;
  580. X                    for(j=0;j<3;j++)tablewidth[j]=0 ;
  581. X                    }
  582. X                  else { /* dump table */
  583. X                    intablebut = FALSE ;
  584. X                    tableins = table.next ;
  585. X                    fprintf(b,":table cols=\'") ;
  586. X                    for( j=0;j<3;j++)
  587. X                        if(tablewidth[j]>0) fprintf(b," %d",tablewidth[j]);
  588. X                    fprintf(b,"\'.\n") ;
  589. X                    tableins=tableins->next ;     
  590. X                    while( tableins != NULL ) {
  591. X                        if( tableins->col[0][0] != '_' ) {
  592. X                            fprintf(b,":row.\n" ) ;
  593. X                            for( j=0;j<tablecols;j++) 
  594. X                                fprintf(b,":c.%s\n", tableins->col[j] ) ;
  595. X                            }
  596. X                        tableins = tableins->next ;
  597. X                        }
  598. X                    fprintf(b,":etable.\n") ;
  599. X                    if( bt != NULL ) {
  600. X                        rewind( bt ) ;
  601. X                        while( fgets(str, MAX_LINE_LEN, bt) )
  602. X                            fputs( str, b ) ; 
  603. X                        fclose( bt ) ;
  604. X                        remove( "doc2ipf.tmp" ) ;
  605. X                        bt = NULL ;
  606. X                        bo = b ;
  607. X                        }
  608. X                    }
  609. X          break;            /* ignore */
  610. X       }
  611. X       case '#': {            /* latex table entry */
  612. X          break;            /* ignore */
  613. X       }
  614. X       case '%': {            /* troff table entry */
  615. X              if( intable ) {
  616. X                    tablerow = line2 ;
  617. X                    tableins->next = malloc( sizeof( struct TABENTRY ) ) ;
  618. X                    tableins = tableins->next ;
  619. X                    tableins->next = NULL ;
  620. X                    j=0 ;
  621. X                while((pt=strtok( tablerow, "%@\n" ))!=NULL) {
  622. X                    if( *pt != '\0' ) { /* ignore null columns */
  623. X                        strcpy( tableins->col[j], pt ) ;
  624. X                        k=strlen( pt ) ;
  625. X                        if( k > tablewidth[j] ) tablewidth[j]=k ;
  626. X                        ++j ;
  627. X                        tablerow = NULL ;
  628. X                        if( j > tablecols ) tablecols = j ;
  629. X                        }
  630. X                    }
  631. X                for( j; j<3; j++ ) tableins->col[j][0]='\0' ;        
  632. X                }
  633. X          break;            /* ignore */
  634. X       }
  635. X       case '\n':            /* empty text line */
  636. X            para = 0;
  637. X            tabl = 0;
  638. X            fprintf(bo,":p.");
  639. X            break;
  640. X       case ' ': {            /* normal text line */
  641. X                  if( intable && ! intablebut ) break ;
  642. X                  if( intablebut ) { /* indexed items in  table, copy
  643. X                                      to file after table by saving in
  644. X                                      a temp file meantime */
  645. X                                if( bt == NULL ) {
  646. X                                    fflush(bo) ;
  647. X                                    bt = fopen( "doc2ipf.tmp", "w+" ) ;
  648. X                                    if( bt==NULL ) fprintf(stderr, "cant open temp\n" ) ;
  649. X                                    else bo = bt ; 
  650. X                                    }
  651. X                        }
  652. X                  if( intablebut && (bt==NULL )) break ;
  653. X          if ((line2[1] == NULL) || (line2[1] == '\n'))
  654. X          {
  655. X                fprintf(bo,":p."); 
  656. X                para = 0;
  657. X                }
  658. X          if (line2[1] == ' ') 
  659. X          {
  660. X                if (!tabl)
  661. X                {
  662. X                    fprintf(bo,":p."); 
  663. X                    }
  664. X                  fprintf(bo,"%s",&line2[1]); 
  665. X                fprintf(bo,"\n.br\n");
  666. X                tabl = 1;
  667. X                para = 0;
  668. X                }
  669. X          else
  670. X          {
  671. X                if (!para)
  672. X                {
  673. X                    para = 1;        /* not in para so start one */
  674. X                    tabl = 0;
  675. X                    }
  676. X                  fprintf(bo,"%s \n",&line2[1]); 
  677. X                }
  678. X                  fflush(bo) ;
  679. X          break;
  680. X       }
  681. X       default: {
  682. X          if (isdigit(line[0])) { /* start of section */
  683. X                  if( intable ) {
  684. X                      intablebut = TRUE ;
  685. X                                if( bt == NULL ) {
  686. X                                    fflush(bo) ;
  687. X                                    bt = fopen( "doc2ipf.tmp", "w+" ) ;
  688. X                                    if( bt==NULL ) fprintf(stderr, "cant open temp\n" ) ;
  689. X                                    else bo = bt ; 
  690. X                                    }
  691. X                                }
  692. X            if (!startpage)
  693. X            {
  694. X                refs(last_line,bo);
  695. X                }
  696. X            para = 0;                    /* not in a paragraph */
  697. X            tabl = 0;
  698. X            last_line = line_count;
  699. X            startpage = 0;
  700. Xfprintf( stderr, "%d: %s\n", line_count, &line2[1] ) ;
  701. X            k=lookup(&line2[2]) ;
  702. X/*            if( k<0 ) fprintf(bo,":h%c.", line[0]=='1'?line[0]:line[0]-1);
  703. X            else*/ fprintf(bo,":h%c res=%d.", line[0]=='1'?line[0]:line[0]-1,line_count);
  704. X            fprintf(bo,&(line2[1])); /* title */
  705. X            fprintf(bo,"\n:p." ) ;
  706. X          } else
  707. X            fprintf(stderr, "unknown control code '%c' in column 1, line %d\n",
  708. X                line[0], line_count);
  709. X          break;
  710. X       }
  711. X    }
  712. X}
  713. X
  714. END_OF_FILE
  715.   if test 15131 -ne `wc -c <'gnuplot/docs/doc2ipf.c'`; then
  716.     echo shar: \"'gnuplot/docs/doc2ipf.c'\" unpacked with wrong size!
  717.   fi
  718.   # end of 'gnuplot/docs/doc2ipf.c'
  719. fi
  720. if test -f 'gnuplot/os2/dialogs.c' -a "${1}" != "-c" ; then 
  721.   echo shar: Will not clobber existing file \"'gnuplot/os2/dialogs.c'\"
  722. else
  723.   echo shar: Extracting \"'gnuplot/os2/dialogs.c'\" \(13594 characters\)
  724.   sed "s/^X//" >'gnuplot/os2/dialogs.c' <<'END_OF_FILE'
  725. X#ifdef INCRCSDATA
  726. Xstatic char RCSid[]="$Id: dialogs.c%v 3.50 1993/07/09 05:35:24 woo Exp $" ;
  727. X#endif
  728. X
  729. X/****************************************************************************
  730. X
  731. X    PROGRAM: gnupmdrv
  732. X    
  733. X        Outboard PM driver for GNUPLOT 3.3
  734. X
  735. X    MODULE:  dialogs.c  Dialog procedures for gnupmdrv 
  736. X        
  737. X****************************************************************************/
  738. X
  739. X/*
  740. X * PM driver for GNUPLOT
  741. X * Copyright (C) 1992   Roger Fearick
  742. X *
  743. X * Permission to use, copy, and distribute this software and its
  744. X * documentation for any purpose with or without fee is hereby granted, 
  745. X * provided that the above copyright notice appear in all copies and 
  746. X * that both that copyright notice and this permission notice appear 
  747. X * in supporting documentation.
  748. X *
  749. X * Permission to modify the software is granted, but not the right to
  750. X * distribute the modified code.  Modifications are to be distributed 
  751. X * as patches to released version.
  752. X *  
  753. X * This software is provided "as is" without express or implied warranty.
  754. X * 
  755. X *
  756. X * AUTHOR
  757. X * 
  758. X *   Gnuplot driver for OS/2:  Roger Fearick
  759. X * 
  760. X * Send your comments or suggestions to 
  761. X *  info-gnuplot@dartmouth.edu.
  762. X * This is a mailing list; to join it send a note to 
  763. X *  info-gnuplot-request@dartmouth.edu.  
  764. X * Send bug reports to
  765. X *  bug-gnuplot@dartmouth.edu.
  766. X**/
  767. X
  768. X#define INCL_PM
  769. X#define INCL_WIN
  770. X#define INCL_DEV
  771. X#define INCL_SPL
  772. X#define INCL_SPLDOSPRINT
  773. X#define INCL_WINDIALOGS
  774. X#define INCL_WINBUTTONS
  775. X#define INCL_WINSYS
  776. X#define INCL_WINFRAMEMGR
  777. X#define INCL_WINPOINTERS
  778. X#define INCL_WINTRACKRECT
  779. X#define INCL_WINENTRYFIELDS
  780. X#define INCL_WINWINDOWMGR
  781. X#include <os2.h>
  782. X#include <math.h>
  783. X#include <stdio.h>
  784. X#include <stdlib.h>
  785. X#include <string.h>
  786. X#include "gnupmdrv.h"
  787. X
  788. X/* struct for printer capabilities */
  789. X
  790. Xstatic struct { 
  791. X    long    lTech ;     // printer technology
  792. X    long    lVer ;      // driver version
  793. X    long    lWidth ;    // page width in pels
  794. X    long    lHeight ;   // page height in pels
  795. X    long    lWChars ;   // page width in chars    
  796. X    long    lHChars ;   // page height in chars    
  797. X    long    lHorRes ;   // horizontal resolution pels / metre
  798. X    long    lVertRes ;  // vertical resolution pels / metre
  799. X    } prCaps ;
  800. X
  801. XMRESULT EXPENTRY QPrintDlgProc ( HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2 )
  802. X/*
  803. X**  Query print area and printer setup
  804. X*/
  805. X    {
  806. X    static PQPRINT pqp = NULL ;
  807. X    static SWP     swp ;    
  808. X    TRACKINFO   ti ;
  809. X    RECTL       rectlBox ;
  810. X    HDC         hdc ;
  811. X    ULONG       ulStyle ;
  812. X    char        *psz ;
  813. X
  814. X    switch ( usMsg ) {
  815. X
  816. X        case WM_INITDLG :
  817. X                                   
  818. X            pqp = (PQPRINT) PVOIDFROMMP( mp2 ) ;
  819. X            if( pqp->caps & QP_CAPS_FILE ) {
  820. X                ulStyle = WinQueryWindowULong( WinWindowFromID( hwnd, IDD_PRINTQNAME ),
  821. X                                               QWL_STYLE ) ;
  822. X                WinSetWindowULong( WinWindowFromID( hwnd, IDD_PRINTQNAME ),
  823. X                                   QWL_STYLE, ulStyle ^ DT_HALFTONE  ) ;
  824. X                }
  825. X            else {
  826. X                WinSendMsg( WinWindowFromID( hwnd, IDD_QPRNAME ),
  827. X                            EM_SETREADONLY, (MPARAM)TRUE, 0L ) ;
  828. X                }
  829. X             
  830. X        case WM_USER_SET_DATA :
  831. X
  832. X            psz = *pqp->piPrinter->pszComment ? pqp->piPrinter->pszComment :
  833. X                                        pqp->piPrinter->pszName ;
  834. X            WinSetDlgItemText( hwnd, IDD_PRINTNAME, psz ) ;
  835. X            WinSetDlgItemFloatF( hwnd, IDD_QPRXSIZE, 1, pqp->xsize ) ;
  836. X            WinSetDlgItemFloatF( hwnd, IDD_QPRYSIZE, 1, pqp->ysize ) ;
  837. X            WinSetDlgItemFloat( hwnd, IDD_QPRXFRAC, pqp->xfrac ) ;
  838. X            WinSetDlgItemFloat( hwnd, IDD_QPRYFRAC, pqp->yfrac ) ;
  839. X            WinQueryWindowRect( WinWindowFromID( hwnd, IDD_QPRBOX ),
  840. X                                &rectlBox ) ;
  841. X            WinQueryWindowPos( WinWindowFromID( hwnd, IDD_QPRBOX ),
  842. X                               &swp ) ;
  843. X            rectlBox.xRight = rectlBox.yTop * pqp->xsize/pqp->ysize ;
  844. X            WinSetWindowPos( WinWindowFromID( hwnd, IDD_QPRBOX ),
  845. X                             NULLHANDLE, 0, 0, (short) rectlBox.xRight, (short)rectlBox.yTop, SWP_SIZE ) ;
  846. X            rectlBox.xRight *= pqp->xfrac ;
  847. X            rectlBox.yTop *= pqp->yfrac ;
  848. X            WinSetWindowPos( WinWindowFromID( hwnd, IDD_QPRFRAME ),
  849. X                             NULLHANDLE, 
  850. X                             swp.x, swp.y, //+(short)(swp.cy*(1.0-pqp->yfrac)),
  851. X                             (short)rectlBox.xRight, (short)rectlBox.yTop, SWP_SIZE|SWP_MOVE ) ;
  852. X            break ;
  853. X            
  854. X        case WM_COMMAND :
  855. X
  856. X            switch ( SHORT1FROMMP(mp1) ) {
  857. X
  858. X                case DID_OK:
  859. X                    WinQueryDlgItemFloat( hwnd, IDD_QPRXFRAC, &pqp->xfrac ) ;
  860. X                    WinQueryDlgItemFloat( hwnd, IDD_QPRYFRAC, &pqp->yfrac ) ;
  861. X
  862. X                    if( pqp->caps & QP_CAPS_FILE ) {
  863. X                        WinQueryDlgItemText( hwnd, IDD_QPRNAME, 32, pqp->szFilename ) ;
  864. X                        }
  865. X                    break ;
  866. X
  867. X                case IDD_QPRSETPR:   /* printer setup */
  868. X                    if( SetPrinterMode( hwnd, pqp->piPrinter ) == 1 ) {
  869. X                        if( (hdc = OpenPrinterDC( WinQueryAnchorBlock( hwnd ), 
  870. X                                                  pqp->piPrinter, 
  871. X                                                  OD_INFO, 
  872. X                                                  NULL )) != DEV_ERROR ) {
  873. X                            DevQueryCaps( hdc, CAPS_TECHNOLOGY, (long)sizeof(prCaps)/sizeof(long), (PLONG)&prCaps ) ;
  874. X                            DevCloseDC( hdc ) ;
  875. X                            pqp->xsize = (float)100.0* (float) prCaps.lWidth / (float) prCaps.lHorRes ; // in cm
  876. X                            pqp->ysize = (float)100.0* (float) prCaps.lHeight / (float) prCaps.lVertRes ; // in cm
  877. X                            WinSendMsg( hwnd, WM_USER_SET_DATA, 0L, 0L ) ;
  878. X                            }
  879. X                        }
  880. X                    return 0L ;
  881. X
  882. X                case IDD_QPRTRACK :     /* track plot area */
  883. X                    WinQueryWindowRect( WinWindowFromID( hwnd, IDD_QPRBOX ),
  884. X                                        &rectlBox ) ;
  885. X                    ti.cxBorder = ti.cyBorder = 2 ;
  886. X                    ti.cxGrid = ti.cyGrid = 0 ;
  887. X                    ti.cxKeyboard = ti.cyKeyboard = 2 ;
  888. X                    ti.ptlMinTrackSize.x = ti.ptlMinTrackSize.y = 2 ;
  889. X                    ti.rclBoundary = rectlBox ;
  890. X                    ti.ptlMaxTrackSize.x = rectlBox.xRight ;
  891. X                    ti.ptlMaxTrackSize.y = rectlBox.yTop ;
  892. X                    ti.rclTrack.xRight = pqp->xfrac * rectlBox.xRight ;
  893. X                    ti.rclTrack.yTop = pqp->yfrac*rectlBox.yTop ;
  894. X                    ti.rclTrack.xLeft = 0 ;
  895. X                    ti.rclTrack.yBottom = 0 ;//(1.0-pqp->yfrac) * rectlBox.yTop ;
  896. X                    ti.fs = TF_RIGHT|TF_TOP|TF_STANDARD|TF_SETPOINTERPOS|TF_ALLINBOUNDARY ;
  897. X                    WinSetPointer( HWND_DESKTOP, 
  898. X                                   WinQuerySysPointer( HWND_DESKTOP, SPTR_SIZENWSE, FALSE ) ) ;
  899. X                    WinTrackRect( WinWindowFromID( hwnd, IDD_QPRBOX ),
  900. X                                  NULL, 
  901. X                                  &ti ) ;
  902. X                    pqp->xfrac = (float)ti.rclTrack.xRight / (float)rectlBox.xRight ;
  903. X                    pqp->yfrac = ((float)(ti.rclTrack.yTop-ti.rclTrack.yBottom) / (float)rectlBox.yTop) ;
  904. X                    rectlBox.yTop = ti.rclTrack.yTop - ti.rclTrack.yBottom ;
  905. X                    rectlBox.xRight = ti.rclTrack.xRight ;
  906. X                    WinSetWindowPos( WinWindowFromID( hwnd, IDD_QPRFRAME ),
  907. X                                     NULLHANDLE, 
  908. X                                     swp.x, swp.y,//+(short)(swp.cy*(1.0-pqp->yfrac)),
  909. X                                     (short)rectlBox.xRight, (short)rectlBox.yTop, SWP_SIZE|SWP_MOVE ) ;
  910. X                    WinSetDlgItemFloat( hwnd, IDD_QPRXFRAC, pqp->xfrac ) ;
  911. X                    WinSetDlgItemFloat( hwnd, IDD_QPRYFRAC, pqp->yfrac ) ;
  912. X                    return 0L ;
  913. X                    
  914. X                default:
  915. X                    break ;
  916. X                }
  917. X                
  918. X         default:
  919. X            break ;
  920. X            }
  921. X        /* fall through to the default control processing */
  922. X
  923. X    return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
  924. X    }
  925. X
  926. XMRESULT EXPENTRY QPrintersDlgProc ( HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2 )
  927. X/*
  928. X**  Query printers and allow selection
  929. X*/
  930. X    {
  931. X    static HWND hwndLB ;
  932. X    static PPRQINFO3 pprq ;
  933. X    static int cPrinters ;
  934. X    static USHORT usItem ;
  935. X    static char *szPrinterName ;
  936. X    int i, iSelect ;
  937. X    char *psz ;
  938. X
  939. X    switch ( usMsg ) {
  940. X
  941. X        case WM_INITDLG :
  942. X
  943. X            szPrinterName = (char*) PVOIDFROMMP( mp2 ) ;
  944. X            iSelect = 0 ;
  945. X            GetPrinters( &pprq, &cPrinters ) ;
  946. X            hwndLB = WinWindowFromID( hwnd, IDD_QPRSLIST ) ;
  947. X            for( i=0; i<cPrinters;i++ ) {
  948. X                psz = *pprq[i].pszComment ? pprq[i].pszComment :
  949. X                                            pprq[i].pszName ;
  950. X                WinSendMsg( hwndLB,
  951. X                            LM_INSERTITEM,
  952. X                            (MPARAM)LIT_END,
  953. X                            MPFROMP(psz) ) ;
  954. X                if( strcmp( pprq[i].pszName, szPrinterName ) == 0 )
  955. X                    iSelect = i ;
  956. X                } 
  957. X                
  958. X            WinSendMsg( hwndLB,
  959. X                        LM_SELECTITEM,
  960. X                        MPFROMSHORT( iSelect ),
  961. X                        (MPARAM)TRUE ) ;
  962. X       
  963. X            break ;
  964. X
  965. X        case WM_COMMAND :
  966. X
  967. X            switch ( SHORT1FROMMP(mp1) ) {
  968. X
  969. X                case DID_OK:
  970. X                    strcpy( szPrinterName, pprq[usItem].pszName ) ;
  971. X                case DID_CANCEL:
  972. X                    free( pprq ) ;
  973. X                    break ;
  974. X                }
  975. X            break ;
  976. X
  977. X        case WM_CONTROL:
  978. X        
  979. X            if( SHORT1FROMMP( mp1 ) == IDD_QPRSLIST ) {
  980. X                if( SHORT2FROMMP( mp1 ) == LN_SELECT  ) {
  981. X                    usItem = (ULONG)WinSendMsg( hwndLB,
  982. X                                LM_QUERYSELECTION,
  983. X                                0L,
  984. X                                0L ) ;
  985. X                    }
  986. X                }
  987. X
  988. X        default:
  989. X            break ;
  990. X        }
  991. X        /* fall through to the default control processing */
  992. X    return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
  993. X    }
  994. X    
  995. Xint GetPrinters( PPRQINFO3 *pprq, int *pcTot  )
  996. X/*
  997. X** get a list of printers
  998. X*/
  999. X    {
  1000. X    ULONG rc ;
  1001. X    ULONG cQueues, cbData ;
  1002. X    
  1003. X    rc = SplEnumQueue( NULL, 3, NULL, 0, &cQueues, pcTot, &cbData, NULL ) ;
  1004. X   
  1005. X    if( *pcTot == 0 ) { /* no printers */
  1006. X        *pprq == NULL ;
  1007. X        return 0 ;
  1008. X        }
  1009. X    *pprq = malloc( cbData ) ;
  1010. X    rc = SplEnumQueue( NULL,
  1011. X                       3,
  1012. X                       *pprq,
  1013. X                       cbData,
  1014. X                       &cQueues,
  1015. X                       pcTot,
  1016. X                       &cbData,
  1017. X                       NULL ) ;
  1018. X    return *pcTot ;
  1019. X    }
  1020. X
  1021. XMRESULT EXPENTRY PauseMsgDlgProc ( HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2 )
  1022. X/*
  1023. X**  Pause message dialog box proc
  1024. X*/
  1025. X    {
  1026. X    static PSWP pswp = NULL ;
  1027. X    switch ( usMsg ) {
  1028. X
  1029. X        case WM_INITDLG :
  1030. X                /* set the position so user can move out the way, and
  1031. X                   have it come back there next time */
  1032. X            if( pswp != NULL ) 
  1033. X                WinSetWindowPos( hwnd, HWND_TOP, pswp->x, pswp->y,
  1034. X                                 0, 0, SWP_MOVE ) ; 
  1035. X            WinSetDlgItemText( hwnd, IDD_PAUSETEXT, (char*) PVOIDFROMMP( mp2 ) ) ;
  1036. X            break ;
  1037. X
  1038. X        case WM_COMMAND :
  1039. X            switch ( SHORT1FROMMP(mp1) ) {
  1040. X                case DID_OK:
  1041. X                case DID_CANCEL:
  1042. X                    WinPostMsg( WinQueryWindow( hwnd, QW_OWNER ),
  1043. X                                WM_PAUSEEND, 
  1044. X                                SHORT1FROMMP(mp1)==DID_OK?(MPARAM)1L:0L, 
  1045. X                                0L ) ;
  1046. X                    if( pswp == NULL ) pswp = (PSWP)malloc( sizeof(SWP) ) ;
  1047. X                    WinQueryWindowPos( hwnd, pswp ) ;
  1048. X                    WinDismissDlg( hwnd, 0 ) ; 
  1049. X                    break ;
  1050. X                default:
  1051. X                    break ;
  1052. X                }
  1053. X        default:
  1054. X            break ;
  1055. X        }
  1056. X        /* fall through to the default control processing */
  1057. X    return WinDefDlgProc ( hwnd , usMsg , mp1 , mp2 ) ;
  1058. X    }
  1059. X    
  1060. Xvoid WinSetDlgItemFloatF( HWND hwnd, USHORT usID, int nDec, float flValue )
  1061. X/*
  1062. X** A function microsoft forgot ( in v1.1) , see WinSet...Short
  1063. X*/
  1064. X    {
  1065. X    char achBuffer [ 34 ], *szCvt ; // default string field size ...
  1066. X    int  iDec ;
  1067. X    int  iSign ;
  1068. X    char fmt[32] ;
  1069. X    sprintf( fmt, "%%12.%df", nDec ) ;
  1070. X    sprintf( achBuffer, fmt, flValue ) ;
  1071. X    WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  1072. X    }
  1073. X
  1074. Xvoid WinSetDlgItemFloat( HWND hwnd, USHORT usID, float flValue )
  1075. X/*
  1076. X** A function microsoft forgot ( in v1.1) , see WinSet...Short
  1077. X*/
  1078. X    {
  1079. X    char achBuffer [ 34 ] ; // default string field size ...
  1080. X    char fmt[10] ;
  1081. X    sprintf( fmt, "%%12.%df", 4 ) ;
  1082. X    sprintf( achBuffer, fmt, flValue ) ;
  1083. X    WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  1084. X    WinSetDlgItemText( hwnd, usID, achBuffer ) ;
  1085. X    }
  1086. X
  1087. Xvoid WinQueryDlgItemFloat( HWND hwnd, USHORT usID, float *pflValue )
  1088. X/*
  1089. X** A function microsoft forgot ( in v1.1) , see WinQ...Short
  1090. X*/
  1091. X    {
  1092. X    char achBuffer [ 34 ] ; // default string field size ...
  1093. X    ULONG ulTemp ;
  1094. X    
  1095. X    WinQueryDlgItemText( hwnd, usID, 34, achBuffer ) ;
  1096. X    *pflValue = (float) atof( achBuffer ) ;
  1097. X    }
  1098. X
  1099. END_OF_FILE
  1100.   if test 13594 -ne `wc -c <'gnuplot/os2/dialogs.c'`; then
  1101.     echo shar: \"'gnuplot/os2/dialogs.c'\" unpacked with wrong size!
  1102.   fi
  1103.   # end of 'gnuplot/os2/dialogs.c'
  1104. fi
  1105. if test -f 'gnuplot/term/epson.trm' -a "${1}" != "-c" ; then 
  1106.   echo shar: Will not clobber existing file \"'gnuplot/term/epson.trm'\"
  1107. else
  1108.   echo shar: Extracting \"'gnuplot/term/epson.trm'\" \(15575 characters\)
  1109.   sed "s/^X//" >'gnuplot/term/epson.trm' <<'END_OF_FILE'
  1110. X/*
  1111. X * $Id: epson.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  1112. X *
  1113. X */
  1114. X
  1115. X/* GNUPLOT - epson.trm */
  1116. X/*
  1117. X * Copyright (C) 1990 - 1993   
  1118. X *
  1119. X * Permission to use, copy, and distribute this software and its
  1120. X * documentation for any purpose with or without fee is hereby granted, 
  1121. X * provided that the above copyright notice appear in all copies and 
  1122. X * that both that copyright notice and this permission notice appear 
  1123. X * in supporting documentation.
  1124. X *
  1125. X * Permission to modify the software is granted, but not the right to
  1126. X * distribute the modified code.  Modifications are to be distributed 
  1127. X * as patches to released version.
  1128. X *  
  1129. X * This software  is provided "as is" without express or implied warranty.
  1130. X * 
  1131. X * This file is included by ../term.c.
  1132. X *
  1133. X * This terminal driver supports:
  1134. X *  epson_lx800, nec_cp6, starc,
  1135. X *  epson_60dpi, tandy_60dpi
  1136. X *  epson_180dpi
  1137. X *
  1138. X * AUTHORS
  1139. X *  Russell Lang
  1140. X *  William Wilson
  1141. X *
  1142. X * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  1143. X * 
  1144. X */
  1145. X
  1146. X/* The following epson lx800 driver uses generic bit mapped graphics
  1147. X   routines to build up a bit map in memory. */
  1148. X/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  1149. X/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  1150. X/* EPSON_init changes outfile to binary mode on PC's */
  1151. X
  1152. X#ifdef EPSONP
  1153. X
  1154. X#define EPSONXMAX    512 
  1155. X#define EPSONYMAX    384
  1156. X
  1157. X#define EPSONXLAST (EPSONXMAX - 1)
  1158. X#define EPSONYLAST (EPSONYMAX - 1)
  1159. X
  1160. X#define EPSONVCHAR        FNT5X9_VCHAR      
  1161. X#define EPSONHCHAR        FNT5X9_HCHAR        
  1162. X#define EPSONVTIC        6
  1163. X#define EPSONHTIC        6
  1164. X
  1165. XEPSONinit()
  1166. X{
  1167. X#ifdef REOPEN_BINARY
  1168. X    reopen_binary();
  1169. X#endif
  1170. X}
  1171. X
  1172. X
  1173. XEPSONgraphics()
  1174. X{
  1175. X    b_charsize(FNT5X9);
  1176. X    b_makebitmap((unsigned int)(EPSONXMAX*xsize),
  1177. X                 (unsigned int)(EPSONYMAX*ysize),1);
  1178. X}
  1179. X
  1180. X
  1181. XEPSONtext()
  1182. X{
  1183. X    epson_dump();
  1184. X    b_freebitmap();
  1185. X}
  1186. X
  1187. X
  1188. X#define EPSONlinetype b_setlinetype
  1189. X#define EPSONmove b_move
  1190. X#define EPSONvector b_vector
  1191. X#define EPSONput_text b_put_text
  1192. X#define EPSON_text_angle b_text_angle
  1193. X
  1194. XEPSONreset()
  1195. X{
  1196. X#ifdef vms
  1197. X    fflush_binary();
  1198. X#endif
  1199. X}
  1200. X
  1201. X
  1202. X/* output file must be binary mode for epson_dump */
  1203. Xepson_dump()
  1204. X{
  1205. X  register unsigned int x;
  1206. X  int j;
  1207. X    for (j=(b_ysize/8)-1; j>=0; j--) {
  1208. X        /* select plotter graphics mode (square pixels) */
  1209. X        fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  1210. X        fprintf(outfile,"\r\033*\005");
  1211. X        (void) fputc((char)(b_xsize%256),outfile);
  1212. X        (void) fputc((char)(b_xsize/256),outfile);
  1213. X        for (x=0; x<b_xsize; x++) {
  1214. X            (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  1215. X        }
  1216. X    }
  1217. X#ifdef PC
  1218. X    fprintf(stderr,"Print using: COPY /B\n");
  1219. X#endif
  1220. X}
  1221. X
  1222. X#endif /* EPSONP */
  1223. X
  1224. X
  1225. X/* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics
  1226. X   routines to build up a bit map in memory. */
  1227. X/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  1228. X/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  1229. X/* NECinit changes outfile to binary mode for PC's */
  1230. X
  1231. X/* Add a Monochrome NEC printer (for faster speed and line types) jdc */
  1232. X
  1233. X#ifdef NEC
  1234. X
  1235. X#define NECXMAX    400 
  1236. X#define NECYMAX    320
  1237. X
  1238. X#define NECXLAST (NECXMAX - 1)
  1239. X#define NECYLAST (NECYMAX - 1)
  1240. X
  1241. X#define NECVCHAR        FNT5X9_VCHAR      
  1242. X#define NECHCHAR        FNT5X9_HCHAR        
  1243. X#define NECVTIC        6
  1244. X#define NECHTIC        6
  1245. X
  1246. X/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  1247. Xstatic unsigned int neccolor[] = {1,8,4,2,10,12,6,14};
  1248. Xstatic unsigned int necpcolor[]= {0,2,1,4};
  1249. X
  1250. Xstatic int NECmode;
  1251. X
  1252. XNECoptions()
  1253. X{
  1254. X    if( END_OF_COMMAND ) {
  1255. X        strcpy(term_options,"monochrome");
  1256. X        NECmode='m';
  1257. X    } else
  1258. X    if( almost_equals(c_token,"m$onochrome") ) {
  1259. X        c_token++;
  1260. X        strcpy(term_options,"monochrome");
  1261. X        NECmode='m';
  1262. X    } else
  1263. X    if( almost_equals(c_token,"c$olor") ) {
  1264. X        c_token++;
  1265. X        strcpy(term_options,"color");
  1266. X        NECmode='c';
  1267. X    } else
  1268. X    if( almost_equals(c_token,"d$raft") ) {
  1269. X        c_token++;
  1270. X        strcpy(term_options,"draft");
  1271. X        NECmode='d';
  1272. X    } else {
  1273. X    /* error, but since the terminal is already set, default to mono */
  1274. X        strcpy(term_options,"monochrome");
  1275. X        NECmode='m';
  1276. X        int_error("modes: color, monochrome, draft",c_token);
  1277. X    }
  1278. X}
  1279. X
  1280. XNECinit()
  1281. X{
  1282. X#ifdef REOPEN_BINARY
  1283. X    reopen_binary();
  1284. X#endif
  1285. X}
  1286. X
  1287. XNECgraphics()
  1288. X{
  1289. X    b_charsize(FNT5X9);
  1290. X    b_makebitmap((unsigned int)(NECXMAX*xsize),
  1291. X             (unsigned int)(NECYMAX*ysize),(NECmode=='c' ? 4 : 1));
  1292. X}
  1293. X
  1294. XNECtext()
  1295. X{
  1296. X    if( NECmode=='d' ) {
  1297. X        nec_draft_dump();
  1298. X    } else {
  1299. X    nec_dump();
  1300. X    }
  1301. X    b_freebitmap();
  1302. X}
  1303. X
  1304. XNEClinetype(linetype)
  1305. Xint linetype;
  1306. X{
  1307. X    if( NECmode=='c' ) {
  1308. X    if (linetype>=6)
  1309. X        linetype %= 6;
  1310. X    b_setvalue(neccolor[linetype+2]);
  1311. X    } else {
  1312. X        b_setlinetype(linetype);
  1313. X    }
  1314. X}
  1315. X
  1316. X#define NECmove b_move
  1317. X#define NECvector b_vector
  1318. X#define NECput_text b_put_text
  1319. X#define NEC_text_angle b_text_angle
  1320. X
  1321. X    
  1322. XNECreset()
  1323. X{
  1324. X#ifdef vms
  1325. X    fflush_binary();
  1326. X#endif
  1327. X}
  1328. X
  1329. X
  1330. X/* output file must be binary mode for nec_dump */
  1331. Xnec_dump()
  1332. X{
  1333. Xunsigned int x;
  1334. Xunsigned int plane,offset;
  1335. Xint j;
  1336. Xunsigned int column8;
  1337. Xunsigned long column24;
  1338. Xchar column3, column2, column1;
  1339. X    fprintf(outfile,"\033P\033l\005");  /* 10cpi, left margin 5 char */
  1340. X    for (j=(b_ysize/8)-1;j>=0;j--) {
  1341. X            fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  1342. X            for (plane=0; plane<b_planes; plane++) {
  1343. X                offset=plane*b_psize;
  1344. X                if (b_planes>1) {
  1345. X                    /* select colour for plane */
  1346. X                    fprintf(outfile,"\033r");
  1347. X                    (void) fputc((char)necpcolor[plane],outfile);
  1348. X                }
  1349. X                /* select plotter graphics mode (square pixels) */
  1350. X                fprintf(outfile,"\r\033*\047");
  1351. X                (void) fputc((char)((b_xsize*3)%256),outfile);
  1352. X                (void) fputc((char)((b_xsize*3)/256),outfile);
  1353. X                for (x=0; x<b_xsize; x++) {
  1354. X                    column8= (unsigned int)(*((*b_p)[j+offset]+x));
  1355. X                    column24=0;
  1356. X                    if (column8&0x01) column24|=(long)0x000007;
  1357. X                    if (column8&0x02) column24|=(long)0x000038;
  1358. X                    if (column8&0x04) column24|=(long)0x0001c0;
  1359. X                    if (column8&0x08) column24|=(long)0x000e00;
  1360. X                    if (column8&0x10) column24|=(long)0x007000;
  1361. X                    if (column8&0x20) column24|=(long)0x038000;
  1362. X                    if (column8&0x40) column24|=(long)0x1c0000;
  1363. X                    if (column8&0x80) column24|=(long)0xe00000;
  1364. X                    column1 = (char) ( column24      & (long)0xff);
  1365. X                    column2 = (char) ((column24>>8)  & (long)0xff);
  1366. X                    column3 = (char) ((column24>>16) & (long)0xff);
  1367. X                    (void) fputc(column3,outfile);
  1368. X                    (void) fputc(column2,outfile);
  1369. X                    (void) fputc(column1,outfile);
  1370. X                    (void) fputc(column3,outfile);
  1371. X                    (void) fputc(column2,outfile);
  1372. X                    (void) fputc(column1,outfile);
  1373. X                    (void) fputc(column3,outfile);
  1374. X                    (void) fputc(column2,outfile);
  1375. X                    (void) fputc(column1,outfile);
  1376. X                }
  1377. X            }
  1378. X    }
  1379. X    fprintf(outfile,"\r\033l");
  1380. X    (void) fputc('\0',outfile);                /* set left margin to 0 */
  1381. X    if (b_planes > 1) {
  1382. X        fprintf(outfile,"\033r");
  1383. X        (void) fputc('\0',outfile);                /* set color to black */
  1384. X    }
  1385. X#ifdef PC
  1386. X    fprintf(stderr,"Print using: COPY /B\n");
  1387. X#endif
  1388. X#ifdef vms
  1389. X    fflush_binary();
  1390. X#endif
  1391. X}
  1392. X
  1393. X/* output file must be binary mode for nec_dump */
  1394. Xnec_draft_dump()
  1395. X{
  1396. Xunsigned int x;
  1397. Xunsigned int plane,offset;
  1398. Xint j;
  1399. X    fprintf(outfile,"\033P\033l\005\r");  /* 10cpi, left margin 5 char */
  1400. X    for (j=(b_ysize/8)-1;j>=0;j--) {
  1401. X            fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  1402. X            for (plane=0; plane<b_planes; plane++) {
  1403. X                offset=plane*b_psize;
  1404. X                if (b_planes>1) {
  1405. X                    /* select colour for plane */
  1406. X                    fprintf(outfile,"\033r");
  1407. X                    (void) fputc((char)necpcolor[plane],outfile);
  1408. X                }
  1409. X                /* select plotter graphics mode (square pixels) */
  1410. X                fprintf(outfile,"\r\033*");
  1411. X                (void) fputc('\0',outfile);
  1412. X                (void) fputc((char)(b_xsize%256),outfile);
  1413. X                (void) fputc((char)(b_xsize/256),outfile);
  1414. X                for (x=0; x<b_xsize; x++) {
  1415. X                    (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  1416. X                }
  1417. X            }
  1418. X    }
  1419. X    fprintf(outfile,"\r\033l");
  1420. X    (void) fputc('\0',outfile);                /* set left margin to 0 */
  1421. X    if (b_planes > 1) {
  1422. X        fprintf(outfile,"\033r");
  1423. X        (void) fputc('\0',outfile);                /* set color to black */
  1424. X    }
  1425. X#ifdef PC
  1426. X    fprintf(stderr,"Print using: COPY /B\n");
  1427. X#endif
  1428. X}
  1429. X
  1430. X#endif /* NEC */
  1431. X
  1432. X#ifdef STARC
  1433. X/* The following Star color driver uses generic bit mapped graphics
  1434. X   routines to build up a bit map in memory. */
  1435. X/* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */
  1436. X/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  1437. X/* STARC_init changes outfile to binary mode on PC's */
  1438. X
  1439. X#define STARCXMAX    512 
  1440. X#define STARCYMAX    384
  1441. X
  1442. X#define STARCXLAST (STARCXMAX - 1)
  1443. X#define STARCYLAST (STARCYMAX - 1)
  1444. X
  1445. X#define STARCVCHAR        FNT5X9_VCHAR      
  1446. X#define STARCHCHAR        FNT5X9_HCHAR        
  1447. X#define STARCVTIC        6
  1448. X#define STARCHTIC        6
  1449. X
  1450. X/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  1451. Xstatic unsigned int STARCcolor[] = {1,8,4,2,10,12,6,14};
  1452. Xstatic unsigned int STARCpcolor[]= {0,2,1,4};
  1453. X
  1454. XSTARCinit()
  1455. X{
  1456. X#ifdef REOPEN_BINARY
  1457. X    reopen_binary();
  1458. X#endif
  1459. X}
  1460. X
  1461. X
  1462. XSTARCgraphics()
  1463. X{
  1464. X    b_charsize(FNT5X9);
  1465. X    b_makebitmap((unsigned int)(STARCXMAX*xsize),
  1466. X                 (unsigned int)(STARCYMAX*ysize),4);
  1467. X}
  1468. X
  1469. X
  1470. XSTARCtext()
  1471. X{
  1472. X    STARC_dump();
  1473. X    b_freebitmap();
  1474. X}
  1475. X
  1476. XSTARClinetype(linetype)
  1477. Xint linetype;
  1478. X{
  1479. X    if (linetype>=6)
  1480. X        linetype %= 6;
  1481. X    b_setvalue(STARCcolor[linetype+2]);
  1482. X}
  1483. X
  1484. X
  1485. X#define STARCmove b_move
  1486. X#define STARCvector b_vector
  1487. X#define STARCput_text b_put_text
  1488. X#define STARC_text_angle b_text_angle
  1489. X
  1490. XSTARCreset()
  1491. X{
  1492. X#ifdef vms
  1493. X    fflush_binary();
  1494. X#endif
  1495. X}
  1496. X
  1497. X
  1498. X/* output file must be binary mode for STARC_dump */
  1499. XSTARC_dump()
  1500. X{
  1501. Xunsigned int x;
  1502. Xunsigned int plane,offset;
  1503. Xint j;
  1504. X    for (j=(b_ysize/8)-1;j>=0;j--) {
  1505. X        fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  1506. X        for (plane=0; plane<b_planes; plane++) {
  1507. X            offset=plane*b_psize;
  1508. X            if (b_planes>1) {
  1509. X                /* select colour for plane */
  1510. X                fprintf(outfile,"\033r");
  1511. X                (void) fputc((char)STARCpcolor[plane],outfile);
  1512. X            }
  1513. X            /* select plotter graphics mode (square pixels) */
  1514. X            fprintf(outfile,"\r\033*\005");
  1515. X            (void) fputc((char)(b_xsize%256),outfile);
  1516. X            (void) fputc((char)(b_xsize/256),outfile);
  1517. X            for (x=0; x<b_xsize; x++) {
  1518. X                (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  1519. X            }
  1520. X        }
  1521. X    }
  1522. X    if (b_planes > 1) {
  1523. X        fprintf(outfile,"\033r");
  1524. X        (void) fputc('\0',outfile);                /* set color to black */
  1525. X    }
  1526. X#ifdef PC
  1527. X    fprintf(stderr,"Print using: COPY /B\n");
  1528. X#endif
  1529. X}
  1530. X
  1531. X#endif /* STARC */
  1532. X
  1533. X
  1534. X#ifdef EPS180
  1535. X
  1536. X#define EPSON180VCHAR        FNT13X25_VCHAR
  1537. X#define EPSON180HCHAR        FNT13X25_HCHAR
  1538. X#define EPSON180VTIC        18
  1539. X#define EPSON180HTIC        18
  1540. X
  1541. X/* make the total dimensions 8 inches by 6 inches */
  1542. X#define EPS180XMAX    1260
  1543. X#define EPS180YMAX    1080
  1544. X
  1545. X#define EPS180XLAST (EPS180XMAX - 1)
  1546. X#define EPS180YLAST (EPS180YMAX - 1)
  1547. X
  1548. XEPS180graphics()
  1549. X{
  1550. X    b_charsize(FNT13X25);
  1551. X    b_makebitmap((unsigned int)(EPS180XMAX*xsize),
  1552. X                 (unsigned int)(EPS180YMAX*ysize),1);
  1553. X}
  1554. X
  1555. X
  1556. XEPS180text()
  1557. X{
  1558. X    eps180_dump();
  1559. X    b_freebitmap();
  1560. X}
  1561. X
  1562. X
  1563. X
  1564. X/* output file must be binary mode for eps180_dump */
  1565. Xeps180_dump()
  1566. X{
  1567. X  register unsigned int x;
  1568. X  int j;
  1569. X    fprintf(outfile,"\033@\033+\060\033l\005"); /* reset, set line spacing
  1570. X                               to 24/180", and
  1571. X                               move left margin */
  1572. X    for (j=(b_ysize/8)-1; j>=0; ) {
  1573. X        /* select printer graphics mode '39' */
  1574. X        fprintf(outfile,"\r\n\033*'");
  1575. X        (void) fputc((char)(b_xsize%256),outfile);
  1576. X        (void) fputc((char)(b_xsize/256),outfile);
  1577. X        for (x=0; x<b_xsize; x++) {
  1578. X                   (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  1579. X                 (void) fputc( (char)(*((*b_p)[j-1]+x)), outfile );
  1580. X               (void) fputc( (char)(*((*b_p)[j-2]+x)), outfile );
  1581. X        }
  1582. X    j -= 3;
  1583. X    }
  1584. X    fprintf(outfile,"\r\n\033@\r\n");     /* reset printer */
  1585. X#ifdef PC
  1586. X    fprintf(stderr,"Print using: COPY /B\n");
  1587. X#endif
  1588. X}
  1589. X
  1590. X#endif /* EPS180 */
  1591. X
  1592. X#ifdef EPS60
  1593. X
  1594. X/* make the total dimensions 8 inches by 5 inches */
  1595. X#define EPS60XMAX    480
  1596. X#define EPS60YMAX    360
  1597. X
  1598. X#define EPS60XLAST (EPS60XMAX - 1)
  1599. X#define EPS60YLAST (EPS60YMAX - 1)
  1600. X
  1601. XEPS60graphics()
  1602. X{
  1603. X    b_charsize(FNT5X9);
  1604. X    b_makebitmap((unsigned int)(EPS60XMAX*xsize),
  1605. X                 (unsigned int)(EPS60YMAX*ysize),1);
  1606. X}
  1607. X
  1608. X
  1609. XEPS60text()
  1610. X{
  1611. X    eps60_dump();
  1612. X    b_freebitmap();
  1613. X}
  1614. X
  1615. X
  1616. X
  1617. X/* output file must be binary mode for eps60_dump */
  1618. Xeps60_dump()
  1619. X{
  1620. X  register unsigned int x;
  1621. X  int j;
  1622. X    fprintf(outfile,"\033%c\030",'3'); /* set line spacing 24/216" = 8 dots */
  1623. X    for (j=(b_ysize/8)-1; j>=0; j--) {
  1624. X        /* select printer graphics mode 'K' */
  1625. X        fprintf(outfile,"\r\n\033K");
  1626. X        (void) fputc((char)(b_xsize%256),outfile);
  1627. X        (void) fputc((char)(b_xsize/256),outfile);
  1628. X        for (x=0; x<b_xsize; x++) {
  1629. X            (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  1630. X        }
  1631. X    }
  1632. X    fprintf(outfile,"\033%c\044\r\n",'3'); /* set line spacing 36/216" = 1/6" */
  1633. X#ifdef PC
  1634. X    fprintf(stderr,"Print using: COPY /B\n");
  1635. X#endif
  1636. X}
  1637. X
  1638. X#endif /* EPS60 */
  1639. X
  1640. X#ifdef TANDY60
  1641. X
  1642. X/* The only difference between TANDY60 and EPS60 is the inclusion
  1643. X   of codes to swap the Tandy printer into IBM mode and back
  1644. X   into Tandy mode.  For a Tandy already in IBM mode, use EPS60. */
  1645. X
  1646. X
  1647. XTANDY60text()
  1648. X{
  1649. X#ifdef PC
  1650. X    fprintf(stderr, "Inserting Tandy/IBM mode conversion codes\n");
  1651. X#endif
  1652. X    /* Switch to IBM mode, and leave 3 inches above the plot so as
  1653. X       to get rough vertical centring on the page.  Perform the
  1654. X       centring by setting 1" line feeds and issuing 3 of them. */
  1655. X    fprintf(outfile, "\033!\033%c%c\n\n\n", '3',216);
  1656. X    eps60_dump();
  1657. X    b_freebitmap();
  1658. X    /* A form feed must be sent before switching back to Tandy mode,
  1659. X       or else the form setting will be messed up. */
  1660. X    fprintf(outfile, "\f\033!");
  1661. X}
  1662. X
  1663. X
  1664. X#endif  /* TANDY60 */
  1665. X
  1666. X#ifdef OKIDATA
  1667. X
  1668. XOKIDATAtext()
  1669. X{
  1670. X    okidata_dump();
  1671. X    b_freebitmap();
  1672. X}
  1673. X
  1674. Xint bitrev_tbl[] = {
  1675. X0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 
  1676. X0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 
  1677. X0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 
  1678. X0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 
  1679. X0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 
  1680. X0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 
  1681. X0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 
  1682. X0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 
  1683. X0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 
  1684. X0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 
  1685. X0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 
  1686. X0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 
  1687. X0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 
  1688. X0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 
  1689. X0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 
  1690. X0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 
  1691. X0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 
  1692. X0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 
  1693. X0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 
  1694. X0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 
  1695. X0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 
  1696. X0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 
  1697. X0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 
  1698. X0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 
  1699. X0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 
  1700. X0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 
  1701. X0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 
  1702. X0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 
  1703. X0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 
  1704. X0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 
  1705. X0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 
  1706. X0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
  1707. X};
  1708. X
  1709. X/* output file must be binary mode for okidata_dump */
  1710. Xokidata_dump()
  1711. X{
  1712. X  register unsigned int x;
  1713. X  int j;
  1714. X  char cur_char;
  1715. X  int  prev_char;
  1716. X
  1717. X  prev_char = 0;
  1718. X    fprintf(outfile,"\033%c%c\020\033*eP:\003",'%','9'); /* set line spacing 16/144" = 8 dots :Turned on single density graphics mode*/
  1719. X    for (j=(b_ysize/8)-1; j>=0; j--) {
  1720. X        fprintf(outfile,"\003\016");
  1721. X/*        (void) fputc((char)(b_xsize%256),outfile); */
  1722. X/*        (void) fputc((char)(b_xsize/256),outfile); */
  1723. X        for (x=0; x<b_xsize; x++) {
  1724. X          if ( (cur_char = (char) 
  1725. X            (bitrev_tbl[ (int) (*((*b_p)[j]+x))])) == '\003') {
  1726. X            fprintf( outfile, "\003\003");
  1727. X          }
  1728. X          else {
  1729. X              (void) fputc( (char) cur_char , outfile);
  1730. X            }
  1731. X        }
  1732. X          }
  1733. X    fprintf(outfile,"\003\002\033%c%c\030\r\n",'%','9'); /* Turned off graphics mode: set line spacing 24/144" = 1/6"*/
  1734. X#ifdef PC
  1735. X    fprintf(stderr,"Print using: COPY /B\n");
  1736. X#endif
  1737. X}
  1738. X
  1739. X#endif /* OKIDATA */
  1740. X
  1741. END_OF_FILE
  1742.   if test 15575 -ne `wc -c <'gnuplot/term/epson.trm'`; then
  1743.     echo shar: \"'gnuplot/term/epson.trm'\" unpacked with wrong size!
  1744.   fi
  1745.   # end of 'gnuplot/term/epson.trm'
  1746. fi
  1747. if test -f 'gnuplot/term/hpgl.trm' -a "${1}" != "-c" ; then 
  1748.   echo shar: Will not clobber existing file \"'gnuplot/term/hpgl.trm'\"
  1749. else
  1750.   echo shar: Extracting \"'gnuplot/term/hpgl.trm'\" \(14106 characters\)
  1751.   sed "s/^X//" >'gnuplot/term/hpgl.trm' <<'END_OF_FILE'
  1752. X/*
  1753. X * $Id: hpgl.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  1754. X */
  1755. X
  1756. X/* GNUPLOT - hpgl.trm */
  1757. X/*
  1758. X * Copyright (C) 1990   
  1759. X *
  1760. X * Permission to use, copy, and distribute this software and its
  1761. X * documentation for any purpose with or without fee is hereby granted, 
  1762. X * provided that the above copyright notice appear in all copies and 
  1763. X * that both that copyright notice and this permission notice appear 
  1764. X * in supporting documentation.
  1765. X *
  1766. X * Permission to modify the software is granted, but not the right to
  1767. X * distribute the modified code.  Modifications are to be distributed 
  1768. X * as patches to released version.
  1769. X *  
  1770. X * This software  is provided "as is" without express or implied warranty.
  1771. X * 
  1772. X * This file is included by ../term.c.
  1773. X *
  1774. X * This terminal driver supports:
  1775. X *  hpgl, hp7580b, HP Laserjet III
  1776. X *
  1777. X * AUTHORS
  1778. X *  Colin Kelley, Thomas Williams, Russell Lang
  1779. X * 
  1780. X * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  1781. X * 
  1782. X */
  1783. X
  1784. X/*
  1785. X *
  1786. X * MODIFIED for expanded HPGL/2 and PCL utilites
  1787. X *  Tom Swiler (tom@silica.mse.ufl.edu)
  1788. X * 
  1789. X */
  1790. X
  1791. X/*
  1792. X * The maximum plot size, in plotter units:
  1793. X */
  1794. X
  1795. X#define HPGL_PUPI    1016    /* Plotter units per inch */
  1796. X  
  1797. X#define HPGL_XMAX_A    10000
  1798. X#define HPGL_YMAX_A    7500
  1799. X  
  1800. X#define HPGL_XMAX_B    15200
  1801. X#define HPGL_YMAX_B    10000
  1802. X
  1803. X#define HPGL_XMAX    HPGL_XMAX_A
  1804. X#define HPGL_YMAX    HPGL_YMAX_A
  1805. X  
  1806. X#define PCL_XMAX    HPGL_XMAX_A
  1807. X#define PCL_YMAX    HPGL_YMAX_A-60
  1808. X
  1809. X/*
  1810. X * Tic sizes
  1811. X */
  1812. X
  1813. X#define HPGL_VTIC    (HPGL_YMAX/70)
  1814. X#define HPGL_HTIC    (HPGL_YMAX/70)
  1815. X
  1816. X#define PCL_VTIC    (PCL_YMAX/70)
  1817. X#define PCL_HTIC    (PCL_YMAX/70)
  1818. X
  1819. X/*
  1820. X * Font size for HPGL
  1821. X */
  1822. X
  1823. X#define HPGL_VCHAR    (HPGL_YMAX/100*32/10) /* 3.2% */
  1824. X#define HPGL_HCHAR    (HPGL_XMAX/100*12/10) /* 1.2% */
  1825. X
  1826. X/*
  1827. X * Font size for HPGL/2
  1828. X */
  1829. X
  1830. X#define HPGL2_DEF_POINT    14    /* Height of font */
  1831. X
  1832. X#define HPGL2_DEF_PITCH    (3 * 72 / (HPGL2_DEF_POINT * 2))
  1833. X#define HPGL2_VCHAR    ((int) HPGL_PUPI * HPGL2_DEF_POINT / 72)
  1834. X#define HPGL2_HCHAR    (HPGL2_VCHAR * 2 / 3)
  1835. X
  1836. X/*
  1837. X * Control constants
  1838. X */
  1839. X
  1840. X#define DOWN        0    /* Pen is down */
  1841. X#define UP         1    /* Pen is up */
  1842. X#define UNKNOWN        -10    /* Unknown status for lots of things */
  1843. X
  1844. X/*
  1845. X * For Polyline Encoded, either use base 64 or base 32.
  1846. X * Save space with base 64, but get 8-bit characters.
  1847. X */
  1848. X
  1849. X#define HPGL2_BASE64 TRUE
  1850. X
  1851. X#if HPGL2_BASE64
  1852. X#define HPGL2_BITS 6
  1853. X#define HPGL2_LOW_OFFS 63
  1854. X#define HPGL2_HIGH_OFFS 191
  1855. X#define HPGL2_MASK 63
  1856. X#else
  1857. X#define HPGL2_BITS 5
  1858. X#define HPGL2_LOW_OFFS 63
  1859. X#define HPGL2_HIGH_OFFS 95
  1860. X#define HPGL2_MASK 31
  1861. X#endif
  1862. X
  1863. X/*
  1864. X * Data structures for options
  1865. X */
  1866. X
  1867. Xstruct HPGL2_font_str {
  1868. X    char           *compare,
  1869. X                   *name;
  1870. X    int             symbol_set,
  1871. X                    spacing;
  1872. X    double          pitch,
  1873. X                    height;
  1874. X    int             posture,
  1875. X                    stroke_weight,
  1876. X                    typeface;
  1877. X};
  1878. X
  1879. Xstruct PCL_mode_str {
  1880. X    char           *compare,
  1881. X                   *name,
  1882. X                   *command;
  1883. X    int             xmax,
  1884. X                    ymax;
  1885. X};
  1886. X
  1887. X/*
  1888. X * The default font goes first.  Although it is the ugliest,  the
  1889. X * stick font is probably supported by the most devices, so it
  1890. X * becomes the default.
  1891. X */
  1892. X
  1893. Xstatic struct HPGL2_font_str GPFAR HPGL2_font_table[] = {
  1894. X        {"u$nivers", "univers", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4148},
  1895. X         {"s$tick", "stick", 277, 0, HPGL2_DEF_PITCH, 0.0, 0, 0, 48},
  1896. X       {"c$g_times", "cg_times", 277, 1, 0.0, HPGL2_DEF_POINT, 0, 0, 4101}
  1897. X};
  1898. X
  1899. X#define HPGL2_FONTS (sizeof(HPGL2_font_table) / sizeof (struct HPGL2_font_str))
  1900. Xstatic struct HPGL2_font_str *HPGL2_font = &HPGL2_font_table[0];
  1901. X
  1902. X/*
  1903. X * The default mode goes first.  Landscape style plots are probably the
  1904. X * most compatable with other HPGL devices.
  1905. X */
  1906. X
  1907. Xstatic struct PCL_mode_str GPFAR PCL_mode_table[] = {
  1908. X          {"l$andscape", "landscape", "\033&l1O", PCL_XMAX, PCL_YMAX},
  1909. X         {"p$ortrait", "portrait", "\033&l0O", PCL_YMAX, PCL_XMAX}
  1910. X};
  1911. X
  1912. X#define PCL_MODES (sizeof(PCL_mode_table) / sizeof (struct PCL_mode_str))
  1913. Xstatic struct PCL_mode_str *PCL_mode = &PCL_mode_table[0];
  1914. X
  1915. X/*
  1916. X * Various line types and widths to distinguish data sets
  1917. X */
  1918. X
  1919. Xstatic char    *HPGL2_lt[] = {"", "4,2", "5,2", "6,2", "7,2", "8,2"},
  1920. X               *HPGL2_pw[] = {".15", ".12", ".08"};
  1921. X
  1922. X#define HPGL2_LINETYPES (sizeof(HPGL2_lt) / sizeof(char *))
  1923. X#define HPGL2_PENWIDTHS (sizeof(HPGL2_pw) / sizeof(char *))
  1924. X
  1925. X/*
  1926. X * Static variables to keep track of where we are, etc.
  1927. X */
  1928. X
  1929. Xstatic int      HPGL_ang = 0,
  1930. X                HPGL_x = UNKNOWN,
  1931. X                HPGL_y = UNKNOWN,
  1932. X                HPGL_penstate = UNKNOWN,
  1933. X                HPGL_pentype = UNKNOWN,
  1934. X                HPGL2_in_pe,
  1935. X                HPGL2_lost;
  1936. X
  1937. X/*
  1938. X * The subroutines, grouped by function for different versions.
  1939. X */
  1940. X
  1941. XHPGL2_options ()
  1942. X{
  1943. X    extern double real();
  1944. X    struct termentry *t = &term_tbl[term];
  1945. X    int             i;
  1946. X    double          point_size;
  1947. X    char       tmp_options[MAX_ID_LEN];
  1948. X    if (!END_OF_COMMAND) {
  1949. X    for (i = 0; i < HPGL2_FONTS &&
  1950. X         !almost_equals (c_token, HPGL2_font_table[i].compare); i++);
  1951. X    if (i < HPGL2_FONTS) {
  1952. X        HPGL2_font = &HPGL2_font_table[i];
  1953. X    } else
  1954. X        int_error ("expecting font: stick, cg_times, or univers", c_token);
  1955. X    c_token++;
  1956. X    if (!END_OF_COMMAND) {
  1957. X        if ((point_size = real(&token[c_token].l_val)) > 0.0) {
  1958. X        t->v_char = (int) HPGL_PUPI *point_size / 72;
  1959. X        t->h_char = t->v_char * 2 / 3;
  1960. X        if (HPGL2_font->spacing)
  1961. X            HPGL2_font->height = point_size;
  1962. X        else
  1963. X            HPGL2_font->pitch = 72 * 3 / (point_size * 2);
  1964. X        } else
  1965. X        int_error ("expecting font point size: real number",c_token);
  1966. X        c_token++;
  1967. X    }
  1968. X    }
  1969. X    sprintf (tmp_options, " %s", HPGL2_font->name);
  1970. X    strcat(term_options,tmp_options);
  1971. X    if (HPGL2_font->spacing){
  1972. X    sprintf (tmp_options, " %lf",
  1973. X          HPGL2_font->height);
  1974. X    strcat(term_options,tmp_options);
  1975. X    }else{
  1976. X    sprintf (tmp_options, " %lf",
  1977. X          HPGL2_font->pitch);
  1978. X        strcat(term_options,tmp_options);
  1979. X    }
  1980. X}
  1981. X
  1982. XPCL_options ()
  1983. X{
  1984. X    int             i;
  1985. X    if (!END_OF_COMMAND) {
  1986. X    for (i = 0; i < PCL_MODES &&
  1987. X         !almost_equals (c_token, PCL_mode_table[i].compare); i++);
  1988. X    if (i < PCL_MODES)
  1989. X        PCL_mode = &PCL_mode_table[i];
  1990. X    else
  1991. X        int_error ("expecting mode: portrait or landscape", c_token);
  1992. X    c_token++;
  1993. X    }
  1994. X    sprintf (term_options, " %s", PCL_mode->name);
  1995. X    HPGL2_options ();
  1996. X}
  1997. X
  1998. XHPGL_init ()
  1999. X{
  2000. X}
  2001. X
  2002. XHPGL2_init ()
  2003. X{
  2004. X}
  2005. X
  2006. XPCL_init ()
  2007. X{
  2008. X    struct termentry *t = &term_tbl[term];
  2009. X/*
  2010. X * Reset printer, set to one copy, orientation of user's choice.
  2011. X * Make the change to the new orientation all at once.
  2012. X */
  2013. X    fprintf (outfile, "\033E\033&l1X%s\n", PCL_mode->command);
  2014. X    t->xmax = PCL_mode->xmax;
  2015. X    t->ymax = PCL_mode->ymax;
  2016. X}
  2017. X
  2018. XHPGL_graphics()
  2019. X{
  2020. X    fputs("\033.Y\n\033.I81;;17:\033.N;19:\033.M500:\n",outfile);
  2021. X/*           1
  2022. X    1. enable eavesdropping
  2023. X*/
  2024. X    fprintf(outfile,
  2025. X    "IN;\nSC0,%d,0,%d;\nSR%f,%f;\n",
  2026. X        HPGL_XMAX,HPGL_YMAX,
  2027. X        ((double)(HPGL_HCHAR)*200/3/HPGL_XMAX),
  2028. X        ((double)(HPGL_VCHAR)*100/2/HPGL_YMAX) );
  2029. X/*     1    2             3 
  2030. X    1. reset to power-up defaults
  2031. X    2. set SCaling
  2032. X    3. set character size
  2033. X*/
  2034. X    HPGL_ang = 0;
  2035. X}
  2036. X
  2037. XHPGL2_graphics ()
  2038. X{
  2039. X/*
  2040. X * IN - Initialize
  2041. X * SP - Select pen
  2042. X * SD - Set default font
  2043. X */
  2044. X    fprintf (outfile, "INSP1SD1,%d,2,%d,",
  2045. X         HPGL2_font->symbol_set, HPGL2_font->spacing);
  2046. X    if (HPGL2_font->spacing)
  2047. X    fprintf (outfile, "4,%lf,", HPGL2_font->height);
  2048. X    else
  2049. X    fprintf (outfile, "3,%lf,", HPGL2_font->pitch);
  2050. X    fprintf (outfile, "5,%d,6,%d,7,%d\n", HPGL2_font->posture,
  2051. X         HPGL2_font->stroke_weight, HPGL2_font->typeface);
  2052. X/*
  2053. X * Control variables
  2054. X */
  2055. X    HPGL_ang = 0;        /* Horizontal */
  2056. X    HPGL2_in_pe = FALSE;    /* Not in PE command */
  2057. X    HPGL2_lost = TRUE;        /* Pen position is unknown */
  2058. X    HPGL_penstate = UP;        /* Pen is up */
  2059. X}
  2060. X
  2061. XPCL_graphics ()
  2062. X{
  2063. X/*
  2064. X * Enter HPGL/2 graphics mode
  2065. X */
  2066. X    fputs ("\033%0B", outfile);
  2067. X    HPGL2_graphics ();
  2068. X}
  2069. X
  2070. XHPGL_text ()
  2071. X{
  2072. X    fputs ("PUSP0;\033.Z\n\0", outfile);
  2073. X/*           1 2   3
  2074. X    1. pen up
  2075. X    2. park pen
  2076. X    3. disable eavesdropping
  2077. X*/
  2078. X    HPGL_penstate = UP;
  2079. X}
  2080. X
  2081. XHPGL2_text ()
  2082. X{
  2083. X/*
  2084. X * If in Polyline Encoded command, leave Polyline Encoded command
  2085. X */
  2086. X    if (HPGL2_in_pe) {
  2087. X    fputs (";\n", outfile);
  2088. X    HPGL2_in_pe = 0;
  2089. X    }
  2090. X/*
  2091. X * Pen up, park pen
  2092. X */
  2093. X    fputs ("PUSP0;", outfile);
  2094. X}
  2095. X
  2096. XPCL_text ()
  2097. X{
  2098. X    if (HPGL2_in_pe) {
  2099. X    fputs (";\n", outfile);
  2100. X    HPGL2_in_pe = 0;
  2101. X    }
  2102. X/*
  2103. X * Go into PCL mode and eject the page
  2104. X */
  2105. X    fputs ("\033%1A\033&l0H\n\0", outfile);
  2106. X}
  2107. X
  2108. XHPGL_linetype (linetype)
  2109. X    int             linetype;
  2110. X{
  2111. X/* allow for 6 pens */
  2112. X    linetype = (linetype + 2) % 6 + 1;
  2113. X/* only select pen if necessary */
  2114. X    if (HPGL_pentype != linetype) {
  2115. X    fprintf (outfile, "PU;\nSP%d;\n", linetype);
  2116. X    HPGL_pentype = linetype;
  2117. X    HPGL_penstate = UP;
  2118. X    }
  2119. X}
  2120. X
  2121. XHP75_linetype (linetype)
  2122. X    int             linetype;
  2123. X{
  2124. X/* allow for 4 pens */
  2125. X    linetype = (linetype + 2) % 4 + 1;
  2126. X/* only select pen if necessary */
  2127. X    if (HPGL_pentype != linetype) {
  2128. X    fprintf (outfile, "PU;\nSP%d;\n", linetype);
  2129. X    HPGL_pentype = linetype;
  2130. X    HPGL_penstate = UP;
  2131. X    }
  2132. X}
  2133. X
  2134. XHPGL2_linetype (linetype)
  2135. X    int             linetype;
  2136. X{
  2137. X/*
  2138. X * If in Polyline Encoded command, leave Polyline Encoded command
  2139. X */
  2140. X    if (HPGL2_in_pe) {
  2141. X    fputs (";\n", outfile);
  2142. X    HPGL2_in_pe = 0;
  2143. X    }
  2144. X/*
  2145. X * Allow for lots of linetypes
  2146. X */
  2147. X    if (linetype >= 0)
  2148. X    linetype = linetype % (HPGL2_LINETYPES * HPGL2_PENWIDTHS);
  2149. X    if (linetype != HPGL_pentype) {
  2150. X    if (linetype >= 0) {
  2151. X        fprintf (outfile, "PW%sLT%s",
  2152. X             HPGL2_pw[linetype / HPGL2_LINETYPES],
  2153. X             HPGL2_lt[linetype % HPGL2_LINETYPES]);
  2154. X    } else if (linetype == -2)
  2155. X/*
  2156. X * Borders and tics
  2157. X */
  2158. X        fprintf (outfile, "PW.2LT");
  2159. X    else if (linetype == -1)
  2160. X/*
  2161. X * Axes and grids
  2162. X */
  2163. X        fprintf (outfile, "PW.1LT1,.25");
  2164. X    HPGL_pentype = linetype;
  2165. X    }
  2166. X}
  2167. X
  2168. XHPGL_put_text (x, y, str)
  2169. X    int             x,
  2170. X                    y;
  2171. X    char           *str;
  2172. X{
  2173. X    if (HPGL_ang == 1)
  2174. X    HPGL_move (x + HPGL_VCHAR / 4, y);
  2175. X    else
  2176. X    HPGL_move (x, y - HPGL_VCHAR / 4);
  2177. X    fprintf (outfile, "LB%s\003\n", str);
  2178. X}
  2179. X
  2180. XHPGL2_put_text (x, y, str)
  2181. X    int             x,
  2182. X                    y;
  2183. X    char           *str;
  2184. X{
  2185. X    struct termentry *t = &term_tbl[term];
  2186. X/*
  2187. X * Position the pen
  2188. X */
  2189. X    if (HPGL_ang == 1)
  2190. X    HPGL2_move (x + t->v_char / 4, y);
  2191. X    else
  2192. X    HPGL2_move (x, y - t->v_char / 4);
  2193. X/*
  2194. X * If in Polyline Encoded command, leave Polyline Encoded command
  2195. X */
  2196. X    if (HPGL2_in_pe) {
  2197. X    fputs (";\n", outfile);
  2198. X    HPGL2_in_pe = 0;
  2199. X    }
  2200. X/*
  2201. X * Print the text string
  2202. X */
  2203. X    fprintf (outfile, "LB%s\003\n", str);
  2204. X    HPGL2_lost = 1;
  2205. X}
  2206. X/*
  2207. X * Some early HPGL plotters (e.g. HP7220C) require the
  2208. X * Pen Up/Down and Pen (move) Absolute commands to be separate.
  2209. X */
  2210. X
  2211. XHPGL_move (x, y)
  2212. X    int             x,
  2213. X                    y;
  2214. X{
  2215. X    if (HPGL_x != x || HPGL_y != y) {        /* only move if necessary */
  2216. X    fprintf (outfile, "PU;PA%d,%d;\n", x, y);
  2217. X    HPGL_penstate = UP;
  2218. X    HPGL_x = x;
  2219. X    HPGL_y = y;
  2220. X    }
  2221. X}
  2222. X
  2223. XHPGL_vector (x, y)
  2224. X    int             x,
  2225. X                    y;
  2226. X{
  2227. X    if (HPGL_penstate != DOWN) {
  2228. X    fprintf (outfile, "PD;PA%d,%d;\n", x, y);
  2229. X    HPGL_penstate = DOWN;
  2230. X    } else
  2231. X    fprintf (outfile, "PA%d,%d;\n", x, y);
  2232. X    HPGL_x = x;
  2233. X    HPGL_y = y;
  2234. X}
  2235. X
  2236. XHPGL2_move (x, y)
  2237. X    int             x,
  2238. X                    y;
  2239. X{
  2240. X    register int    dx,
  2241. X                    dy;
  2242. X    if (HPGL2_in_pe) {
  2243. X    dx = x - HPGL_x;
  2244. X    dy = y - HPGL_y;
  2245. X    fputs ("<", outfile);
  2246. X    } else {
  2247. X#if HPGL2_BASE64
  2248. X    fputs ("PE<", outfile);
  2249. X#else
  2250. X    fputs ("PE7<", outfile);
  2251. X#endif
  2252. X    if (HPGL2_lost) {
  2253. X        dx = x;
  2254. X        dy = y;
  2255. X        HPGL2_lost = 0;
  2256. X        fputs ("=", outfile);
  2257. X    } else {
  2258. X        dx = x - HPGL_x;
  2259. X        dy = y - HPGL_y;
  2260. X    }
  2261. X    HPGL2_in_pe = 1;
  2262. X    }
  2263. X#if HPGL2_EXPLICIT_PD
  2264. X    if (HPGL_penstate == DOWN)
  2265. X    HPGL_penstate = UP;
  2266. X#endif
  2267. X    HPGL2_encode (dx);
  2268. X    HPGL2_encode (dy);
  2269. X    fputs("\n",outfile);
  2270. X    HPGL_x = x;
  2271. X    HPGL_y = y;
  2272. X}
  2273. X
  2274. XHPGL2_vector (x, y)
  2275. X    int             x,
  2276. X                    y;
  2277. X{
  2278. X    register int    dx,
  2279. X                    dy;
  2280. X    if (HPGL2_in_pe) {
  2281. X    dx = x - HPGL_x;
  2282. X    dy = y - HPGL_y;
  2283. X    } else {
  2284. X#if HPGL2_BASE64
  2285. X    fputs ("PE", outfile);
  2286. X#else
  2287. X    fputs ("PE7", outfile);
  2288. X#endif
  2289. X    if (HPGL2_lost) {
  2290. X        dx = x;
  2291. X        dy = y;
  2292. X        HPGL2_lost = 0;
  2293. X        fputs ("=", outfile);
  2294. X    } else {
  2295. X        dx = x - HPGL_x;
  2296. X        dy = y - HPGL_y;
  2297. X    }
  2298. X    HPGL2_in_pe = 1;
  2299. X    }
  2300. X#if HPGL2_EXPLICIT_PD
  2301. X/*
  2302. X * Put the pen down in the current position,
  2303. X * relative vector of 0,0.
  2304. X */
  2305. X    if (HPGL_penstate == UP) {
  2306. X    fputc ((char) HPGL2_HIGH_OFFS, outfile);
  2307. X    fputc ((char) HPGL2_HIGH_OFFS, outfile);
  2308. X    HPGL_penstate = DOWN;
  2309. X    }
  2310. X#endif
  2311. X    HPGL2_encode (dx);
  2312. X    HPGL2_encode (dy);
  2313. X    fputs("\n",outfile);
  2314. X    HPGL_x = x;
  2315. X    HPGL_y = y;
  2316. X}
  2317. X
  2318. X/*
  2319. X * Routine to encode position in base 32 or base 64 characters
  2320. X */
  2321. X
  2322. XHPGL2_encode (d)
  2323. X    register int    d;
  2324. X{
  2325. X    register int    c;
  2326. X    if ((d <<= 1) < 0)
  2327. X    d = 1 - d;
  2328. X    do {
  2329. X    c = d & HPGL2_MASK;
  2330. X    d >>= HPGL2_BITS;
  2331. X    if (d > 0)
  2332. X        fputc ((char) (c + HPGL2_LOW_OFFS), outfile);
  2333. X    else
  2334. X        fputc ((char) (c + HPGL2_HIGH_OFFS), outfile);
  2335. X    } while (d > 0);
  2336. X}
  2337. X
  2338. Xint
  2339. XHPGL_text_angle (ang)
  2340. X    int             ang;
  2341. X{
  2342. X    HPGL_ang = ang;
  2343. X    if (ang == 1)
  2344. X/*
  2345. X *  Vertical
  2346. X */
  2347. X    fprintf (outfile, "DI0,1;\n");
  2348. X    else
  2349. X/*
  2350. X * Horizontal
  2351. X */
  2352. X    fprintf (outfile, "DI1,0;\n");
  2353. X    return TRUE;
  2354. X}
  2355. X
  2356. Xint
  2357. XHPGL2_text_angle (ang)
  2358. X    int             ang;
  2359. X{
  2360. X/*
  2361. X * If in Polyline Encoded command, leave Polyline Encoded command
  2362. X */
  2363. X    if (HPGL2_in_pe) {
  2364. X    fputs (";", outfile);
  2365. X    HPGL2_in_pe = 0;
  2366. X    }
  2367. X    if (ang == 1)
  2368. X/*
  2369. X *  Vertical
  2370. X */
  2371. X    fprintf (outfile, "DI0,1");
  2372. X    else
  2373. X/*
  2374. X * Horizontal
  2375. X */
  2376. X    fprintf (outfile, "DI1,0");
  2377. X    HPGL_ang = ang;
  2378. X    return TRUE;
  2379. X}
  2380. X
  2381. XHPGL_reset ()
  2382. X{
  2383. X/*
  2384. X * I am not sure that "PG" is a command in HPGL.
  2385. X    fputs ("PG;", outfile);
  2386. X */
  2387. X}
  2388. X
  2389. XHPGL2_reset ()
  2390. X{
  2391. X/*
  2392. X * Park the pen
  2393. X * Advance a page
  2394. X * End with ";"
  2395. X */
  2396. X    fputs ("SP0PG;\n", outfile);
  2397. X}
  2398. X
  2399. XPCL_reset ()
  2400. X{
  2401. X/*
  2402. X * Return to PCL mode
  2403. X * Printer reset (conditional eject)
  2404. X */
  2405. X    fputs ("\033%0A\033E\n", outfile);
  2406. X}
  2407. X
  2408. XHPGL2_justify_text (just)
  2409. X    int             just;
  2410. X{
  2411. X/*
  2412. X * If in Polyline Encoded command, leave Polyline Encoded command
  2413. X */
  2414. X    if (HPGL2_in_pe) {
  2415. X    fputs (";\n", outfile);
  2416. X    HPGL2_in_pe = 0;
  2417. X    }
  2418. X    switch (just) {
  2419. X    case LEFT:
  2420. X    fputs ("LO1", outfile);
  2421. X    break;
  2422. X    case CENTRE:
  2423. X    fputs ("LO4", outfile);
  2424. X    break;
  2425. X    case RIGHT:
  2426. X    fputs ("LO7", outfile);
  2427. X    break;
  2428. X    default:
  2429. X    return 0;
  2430. X    }
  2431. X    return 1;
  2432. X}
  2433. X
  2434. END_OF_FILE
  2435.   if test 14106 -ne `wc -c <'gnuplot/term/hpgl.trm'`; then
  2436.     echo shar: \"'gnuplot/term/hpgl.trm'\" unpacked with wrong size!
  2437.   fi
  2438.   # end of 'gnuplot/term/hpgl.trm'
  2439. fi
  2440. if test -f 'gnuplot/term/unixpc.trm' -a "${1}" != "-c" ; then 
  2441.   echo shar: Will not clobber existing file \"'gnuplot/term/unixpc.trm'\"
  2442. else
  2443.   echo shar: Extracting \"'gnuplot/term/unixpc.trm'\" \(14316 characters\)
  2444.   sed "s/^X//" >'gnuplot/term/unixpc.trm' <<'END_OF_FILE'
  2445. X/*
  2446. X * $Id: unixpc.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  2447. X *
  2448. X */
  2449. X
  2450. X/* GNUPLOT - unixpc.trm */
  2451. X/*
  2452. X * Copyright (C) 1990 - 1993   
  2453. X *
  2454. X * Permission to use, copy, and distribute this software and its
  2455. X * documentation for any purpose with or without fee is hereby granted, 
  2456. X * provided that the above copyright notice appear in all copies and 
  2457. X * that both that copyright notice and this permission notice appear 
  2458. X * in supporting documentation.
  2459. X *
  2460. X * Permission to modify the software is granted, but not the right to
  2461. X * distribute the modified code.  Modifications are to be distributed 
  2462. X * as patches to released version.
  2463. X *  
  2464. X * This software  is provided "as is" without express or implied warranty.
  2465. X * 
  2466. X * This file is included by ../term.c.
  2467. X *
  2468. X * This terminal driver supports:
  2469. X *  Unix PC's (ATT 3b1)
  2470. X *
  2471. X * AUTHORS
  2472. X *    John Campbell
  2473. X * 
  2474. X * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  2475. X * 
  2476. X */
  2477. X
  2478. X/*
  2479. X>From: John Campbell (...!arizona!naucse!jdc)
  2480. X
  2481. XI originally ported gnuplot to the ATT 3b1 (ATT7300) on 12/4/88, and then
  2482. Xadded the minimal code needed to bring it up to 2.0 level on 1/28/90.  The 
  2483. X3b1, as I view it, is a 720x300 bitmapped, monochrome display (often people 
  2484. Xdon't use the top 12 scan lines and thus the effective size is 720x288).  I 
  2485. Xtried to maximize the size of the graph area, by using these top 12 lines 
  2486. X(normally reserved) and set up a signal handler to restore them upon exit, 
  2487. Xabort, etc.
  2488. X
  2489. XLine styles were "fudged" (they do not know the aspect ratio).  The same
  2490. Xline style may look different depending upon the slope of the curve.  Due to
  2491. Xthis only 4 line styles were implemented.  While more line types are possible,
  2492. Xthe current styles were chosen as distinguishable.
  2493. X
  2494. XThe 3b1 has 4 "special" rows at the bottom that I could not use in graphics
  2495. Xmode.  It has been suggested that we use these lines for command prompting.
  2496. XOthers have requested that we have a graphics window and a command window.
  2497. XMy experience with gnuplot only includes relatively dumb graphics devices--
  2498. Xhence gnuplot "looks and feels" normal to me the way I implemented it.
  2499. XI welcome either of these changes from someone else, however.
  2500. X*/
  2501. X
  2502. X#include <sys/window.h>   /* Started with tam.h--too much trouble. */
  2503. X#include <sys/signal.h>
  2504. X#include <errno.h>
  2505. X
  2506. X#define uPC_HIGH_BIT    (0x8000)
  2507. X
  2508. Xtypedef unsigned short Scr_type;
  2509. Xtypedef unsigned char Scr_kluge;
  2510. X
  2511. X#define uPC_XMAX 720
  2512. X#define uPC_YMAX 300
  2513. X
  2514. X#define uPC_XSIZE       45 /* Short ints. */
  2515. X#define uPC_YSIZE uPC_YMAX
  2516. X
  2517. XScr_type uPC_display[uPC_YSIZE][uPC_XSIZE];
  2518. Xint uPC_width = 2*uPC_XSIZE;
  2519. Xint uPC_sx=0, uPC_sy=0;
  2520. Xint uPC_cur_linetype=0;
  2521. Xint uPC_angle = 0;
  2522. Xunsigned short uPC_raster_count=0;
  2523. Xstatic Scr_type lookup[] = {
  2524. X      0x0001, 0x0002, 0x0004, 0x0008,
  2525. X      0x0010, 0x0020, 0x0040, 0x0080,
  2526. X      0x0100, 0x0200, 0x0400, 0x0800,
  2527. X      0x1000, 0x2000, 0x4000, 0x8000,
  2528. X   };
  2529. X
  2530. X#define uPC_XLAST (uPC_XMAX - 1)
  2531. X#define uPC_YLAST (uPC_YMAX - 1)
  2532. X
  2533. X#define uPC_VCHAR FNT5X9_VCHAR
  2534. X#define uPC_HCHAR FNT5X9_HCHAR
  2535. X#define uPC_VTIC  uPC_VCHAR/2  /* Was 8  */
  2536. X#define uPC_HTIC  uPC_HCHAR    /* Was 12 */
  2537. X
  2538. Xextern errno, sys_nerr;
  2539. Xextern char *sys_errlist[];
  2540. X
  2541. Xstatic struct urdata uPC_ur = {(unsigned short *)uPC_display, 2*uPC_XSIZE, 0, 0,
  2542. X                           0, 0, 0, 0, uPC_XMAX, uPC_YMAX, SRCSRC, DSTOR, 0};
  2543. X
  2544. X#define IfErrOut(e1,e2,s1,s2) if (e1 e2) {\
  2545. Xfprintf(stderr, "%s:: %s %s\n", sys_errlist[errno], s1, s2);\
  2546. XuPC_fixwind(0);\
  2547. Xexit(-1);}
  2548. X
  2549. XuPC_init()
  2550. X{
  2551. X/* This routine will ioctl to change 0 size */
  2552. X   int i;
  2553. X   struct uwdata uw;
  2554. X   int uPC_fixwind();
  2555. X   short gw;
  2556. X
  2557. X/* Check that we are on the bitmapped window. */
  2558. X   if (iswind() != 0) {
  2559. X      fprintf (stderr, "Sorry--must run from the bitmapped terminal\n");
  2560. X      exit(-1);
  2561. X   }
  2562. X   for (i=1; i<=16; i++) {
  2563. X      if (i != SIGINT && i != SIGFPE)  /* Two are caught in plot.c */
  2564. X         signal (i, uPC_fixwind);
  2565. X   }
  2566. X
  2567. X/* Increase the screen size */
  2568. X   uw.uw_x = 0;
  2569. X   uw.uw_y = 0;   /* Leave room for top status line. */
  2570. X   uw.uw_width = uPC_XMAX;      /* 720 */
  2571. X   uw.uw_height = uPC_YMAX;     /* 288 normal--we clobber 12 (top row)*/
  2572. X   uw.uw_uflags = 1;         /* Creates with no border */
  2573. X
  2574. X   IfErrOut (ioctl(1, WIOCSETD, &uw), <0, "ioctl failed on", "WIOCSETD");
  2575. X}
  2576. X
  2577. X
  2578. XuPC_graphics()
  2579. X{
  2580. X/* This routine will clear the uPC_display buffer and window. */
  2581. X   register Scr_type *j;
  2582. X   register int i;
  2583. X
  2584. X   j = (Scr_type *)uPC_display;
  2585. X   i = uPC_YSIZE*uPC_XSIZE + 1;
  2586. X
  2587. X   while (--i)
  2588. X      *j++ = 0;
  2589. X/*
  2590. X   Position the cursor to the bottom of the screen so when we come back to
  2591. X   text mode we are just below the graph.
  2592. X*/
  2593. X   printf ("\033[25;1H");
  2594. X
  2595. X   uPC_ur.ur_dstop = DSTSRC;   /* replace (clear screen). */
  2596. X   IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
  2597. X      "ioctl failed", "WIOCRASTOP");
  2598. X   uPC_ur.ur_dstop = DSTOR;   /* Or in (show text) */
  2599. X}
  2600. X
  2601. X
  2602. XuPC_text()
  2603. X{
  2604. X/* This routine will flush the display. */
  2605. X
  2606. X   IfErrOut (ioctl(1, WIOCRASTOP, &uPC_ur), <0,
  2607. X      "ioctl failed", "WIOCRASTOP");
  2608. X}
  2609. X
  2610. X
  2611. XuPC_linetype(linetype)
  2612. Xint linetype;
  2613. X{
  2614. X/* This routine records the current linetype. */
  2615. X   if (uPC_cur_linetype != linetype) {
  2616. X      uPC_raster_count = 0;
  2617. X      uPC_cur_linetype = linetype;
  2618. X   }
  2619. X}
  2620. X
  2621. X
  2622. XuPC_move(x,y)
  2623. Xunsigned int x,y;
  2624. X{
  2625. X/* This routine just records x and y in uPC_sx, uPC_sy */
  2626. X   uPC_sx = x;
  2627. X   uPC_sy = y;
  2628. X}
  2629. X
  2630. X
  2631. X/* Was just (*(a)|=(b)) */
  2632. X#define uPC_PLOT(a,b)   (uPC_cur_linetype != 0 ? uPC_plot_word (a,b) :\
  2633. X                                (*(a)|=(b)))
  2634. X
  2635. XuPC_plot_word(a,b)
  2636. XScr_type *a, b;
  2637. X/*
  2638. X   Weak attempt to make line styles.  The real problem is the aspect
  2639. X   ratio.  This routine is called only when a bit is to be turned on in
  2640. X   a horizontal word.  A better line style routine would know something
  2641. X   about the slope of the line around the current point (in order to
  2642. X   change weighting).
  2643. X
  2644. X   This yields 3 working linetypes plus a usable axis line type.
  2645. X*/
  2646. X{
  2647. X/* Various line types */
  2648. X   switch (uPC_cur_linetype) {
  2649. X   case -1:
  2650. X   /* Distinguish between horizontal and vertical axis. */
  2651. X      if (uPC_sx > uPC_XMAX/8 && uPC_sx < 7*uPC_XMAX/8) {
  2652. X      /* Fuzzy tolerance because we don't know exactly where the y axis is */
  2653. X         if (++uPC_raster_count % 2 == 0) *(a) |= b;
  2654. X      }
  2655. X      else {
  2656. X      /* Due to aspect ratio, take every other y pixel and every third x. */
  2657. X         *(a) |= (b & 0x9999);
  2658. X      }
  2659. X   break;
  2660. X   case 1:
  2661. X   case 5:
  2662. X   /* Make a |    |----|    |----| type of line. */
  2663. X      if ((1<<uPC_raster_count) & 0xF0F0) *(a) |= b;
  2664. X      if (++uPC_raster_count > 15) uPC_raster_count = 0;
  2665. X   break;
  2666. X   case 2:
  2667. X   case 6:
  2668. X   /* Make a |----|----|----|--- |    | type of line. */
  2669. X      if ((1<<uPC_raster_count) & 0x0EFFF) *(a) |= b;
  2670. X      if (++uPC_raster_count > 19) uPC_raster_count = 0;
  2671. X   break;
  2672. X   case 3:
  2673. X   case 7:
  2674. X   /* Make a | -  | -  | -  | -  | type of line. */
  2675. X      if ((1<<uPC_raster_count) & 0x4444) *(a) |= b;
  2676. X      if (++uPC_raster_count > 15) uPC_raster_count = 0;
  2677. X   break;
  2678. X   case 4:
  2679. X   case 8:
  2680. X   default:
  2681. X      *(a) |= b;
  2682. X   break;
  2683. X   }
  2684. X}
  2685. X
  2686. XuPC_vector(x,y)
  2687. Xunsigned int x,y;
  2688. X{
  2689. X/* This routine calls line with x,y */
  2690. X   int x1 = uPC_sx, y1=uPC_sy, x2 = x, y2 = y;
  2691. X   register int  c, e, dx, dy, width;
  2692. X   register Scr_type mask, *a;
  2693. X
  2694. X/* Record new sx, sy for next call to the vector routine. */
  2695. X   uPC_sx = x2;
  2696. X   uPC_sy = y2;
  2697. X
  2698. X   a = &uPC_display[(uPC_YSIZE - 1) - y1][x1 >> 4];
  2699. X   mask = lookup[x1 & 0x0f];
  2700. X   width = uPC_width;
  2701. X
  2702. X   if ((dx = x2 - x1) > 0) {
  2703. X      if ((dy = y2 - y1) > 0) {
  2704. X         if (dx > dy) {         /* dx > 0, dy > 0, dx > dy */
  2705. X            dy <<= 1;
  2706. X            e = dy - dx;
  2707. X            c = dx + 2;
  2708. X            dx <<= 1;
  2709. X
  2710. X            while (--c) {
  2711. X               uPC_PLOT(a, mask);
  2712. X               if (e >= 0) {
  2713. X                  (Scr_kluge *)a -= width;
  2714. X                  e -= dx;
  2715. X               }
  2716. X               if (mask & uPC_HIGH_BIT) {
  2717. X                  mask = 1;
  2718. X                  a++;
  2719. X               } else
  2720. X                  mask <<= 1;
  2721. X               e += dy;
  2722. X            }
  2723. X         } else {            /* dx > 0, dy > 0, dx <= dy */
  2724. X            dx <<= 1;
  2725. X            e = dx - dy;
  2726. X            c = dy + 2;
  2727. X            dy <<= 1;
  2728. X
  2729. X            while (--c) {
  2730. X               uPC_PLOT(a, mask);
  2731. X               if (e >= 0) {
  2732. X                  if (mask & uPC_HIGH_BIT) {
  2733. X                     mask = 1;
  2734. X                     a++;
  2735. X                  } else
  2736. X                     mask <<= 1;
  2737. X                  e -= dy;
  2738. X               }
  2739. X               (Scr_kluge *)a -= width;
  2740. X               e += dx;
  2741. X            }
  2742. X         }
  2743. X      } else {
  2744. X         dy = -dy;
  2745. X         if (dx > dy) {         /* dx > 0, dy <= 0, dx > dy */
  2746. X            dy <<= 1;
  2747. X            e = dy - dx;
  2748. X            c = dx + 2;
  2749. X            dx <<= 1;
  2750. X
  2751. X            while (--c) {
  2752. X               uPC_PLOT(a, mask);
  2753. X               if (e >= 0) {
  2754. X                  (Scr_kluge *)a += width;
  2755. X                  e -= dx;
  2756. X               }
  2757. X               if (mask & uPC_HIGH_BIT) {
  2758. X                  mask = 1;
  2759. X                  a++;
  2760. X               } else
  2761. X                  mask <<= 1;
  2762. X               e += dy;
  2763. X            }
  2764. X         } else {            /* dx > 0, dy <= 0, dx <= dy */
  2765. X            dx <<= 1;
  2766. X            e = dx - dy;
  2767. X            c = dy + 2;
  2768. X            dy <<= 1;
  2769. X
  2770. X            while (--c) {
  2771. X               uPC_PLOT(a, mask);
  2772. X               if (e >= 0) {
  2773. X                  if (mask & uPC_HIGH_BIT) {
  2774. X                     mask = 1;
  2775. X                     a++;
  2776. X                  } else
  2777. X                     mask <<= 1;
  2778. X                  e -= dy;
  2779. X               }
  2780. X               (Scr_kluge *)a += width;
  2781. X               e += dx;
  2782. X            }
  2783. X         }
  2784. X      }
  2785. X   } else {
  2786. X      dx = -dx;
  2787. X      if ((dy = y2 - y1) > 0) {
  2788. X         if (dx > dy) {         /* dx <= 0, dy > 0, dx > dy */
  2789. X            dy <<= 1;
  2790. X            e = dy - dx;
  2791. X            c = dx + 2;
  2792. X            dx <<= 1;
  2793. X
  2794. X            while (--c) {
  2795. X               uPC_PLOT(a, mask);
  2796. X               if (e >= 0) {
  2797. X                  (Scr_kluge *)a -= width;
  2798. X                  e -= dx;
  2799. X               }
  2800. X               if (mask & 1) {
  2801. X                  mask = uPC_HIGH_BIT;
  2802. X                  a--;
  2803. X               } else
  2804. X                  mask >>= 1;
  2805. X               e += dy;
  2806. X            }
  2807. X         } else {            /* dx <= 0, dy > 0, dx <= dy */
  2808. X            dx <<= 1;
  2809. X            e = dx - dy;
  2810. X            c = dy + 2;
  2811. X            dy <<= 1;
  2812. X
  2813. X            while (--c) {
  2814. X               uPC_PLOT(a, mask);
  2815. X               if (e >= 0) {
  2816. X                  if (mask & 1) {
  2817. X                     mask = uPC_HIGH_BIT;
  2818. X                     a--;
  2819. X                  } else
  2820. X                     mask >>= 1;
  2821. X                  e -= dy;
  2822. X               }
  2823. X               (Scr_kluge *)a -= width;
  2824. X               e += dx;
  2825. X            }
  2826. X         }
  2827. X      } else {
  2828. X         dy = -dy;
  2829. X         if (dx > dy) {         /* dx <= 0, dy <= 0, dx > dy */
  2830. X            dy <<= 1;
  2831. X            e = dy - dx;
  2832. X            c = dx + 2;
  2833. X            dx <<= 1;
  2834. X
  2835. X            while (--c) {
  2836. X               uPC_PLOT(a, mask);
  2837. X               if (e >= 0) {
  2838. X                  (Scr_kluge *)a += width;
  2839. X                  e -= dx;
  2840. X               }
  2841. X               if (mask & 1) {
  2842. X                  mask = uPC_HIGH_BIT;
  2843. X                  a--;
  2844. X               } else
  2845. X                  mask >>= 1;
  2846. X               e += dy;
  2847. X            }
  2848. X         } else {            /* dx <= 0, dy <= 0, dx <= dy */
  2849. X            dx <<= 1;
  2850. X            e = dx - dy;
  2851. X            c = dy + 2;
  2852. X            dy <<= 1;
  2853. X
  2854. X            while (--c) {
  2855. X               uPC_PLOT(a, mask);
  2856. X               if (e >= 0) {
  2857. X                  if (mask & 1) {
  2858. X                     mask = uPC_HIGH_BIT;
  2859. X                     a--;
  2860. X                  } else
  2861. X                     mask >>= 1;
  2862. X                  e -= dy;
  2863. X               }
  2864. X               (Scr_kluge *)a += width;
  2865. X               e += dx;
  2866. X            }
  2867. X         }
  2868. X      }
  2869. X   }
  2870. X}
  2871. X
  2872. X
  2873. X#ifdef uPC_NOT_USED
  2874. X/* Added by Russell Lang, eln272v@monu1.cc.monash.oz
  2875. X   This placement to the nearest character cell worked, and I'm leaving
  2876. X   it here so the calculations involved won't be lost!  (jdc)
  2877. X*/
  2878. XuPC_put_text(x,y,str)
  2879. Xunsigned int x,y;
  2880. Xchar str[];
  2881. X{
  2882. X/* This routine puts the text at the cursor location nearest
  2883. X   to (x,y).  Obviously the exact postion would look better */
  2884. X
  2885. X/* Just use the ANSI escape sequence CUP (iswind said that was ok!) */
  2886. X   printf ("\033[%d;%dH%s\033[25;1H", (int)(24-(y-uPC_VCHAR/2)*25/uPC_YMAX), 
  2887. X                (int)(x*80/uPC_XMAX), str); 
  2888. X   fflush (stdout);
  2889. X}
  2890. X#endif
  2891. X
  2892. X
  2893. XuPC_put_text(x,y,str)
  2894. Xunsigned int x,y;
  2895. Xchar str[];
  2896. X{
  2897. X   if (uPC_angle == 1)
  2898. X      x += uPC_VCHAR/2;
  2899. X   else
  2900. X      y -= uPC_VCHAR/2;
  2901. X
  2902. X   switch (uPC_angle) {
  2903. X      case 0:
  2904. X         for (; *str; ++str, x += uPC_HCHAR)
  2905. X            uPC_putc (x, y, *str, uPC_angle);
  2906. X      break;
  2907. X      case 1:
  2908. X         for (; *str; ++str, y += uPC_HCHAR)
  2909. X            uPC_putc (x, y, *str, uPC_angle);
  2910. X      break;
  2911. X   }
  2912. X}
  2913. X
  2914. X
  2915. XuPC_putc (x, y, c, angle)
  2916. Xunsigned int x, y;
  2917. Xint c, angle;
  2918. X/*
  2919. X   Put a character at an x,y location in the bit map (using the fnt5x9
  2920. X   array.  This is mostly just copied from the bitmap.c driver.
  2921. X*/
  2922. X{
  2923. X   int i, j, k;
  2924. X   register Scr_type mask, *a;
  2925. X   char_row fc;
  2926. X   unsigned int pixelon;
  2927. X
  2928. X   i = c - ' ';
  2929. X   for (j=0; j<FNT5X9_VBITS; j++) {
  2930. X      fc = fnt5x9[i][j];
  2931. X      for (k=0; k<FNT5X9_HBITS; k++) {
  2932. X         pixelon = ((unsigned int)(fc))>>k & 1;
  2933. X         if (pixelon) {
  2934. X            switch (angle) {
  2935. X            case 0:
  2936. X               mask = lookup[x+k+1 & 0x0f];
  2937. X               a = &uPC_display[(uPC_YSIZE - 1) - (y+j)][(x+k+1) >> 4];
  2938. X            break;
  2939. X            case 1:
  2940. X               mask = lookup[x-j & 0x0f];
  2941. X               a = &uPC_display[(uPC_YSIZE - 1) - (y+k+1)][(x-j) >> 4];
  2942. X            break;
  2943. X            }
  2944. X            *(a) |= (mask);  /* see uPC_PLOT macro */
  2945. X         }
  2946. X      }
  2947. X   }
  2948. X}
  2949. X
  2950. X
  2951. XuPC_text_angle (ang)
  2952. Xint ang;
  2953. X{
  2954. X   uPC_angle = ang;
  2955. X   return TRUE;
  2956. X}
  2957. X
  2958. X
  2959. XuPC_reset()
  2960. X{
  2961. X/* Reset window to normal size. */
  2962. X   uPC_fixwind (0);
  2963. X}
  2964. X
  2965. X
  2966. X
  2967. XuPC_fixwind(signo)
  2968. Xint signo;
  2969. X{
  2970. X   static struct uwdata wreset = { 0, 12, 720, 288, 0x1};
  2971. X   struct utdata ut;
  2972. X
  2973. X/* Reset the window to the right size. */
  2974. X   ioctl(1, WIOCSETD, &wreset);   /* 0, not wncur here! */
  2975. X
  2976. X/* Scroll the screen once. (avoids typing over the same line) */
  2977. X   fprintf (stderr, "\n");
  2978. X
  2979. X   if (signo) {
  2980. X      if (signo == SIGILL || signo == SIGTRAP || signo == SIGPWR)
  2981. X         signal (signo, SIG_DFL);
  2982. X      kill (0,signo);  /* Redo the signal (as if we never trapped it). */
  2983. X   }
  2984. X}
  2985. END_OF_FILE
  2986.   if test 14316 -ne `wc -c <'gnuplot/term/unixpc.trm'`; then
  2987.     echo shar: \"'gnuplot/term/unixpc.trm'\" unpacked with wrong size!
  2988.   fi
  2989.   # end of 'gnuplot/term/unixpc.trm'
  2990. fi
  2991. echo shar: End of archive 21 \(of 33\).
  2992. cp /dev/null ark21isdone
  2993. MISSING=""
  2994. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  2995.     if test ! -f ark${I}isdone ; then
  2996.     MISSING="${MISSING} ${I}"
  2997.     fi
  2998. done
  2999. if test "${MISSING}" = "" ; then
  3000.     echo You have unpacked all 33 archives.
  3001.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3002. else
  3003.     echo You still must unpack the following archives:
  3004.     echo "        " ${MISSING}
  3005. fi
  3006. exit 0
  3007. exit 0 # Just in case...
  3008.