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