]> git.lyx.org Git - lyx.git/blob - src/LaTeX.h
more keyboard/keysym changes
[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         /** Return values from scanLogFile() and run() (to come)
67             
68             This enum should be enlarged a bit so that one could
69             get more feedback from the LaTeX run.
70         */
71         enum log_status {
72                 ///
73                 NO_ERRORS = 0,
74                 ///
75                 NO_LOGFILE = 1,
76                 ///
77                 NO_OUTPUT = 2,
78                 ///
79                 UNDEF_REF = 4, // Reference '...' on page ... undefined.
80                 ///
81                 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
82                 ///
83                 RERUN = 16, // Label(s) may have changed. Rerun to get...
84                 ///
85                 TEX_ERROR = 32,
86                 ///
87                 TEX_WARNING = 64,
88                 ///
89                 LATEX_ERROR = 128,
90                 ///
91                 LATEX_WARNING = 256,
92                 ///
93                 PACKAGE_WARNING = 512,
94                 ///
95                 NO_FILE = 1024,
96                 ///
97                 NO_CHANGE = 2048,
98                 ///
99                 TOO_MANY_ERRORS = 4096,
100                 ///
101                 ERRORS = TEX_ERROR + LATEX_ERROR,
102                 ///
103                 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
104         };
105         
106
107         /**
108            cmd = the latex command, file = name of the (temporary) latex file,
109            path = name of the files original path.
110         */
111         LaTeX(string const & cmd, string const & file, string const & path);
112         
113         /// runs LaTeX several times
114         int run(TeXErrors &, MiniBuffer *);
115
116         ///
117         int getNumErrors() { return num_errors;}
118
119         /// use this for running LaTeX once
120         int operator() ();
121 protected:
122         /// The dependency file.
123         string depfile;
124
125         /// unavail
126         LaTeX(LaTeX const &);
127         /// unavail
128         LaTeX & operator= (LaTeX const &);
129         
130         ///
131         void deplog(DepTable & head);
132
133         ///
134         int scanLogFile(TeXErrors &);
135
136         ///
137         bool runMakeIndex(string const &);
138
139         ///
140         bool scanAux(DepTable &);
141         
142         ///
143         bool runBibTeX(string const &, DepTable &);
144
145         ///
146         void deleteFilesOnError() const;
147         
148         ///
149         string cmd;
150
151         ///
152         string file;
153         
154         ///
155         string path;
156
157         /// used by scanLogFile
158         int num_errors;
159 };
160
161 #endif