]> git.lyx.org Git - lyx.git/blob - src/lyxrc.h
2006-04-06 Bo Peng <ben.bob@gmail.com>
[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 class LyXLex;
28
29 /// This contains the runtime configuration of LyX
30 class LyXRC //: public noncopyable {
31 // after 1.1.6 I will use a LyXRCStruct here and then this can be made
32 // noncopyable again.  For now I want to minimise changes.  ARRae 20001010
33 {
34 public:
35         enum LyXRCTags {
36                 RC_ACCEPT_COMPOUND = 1,
37                 RC_ALT_LANG,
38                 RC_ASCIIROFF_COMMAND,
39                 RC_ASCII_LINELEN,
40                 RC_AUTOREGIONDELETE,
41                 RC_AUTORESET_OPTIONS,
42                 RC_AUTOSAVE,
43                 RC_AUTO_NUMBER,
44                 RC_BACKUPDIR_PATH,
45                 RC_BIBTEX_COMMAND,
46                 RC_BINDFILE,
47                 RC_CHECKLASTFILES,
48                 RC_CHKTEX_COMMAND,
49                 RC_CONVERTER,
50                 RC_COPIER,
51                 RC_CURSOR_FOLLOWS_SCROLLBAR,
52                 RC_CUSTOM_EXPORT_COMMAND,
53                 RC_CUSTOM_EXPORT_FORMAT,
54                 RC_CYGWIN_PATH_FIX,
55                 RC_DATE_INSERT_FORMAT,
56                 RC_DEFAULT_LANGUAGE,
57                 RC_DEFAULT_PAPERSIZE,
58                 RC_DIALOGS_ICONIFY_WITH_MAIN,
59                 RC_DISPLAY_GRAPHICS,
60                 RC_DOCUMENTPATH,
61                 RC_ESC_CHARS,
62                 RC_FONT_ENCODING,
63                 RC_FORMAT,
64                 RC_INDEX_COMMAND,
65                 RC_INPUT,
66                 RC_KBMAP,
67                 RC_KBMAP_PRIMARY,
68                 RC_KBMAP_SECONDARY,
69                 RC_LABEL_INIT_LENGTH,
70                 RC_LANGUAGE_AUTO_BEGIN,
71                 RC_LANGUAGE_AUTO_END,
72                 RC_LANGUAGE_COMMAND_BEGIN,
73                 RC_LANGUAGE_COMMAND_END,
74                 RC_LANGUAGE_COMMAND_LOCAL,
75                 RC_LANGUAGE_GLOBAL_OPTIONS,
76                 RC_LANGUAGE_PACKAGE,
77                 RC_LANGUAGE_USE_BABEL,
78                 RC_USELASTFILEPOS,
79                 RC_LOADSESSION,
80                 RC_MAKE_BACKUP,
81                 RC_MARK_FOREIGN_LANGUAGE,
82                 RC_NUMLASTFILES,
83                 RC_PATH_PREFIX,
84                 RC_PERS_DICT,
85                 RC_POPUP_BOLD_FONT,
86                 RC_POPUP_FONT_ENCODING,
87                 RC_POPUP_NORMAL_FONT,
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_ENCODING,
112                 RC_SCREEN_FONT_ROMAN,
113                 RC_SCREEN_FONT_ROMAN_FOUNDRY,
114                 RC_SCREEN_FONT_SANS,
115                 RC_SCREEN_FONT_SANS_FOUNDRY,
116                 RC_SCREEN_FONT_SCALABLE,
117                 RC_SCREEN_FONT_SIZES,
118                 RC_SCREEN_FONT_TYPEWRITER,
119                 RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
120                 RC_SCREEN_GEOMETRY_HEIGHT,
121                 RC_SCREEN_GEOMETRY_WIDTH,
122                 RC_SCREEN_GEOMETRY_XYSAVED,
123                 RC_SCREEN_ZOOM,
124                 RC_SERVERPIPE,
125                 RC_SET_COLOR,
126                 RC_SHOW_BANNER,
127                 RC_SPELL_COMMAND,
128                 RC_TEMPDIRPATH,
129                 RC_TEMPLATEPATH,
130                 RC_TEX_ALLOWS_SPACES,
131                 RC_UIFILE,
132                 RC_USER_EMAIL,
133                 RC_USER_NAME,
134                 RC_USETEMPDIR,
135                 RC_USE_ALT_LANG,
136                 RC_USE_ESC_CHARS,
137                 RC_USE_INP_ENC,
138                 RC_USE_PERS_DICT,
139                 RC_USE_SPELL_LIB,
140                 RC_VIEWDVI_PAPEROPTION,
141                 RC_VIEWER,
142                 RC_WHEEL_JUMP,
143                 RC_LAST
144         };
145
146         ///
147         LyXRC();
148         ///
149         void setDefaults();
150         ///
151         int read(std::string const & filename);
152         ///
153         int read(std::istream &);
154 private:
155         ///
156         int read(LyXLex &);
157 public:
158         ///
159         void write(std::string const & filename,
160                    bool ignore_system_lyxrc) const;
161         ///
162         void write(std::ostream & os,
163                    bool ignore_system_lyxrc) const;
164         ///
165         void print() const;
166         ///
167         static std::string const getDescription(LyXRCTags);
168         ///
169         std::string bind_file;
170         ///
171         std::string ui_file;
172         ///
173         std::string printer;
174         ///
175         std::string print_command;
176         ///
177         std::string print_evenpage_flag;
178         ///
179         std::string print_oddpage_flag;
180         ///
181         std::string print_pagerange_flag;
182         ///
183         std::string print_copies_flag;
184         ///
185         std::string print_collcopies_flag;
186         ///
187         std::string print_reverse_flag;
188         ///
189         std::string print_landscape_flag;
190         ///
191         std::string print_to_printer;
192         ///
193         bool print_adapt_output;
194         ///
195         std::string print_to_file;
196         ///
197         std::string print_file_extension;
198         ///
199         std::string print_extra_options;
200         ///
201         std::string print_spool_command;
202         ///
203         std::string print_spool_printerprefix;
204         ///
205         std::string print_paper_flag;
206         ///
207         std::string print_paper_dimension_flag;
208         ///
209         std::string custom_export_command;
210         ///
211         std::string custom_export_format;
212         /// option for telling the dvi viewer about the paper size
213         std::string view_dvi_paper_option;
214         /// default paper size for local xdvi/dvips/ghostview/whatever
215         PAPER_SIZE default_papersize;
216         /// command to run chktex incl. options
217         std::string chktex_command;
218         /// command to run bibtex incl. options
219         std::string bibtex_command;
220         /// command to run makeindex incl. options or other index programs
221         std::string index_command;
222         ///
223         std::string document_path;
224         ///
225         std::string template_path;
226         ///
227         std::string tempdir_path;
228         ///
229         bool auto_region_delete;
230         /// flag telling whether lastfiles should be checked for existance
231         bool auto_reset_options;
232         ///
233         bool check_lastfiles;
234         /// maximal number of lastfiles
235         unsigned int num_lastfiles;
236         /// whether or not go to saved position when opening a file
237         bool use_lastfilepos;
238         /// load files from last session automatically
239         bool load_session;
240         /// shall a backup file be created
241         bool make_backup;
242         /// A directory for storing backup files
243         std::string backupdir_path;
244         /// Width of MainWindow. if 0, value from last session will be used
245         int geometry_width;
246         /// Height of MainWindow, if 0, value from last session will be used
247         int geometry_height;
248         /// Whether or not save/restore windows position as session info
249         bool geometry_xysaved;
250         /// Zoom factor for screen fonts
251         unsigned int zoom;
252         /// parameter for button_4 and button_5 (scrollwheel)
253         /// Only used by the xforms frontend
254         unsigned int wheel_jump;
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         std::string popup_bold_font;
277         ///
278         std::string popup_normal_font;
279         ///
280         std::string font_norm;
281         ///
282         enum FontEncoding {
283                 ///
284                 ISO_10646_1,
285                 ///
286                 ISO_8859_1,
287                 ///
288                 ISO_8859_3,
289                 ///
290                 ISO_8859_4,
291                 ///
292                 ISO_8859_6_8,
293                 ///
294                 ISO_8859_9,
295                 ///
296                 ISO_8859_15,
297                 ///
298                 OTHER_ENCODING
299         };
300         ///
301         FontEncoding font_norm_type;
302         ///
303         void set_font_norm_type();
304         ///
305         std::string popup_font_encoding;
306         ///
307         unsigned int autosave;
308         ///
309         std::string ascii_roff_command;
310         ///
311         unsigned int ascii_linelen;
312         /// use library instead of process
313         bool use_spell_lib;
314         /// Ispell command
315         std::string isp_command;
316         /// Accept compound words in spellchecker?
317         bool isp_accept_compound;
318         /// Pass input encoding switch to ispell?
319         bool isp_use_input_encoding;
320         /// Use alternate language?
321         bool isp_use_alt_lang;
322         /// Use personal dictionary?
323         bool isp_use_pers_dict;
324         /// Use escape chars?
325         bool isp_use_esc_chars;
326         /// Alternate language for ispell
327         std::string isp_alt_lang;
328         /// Alternate personal dictionary file for ispell
329         std::string isp_pers_dict;
330         /// Escape characters
331         std::string isp_esc_chars;
332         ///
333         bool use_kbmap;
334         ///
335         std::string primary_kbmap;
336         ///
337         std::string secondary_kbmap;
338         ///
339         std::string lyxpipes;
340         ///
341         std::string date_insert_format;
342         ///
343         std::string language_package;
344         ///
345         bool language_auto_begin;
346         ///
347         bool language_auto_end;
348         ///
349         std::string language_command_begin;
350         ///
351         std::string language_command_end;
352         ///
353         std::string language_command_local;
354         ///
355         bool language_global_options;
356         ///
357         bool language_use_babel;
358         ///
359         bool rtl_support;
360         ///
361         bool auto_number;
362         ///
363         bool mark_foreign_language;
364         ///
365         std::string default_language;
366         ///
367         bool cursor_follows_scrollbar;
368         ///
369         bool dialogs_iconify_with_main;
370         ///
371         int label_init_length;
372         ///
373         lyx::graphics::DisplayType display_graphics;
374         ///
375         bool show_banner;
376         ///
377         enum PreviewStatus {
378                 PREVIEW_OFF,
379                 PREVIEW_NO_MATH,
380                 PREVIEW_ON
381         };
382         ///
383         PreviewStatus preview;
384         ///
385         bool preview_hashed_labels;
386         ///
387         std::string preview_scale_factor;
388         /// user name
389         std::string user_name;
390         /// user email
391         std::string user_email;
392         ///
393         bool cygwin_path_fix;
394         /// True if the TeX engine can handle file names containing spaces
395         bool tex_allows_spaces;
396         /** Prepend paths to the PATH environment variable.
397          *  The string is input, stored and output in native format.
398          */
399         std::string path_prefix;
400 };
401
402
403 /** \c LyXRC_PreviewStatus is a wrapper for LyXRC::PreviewStatus.
404  *  It can be forward-declared and passed as a function argument without
405  *  having to expose lyxrc.h.
406  */
407 class LyXRC_PreviewStatus {
408         LyXRC::PreviewStatus val_;
409 public:
410         LyXRC_PreviewStatus(LyXRC::PreviewStatus val) : val_(val) {}
411         operator LyXRC::PreviewStatus() const{ return val_; }
412 };
413
414
415 ///
416 extern LyXRC lyxrc;
417 ///
418 extern LyXRC system_lyxrc;
419 #endif