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