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