]> git.lyx.org Git - lyx.git/blob - src/LyXRC.h
CmdDef.cpp/h: A class that manages command definitions. The definitions are
[lyx.git] / src / LyXRC.h
1 // -*- C++ -*-
2 /**
3  * \file LyXRC.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author Angus Leeming
10  * \author John Levon
11  * \author André Pönitz
12  * \author Allan Rae
13  * \author Dekel Tsur
14  *
15  * Full author contact details are available in file CREDITS.
16  */
17
18 #ifndef LYXRC_H
19 #define LYXRC_H
20
21 #include "paper.h"
22 #include "graphics/GraphicsTypes.h"
23
24 #include <iosfwd>
25 #include <string>
26
27
28 namespace lyx {
29
30 namespace support { class FileName; }
31
32 class Lexer;
33
34 /// This contains the runtime configuration of LyX
35 class LyXRC //: public noncopyable
36 // after 1.1.6 I will use a LyXRCStruct here and then this can be made
37 // noncopyable again.  For now I want to minimise changes.  ARRae 20001010
38 {
39 public:
40         enum LyXRCTags {
41                 RC_ACCEPT_COMPOUND = 1,
42                 RC_ALT_LANG,
43                 RC_PLAINTEXT_ROFF_COMMAND,
44                 RC_PLAINTEXT_LINELEN,
45                 RC_AUTOREGIONDELETE,
46                 RC_AUTORESET_OPTIONS,
47                 RC_AUTOSAVE,
48                 RC_AUTO_NUMBER,
49                 RC_BACKUPDIR_PATH,
50                 RC_BIBTEX_COMMAND,
51                 RC_BINDFILE,
52                 RC_CHECKLASTFILES,
53                 RC_CHKTEX_COMMAND,
54                 RC_CONVERTER,
55                 RC_CONVERTER_CACHE_MAXAGE,
56                 RC_COPIER,
57                 RC_CURSOR_FOLLOWS_SCROLLBAR,
58                 RC_CUSTOM_EXPORT_COMMAND,
59                 RC_CUSTOM_EXPORT_FORMAT,
60                 RC_DATE_INSERT_FORMAT,
61                 RC_DEFFILE,
62                 RC_DEFAULT_LANGUAGE,
63                 RC_DEFAULT_PAPERSIZE,
64                 RC_DIALOGS_ICONIFY_WITH_MAIN,
65                 RC_DISPLAY_GRAPHICS,
66                 RC_DOCUMENTPATH,
67                 RC_ESC_CHARS,
68                 RC_FONT_ENCODING,
69                 RC_FORMAT,
70                 RC_INDEX_COMMAND,
71                 RC_INPUT,
72                 RC_KBMAP,
73                 RC_KBMAP_PRIMARY,
74                 RC_KBMAP_SECONDARY,
75                 RC_LABEL_INIT_LENGTH,
76                 RC_LANGUAGE_AUTO_BEGIN,
77                 RC_LANGUAGE_AUTO_END,
78                 RC_LANGUAGE_COMMAND_BEGIN,
79                 RC_LANGUAGE_COMMAND_END,
80                 RC_LANGUAGE_COMMAND_LOCAL,
81                 RC_LANGUAGE_GLOBAL_OPTIONS,
82                 RC_LANGUAGE_PACKAGE,
83                 RC_LANGUAGE_USE_BABEL,
84                 RC_USELASTFILEPOS,
85                 RC_LOADSESSION,
86                 RC_MAKE_BACKUP,
87                 RC_MARK_FOREIGN_LANGUAGE,
88                 RC_NUMLASTFILES,
89                 RC_PATH_PREFIX,
90                 RC_PERS_DICT,
91                 RC_PREVIEW,
92                 RC_PREVIEW_HASHED_LABELS,
93                 RC_PREVIEW_SCALE_FACTOR,
94                 RC_PRINTCOLLCOPIESFLAG,
95                 RC_PRINTCOPIESFLAG,
96                 RC_PRINTER,
97                 RC_PRINTEVENPAGEFLAG,
98                 RC_PRINTEXSTRAOPTIONS,
99                 RC_PRINTFILEEXTENSION,
100                 RC_PRINTLANDSCAPEFLAG,
101                 RC_PRINTODDPAGEFLAG,
102                 RC_PRINTPAGERANGEFLAG,
103                 RC_PRINTPAPERDIMENSIONFLAG,
104                 RC_PRINTPAPERFLAG,
105                 RC_PRINTREVERSEFLAG,
106                 RC_PRINTSPOOL_COMMAND,
107                 RC_PRINTSPOOL_PRINTERPREFIX,
108                 RC_PRINTTOFILE,
109                 RC_PRINTTOPRINTER,
110                 RC_PRINT_ADAPTOUTPUT,
111                 RC_PRINT_COMMAND,
112                 RC_RTL_SUPPORT,
113                 RC_SCREEN_DPI,
114                 RC_SCREEN_FONT_ROMAN,
115                 RC_SCREEN_FONT_ROMAN_FOUNDRY,
116                 RC_SCREEN_FONT_SANS,
117                 RC_SCREEN_FONT_SANS_FOUNDRY,
118                 RC_SCREEN_FONT_SCALABLE,
119                 RC_SCREEN_FONT_SIZES,
120                 RC_SCREEN_FONT_TYPEWRITER,
121                 RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
122                 RC_SCREEN_GEOMETRY_HEIGHT,
123                 RC_SCREEN_GEOMETRY_WIDTH,
124                 RC_SCREEN_GEOMETRY_XYSAVED,
125                 RC_SCREEN_ZOOM,
126                 RC_SERVERPIPE,
127                 RC_SET_COLOR,
128                 RC_SHOW_BANNER,
129                 RC_SPELL_COMMAND,
130                 RC_TEMPDIRPATH,
131                 RC_TEMPLATEPATH,
132                 RC_TEX_ALLOWS_SPACES,
133                 RC_TEX_EXPECTS_WINDOWS_PATHS,
134                 RC_UIFILE,
135                 RC_USER_EMAIL,
136                 RC_USER_NAME,
137                 RC_USETEMPDIR,
138                 RC_USE_ALT_LANG,
139                 RC_USE_CONVERTER_CACHE,
140                 RC_USE_ESC_CHARS,
141                 RC_USE_INP_ENC,
142                 RC_USE_PERS_DICT,
143                 RC_USE_SPELL_LIB,
144                 RC_VIEWDVI_PAPEROPTION,
145                 RC_VIEWER,
146                 RC_LAST
147         };
148
149         ///
150         LyXRC();
151         ///
152         void setDefaults();
153         ///
154         int read(support::FileName const & filename);
155         ///
156         int read(std::istream &);
157 private:
158         ///
159         int read(Lexer &);
160 public:
161         ///
162         void write(support::FileName const & filename,
163                    bool ignore_system_lyxrc) const;
164         /// write rc. If a specific tag is given, only output that one.
165         void write(std::ostream & os,
166                    bool ignore_system_lyxrc, 
167                    std::string const & tag = std::string()) const;
168         ///
169         void print() const;
170         // FIXME unused (was used for xforms. Do we still need this?)
171         //static docstring const getDescription(LyXRCTags);
172         ///
173         std::string bind_file;
174         ///
175         std::string def_file;
176         ///
177         std::string ui_file;
178         ///
179         std::string printer;
180         ///
181         std::string print_command;
182         ///
183         std::string print_evenpage_flag;
184         ///
185         std::string print_oddpage_flag;
186         ///
187         std::string print_pagerange_flag;
188         ///
189         std::string print_copies_flag;
190         ///
191         std::string print_collcopies_flag;
192         ///
193         std::string print_reverse_flag;
194         ///
195         std::string print_landscape_flag;
196         ///
197         std::string print_to_printer;
198         ///
199         bool print_adapt_output;
200         ///
201         std::string print_to_file;
202         ///
203         std::string print_file_extension;
204         ///
205         std::string print_extra_options;
206         ///
207         std::string print_spool_command;
208         ///
209         std::string print_spool_printerprefix;
210         ///
211         std::string print_paper_flag;
212         ///
213         std::string print_paper_dimension_flag;
214         ///
215         std::string custom_export_command;
216         ///
217         std::string custom_export_format;
218         /// option for telling the dvi viewer about the paper size
219         std::string view_dvi_paper_option;
220         /// default paper size for local xdvi/dvips/ghostview/whatever
221         PAPER_SIZE default_papersize;
222         /// command to run chktex incl. options
223         std::string chktex_command;
224         /// command to run bibtex incl. options
225         std::string bibtex_command;
226         /// command to run makeindex incl. options or other index programs
227         std::string index_command;
228         ///
229         std::string document_path;
230         ///
231         std::string template_path;
232         ///
233         std::string tempdir_path;
234         ///
235         bool auto_region_delete;
236         /// flag telling whether lastfiles should be checked for existance
237         bool auto_reset_options;
238         ///
239         bool check_lastfiles;
240         /// maximal number of lastfiles
241         unsigned int num_lastfiles;
242         /// whether or not go to saved position when opening a file
243         bool use_lastfilepos;
244         /// load files from last session automatically
245         bool load_session;
246         /// shall a backup file be created
247         bool make_backup;
248         /// A directory for storing backup files
249         std::string backupdir_path;
250         /// Width of MainWindow. if 0, value from last session will be used
251         int geometry_width;
252         /// Height of MainWindow, if 0, value from last session will be used
253         int geometry_height;
254         /// Whether or not save/restore windows position as session info
255         bool geometry_xysaved;
256         /// Zoom factor for screen fonts
257         unsigned int zoom;
258         /// Screen font sizes in points for each font size
259         std::string font_sizes[10];
260         /// Allow the use of scalable fonts? Default is yes.
261         bool use_scalable_fonts;
262         /// DPI of monitor
263         unsigned int dpi;
264         ///
265         std::string fontenc;
266         ///
267         std::string roman_font_name;
268         ///
269         std::string sans_font_name;
270         ///
271         std::string typewriter_font_name;
272         ///
273         std::string roman_font_foundry;
274         ///
275         std::string sans_font_foundry;
276         ///
277         std::string typewriter_font_foundry;
278         ///
279         unsigned int autosave;
280         ///
281         std::string plaintext_roff_command;
282         ///
283         unsigned int plaintext_linelen;
284         /// use library instead of process
285         bool use_spell_lib;
286         /// Ispell command
287         std::string isp_command;
288         /// Accept compound words in spellchecker?
289         bool isp_accept_compound;
290         /// Pass input encoding switch to ispell?
291         bool isp_use_input_encoding;
292         /// Use alternate language?
293         bool isp_use_alt_lang;
294         /// Use personal dictionary?
295         bool isp_use_pers_dict;
296         /// Use escape chars?
297         bool isp_use_esc_chars;
298         /// Alternate language for ispell
299         std::string isp_alt_lang;
300         /// Alternate personal dictionary file for ispell
301         std::string isp_pers_dict;
302         /// Escape characters
303         std::string isp_esc_chars;
304         ///
305         bool use_kbmap;
306         ///
307         std::string primary_kbmap;
308         ///
309         std::string secondary_kbmap;
310         ///
311         std::string lyxpipes;
312         ///
313         std::string date_insert_format;
314         ///
315         std::string language_package;
316         ///
317         bool language_auto_begin;
318         ///
319         bool language_auto_end;
320         ///
321         std::string language_command_begin;
322         ///
323         std::string language_command_end;
324         ///
325         std::string language_command_local;
326         ///
327         bool language_global_options;
328         ///
329         bool language_use_babel;
330         ///
331         bool rtl_support;
332         ///
333         bool auto_number;
334         ///
335         bool mark_foreign_language;
336         ///
337         std::string default_language;
338         ///
339         bool cursor_follows_scrollbar;
340         ///
341         bool dialogs_iconify_with_main;
342         ///
343         int label_init_length;
344         ///
345         graphics::DisplayType display_graphics;
346         ///
347         bool show_banner;
348         ///
349         enum PreviewStatus {
350                 PREVIEW_OFF,
351                 PREVIEW_NO_MATH,
352                 PREVIEW_ON
353         };
354         ///
355         PreviewStatus preview;
356         ///
357         bool preview_hashed_labels;
358         ///
359         std::string preview_scale_factor;
360         /// user name
361         std::string user_name;
362         /// user email
363         std::string user_email;
364         /// True if the TeX engine cannot handle posix paths
365         bool windows_style_tex_paths;
366         /// True if the TeX engine can handle file names containing spaces
367         bool tex_allows_spaces;
368         /** Prepend paths to the PATH environment variable.
369          *  The string is input, stored and output in native format.
370          */
371         std::string path_prefix;
372         /// Use the cache for file converters?
373         bool use_converter_cache;
374         /// The maximum age of cache files in seconds
375         unsigned int converter_cache_maxage;
376 };
377
378
379 /** \c LyXRC_PreviewStatus is a wrapper for LyXRC::PreviewStatus.
380  *  It can be forward-declared and passed as a function argument without
381  *  having to expose LyXRC.h.
382  */
383 class LyXRC_PreviewStatus {
384         LyXRC::PreviewStatus val_;
385 public:
386         LyXRC_PreviewStatus(LyXRC::PreviewStatus val) : val_(val) {}
387         operator LyXRC::PreviewStatus() const{ return val_; }
388 };
389
390
391 ///
392 extern LyXRC lyxrc;
393 ///
394 extern LyXRC system_lyxrc;
395
396 } // namespace lyx
397
398 #endif