home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / wxwin140 / utils / wxhelp / src / tex2any.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  4.5 KB  |  162 lines

  1. /*
  2.  * File:     tex2any.h
  3.  * Purpose:  Header file for LaTeX --> wxHelp conversion
  4.  *
  5.  *                       wxWindows 1.40
  6.  * Copyright (c) 1993 Artificial Intelligence Applications Institute,
  7.  *                   The University of Edinburgh
  8.  *
  9.  *                     Author: Julian Smart
  10.  *                        Date: 18-4-93
  11.  *
  12.  * Permission to use, copy, modify, and distribute this software and its
  13.  * documentation for any purpose is hereby granted without fee, provided
  14.  * that the above copyright notice, author statement and this permission
  15.  * notice appear in all copies of this software and related documentation.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
  18.  * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
  19.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
  22.  * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
  23.  * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
  24.  * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
  25.  * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
  26.  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include "wx.h"
  31. #include "wx_utils.h"
  32. #include "wx_list.h"
  33.  
  34. /*
  35.  * We have a list of macro definitions which we must define
  36.  * in advance to enable the parsing to recognize macros.
  37.  */
  38.  
  39. class TexMacroDef: public wxObject
  40. {
  41.  public:
  42.   int no_args;
  43.   char *name;
  44.   Bool ignore;
  45.   Bool consume_space;
  46.  
  47.   TexMacroDef(char *the_name, int n, Bool ig, Bool consumeSpace = FALSE);
  48.   ~TexMacroDef(void);
  49. };
  50.  
  51. #define CHUNK_TYPE_MACRO    1
  52. #define CHUNK_TYPE_ARG      2
  53. #define CHUNK_TYPE_STRING   3
  54.  
  55. /*
  56.  We have nested lists to represent the Tex document.
  57.  Each element of a list of chunks can be one of:
  58.   - a plain string
  59.   - a macro with/without arguments. Arguments are lists of TexChunks.
  60.  
  61. Example (\toplevel is implicit but made explicit here):
  62.  
  63. AddMacroDef("mymat", 2);
  64.  
  65. \toplevel{The cat sat on the \mymat{very coarse and {\it cheap}}{mat}}.
  66.  
  67. Parsed as:
  68.  
  69. TexChunk: type = macro, name = toplevel, no_args = 1
  70.   Children:
  71.  
  72.     TexChunk: type = argument
  73.  
  74.       Children:
  75.         TexChunk: type = string, value = "The cat sat on the "
  76.         TexChunk: type = macro, name = mymat, no_args = 2
  77.  
  78.           Children:
  79.             TexChunk: type = argument
  80.  
  81.               Children:
  82.                 TexChunk: type = string, value = "very coarse and "
  83.                 TexChunk: type = macro, name = it, no_args = 1
  84.  
  85.                   Children:
  86.                     TexChunk: type = argument
  87.  
  88.                       Children:
  89.                         TexChunk: type = string, value = "cheap"
  90.  
  91.             TexChunk: type = argument
  92.  
  93.               Children:
  94.                 TexChunk: type = string, value = mat
  95.  */
  96.  
  97. class TexChunk: public wxObject
  98. {
  99.  public:
  100.   int type;
  101.   char *name;
  102.   char *value;
  103.   int no_args;
  104.   int argn;
  105.   wxList children;
  106.   TexChunk(int the_type);
  107.   ~TexChunk(void);
  108. };
  109.  
  110. extern TexChunk *TopLevel;
  111.  
  112. Bool read_a_line(FILE *fd, char *buf);
  113. Bool TexLoadFile(char *filename);
  114. int ParseArg(wxList& children, char *buffer, int pos, char *environment = NULL);
  115. int ParseMacroBody(char *macro_name, wxList& children, int no_args,
  116.                    char *buffer, int pos, char *environment = NULL);
  117. void TraverseDocument(void);
  118. void TraverseDocument1(TexChunk *chunk);
  119. void SetCurrentOutput(FILE *fd);
  120. void SetCurrentOutputs(FILE *fd1, FILE *fd2);
  121. void AddMacroDef(char *name, int n, Bool ignore = FALSE, Bool consume_space = FALSE);
  122. void TexInitialize(void);
  123. void TexOutput(char *s);
  124.  
  125. /*
  126.  * Client-defined
  127.  *
  128.  */
  129.  
  130. // Called on start/end of macro examination
  131. void OnMacro(char *name, int no_args, Bool start);
  132.  
  133. // Called on start/end of argument examination
  134. void OnArgument(char *macro_name, int arg_no, Bool start);
  135.  
  136. /*
  137. #define hyBLOCK_NORMAL   1
  138. #define hyBLOCK_RED      2
  139. #define hyBLOCK_BLUE     3
  140. #define hyBLOCK_GREEN    4
  141. #define hyBLOCK_LARGE_HEADING 5
  142. #define hyBLOCK_SMALL_HEADING 6
  143. #define hyBLOCK_ITALIC   7
  144. #define hyBLOCK_BOLD     8
  145. #define hyBLOCK_INVISIBLE_SECTION 9
  146. #define hyBLOCK_LARGE_VISIBLE_SECTION 10
  147. #define hyBLOCK_SMALL_VISIBLE_SECTION 11
  148. #define hyBLOCK_SMALL_TEXT 12
  149. #define hyBLOCK_RED_ITALIC 13
  150. */
  151.  
  152. #define BLOCK_LARGE_SECTION 10
  153. #define BLOCK_SMALL_SECTION 11
  154. #define BLOCK_LARGE_HEADING 5
  155. #define BLOCK_SMALL_HEADING 6
  156. #define BLOCK_RED_ITALIC    13
  157. #define BLOCK_RED           2
  158. #define BLOCK_ITALIC        7
  159. #define BLOCK_BOLD          8
  160. #define BLOCK_TELETYPE      14
  161.  
  162.