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