]> git.lyx.org Git - lyx.git/blob - src/LyXRC.h
More requires --> required, for C++2a.
[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 "Length.h"
22 #include "LyX.h"
23
24 #include "support/strfwd.h"
25 #include "support/userinfo.h"
26
27 #include <map>
28 #include <set>
29 #include <string>
30
31
32 namespace lyx {
33
34 namespace support { class FileName; }
35
36 class Lexer;
37
38 /// This contains the runtime configuration of LyX
39 class LyXRC
40 {
41 public:
42         enum LyXRCTags {
43                 RC_ACCEPT_COMPOUND = 1,
44                 RC_ALT_LANG,
45                 RC_AUTOCORRECTION_MATH,
46                 RC_AUTOREGIONDELETE,
47                 RC_AUTORESET_OPTIONS,
48                 RC_AUTOSAVE,
49                 RC_AUTO_NUMBER,
50                 RC_BACKUPDIR_PATH,
51                 RC_BIBTEX_ALTERNATIVES,
52                 RC_BIBTEX_COMMAND,
53                 RC_BINDFILE,
54                 RC_CHECKLASTFILES,
55                 RC_CHKTEX_COMMAND,
56                 RC_COMPLETION_CURSOR_TEXT,
57                 RC_COMPLETION_INLINE_DELAY,
58                 RC_COMPLETION_INLINE_MATH,
59                 RC_COMPLETION_INLINE_TEXT,
60                 RC_COMPLETION_INLINE_DOTS,
61                 RC_COMPLETION_MINLENGTH,
62                 RC_COMPLETION_POPUP_DELAY,
63                 RC_COMPLETION_POPUP_MATH,
64                 RC_COMPLETION_POPUP_TEXT,
65                 RC_COMPLETION_POPUP_AFTER_COMPLETE,
66                 RC_CONVERTER,
67                 RC_CONVERTER_CACHE_MAXAGE,
68                 RC_COPIER,
69                 RC_CT_ADDITIONS_UNDERLINED,
70                 RC_CT_MARKUP_COPIED,
71                 RC_CURSOR_FOLLOWS_SCROLLBAR,
72                 RC_CURSOR_WIDTH,
73                 RC_DEFAULT_DECIMAL_SEP,
74                 RC_DEFAULT_LENGTH_UNIT,
75                 RC_DEFAULT_OTF_VIEW_FORMAT,
76                 RC_DEFAULT_PLATEX_VIEW_FORMAT,
77                 RC_DEFAULT_VIEW_FORMAT,
78                 RC_DEFFILE,
79                 RC_DIALOGS_ICONIFY_WITH_MAIN,
80                 RC_DISPLAY_GRAPHICS,
81                 RC_DOCUMENTPATH,
82                 RC_EDITOR_ALTERNATIVES,
83                 RC_ESC_CHARS,
84                 RC_EXAMPLEPATH,
85                 RC_EXPORT_OVERWRITE,
86                 RC_FILEFORMAT,
87                 RC_FORWARD_SEARCH_DVI,
88                 RC_FORWARD_SEARCH_PDF,
89                 RC_FULL_SCREEN_LIMIT,
90                 RC_FULL_SCREEN_SCROLLBAR,
91                 RC_FULL_SCREEN_STATUSBAR,
92                 RC_FULL_SCREEN_TABBAR,
93                 RC_FULL_SCREEN_MENUBAR,
94                 RC_FULL_SCREEN_TOOLBARS,
95                 RC_FULL_SCREEN_WIDTH,
96                 RC_GEOMETRY_SESSION,
97                 RC_GROUP_LAYOUTS,
98                 RC_GUI_LANGUAGE,
99                 RC_HUNSPELLDIR_PATH,
100                 RC_ICON_SET,
101                 RC_INDEX_ALTERNATIVES,
102                 RC_INDEX_COMMAND,
103                 RC_INPUT,
104                 RC_JBIBTEX_ALTERNATIVES,
105                 RC_JBIBTEX_COMMAND,
106                 RC_JINDEX_COMMAND,
107                 RC_KBMAP,
108                 RC_KBMAP_PRIMARY,
109                 RC_KBMAP_SECONDARY,
110                 RC_LANGUAGE_AUTO_BEGIN,
111                 RC_LANGUAGE_AUTO_END,
112                 RC_LANGUAGE_COMMAND_BEGIN,
113                 RC_LANGUAGE_COMMAND_END,
114                 RC_LANGUAGE_COMMAND_LOCAL,
115                 RC_LANGUAGE_GLOBAL_OPTIONS,
116                 RC_LANGUAGE_CUSTOM_PACKAGE,
117                 RC_LANGUAGE_PACKAGE_SELECTION,
118                 RC_LOADSESSION,
119                 RC_LYXRCFORMAT,
120                 RC_MACRO_EDIT_STYLE,
121                 RC_MAC_DONTSWAP_CTRL_META,
122                 RC_MAC_LIKE_CURSOR_MOVEMENT,
123                 RC_MAKE_BACKUP,
124                 RC_MARK_FOREIGN_LANGUAGE,
125                 RC_MOUSE_WHEEL_SPEED,
126                 RC_MOUSE_MIDDLEBUTTON_PASTE,
127                 RC_NOMENCL_COMMAND,
128                 RC_NUMLASTFILES,
129                 RC_OPEN_BUFFERS_IN_TABS,
130                 RC_PARAGRAPH_MARKERS,
131                 RC_PATH_PREFIX,
132                 RC_PLAINTEXT_LINELEN,
133                 RC_PREVIEW,
134                 RC_PREVIEW_HASHED_LABELS,
135                 RC_PREVIEW_SCALE_FACTOR,
136                 RC_PRINTLANDSCAPEFLAG,
137                 RC_PRINTPAPERDIMENSIONFLAG,
138                 RC_PRINTPAPERFLAG,
139                 RC_PYGMENTIZE_COMMAND,
140                 RC_RESPECT_OS_KBD_LANGUAGE,
141                 RC_SAVE_COMPRESSED,
142                 RC_SAVE_ORIGIN,
143                 RC_SCREEN_DPI,
144                 RC_SCREEN_FONT_ROMAN,
145                 RC_SCREEN_FONT_ROMAN_FOUNDRY,
146                 RC_SCREEN_FONT_SANS,
147                 RC_SCREEN_FONT_SANS_FOUNDRY,
148                 RC_SCREEN_FONT_SCALABLE,
149                 RC_SCREEN_FONT_SIZES,
150                 RC_SCREEN_FONT_TYPEWRITER,
151                 RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
152                 RC_SCREEN_ZOOM,
153                 RC_SCROLL_BELOW_DOCUMENT,
154                 RC_SCROLL_WHEEL_ZOOM,
155                 RC_SERVERPIPE,
156                 RC_SET_COLOR,
157                 RC_SHOW_BANNER,
158                 RC_SINGLE_CLOSE_TAB_BUTTON,
159                 RC_SINGLE_INSTANCE,
160                 RC_SORT_LAYOUTS,
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_TEXINPUTS_PREFIX,
170                 RC_THESAURUSDIRPATH,
171                 RC_UIFILE,
172                 RC_USELASTFILEPOS,
173                 RC_USER_EMAIL,
174                 RC_USER_INITIALS,
175                 RC_USER_NAME,
176                 RC_USE_CONVERTER_CACHE,
177                 RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN,
178                 RC_USE_CONVERTER_NEEDAUTH,
179                 RC_USE_NATIVE_FILEDIALOG,
180                 RC_USE_SYSTEM_COLORS,
181                 RC_USE_TOOLTIP,
182                 RC_USE_SYSTEM_THEME_ICONS,
183                 RC_VIEWDVI_PAPEROPTION,
184                 RC_VIEWER,
185                 RC_VIEWER_ALTERNATIVES,
186                 RC_VISUAL_CURSOR,
187                 RC_CLOSE_BUFFER_WITH_LAST_VIEW,
188                 RC_LAST
189         };
190
191         ///
192         LyXRC() : user_name(support::user_name()),
193                   user_email(support::user_email()) // always empty
194                 {};
195
196         /// \param check_format: whether to try to convert the file format,
197         /// if it is not current. this should only be true, really, for the
198         /// user's own preferences file.
199         bool read(support::FileName const & filename, bool check_format);
200         ///
201         bool read(std::istream &);
202 private:
203         enum ReturnValues {
204                 ReadOK,
205                 ReadError,
206                 FormatMismatch
207         };
208         ///
209         ReturnValues read(Lexer &, bool check_format);
210 public:
211         ///
212         typedef std::set<std::string> CommandSet;
213         /// maps a format to a set of commands that can be used to
214         /// edit or view it.
215         typedef std::map<std::string, CommandSet> Alternatives;
216         ///
217         void write(support::FileName const & filename,
218                    bool ignore_system_lyxrc) const;
219         /// write rc. If a specific tag is given, only output that one.
220         void write(std::ostream & os,
221                    bool ignore_system_lyxrc,
222                    std::string const & tag = std::string()) const;
223         ///
224         void print() const;
225         ///
226         std::set<std::string> getRCs();
227         // FIXME unused (was used for xforms. Do we still need this?)
228         //static docstring const getDescription(LyXRCTags);
229         ///
230         std::string bind_file = "cua";
231         ///
232         std::string def_file = "default";
233         ///
234         std::string ui_file = "default";
235         ///
236         std::string print_landscape_flag = "-t landscape";
237         ///
238         std::string print_paper_flag = "-t";
239         ///
240         std::string print_paper_dimension_flag = "-T";
241         /// option for telling the dvi viewer about the paper size
242         std::string view_dvi_paper_option;
243         /// default paper size for local xdvi/dvips/ghostview/whatever
244         /// command to run chktex incl. options
245         std::string chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
246         /// all available commands to run bibtex incl. options
247         CommandSet bibtex_alternatives;
248         /// command to run bibtex incl. options
249         std::string bibtex_command = "automatic";
250         /// command to run japanese bibtex incl. options
251         std::string jbibtex_command;
252         /// all available commands to run japanese bibtex incl. options
253         CommandSet jbibtex_alternatives;
254         /// all available index commands incl. options
255         CommandSet index_alternatives;
256         /// command to run makeindex incl. options or other index programs
257         std::string index_command = "makeindex -c -q";
258         /// command to run japanese index program incl. options
259         std::string jindex_command;
260         /// command to generate multiple indices
261         std::string splitindex_command;
262         /// command to run makeindex incl. options for nomencl
263         std::string nomencl_command = "makeindex -s nomencl.ist";
264         /// command to run the python pygments syntax highlighter
265         std::string pygmentize_command;
266         ///
267         std::string document_path;
268         ///
269         std::string example_path;
270         ///
271         std::string template_path;
272         ///
273         std::string tempdir_path;
274         ///
275         std::string thesaurusdir_path;
276         ///
277         std::string hunspelldir_path;
278         ///
279         bool auto_region_delete = true;
280         /// enable middle-mouse-button paste
281         bool mouse_middlebutton_paste = true;
282         ///
283         bool auto_reset_options = false;
284         /// flag telling whether lastfiles should be checked for existance
285         bool check_lastfiles = true;
286         /// maximal number of lastfiles
287         unsigned int num_lastfiles = 20;
288         /// whether or not go to saved position when opening a file
289         bool use_lastfilepos = true;
290         /// load files from last session automatically
291         bool load_session = false;
292         /// do we save new documents as compressed by default
293         bool save_compressed = false;
294         /// whether or not to save the document dir in the file
295         bool save_origin = false;
296         /// shall a backup file be created
297         bool make_backup = true;
298         /// A directory for storing backup files
299         std::string backupdir_path;
300         /// Whether or not save/restore session information
301         /// like windows position and geometry.
302         bool allow_geometry_session = true;
303         /// Scrolling speed of the mouse wheel
304         double mouse_wheel_speed = 1.0;
305         /// Default zoom factor for screen fonts
306         int defaultZoom = 150;
307         /// Actual zoom factor for screen fonts
308         /// (default zoom plus buffer zoom factor)
309         int currentZoom = 150;
310         /// Screen font sizes in points for each font size
311         std::string font_sizes[10] = { "5.0", "7.0", "8.0", "9.0", "10.0",
312                                        "12.0", "14.4", "17.26", "20.74", "24.88"};
313         /// Allow the use of scalable fonts? Default is yes.
314         bool use_scalable_fonts = true;
315         /// DPI of monitor
316         unsigned int dpi = 75;
317         ///
318         std::string roman_font_name;
319         ///
320         std::string sans_font_name;
321         ///
322         std::string typewriter_font_name;
323         ///
324         std::string roman_font_foundry;
325         ///
326         std::string sans_font_foundry;
327         ///
328         std::string typewriter_font_foundry;
329         ///
330         unsigned int autosave = 300;
331         ///
332         unsigned int plaintext_linelen = 65;
333         /// End of paragraph markers?
334         bool paragraph_markers = false;
335         /// Use tooltips?
336         bool use_tooltip = true;
337         /// Use the colors from current system theme?
338         bool use_system_colors = false;
339         /// use native file dialog or our own ?
340         bool use_native_filedialog = true;
341         /// Spellchecker engine: aspell, hunspell, etc
342         std::string spellchecker
343 #if defined(USE_MACOSX_PACKAGING)
344                 = "native";
345 #elif defined(USE_ENCHANT)
346                 = "enchant";
347 #elif defined(USE_ASPELL)
348                 = "aspell";
349 #elif defined(USE_HUNSPELL)
350                 = "hunspell";
351 #else
352                 = "aspell";
353 #endif
354         /// Alternate language for spellchecker
355         std::string spellchecker_alt_lang;
356         /// Escape characters
357         std::string spellchecker_esc_chars;
358         /// Accept compound words in spellchecker?
359         bool spellchecker_accept_compound = false;
360         /// spellcheck continuously?
361         bool spellcheck_continuously = false;
362         /// spellcheck notes and comments?
363         bool spellcheck_notes = true;
364         /// minimum length of words to complete
365         unsigned int completion_minlength = 6;
366         ///
367         bool use_kbmap = false;
368         ///
369         std::string primary_kbmap;
370         ///
371         std::string secondary_kbmap;
372         ///
373         std::string lyxpipes;
374         ///
375         std::string language_custom_package = "\\usepackage{babel}";
376         ///
377         bool language_auto_begin = true;
378         ///
379         bool language_auto_end = true;
380         ///
381         std::string language_command_begin = "\\selectlanguage{$$lang}";
382         ///
383         std::string language_command_end;
384         ///
385         std::string language_command_local = "\\foreignlanguage{$$lang}{";
386         ///
387         bool language_global_options = true;
388         ///
389         enum LangPackageSelection {
390                 LP_AUTO = 0,
391                 LP_BABEL,
392                 LP_CUSTOM,
393                 LP_NONE
394         };
395         ///
396         LangPackageSelection language_package_selection = LP_AUTO;
397         /// bidi cursor movement: true = visual, false = logical
398         bool visual_cursor = false;
399         ///
400         bool auto_number = true;
401         ///
402         bool mark_foreign_language = true;
403         ///
404         std::string gui_language = "auto";
405         ///
406         bool respect_os_kbd_language = false;
407         ///
408         std::string default_otf_view_format = "pdf4";
409         ///
410         std::string default_platex_view_format = "pdf3";
411         ///
412         std::string default_view_format = "pdf2";
413         /// all available viewers
414         Alternatives viewer_alternatives;
415         /// all available editors
416         Alternatives editor_alternatives;
417         ///
418         bool mac_dontswap_ctrl_meta = false;
419         ///
420         bool mac_like_cursor_movement = false;
421         ///
422         bool cursor_follows_scrollbar = false;
423         ///
424         bool ct_additions_underlined = true;
425         ///
426         bool ct_markup_copied = false;
427         ///
428         bool scroll_below_document = false;
429         ///
430         enum MacroEditStyle {
431                 MACRO_EDIT_INLINE_BOX = 0,
432                 MACRO_EDIT_INLINE,
433                 MACRO_EDIT_LIST
434         };
435         ///
436         MacroEditStyle macro_edit_style = MACRO_EDIT_INLINE_BOX;
437         ///
438         bool dialogs_iconify_with_main = false;
439         ///
440         bool display_graphics = true;
441         ///
442         bool show_banner = true;
443         ///
444         enum PreviewStatus {
445                 PREVIEW_OFF,
446                 PREVIEW_NO_MATH,
447                 PREVIEW_ON
448         };
449         ///
450         PreviewStatus preview = PREVIEW_OFF;
451         ///
452         bool preview_hashed_labels = false;
453         ///
454         double preview_scale_factor = 1.0;
455         /// user name
456         std::string user_name; // set in constructor
457         /// user email
458         std::string user_email; // set in constructor (empty for now)
459         /// user initials
460         std::string user_initials;
461         /// icon set name
462         std::string icon_set;
463         /// whether to use the icons from the theme
464         bool use_system_theme_icons = false;
465         /// True if the TeX engine cannot handle posix paths
466         bool windows_style_tex_paths = false;
467         /// True if the TeX engine can handle file names containing spaces
468         bool tex_allows_spaces = false;
469         /** Prepend paths to the PATH environment variable.
470          *  The string is input, stored and output in native format.
471          */
472         std::string path_prefix;
473         /** Prepend paths to the TEXINPUTS environment variable.
474          *  The string is input, stored and output in native format.
475          *  A '.' here stands for the current document directory.
476          */
477         std::string texinputs_prefix = ".";
478         /// Use the cache for file converters?
479         bool use_converter_cache = true;
480         /// Forbid use of external converters with 'needauth' option
481         bool use_converter_needauth_forbidden = true;
482         /// Ask user before calling external converters with 'needauth' option
483         bool use_converter_needauth = true;
484         /// The maximum age of cache files in seconds
485         unsigned int converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months;
486         /// Sort layouts alphabetically
487         bool sort_layouts = false;
488         /// Group layout by their category
489         bool group_layouts = true;
490         /// Toggle toolbars in fullscreen mode?
491         bool full_screen_toolbars = true;
492         /// Toggle scrollbar in fullscreen mode?
493         bool full_screen_scrollbar = true;
494         /// Toggle tabbar in fullscreen mode?
495         bool full_screen_tabbar = true;
496         /// Toggle menubar in fullscreen mode?
497         bool full_screen_menubar = true;
498         /// Toggle statusbar in fullscreen mode?
499         bool full_screen_statusbar = true;
500         /// Limit the text width?
501         bool full_screen_limit = false;
502         /// Width of limited screen (in pixels) in fullscreen mode
503         int full_screen_width = 700;
504         ///
505         bool completion_cursor_text = true;
506         ///
507         double completion_inline_delay = 0.2;
508         ///
509         bool completion_inline_math = true;
510         ///
511         bool completion_inline_text = false;
512         ///
513         int completion_inline_dots = -1;
514         ///
515         double completion_popup_delay = 2.0;
516         ///
517         bool completion_popup_math = true;
518         ///
519         bool completion_popup_text = false;
520         ///
521         bool completion_popup_after_complete = true;
522         ///
523         bool autocorrection_math = false;
524         ///
525         bool open_buffers_in_tabs = true;
526         ///
527         bool single_close_tab_button = false;
528         ///
529         bool single_instance = true;
530         ///
531         std::string forward_search_dvi;
532         ///
533         std::string forward_search_pdf;
534         ///
535         int export_overwrite = NO_FILES;
536         /// Default decimal point when aligning table columns on decimal
537         std::string default_decimal_sep = "locale";
538         ///
539         Length::UNIT default_length_unit = Length::CM;
540         ///
541         enum ScrollWheelZoom {
542                 SCROLL_WHEEL_ZOOM_OFF,
543                 SCROLL_WHEEL_ZOOM_CTRL,
544                 SCROLL_WHEEL_ZOOM_SHIFT,
545                 SCROLL_WHEEL_ZOOM_ALT
546         };
547         ///
548         ScrollWheelZoom scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
549         ///
550         int cursor_width = 1;
551         /// One of: yes, no, ask
552         std::string close_buffer_with_last_view = "yes";
553 };
554
555
556 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
557
558 ///
559 extern LyXRC lyxrc;
560 ///
561 extern LyXRC system_lyxrc;
562
563 // used by at least frontends/qt/GuiPref.cpp
564 const long maxlastfiles = 50;
565
566 } // namespace lyx
567
568 #endif