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