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