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 
23 #include "support/strfwd.h"
24 
25 #include <map>
26 #include <set>
27 #include <string>
28 
29 
30 namespace lyx {
31 
32 namespace support { class FileName; }
33 
34 class Lexer;
35 
36 /// This contains the runtime configuration of LyX
37 class LyXRC
38 {
39 public:
40 	enum LyXRCTags {
41 		RC_ACCEPT_COMPOUND = 1,
42 		RC_ALT_LANG,
43 		RC_AUTOCORRECTION_MATH,
44 		RC_AUTOREGIONDELETE,
45 		RC_AUTORESET_OPTIONS,
46 		RC_AUTOSAVE,
47 		RC_AUTO_NUMBER,
48 		RC_BACKUPDIR_PATH,
49 		RC_BIBTEX_ALTERNATIVES,
50 		RC_BIBTEX_COMMAND,
51 		RC_BINDFILE,
52 		RC_CHECKLASTFILES,
53 		RC_CHKTEX_COMMAND,
54 		RC_COMPLETION_CURSOR_TEXT,
55 		RC_COMPLETION_INLINE_DELAY,
56 		RC_COMPLETION_INLINE_MATH,
57 		RC_COMPLETION_INLINE_TEXT,
58 		RC_COMPLETION_INLINE_DOTS,
59 		RC_COMPLETION_MINLENGTH,
60 		RC_COMPLETION_POPUP_DELAY,
61 		RC_COMPLETION_POPUP_MATH,
62 		RC_COMPLETION_POPUP_TEXT,
63 		RC_COMPLETION_POPUP_AFTER_COMPLETE,
64 		RC_CONVERTER,
65 		RC_CONVERTER_CACHE_MAXAGE,
66 		RC_COPIER,
67 		RC_CURSOR_FOLLOWS_SCROLLBAR,
68 		RC_CURSOR_WIDTH,
69 		RC_DATE_INSERT_FORMAT,
70 		RC_DEFAULT_DECIMAL_POINT,
71 		RC_DEFAULT_LENGTH_UNIT,
72 		RC_DEFAULT_OTF_VIEW_FORMAT,
73 		RC_DEFAULT_PLATEX_VIEW_FORMAT,
74 		RC_DEFAULT_VIEW_FORMAT,
75 		RC_DEFFILE,
76 		RC_DIALOGS_ICONIFY_WITH_MAIN,
77 		RC_DISPLAY_GRAPHICS,
78 		RC_DOCUMENTPATH,
79 		RC_EDITOR_ALTERNATIVES,
80 		RC_ESC_CHARS,
81 		RC_EXAMPLEPATH,
82 		RC_EXPORT_OVERWRITE,
83 		RC_FONT_ENCODING,
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_SAVE_COMPRESSED,
139 		RC_SAVE_ORIGIN,
140 		RC_SCREEN_DPI,
141 		RC_SCREEN_FONT_ROMAN,
142 		RC_SCREEN_FONT_ROMAN_FOUNDRY,
143 		RC_SCREEN_FONT_SANS,
144 		RC_SCREEN_FONT_SANS_FOUNDRY,
145 		RC_SCREEN_FONT_SCALABLE,
146 		RC_SCREEN_FONT_SIZES,
147 		RC_SCREEN_FONT_TYPEWRITER,
148 		RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
149 		RC_SCREEN_ZOOM,
150 		RC_SCROLL_BELOW_DOCUMENT,
151 		RC_SCROLL_WHEEL_ZOOM,
152 		RC_SERVERPIPE,
153 		RC_SET_COLOR,
154 		RC_SHOW_BANNER,
155 		RC_SINGLE_CLOSE_TAB_BUTTON,
156 		RC_SINGLE_INSTANCE,
157 		RC_SORT_LAYOUTS,
158 		RC_SPELLCHECK_CONTINUOUSLY,
159 		RC_SPELLCHECK_NOTES,
160 		RC_SPELLCHECKER,
161 		RC_SPLITINDEX_COMMAND,
162 		RC_TEMPDIRPATH,
163 		RC_TEMPLATEPATH,
164 		RC_TEX_ALLOWS_SPACES,
165 		RC_TEX_EXPECTS_WINDOWS_PATHS,
166 		RC_TEXINPUTS_PREFIX,
167 		RC_THESAURUSDIRPATH,
168 		RC_UIFILE,
169 		RC_USELASTFILEPOS,
170 		RC_USER_EMAIL,
171 		RC_USER_NAME,
172 		RC_USE_CONVERTER_CACHE,
173 		RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN,
174 		RC_USE_CONVERTER_NEEDAUTH,
175 		RC_USE_NATIVE_FILEDIALOG,
176 		RC_USE_SYSTEM_COLORS,
177 		RC_USE_TOOLTIP,
178 		RC_USE_PIXMAP_CACHE,
179 		RC_USE_QIMAGE,
180 		RC_USE_SYSTEM_THEME_ICONS,
181 		RC_VIEWDVI_PAPEROPTION,
182 		RC_VIEWER,
183 		RC_VIEWER_ALTERNATIVES,
184 		RC_VISUAL_CURSOR,
185 		RC_CLOSE_BUFFER_WITH_LAST_VIEW,
186 		RC_LAST
187 	};
188 
189 	///
190 	LyXRC();
191 	///
192 	void setDefaults();
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 	// FIXME unused (was used for xforms. Do we still need this?)
223 	//static docstring const getDescription(LyXRCTags);
224 	///
225 	std::string bind_file;
226 	///
227 	std::string def_file;
228 	///
229 	std::string ui_file;
230 	///
231 	std::string print_landscape_flag;
232 	///
233 	std::string print_paper_flag;
234 	///
235 	std::string print_paper_dimension_flag;
236 	/// option for telling the dvi viewer about the paper size
237 	std::string view_dvi_paper_option;
238 	/// default paper size for local xdvi/dvips/ghostview/whatever
239 	/// command to run chktex incl. options
240 	std::string chktex_command;
241 	/// all available commands to run bibtex incl. options
242 	CommandSet bibtex_alternatives;
243 	/// command to run bibtex incl. options
244 	std::string bibtex_command;
245 	/// command to run japanese bibtex incl. options
246 	std::string jbibtex_command;
247 	/// all available commands to run japanese bibtex incl. options
248 	CommandSet jbibtex_alternatives;
249 	/// all available index commands incl. options
250 	CommandSet index_alternatives;
251 	/// command to run makeindex incl. options or other index programs
252 	std::string index_command;
253 	/// command to run japanese index program incl. options
254 	std::string jindex_command;
255 	/// command to generate multiple indices
256 	std::string splitindex_command;
257 	/// command to run makeindex incl. options for nomencl
258 	std::string nomencl_command;
259 	/// command to run the python pygments syntax highlighter
260 	std::string pygmentize_command;
261 	///
262 	std::string document_path;
263 	///
264 	std::string example_path;
265 	///
266 	std::string template_path;
267 	///
268 	std::string tempdir_path;
269 	///
270 	std::string thesaurusdir_path;
271 	///
272 	std::string hunspelldir_path;
273 	///
274 	bool auto_region_delete;
275 	/// enable middle-mouse-button paste
276 	bool mouse_middlebutton_paste;
277 	/// flag telling whether lastfiles should be checked for existance
278 	bool auto_reset_options;
279 	///
280 	bool check_lastfiles;
281 	/// maximal number of lastfiles
282 	unsigned int num_lastfiles;
283 	/// whether or not go to saved position when opening a file
284 	bool use_lastfilepos;
285 	/// load files from last session automatically
286 	bool load_session;
287 	/// do we save new documents as compressed by default
288 	bool save_compressed;
289 	/// whether or not to save the document dir in the file
290 	bool save_origin;
291 	/// shall a backup file be created
292 	bool make_backup;
293 	/// A directory for storing backup files
294 	std::string backupdir_path;
295 	/// Whether or not save/restore session information
296 	/// like windows position and geometry.
297 	bool allow_geometry_session;
298 	/// Scrolling speed of the mouse wheel
299 	double mouse_wheel_speed;
300 	/// Default zoom factor for screen fonts
301 	int defaultZoom;
302 	/// Actual zoom factor for screen fonts
303 	/// (default zoom plus buffer zoom factor)
304 	int currentZoom;
305 	/// Screen font sizes in points for each font size
306 	std::string font_sizes[10];
307 	/// Allow the use of scalable fonts? Default is yes.
308 	bool use_scalable_fonts;
309 	/// DPI of monitor
310 	unsigned int dpi;
311 	///
312 	std::string fontenc;
313 	///
314 	std::string roman_font_name;
315 	///
316 	std::string sans_font_name;
317 	///
318 	std::string typewriter_font_name;
319 	///
320 	std::string roman_font_foundry;
321 	///
322 	std::string sans_font_foundry;
323 	///
324 	std::string typewriter_font_foundry;
325 	///
326 	unsigned int autosave;
327 	///
328 	unsigned int plaintext_linelen;
329 	/// Accept compound words in spellchecker?
330 	bool spellchecker_accept_compound;
331 	/// End of paragraph markers?
332 	bool paragraph_markers;
333 	/// Use tooltips?
334 	bool use_tooltip;
335 	/// Use the colors from current system theme?
336 	bool use_system_colors;
337 	/// use native file dialog or our own ?
338 	bool use_native_filedialog;
339 	/// Use pixmap cache?
340 	bool use_pixmap_cache;
341 	/// Use QImage backend?
342 	bool use_qimage;
343 	/// Spellchecker engine: aspell, hunspell, etc
344 	std::string spellchecker;
345 	/// Alternate language for spellchecker
346 	std::string spellchecker_alt_lang;
347 	/// Escape characters
348 	std::string spellchecker_esc_chars;
349 	/// spellcheck continuously?
350 	bool spellcheck_continuously;
351 	/// spellcheck notes and comments?
352 	bool spellcheck_notes;
353 	/// minimum length of words to complete
354 	unsigned int completion_minlength;
355 	///
356 	bool use_kbmap;
357 	///
358 	std::string primary_kbmap;
359 	///
360 	std::string secondary_kbmap;
361 	///
362 	std::string lyxpipes;
363 	///
364 	std::string date_insert_format;
365 	///
366 	std::string language_custom_package;
367 	///
368 	bool language_auto_begin;
369 	///
370 	bool language_auto_end;
371 	///
372 	std::string language_command_begin;
373 	///
374 	std::string language_command_end;
375 	///
376 	std::string language_command_local;
377 	///
378 	bool language_global_options;
379 	///
380 	enum LangPackageSelection {
381 		LP_AUTO = 0,
382 		LP_BABEL,
383 		LP_CUSTOM,
384 		LP_NONE
385 	};
386 	///
387 	LangPackageSelection language_package_selection;
388 	/// bidi cursor movement: true = visual, false = logical
389 	bool visual_cursor;
390 	///
391 	bool auto_number;
392 	///
393 	bool mark_foreign_language;
394 	///
395 	std::string gui_language;
396 	///
397 	std::string default_otf_view_format;
398 	///
399 	std::string default_platex_view_format;
400 	///
401 	std::string default_view_format;
402 	/// all available viewers
403 	Alternatives viewer_alternatives;
404 	/// all available editors
405 	Alternatives editor_alternatives;
406 	///
407 	bool mac_dontswap_ctrl_meta;
408 	///
409 	bool mac_like_cursor_movement;
410 	///
411 	bool cursor_follows_scrollbar;
412 	///
413 	bool scroll_below_document;
414 	///
415 	enum MacroEditStyle {
416 		MACRO_EDIT_INLINE_BOX = 0,
417 		MACRO_EDIT_INLINE,
418 		MACRO_EDIT_LIST
419 	};
420 	///
421 	MacroEditStyle macro_edit_style;
422 	///
423 	bool dialogs_iconify_with_main;
424 	///
425 	bool display_graphics;
426 	///
427 	bool show_banner;
428 	///
429 	enum PreviewStatus {
430 		PREVIEW_OFF,
431 		PREVIEW_NO_MATH,
432 		PREVIEW_ON
433 	};
434 	///
435 	PreviewStatus preview;
436 	///
437 	bool preview_hashed_labels;
438 	///
439 	double preview_scale_factor;
440 	/// user name
441 	std::string user_name;
442 	/// user email
443 	std::string user_email;
444 	/// icon set name
445 	std::string icon_set;
446 	/// whether to use the icons from the theme
447 	bool use_system_theme_icons;
448 	/// True if the TeX engine cannot handle posix paths
449 	bool windows_style_tex_paths;
450 	/// True if the TeX engine can handle file names containing spaces
451 	bool tex_allows_spaces;
452 	/** Prepend paths to the PATH environment variable.
453 	 *  The string is input, stored and output in native format.
454 	 */
455 	std::string path_prefix;
456 	/** Prepend paths to the TEXINPUTS environment variable.
457 	 *  The string is input, stored and output in native format.
458 	 *  A '.' here stands for the current document directory.
459 	 */
460 	std::string texinputs_prefix;
461 	/// Use the cache for file converters?
462 	bool use_converter_cache;
463 	/// Forbid use of external converters with 'needauth' option
464 	bool use_converter_needauth_forbidden;
465 	/// Ask user before calling external converters with 'needauth' option
466 	bool use_converter_needauth;
467 	/// The maximum age of cache files in seconds
468 	unsigned int converter_cache_maxage;
469 	/// Sort layouts alphabetically
470 	bool sort_layouts;
471 	/// Group layout by their category
472 	bool group_layouts;
473 	/// Toggle toolbars in fullscreen mode?
474 	bool full_screen_toolbars;
475 	/// Toggle scrollbar in fullscreen mode?
476 	bool full_screen_scrollbar;
477 	/// Toggle tabbar in fullscreen mode?
478 	bool full_screen_tabbar;
479 	/// Toggle menubar in fullscreen mode?
480 	bool full_screen_menubar;
481 	/// Toggle statusbar in fullscreen mode?
482 	bool full_screen_statusbar;
483 	/// Limit the text width?
484 	bool full_screen_limit;
485 	/// Width of limited screen (in pixels) in fullscreen mode
486 	int full_screen_width;
487 	///
488 	bool completion_cursor_text;
489 	///
490 	double completion_inline_delay;
491 	///
492 	bool completion_inline_math;
493 	///
494 	bool completion_inline_text;
495 	///
496 	int completion_inline_dots;
497 	///
498 	bool autocorrection_math;
499 	///
500 	double completion_popup_delay;
501 	///
502 	bool completion_popup_math;
503 	///
504 	bool completion_popup_text;
505 	///
506 	bool completion_popup_after_complete;
507 	///
508 	bool open_buffers_in_tabs;
509 	///
510 	bool single_close_tab_button;
511 	///
512 	bool single_instance;
513 	///
514 	std::string forward_search_dvi;
515 	///
516 	std::string forward_search_pdf;
517 	///
518 	int export_overwrite;
519 	/// Default decimal point when aligning table columns on decimal
520 	std::string default_decimal_point;
521 	///
522 	Length::UNIT default_length_unit;
523 	///
524 	enum ScrollWheelZoom {
525 		SCROLL_WHEEL_ZOOM_OFF,
526 		SCROLL_WHEEL_ZOOM_CTRL,
527 		SCROLL_WHEEL_ZOOM_SHIFT,
528 		SCROLL_WHEEL_ZOOM_ALT
529 	};
530 	///
531 	ScrollWheelZoom scroll_wheel_zoom;
532 	///
533 	int cursor_width;
534 	/// One of: yes, no, ask
535 	std::string close_buffer_with_last_view;
536 };
537 
538 
539 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
540 
541 ///
542 extern LyXRC lyxrc;
543 ///
544 extern LyXRC system_lyxrc;
545 
546 // used by at least frontends/qt4/GuiPref.cpp
547 const long maxlastfiles = 50;
548 
549 } // namespace lyx
550 
551 #endif
552