home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / LaTeX.h < prev    next >
C/C++ Source or Header  |  1998-04-23  |  4KB  |  236 lines

  1. // -*- C++ -*-
  2. /* This file is part of
  3.  * ======================================================
  4.  * 
  5.  *           LyX, The Document Processor      
  6.  *         Copyright (C) 1995 Matthias Ettrich
  7.  *
  8.  *           This file is Copyright (C) 1996-1998
  9.  *           Lars Gullik Bj°nnes
  10.  *
  11.  *======================================================
  12.  */
  13.  
  14. #ifndef _LATEX_H
  15. #define _LATEX_H
  16.  
  17. #ifdef __GNUG__
  18. #pragma interface
  19. #endif
  20.  
  21. #include "LString.h"
  22. #include "DepTable.h"
  23.  
  24. class LyXLex;
  25. class MiniBuffer;
  26.  
  27. ///
  28. class TeXErrors {
  29. public:
  30.     ///
  31.     TeXErrors() {
  32.         errors = NULL;
  33.         next_error = NULL;
  34.         status = 0;
  35.         number_of_errors = 0;
  36.     }
  37.     ///
  38.     ~TeXErrors(); 
  39.     ///
  40.     void scanError(LyXLex &);
  41.     ///
  42.     bool getFirstError(int *line, LString *text);
  43.     ///
  44.     bool getNextError(int *line, LString *text);
  45.     ///
  46.     void insertError(int line, LString const &error_desc,
  47.              LString const &error_text);
  48.     ///
  49.     void printErrors();
  50.     ///
  51.     void printWarnings();
  52.     ///
  53.     void printStatus();
  54.     ///
  55.     int getStatus() { return status; }
  56. private:
  57.     ///
  58.     friend class LaTeX;
  59.     ///
  60.     int status;
  61.     ///
  62.     int number_of_errors;
  63.     ///
  64.     struct Error {
  65.         ///
  66.         Error () {
  67.             next_error = NULL;
  68.             error_in_line = 0;
  69.         }
  70.         ///
  71.         Error(int line, LString const &desc, LString const &text) {
  72.             next_error = NULL;
  73.             error_in_line = line;
  74.             error_desc = desc;
  75.             error_text = text;
  76.         }
  77.         ///
  78.         ~Error() {
  79.         }
  80.         ///
  81.         Error *next_error;
  82.         /// what line in the TeX file the error occured in
  83.         int error_in_line;
  84.         /// The kind of error
  85.         LString error_desc;
  86.         /// The line/cmd that caused the error.
  87.         LString error_text;
  88.     };
  89.     ///
  90.     Error *errors;
  91.     ///
  92.     Error *next_error;
  93. };
  94.  
  95.  
  96. ///
  97. class LaTeX {
  98. public:
  99.     /** All the different files produced by TeX.
  100.       
  101.       This is the files mentioned on page 208-9 in Lamports book +
  102.       .ltx and .tex files.
  103.      */
  104.     enum TEX_FILES {
  105.         ///
  106.         NO_FILES = 0,
  107.         /// used for table of contents et.al.
  108.         AUX = 1,
  109.         /// written by BibTeX
  110.         BBL = 2,
  111.         /// LaTeX's output
  112.         DVI = 4,
  113.         /// glossary (not supported by LyX so far)
  114.         GLO = 8,
  115.         ///index
  116.         IDX = 16,
  117.         /// written by makeindex
  118.         IND = 32,
  119.         /// list of figures
  120.         LOF = 64,
  121.         /// the LaTeX log file
  122.         LOG = 128,
  123.         /// list of tables
  124.         LOT = 256,
  125.         /// table of contents
  126.         TOC = 512,
  127.         /// latex files
  128.         LTX = 1024,
  129.         /// tex files
  130.         TEX = 2048,
  131.         /// list of algorithms
  132.         LOA = 4096
  133.     };
  134.     
  135.     /** Return values from scanLogFile() and run() (to come)
  136.  
  137.       This enum should be enlarged a bit so that one could
  138.       get more feedback from the LaTeX run.
  139.       */
  140.     enum log_status {
  141.         ///
  142.         NO_ERRORS = 0,
  143.         ///
  144.         NO_LOGFILE = 1,
  145.         ///
  146.         NO_OUTPUT = 2,
  147.         ///
  148.         UNDEF_REF = 4, // Reference '...' on page ... undefined.
  149.         ///
  150.         UNDEF_CIT = 8, // Citation '...' on page ... undefined.
  151.         ///
  152.         RERUN = 16, // Label(s) may have changed. Rerun to get...
  153.         ///
  154.         TEX_ERROR = 32,
  155.         ///
  156.         TEX_WARNING = 64,
  157.         ///
  158.         LATEX_ERROR = 128,
  159.         ///
  160.         LATEX_WARNING = 256,
  161.         ///
  162.         PACKAGE_WARNING = 512,
  163.         ///
  164.         NO_FILE = 1024,
  165.         ///
  166.         NO_CHANGE = 2048,
  167.         ///
  168.         ERRORS = TEX_ERROR + LATEX_ERROR,
  169.         ///
  170.         WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
  171.     };
  172.     
  173.  
  174.     /**
  175.       cmd = the latex command, file = name of the (temporary) latex file,
  176.       path = name of the files original path.
  177.       */
  178.     LaTeX(LString const & cmd, LString const & file, LString const & path);
  179.     
  180.     /// runs LaTeX several times
  181.     int run(TeXErrors &, MiniBuffer *);
  182.  
  183.     ///
  184.     int getNumErrors() { return num_errors;}
  185.  
  186.     /// use this for running LaTeX once
  187.     int operator() ();
  188. private:
  189.     /** The dependency file.
  190.       
  191.       We store the file dependencies in this file.
  192.       the depency file is on the format:
  193.       <file> <new checksum> <old checksum>
  194.       */
  195.     LString depfile;
  196.  
  197.     ///
  198.     LaTeX(){;}
  199.     
  200.     ///
  201.     LaTeX(const LaTeX&){;}
  202.     
  203.     ///
  204.     void deplog(DepTable &head);
  205.     ///
  206.     void deptex(DepTable &head);
  207.     
  208.     ///
  209.     int scanLogFile(TeXErrors &);
  210.  
  211.     ///
  212.     bool runMakeIndex(LString const &);
  213.  
  214.     ///
  215.     bool runBibTeX(LString const &);
  216.     
  217.     ///
  218.     LString cmd;
  219.  
  220.     ///
  221.     LString file;
  222.     
  223.     ///
  224.     LString path;
  225.     ///
  226.     TEX_FILES tex_files;
  227.     
  228.     ///
  229.     int file_count;
  230.  
  231.     // used by scanLogFile
  232.     int num_errors;
  233. };
  234.  
  235. #endif
  236.