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