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