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