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