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