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