home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / debug.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  4.3 KB  |  210 lines

  1. /*
  2.  * $Id: debug.trm,v 1.4 1995/12/20 21:47:42 drd Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - debug.trm */
  7. /*
  8.  * Copyright (C) 1990   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *  DEBUG
  26.  *
  27.  * AUTHORS
  28.  *    luecken@udel.edu
  29.  * 
  30.  * send your comments or suggestions to (luecken@udel.edu).
  31.  * 
  32.  */
  33.  
  34. /*
  35.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  36.  */
  37.  
  38. #ifndef GOT_DRIVER_H
  39. #include "driver.h"
  40. #endif
  41.  
  42. #ifdef TERM_REGISTER
  43. register_term(debug)
  44. #endif
  45.  
  46. #ifdef TERM_PROTO
  47. TERM_PUBLIC void DEBUG_init __P((void));
  48. TERM_PUBLIC void DEBUG_graphics __P((void));
  49. TERM_PUBLIC void DEBUG_text __P((void));
  50. TERM_PUBLIC void DEBUG_linetype __P((int linetype));
  51. TERM_PUBLIC void DEBUG_move __P((unsigned int x, unsigned int y));
  52. TERM_PUBLIC void DEBUG_vector __P((unsigned int x, unsigned int y));
  53. TERM_PUBLIC void DEBUG_put_text __P((unsigned int x, unsigned int y, char *str));
  54. TERM_PUBLIC void DEBUG_reset __P((void));
  55. TERM_PUBLIC int DEBUG_justify_text __P((enum JUSTIFY mode));
  56.  
  57. #define DEBUG_XMAX 512 
  58. #define DEBUG_YMAX 390
  59.  
  60. #define DEBUG_XLAST (DEBUG_XMAX - 1)
  61. #define DEBUG_YLAST (DEBUG_XMAX - 1)
  62.  
  63. /* Assume a character size of 1, or a 7 x 10 grid. */
  64. #define DEBUG_VCHAR    10
  65. #define DEBUG_HCHAR    7
  66. #define DEBUG_VTIC    (DEBUG_YMAX/70)        
  67. #define DEBUG_HTIC    (DEBUG_XMAX/75)        
  68. #endif /* TERM_PROTO */
  69.  
  70. #ifndef TERM_PROTO_ONLY
  71. #ifdef TERM_BODY
  72.  
  73. int DEBUG_linetype_last;
  74. int DEBUG_xlast;
  75. int DEBUG_ylast;
  76.  
  77. TERM_PUBLIC void DEBUG_init()
  78. {
  79.     fprintf(outfile,"init\n");
  80.     DEBUG_linetype_last = -3;
  81. }
  82.  
  83.  
  84. TERM_PUBLIC void DEBUG_graphics()
  85. {
  86.     DEBUG_xlast = DEBUG_ylast=0;
  87.     fprintf(outfile,"graphics\n");
  88. }
  89.  
  90.  
  91. TERM_PUBLIC void DEBUG_text()
  92. {
  93.     fprintf(outfile,"text\n");
  94. }
  95.  
  96.  
  97. TERM_PUBLIC void DEBUG_linetype(linetype)
  98. int linetype;
  99. {
  100.     /*
  101.     if (linetype != DEBUG_linetype_last){
  102.         fprintf(outfile,"l%d",linetype);
  103.         DEBUG_linetype_last = linetype;
  104.     }
  105.     */
  106.     fprintf(outfile,"line %d\n",linetype);
  107. }
  108.  
  109.  
  110. TERM_PUBLIC void DEBUG_move(x,y)
  111. unsigned int x,y;
  112. {
  113.     /*
  114.     if (x != DEBUG_xlast || y != DEBUG_ylast){
  115.         fprintf(outfile,"mm");
  116.         DEBUG_xlast = x;
  117.         DEBUG_ylast = y;
  118.     }
  119.     */
  120.     fprintf(outfile,"move %d, %d\t(%d, %d)\n",x,y,x-DEBUG_xlast,y-DEBUG_ylast);
  121.     DEBUG_xlast = x;
  122.     DEBUG_ylast = y;
  123. }
  124.  
  125.  
  126. TERM_PUBLIC void DEBUG_vector(x,y)
  127. unsigned int x,y;
  128. {
  129.     /*
  130.     if (x != DEBUG_xlast || y != DEBUG_ylast){
  131.         fprintf(outfile,"vv");
  132.         DEBUG_xlast = x;
  133.         DEBUG_ylast = y;
  134.     }
  135.     */
  136.     fprintf(outfile,"vect %d, %d\t(%d, %d)\n",x,y,x-DEBUG_xlast,y-DEBUG_ylast);
  137.     DEBUG_xlast = x;
  138.     DEBUG_ylast = y;
  139. }
  140.  
  141.  
  142. TERM_PUBLIC void DEBUG_put_text(x,y,str)
  143. unsigned int x, y;
  144. char *str;
  145. {
  146.     /*
  147.     DEBUG_move(x,y);
  148.     fprintf(outfile,"tx%s\r",str);
  149.     */
  150.     fprintf(outfile,"put_text calls:");
  151.     DEBUG_move(x,y);
  152.     fprintf(outfile,"put_text '%s'\n",str);
  153. }
  154.  
  155.  
  156.  
  157. TERM_PUBLIC void DEBUG_reset()
  158. {
  159.     fprintf(outfile,"reset");
  160. }
  161.  
  162. TERM_PUBLIC DEBUG_justify_text(mode)
  163. enum JUSTIFY mode;
  164. {
  165.     fprintf(outfile,"justify ");
  166.     switch(mode){
  167.         case (CENTRE):
  168.             fprintf(outfile,"centre");
  169.             break;
  170.         case (RIGHT):
  171.             fprintf(outfile,"right");
  172.             break;
  173.         default:
  174.         case (LEFT):
  175.             fprintf(outfile,"left");
  176.             break;
  177.     }
  178.     fprintf(outfile,"\n");
  179.     return(TRUE);
  180. }
  181.  
  182. #endif /* TERM_BODY */
  183.  
  184. #ifdef TERM_TABLE
  185.  
  186. TERM_TABLE_START(debug_driver)
  187.     "debug", "debugging driver",
  188.        DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR,
  189.        DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset,
  190.        DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector,
  191.        DEBUG_linetype, DEBUG_put_text, null_text_angle, 
  192.        DEBUG_justify_text, line_and_point, do_arrow, set_font_null
  193. TERM_TABLE_END(debug_driver)
  194.  
  195. #undef LAST_TERM
  196. #define LAST_TERM debug_driver
  197.  
  198. #endif /* TERM_TABLE */
  199. #endif /* TERM_PROTO_ONLY */
  200.  
  201. /*
  202.  * NAME: debug
  203.  *
  204.  * OPTIONS: none
  205.  *
  206.  * SUPPORTS: test terminal for debugging gnuplot
  207.  *
  208.  * Further Info: Not very usefull for the pure user I suppose.
  209.  *
  210.  */