home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume14 / xascii / part01 next >
Encoding:
Internet Message Format  |  1991-08-27  |  27.3 KB

  1. Path: uunet!cs.utexas.edu!sun-barr!cronkite.Central.Sun.COM!exodus!eng.auburn.edu
  2. From: kkirksey@eng.auburn.edu (Kenneth B. Kirksey)
  3. Newsgroups: comp.sources.x
  4. Subject: v14i022: xascii -- ASCII previewer, Part01/01
  5. Message-ID: <19144@exodus.Eng.Sun.COM>
  6. Date: 28 Aug 91 01:40:49 GMT
  7. Sender: news@exodus.Eng.Sun.COM
  8. Lines: 858
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: Kenneth B. Kirksey <kkirksey@eng.auburn.edu>
  12. Posting-number: Volume 14, Issue 22
  13. Archive-name: xascii/part01
  14.  
  15. +---------------+
  16. Moderator's note:
  17.     "Rogue Monster"?????
  18. +---------------+
  19.  
  20. #!/bin/sh
  21. # to extract, remove the header and type "sh filename"
  22. if `test ! -s ./Imakefile`
  23. then
  24. echo "writing ./Imakefile"
  25. cat > ./Imakefile << '\Rogue\Monster\'
  26. LOCAL_LIBRARIES = XawClientLibs
  27.  
  28. SRCS = xascii.c
  29. OBJS = xascii.o
  30.  
  31. ComplexProgramTarget(xascii)
  32. \Rogue\Monster\
  33. else
  34.   echo "will not over write ./Imakefile"
  35. fi
  36. if `test ! -s ./Makefile`
  37. then
  38. echo "writing ./Makefile"
  39. cat > ./Makefile << '\Rogue\Monster\'
  40.  xascii: xascii.o 
  41.     cc xascii.o -lXaw -lXmu -lXt -lX11 -o xascii
  42.  
  43.  xascii.o: xascii.c xascii.h
  44.     cc -c xascii.c
  45.  
  46.  
  47. \Rogue\Monster\
  48. else
  49.   echo "will not over write ./Makefile"
  50. fi
  51. if `test ! -s ./README`
  52. then
  53. echo "writing ./README"
  54. cat > ./README << '\Rogue\Monster\'
  55. WHY XASCII?
  56.  
  57.     I wrote this one because I got fed up with having to look up the ascii
  58. man page every time I wanted a charater value.  It`s a neat little handy
  59. reference to have on your desktop.  A couple of instructors here have even
  60. taken to using it in their labs.
  61.  
  62.  
  63. DISTRIBUTION
  64.     
  65.     XAscii is distributed under the happiware system.  If you use Xascii and
  66. like it, send me e-mail and let me know.
  67.  
  68.  
  69. SUPPORT & COPYRIGHT
  70.     
  71.     XAscii is distrubuted as is and is only guaranteed to take up space on
  72. your disk.  It is provided without warranty, either express or implied,
  73. for any purpose whatsoever.  I am not liable for any loss or damages arising
  74. from the use or possession of Xascii.
  75.  
  76.     XAscii is free, but copyright is held by the author. You may distribute
  77. Xascii freely under the following conditions:
  78.  
  79.         1) All files from the original distribution (including this Readme)
  80.            are included.
  81.  
  82.         2) No modifications have been made to any of the files in said
  83.            distribution
  84.  
  85.     If you find anything wrong with Xascii, let me know, but I can't promise to
  86. do anything about it.  I'm graduating next quarter and am going to be quite 
  87. busy until then.
  88.  
  89.  
  90. BUGS
  91.  
  92.     None that I know of.
  93.  
  94. An OLIT Version?
  95.  
  96.     If anyone is interested in seeing an OLIT 2.5 version of XAscii, send
  97. me email.  If enough people are interested, I'll take a day off and 
  98. crank one out.
  99.  
  100.  
  101. Ken Kirksey
  102. Internet:  kkirksey@eng.auburn.edu
  103. Fidonet:   3613/13.4
  104. AOL:       kkirksey1
  105. \Rogue\Monster\
  106. else
  107.   echo "will not over write ./README"
  108. fi
  109. if `test ! -s ./XAscii`
  110. then
  111. echo "writing ./XAscii"
  112. cat > ./XAscii << '\Rogue\Monster\'
  113.  
  114. !------------------------------------------------------------------------------
  115. ! Background Color    
  116. !------------------------------------------------------------------------------
  117. XAscii*background:              #cccccc
  118.  
  119. !------------------------------------------------------------------------------
  120. ! Highlight Color   
  121. !------------------------------------------------------------------------------
  122. XAscii*highlightColor:          red
  123.  
  124. !------------------------------------------------------------------------------
  125. ! Value Display Font   
  126. !------------------------------------------------------------------------------
  127. XAscii*valueFont:               -*-courier-bold-r-*-*-*-120-*-*-*-*-*-*
  128. \Rogue\Monster\
  129. else
  130.   echo "will not over write ./XAscii"
  131. fi
  132. if `test ! -s ./patchlevel.h`
  133. then
  134. echo "writing ./patchlevel.h"
  135. cat > ./patchlevel.h << '\Rogue\Monster\'
  136. #define PATCHLEVEL 1
  137. \Rogue\Monster\
  138. else
  139.   echo "will not over write ./patchlevel.h"
  140. fi
  141. if `test ! -s ./xascii.1`
  142. then
  143. echo "writing ./xascii.1"
  144. cat > ./xascii.1 << '\Rogue\Monster\'
  145. .TH XASCII 1 "Release 4" "X Version 11"
  146. .SH NAME
  147. xascii - ascii character set table for X
  148. .SH SYNOPSIS
  149. .ta 8n
  150. \fBxascii\fP    [-option]
  151. .br
  152. .SH DESCRIPTION
  153. The
  154. .I xascii 
  155. program displays the complete ascii character set along with each character's
  156. value in either decimal, hexidecimal, or octal notation.
  157. .SH OPTIONS
  158. .I Xascii
  159. accepts all of the standard X Toolkit command line options along with the 
  160. additional options listed below:
  161. .TP 8
  162. .B \-hc \fIcolor\fP
  163. This option specifies the color that the title, values, and buttons will
  164. be displayed in.  The default is \fIred\fP.
  165. .TP 8
  166. .B \-vf \fIfont\fP
  167. This option specifies the font that the ascii characters and their values
  168. will be displayed in.  The default is \fIcourier\fP.
  169. .SH RESOURCES
  170. .PP
  171. Application specific resources (see app defaults file for more info):
  172. .PP
  173. .TP 8
  174. .B "highlightColor"
  175. Specifies the color that the title, values, and buttons will be displayed in.
  176. .TP 8
  177. .B "valueFont"
  178. Specifies the font that the ASCII characters and their values will be displayed
  179. in.
  180. .PP
  181. .SH BUGS
  182. .PP
  183. None that I know of
  184. .PP
  185. .SH COPYRIGHT
  186. Copyright 1991, Ken Kirksey.
  187. .br
  188. .SH AUTHOR
  189. Ken Kirksey (Auburn University)
  190. .br
  191. Internet: kkirksey@eng.auburn.edu
  192. .br
  193. FidoNet: 3613/13.4 
  194. \Rogue\Monster\
  195. else
  196.   echo "will not over write ./xascii.1"
  197. fi
  198. if `test ! -s ./xascii.c`
  199. then
  200. echo "writing ./xascii.c"
  201. cat > ./xascii.c << '\Rogue\Monster\'
  202. /*****************************************************************************
  203. * XAscii                                                      by Ken Kirksey *
  204. *                                                                            *
  205. * XAscii displays a table of ascii characters and their respective values.   *
  206. * The user choses which format the values are displayed in:  either hex,     *
  207. * decimal or octal.                                                          *
  208. *                                                                            *
  209. * BASICALLY THE WAY IT WORKS                                                 *
  210. *        In xascii.h four static arrays of strings are declared, one for      *
  211. *       ascii characters, one for decimal values, one for hex values and one *
  212. *        for octal values.  Each of these are broken up into five separate    *
  213. *        strings, each of which make up a column (label widget) in the xascii *
  214. *        window.  The ascii value columns remain static, they never change.   *
  215. *        The label widgets that hold the values, however, change whenever the *
  216. *        user changes the notational mode (clicks on the dec ,hex, or octal   *
  217. *       button).  What happens when one of these buttons is clicked is that  *
  218. *       an XtVaSetValues is done on the value label widgets to change their  *
  219. *        label resource to display the values in the notation specified by the*
  220. *        button press.                                                        *
  221. *                                                                            *
  222. * Send all kudos, complaints, suggestions, or bug reports to:                *
  223. *        Ken Kirksey  (kkirksey@eng.auburn.edu)                               *
  224. *                                                                            *
  225. * BTW:  I use 4 column tabs for coding, so if your text editor isn't set for *
  226. *         4 column tabs, this program probably looks really funny.             *
  227. *                                                                               *
  228. ******************************************************************************
  229. * Version 1.1                                                       5 Aug 91 *
  230. *                                                                            *
  231. *  Removed the #include <strings.h> as this was a portability no-no.         *
  232. *  Added an Imakefile (courtesy of Dave Elliot) to the release archive.      *   *                                                                               *
  233. ******************************************************************************
  234. * Version 1.2                                                       6 Aug 91 *
  235. *                                                                            *
  236. * Fixed the problem that was causing my use of the valueFont resource to     *
  237. * kill the program.  The bug was pointed out by Dave Brooks.                 *
  238. *                                                                               *
  239. *****************************************************************************/                                                                           
  240.  
  241. #include <stdio.h>
  242. #include <stdlib.h>
  243. #include <X11/Intrinsic.h>
  244. #include <X11/Shell.h>
  245. #include <X11/Xos.h>
  246. #include <X11/StringDefs.h>
  247. #include <X11/Xaw/Command.h>
  248. #include <X11/Xaw/Toggle.h>
  249. #include <X11/Xaw/Label.h>    
  250. #include <X11/Xaw/Form.h>
  251. #include "xascii.h"
  252.  
  253. /*===========================================================================+
  254. | Function Declarations                                                      |
  255. +===========================================================================*/
  256. static void Quit(),                    /* Callbacks                            */
  257.             ToHex(),
  258.             ToDec(),
  259.             ToOct(),
  260.             Done(),
  261.  
  262.             AboutXascii(),            /* Actions                                */
  263.  
  264.             Syntax();                /* Utilitie                                */
  265.  
  266.  
  267. /*===========================================================================+
  268. | Global Variable Declarations                                               |
  269. +===========================================================================*/
  270.  
  271. static XtAppContext appl_context;
  272.  
  273. static XtActionsRec about_box[]= {
  274.         {"about_xascii", AboutXascii},
  275. };
  276.  
  277. static Widget     toplevel,
  278.                 base_win,
  279.                 title_label,
  280.                 quit_button,
  281.                 toggles[3],
  282.                 ascii_list[6],
  283.                 value_list[6],
  284.                 pshell,
  285.                 about_base_win,
  286.                 about_label,
  287.                 done_button;
  288.  
  289. char        **hex_columns,
  290.             **decimal_columns,
  291.             **octal_columns,
  292.             **ascii_columns;
  293.  
  294. /*===========================================================================+
  295. | MAIN                                                                       | +===========================================================================*/
  296. main (argc,argv)
  297.     int     argc; 
  298.     char     ** argv;
  299. {
  300.     int        i, j;
  301.  
  302. /*---------------------------------------------------------------------------+
  303. | Break up the Ascii table and values into separate columns (22 rows, 6 cols)|
  304. | for display.                                                               |
  305. +---------------------------------------------------------------------------*/
  306.     ascii_columns = (char **)XtCalloc (6, sizeof (char *));
  307.     hex_columns = (char **) XtCalloc (6, sizeof (char *));
  308.     decimal_columns = (char **) XtCalloc (6, sizeof (char *));
  309.     octal_columns = (char **) XtCalloc (6, sizeof (char *));
  310.  
  311.     for (i=0; i<6; i++)
  312.     {
  313.         ascii_columns[i] = (char *)  XtCalloc (90, sizeof (char));
  314.         hex_columns[i] = (char *)  XtCalloc (90, sizeof (char));
  315.         decimal_columns[i] = (char *)  XtCalloc (90, sizeof (char));
  316.         octal_columns[i] = (char *)  XtCalloc (90, sizeof (char));
  317.     
  318.         for (j= (i*22); j < ((i+1) * 22); j++)
  319.         {
  320.             strcat (ascii_columns[i], ascii_values[j]);
  321.             strcat (ascii_columns[i], "\n");
  322.  
  323.             strcat (hex_columns[i], hex_values[j]);
  324.             strcat (hex_columns[i], "\n");
  325.  
  326.             strcat (decimal_columns[i], decimal_values[j]);
  327.             strcat (decimal_columns[i], "\n");
  328.  
  329.             strcat (octal_columns[i], octal_values[j]);
  330.             strcat (octal_columns[i], "\n");
  331.         }
  332.     }
  333.  
  334.     /*-----------------------------------------------------------------------+
  335.     | Begin Widget Initialization.                                           |
  336.     +-----------------------------------------------------------------------*/     
  337.     toplevel = XtAppInitialize(
  338.                     &appl_context,
  339.                     "XAscii",
  340.                     options,
  341.                     XtNumber(options),
  342.                     &argc,argv,NULL, NULL,0);
  343.  
  344.     /*-----------------------------------------------------------------------+
  345.     | Check for Invalid command line options                                 |
  346.     +-----------------------------------------------------------------------*/
  347.     if (argc > 1)
  348.         Syntax (argc, argv);
  349.  
  350.     XtVaGetApplicationResources (toplevel,
  351.                     &app_data,
  352.                     resources,
  353.                     XtNumber (resources),
  354.                     NULL);
  355.  
  356.     base_win = XtVaCreateManagedWidget(
  357.                     "base_win", 
  358.                     formWidgetClass, 
  359.                     toplevel,
  360.                     NULL, 0);
  361.  
  362.     /*----------------------------------------------------------------------+
  363.     |  Note the translation that invokes that about box pop up on a button  |
  364.     |  click in this label widget.                                          |
  365.     +----------------------------------------------------------------------*/
  366.     title_label    = XtVaCreateManagedWidget (
  367.                     "title_label",
  368.                     labelWidgetClass,
  369.                     base_win,
  370.                         XtNforeground, app_data.highlight_color,
  371.                         XtNlabel, "X ASCII Chart",
  372.                         XtNwidth, 408,
  373.                         XtNtranslations, XtParseTranslationTable             
  374.                             (defaultTranslations),
  375.                         XtVaTypedArg,
  376.                             XtNbackground,
  377.                             XtRString,
  378.                             white_bg,
  379.                             sizeof (white_bg),
  380.                         XtVaTypedArg,
  381.                             XtNfont,
  382.                             XtRString,
  383.                             title_font,
  384.                             sizeof (title_font),
  385.                     NULL, 0);
  386.  
  387.     /*-----------------------------------------------------------------------+
  388.     |Create the label widgets for chart display. Default value mode is dec.  |
  389.     +-----------------------------------------------------------------------*/
  390.     for (i=0; i<6;  i++)
  391.     {
  392.         value_list[i] = XtVaCreateManagedWidget(
  393.                         "value_list",
  394.                         labelWidgetClass,
  395.                         base_win,
  396.                             XtNforeground, app_data.highlight_color,
  397.                             XtNfont, app_data.value_font,  
  398.                             XtNfromVert, title_label, 
  399.                             XtNlabel, decimal_columns[i],
  400.                             XtNhorizDistance, 10,
  401.                             XtNborderWidth, 0,
  402.                             XtNvertDistance, 10,
  403.                             XtVaTypedArg,
  404.                                 XtNbackground,
  405.                                 XtRString,
  406.                                 white_bg,
  407.                                 sizeof (white_bg),
  408.  
  409.                         NULL);
  410.  
  411.         ascii_list[i] = XtVaCreateManagedWidget(
  412.                         "ascii_list",
  413.                         labelWidgetClass,
  414.                         base_win,
  415.                             XtNfont, app_data.value_font,  
  416.                             XtNfromVert, title_label, 
  417.                             XtNlabel, ascii_columns[i],
  418.                             XtNfromHoriz, value_list[i],
  419.                             XtNborderWidth, 0,
  420.                             XtNvertDistance, 10,
  421.                             XtNhorizDistance, 0,
  422.                             XtVaTypedArg,
  423.                                 XtNbackground,
  424.                                 XtRString,
  425.                                 white_bg,
  426.                                 sizeof (white_bg),
  427.  
  428.                         NULL);
  429.  
  430.     }
  431.         
  432.     for (i=1; i<6; i++)
  433.         XtVaSetValues (value_list[i], XtNfromHoriz, ascii_list[i-1], NULL);                
  434.     /*-----------------------------------------------------------------------+
  435.     | Create the buttons for value mode selection.  Make them a radio group, |
  436.     | so that only one will be selected (highlighted) at a time.             |
  437.     +-----------------------------------------------------------------------*/
  438.     for (i=0; i<3; i++)
  439.     {
  440.         toggles[i] = XtVaCreateManagedWidget (
  441.                     "toggle", 
  442.                     toggleWidgetClass, 
  443.                     base_win,
  444.                         XtNforeground, app_data.highlight_color,
  445.                         XtNborderColor, app_data.highlight_color,
  446.                         XtNfromVert, ascii_list[0],
  447.                         XtNvertDistance, 15,
  448.                         XtNwidth, 95,
  449.                         XtNresize, FALSE,
  450.                         XtNhorizDistance, 30,
  451.                         XtVaTypedArg,
  452.                             XtNbackground,
  453.                             XtRString,
  454.                             white_bg,
  455.                             sizeof (white_bg),
  456.  
  457.                     NULL, 0);
  458.  
  459.         if (i != 0)
  460.             XtVaSetValues(toggles[i], XtNfromHoriz, toggles[i-1], NULL);
  461.  
  462.         XtVaSetValues (toggles[i], XtNradioGroup, toggles[0], NULL);
  463.     }
  464.  
  465.     XtVaSetValues (toggles[0],
  466.                     XtNlabel,    "Hex",
  467.                     XtNhorizDistance, 0,
  468.                     XtNfromHoriz, value_list[0],
  469.                     NULL);
  470.  
  471.     XtVaSetValues (toggles[1],
  472.                     XtNstate, TRUE,
  473.                     XtNlabel, "Decimal", 
  474.                     NULL);
  475.  
  476.     XtVaSetValues (toggles[2],
  477.                     XtNlabel,    "Octal",
  478.                     NULL);
  479.  
  480.     XtAddCallback (toggles[0], XtNcallback, ToHex, NULL); 
  481.     XtAddCallback (toggles[1], XtNcallback, ToDec, NULL);
  482.      XtAddCallback (toggles[2], XtNcallback, ToOct, NULL); 
  483.  
  484.     
  485.     quit_button = XtVaCreateManagedWidget (
  486.                     "quit_button", 
  487.                     commandWidgetClass, 
  488.                     base_win,
  489.                         XtNfromVert, toggles[0],
  490.                         XtNfromHoriz, ascii_list[0],
  491.                         XtNlabel, "Quit",
  492.                         XtNwidth, 100,
  493.                         XtNvertDistance, 15,
  494.                         XtNhorizDistance, 95,
  495.                         XtVaTypedArg,
  496.                             XtNbackground,
  497.                             XtRString,
  498.                             white_bg,
  499.                             sizeof (white_bg),
  500.  
  501.                     NULL, 0);
  502.  
  503.     XtAddCallback (quit_button, XtNcallback, Quit, NULL);
  504.  
  505.     /*-----------------------------------------------------------------------+
  506.     | Create the About Box.  Invoked on click in title label.                |
  507.     +-----------------------------------------------------------------------*/
  508.     pshell = XtVaCreatePopupShell (
  509.                     "pshell",
  510.                     transientShellWidgetClass,
  511.                     toplevel,
  512.                     NULL);
  513.  
  514.     about_base_win = XtVaCreateManagedWidget(
  515.                     "about_base_win",
  516.                     formWidgetClass,
  517.                     pshell,
  518.  
  519.                     NULL);
  520.  
  521.     about_label = XtVaCreateManagedWidget(
  522.                     "about_label",
  523.                     labelWidgetClass,
  524.                     about_base_win,
  525.                         XtVaTypedArg,
  526.                             XtNbackground,
  527.                             XtRString,
  528.                             white_bg,
  529.                             sizeof (white_bg),
  530.                         XtNlabel, about_text,
  531.                         XtNforeground, app_data.highlight_color,
  532.                         XtNborderColor, app_data.highlight_color,
  533.                         XtNborderWidth, 4,
  534.                     NULL);
  535.  
  536.     done_button = XtVaCreateManagedWidget(
  537.                     "done_button",
  538.                     commandWidgetClass,
  539.                     about_base_win,
  540.                         XtVaTypedArg,
  541.                             XtNbackground,
  542.                             XtRString,
  543.                             white_bg,
  544.                             sizeof (white_bg),
  545.                         XtNfromVert, about_label,
  546.                         XtNvertDistance, 10,
  547.                         XtNhorizDistance, 165,
  548.                         XtNlabel, "Slainte!",
  549.                     NULL);
  550.  
  551.     XtAddCallback (done_button, XtNcallback, Done, NULL);
  552.  
  553.     XtAppAddActions (appl_context, about_box, XtNumber(about_box) );
  554.  
  555.      XtRealizeWidget(toplevel);
  556.      XtAppMainLoop(appl_context);
  557. }
  558.  
  559. /*===========================================================================+
  560. | CALLBACK FUNCTIONS                                                          | +===========================================================================*/
  561.  
  562. /*---------------------------------------------------------------------------+
  563. | Quit                                                                       |
  564. |         Quit the application.  Invoked by click on quit button.              |
  565. +---------------------------------------------------------------------------*/     static void Quit (w,ignore1,ignore2)
  566. Widget w; XtPointer ignore1, ignore2;
  567. {   XtDestroyApplicationContext(appl_context);
  568.     exit(0);
  569. }
  570.  
  571. /*---------------------------------------------------------------------------+
  572. | ToHex                                                                      |
  573. |         Changes the ascii character values to Hex notation.                  |
  574. +---------------------------------------------------------------------------*/  
  575. static void ToHex (w,ignore1,ignore2)
  576. Widget w; XtPointer ignore1, ignore2;
  577.   int i;
  578.  
  579.     for (i=0; i<6; i++)
  580.         XtVaSetValues (value_list[i], XtNlabel, hex_columns[i], NULL);
  581.  
  582. }
  583.  
  584.  
  585. /*---------------------------------------------------------------------------+
  586. | ToDec                                                                      |
  587. |         Changes the ascii character values to Decimal notation.              |
  588. +---------------------------------------------------------------------------*/  
  589. static void ToDec (w,ignore1,ignore2)
  590. Widget w; XtPointer ignore1, ignore2;
  591.   int i;
  592.  
  593.     for (i=0; i<6; i++)
  594.         XtVaSetValues (value_list[i], XtNlabel, decimal_columns[i], NULL);
  595.  
  596. }
  597.  
  598.  
  599. /*---------------------------------------------------------------------------+
  600. | ToOct                                                                      |
  601. |         Changest the ascii character values to Octal notation.               |
  602. +---------------------------------------------------------------------------*/  
  603. static void ToOct (w,ignore1,ignore2)
  604. Widget w; XtPointer ignore1, ignore2;
  605.   int i;
  606.  
  607.     for (i=0; i<6; i++)
  608.         XtVaSetValues (value_list[i], XtNlabel, octal_columns[i], NULL);
  609.  
  610. }
  611.  
  612.  
  613. /*---------------------------------------------------------------------------+
  614. | Done                                                                       |
  615. |         Pops down the about box popup shell.                                 |
  616. +---------------------------------------------------------------------------*/  
  617. static void Done (w,ignore1,ignore2)
  618. Widget w; XtPointer ignore1, ignore2;
  619.   int i;
  620.  
  621.     XtPopdown (pshell);
  622. }
  623.  
  624.  
  625. /*===========================================================================+
  626. | ACTION FUNCTIONS                                                               | +===========================================================================*/
  627.  
  628. /*---------------------------------------------------------------------------+
  629. | AboutXascii                                                                |
  630. |             Positions and pops up the about box popup shell.                 |
  631. +---------------------------------------------------------------------------*/  
  632. static void AboutXascii (w, event, nuffin1, nuffin2)
  633. Widget            w;
  634. XButtonEvent    event;
  635. String            *nuffin1;
  636. Cardinal        *nuffin2;
  637. {    
  638.     Position    x, 
  639.                 y;
  640.  
  641.     Dimension    width, 
  642.                 height;
  643.  
  644.     int            i;
  645.  
  646.     XtVaGetValues (toplevel,
  647.             XtNwidth, &width,
  648.             XtNheight, &height,
  649.             NULL);
  650.  
  651.     XtTranslateCoords (toplevel,
  652.             (Position) 0,
  653.             (Position) height/2,
  654.             &x, &y,
  655.             NULL);
  656.  
  657.     XtVaSetValues (pshell,
  658.             XtNx, x,
  659.             XtNy, y,
  660.             NULL);
  661.  
  662.     XtPopup (pshell, XtGrabNonexclusive);
  663. }
  664.  
  665. /*===========================================================================+
  666. | UTILITY FUNCTIONS                                                              | +===========================================================================*/
  667.  
  668. /*---------------------------------------------------------------------------+
  669. | Syntax                                                                     |
  670. |        Parses off bad command line options (i.e. the stuff left over when   |
  671. |         XtVaAppInitialize is through).                                       |
  672. +---------------------------------------------------------------------------*/       static void Syntax (argc, argv)
  673. int     argc;
  674. char    **argv;
  675. {
  676.     int     i,
  677.             err = 0;
  678.  
  679.     for (i=1; i < argc; i++)
  680.     {
  681.         if (!err++)
  682.             fprintf (stderr, "\nxascii: unknown command line option\n");
  683.  
  684.         fprintf (stderr, "option:  %s\n", argv[i]);
  685.     }
  686.  
  687. }
  688.  
  689.         
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701. \Rogue\Monster\
  702. else
  703.   echo "will not over write ./xascii.c"
  704. fi
  705. if `test ! -s ./xascii.h`
  706. then
  707. echo "writing ./xascii.h"
  708. cat > ./xascii.h << '\Rogue\Monster\'
  709. /*****************************************************************************
  710. * Application Resource Definitions                                           *
  711. *****************************************************************************/
  712. #define XtNhighlightColor    "highlightColor"
  713. #define XtCHighlightColor    "HighlightColor"
  714. #define XtNvalueFont        "valueFont"
  715. #define XtCValueFont        "ValueFont"
  716.  
  717. typedef struct 
  718. {
  719.     Pixel            highlight_color;
  720.     XFontStruct        *value_font;
  721. }  AppData, *AppDataPtr;
  722.  
  723. AppData        app_data;
  724.  
  725. static XtResource    resources[] = {
  726.     {
  727.         XtNhighlightColor,
  728.         XtCHighlightColor,
  729.         XtRPixel,
  730.         sizeof (Pixel),
  731.         XtOffset (AppDataPtr, highlight_color),
  732.         XtRString,
  733.         "red"
  734.     },
  735.     {
  736.         XtNvalueFont,
  737.         XtCValueFont,
  738.         XtRFontStruct,
  739.         sizeof (XFontStruct *),
  740.         XtOffset (AppDataPtr, value_font),
  741.         XtRString,
  742.         XtDefaultFont
  743.     },
  744. };
  745.  
  746.  
  747. /****************************************************************************
  748. * Define Command line options.                                              *
  749. ****************************************************************************/
  750. static XrmOptionDescRec     options[] =
  751.  {
  752.     { "-hc",            "*highlightColor",    XrmoptionSepArg, NULL},
  753.     { "-highlight",        "*highlightColor",    XrmoptionSepArg, NULL},
  754.     { "-vf",            "*valueFont",        XrmoptionSepArg, NULL},
  755. };
  756.  
  757.  
  758. /****************************************************************************
  759. * String Constants.                                                         *
  760. ****************************************************************************/
  761. static char white_bg [] = "white";
  762. static char grey_bg  [] = "#cccccc";
  763.  
  764. static char title_font[] = "-*-helvetica-bold-r-*-*-14-140-*-*-*-*-*-*";
  765.  
  766. static char about_text [] =
  767. "X Ascii Chart                            by Ken Kirksey\n\
  768.                                          Auburn University\n\n\
  769.             An Exercise in Procrastination\n\
  770.   \"I shoulda been working on my senior design project\"\n\
  771.                      March 26, 1991";
  772.  
  773. static char defaultTranslations [] = "#override\n\
  774.     <Btn1Down>:                about_xascii()";
  775.  
  776.  
  777. /*****************************************************************************
  778. * Translation Data                                                           *
  779. *****************************************************************************/
  780. char *ascii_values[132] =
  781. {
  782. "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
  783. "BS ", "HT ", "LF ", "VT ", "FF ", "CR ", "SO ", "SI ",
  784. "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYC", "ETB",
  785. "CAN", "EM ", "SUB", "ESC", "FS ", "GS ", "RS ", "US ",
  786. "SPA", "!  ", "\"  ", "#  ", "$  ", "%  ", "&  ", "'  ",
  787. "(  ", ")  ", "*  ", "+  ", ",  ", "-  ", ".  ", "/  ",
  788. "0  ", "1  ", "2  ", "3  ", "4  ", "5  ", "6  ", "7  ",
  789. "8  ", "9  ", ":  ", ";  ", "<  ", "=  ", ">  ", "?  ",
  790. "@  ", "A  ", "B  ", "C  ", "D  ", "E  ", "F  ", "G  ",
  791. "H  ", "I  ", "J  ", "K  ", "L  ", "M  ", "N  ", "O  ",
  792. "P  ", "Q  ", "R  ", "S  ", "T  ", "U  ", "V  ", "W  ",
  793. "X  ", "Y  ", "Z  ", "[  ", "\\  ", "]  ", "^  ", "_  ",
  794. "`  ", "a  ", "b  ", "c  ", "d  ", "e  ", "f  ", "g  ",
  795. "h  ", "i  ", "j  ", "k  ", "l  ", "m  ", "n  ", "o  ",
  796. "p  ", "q  ", "r  ", "s  ", "t  ", "u  ", "v  ", "w  ",
  797. "x  ", "y  ", "z  ", "{  ", "|  ", "}  ", "~  ", "DEL",
  798. "   ", "   ", "   ", "   "                           
  799. },    
  800.  
  801.  
  802. *octal_values[132] =
  803. {    
  804. "000", "001", "002", "003", "004", "005", "006", "007",    
  805. "010", "011", "012", "013", "014", "015", "016", "017",    
  806. "020", "021", "022", "023", "024", "025", "026", "027",
  807. "030", "031", "032", "033", "034", "035", "036", "037",
  808. "040", "041", "042", "043", "044", "045", "046", "047",
  809. "050", "051", "052", "053", "054", "055", "056", "057",
  810. "060", "061", "062", "063", "064", "065", "066", "067",
  811. "070", "071", "072", "073", "074", "075", "076", "077",
  812. "100", "101", "102", "103", "104", "105", "106", "107",
  813. "110", "111", "112", "113", "114", "115", "116", "117",
  814. "120", "121", "122", "123", "124", "125", "126", "127",
  815. "130", "131", "132", "133", "134", "135", "136", "137",
  816. "140", "141", "142", "143", "144", "145", "146", "147",
  817. "150", "151", "152", "153", "154", "155", "156", "157",
  818. "160", "161", "162", "163", "164", "165", "166", "167",
  819. "170", "171", "172", "173", "174", "175", "176", "177",
  820.         "   ", "   ", "   ", "   "
  821. },
  822.  
  823. *hex_values [132] = 
  824. {
  825. "00","01","02","03","04","05","06","07","08","09","0A","0B","0C","0D","0E","0F",
  826. "10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F",
  827. "20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F",
  828. "30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F",
  829. "40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F",
  830. "50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F",
  831. "60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F",
  832. "70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F",
  833. "  ", "  ", "  ", "  "
  834. },
  835.  
  836. *decimal_values [132] =
  837. {
  838. "000", "001", "002", "003", "004", "005", "006", "007", "008", "009",
  839. "010", "011", "012", "013", "014", "015", "016", "017", "018", "019",
  840. "020", "021", "022", "023", "024", "025", "026", "027", "028", "029",
  841. "030", "031", "032", "033", "034", "035", "036", "037", "038", "039",
  842. "040", "041", "042", "043", "044", "045", "046", "047", "048", "049",
  843. "050", "051", "052", "053", "054", "055", "056", "057", "058", "059",
  844. "060", "061", "062", "063", "064", "065", "066", "067", "068", "069",
  845. "070", "071", "072", "073", "074", "075", "076", "077", "078", "079",
  846. "080", "081", "082", "083", "084", "085", "086", "087", "088", "089",
  847. "090", "091", "092", "093", "094", "095", "096", "097", "098", "099",
  848. "100", "101", "102", "103", "104", "105", "106", "107", "108", "109",
  849. "110", "111", "112", "113", "114", "115", "116", "117", "118", "119",
  850. "120", "121", "122", "123", "124", "125", "126", "127", "   ", "   ",
  851. "   ", "   "
  852. };
  853. \Rogue\Monster\
  854. else
  855.   echo "will not over write ./xascii.h"
  856. fi
  857. echo "Finished archive 1 of 1"
  858. exit
  859.  
  860. --
  861. Dan Heller
  862. O'Reilly && Associates       Z-Code Software    Comp-sources-x:
  863. Senior Writer                President          comp-sources-x@uunet.uu.net
  864. argv@ora.com                 argv@zipcode.com
  865.