X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXRC.cpp;h=99289aa1b02fd68de1036dc8d3ef695149d34887;hb=1e519d1115f41f71c253cb9e2fbb7803e9a583a9;hp=654468e957fd0cca0e556bed1e7ab6f97b17934e;hpb=891a7ef79f9b42e638ccd254a4681f9e8532ca8f;p=lyx.git diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 654468e957..99289aa1b0 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -23,6 +23,8 @@ #include "Converter.h" #include "FontEnums.h" #include "Format.h" +#include "FuncCode.h" +#include "FuncRequest.h" #include "Lexer.h" #include "LyX.h" #include "Mover.h" @@ -59,8 +61,7 @@ namespace { // The format should also be updated in configure.py, and conversion code // should be added to prefs2prefs_prefs.py. -static unsigned int const LYXRC_FILEFORMAT = 25; // spitz: rename collapsible - +static unsigned int const LYXRC_FILEFORMAT = 29; // spitz: remove \\date_insert_format // when adding something to this array keep it sorted! LexerKeyword lyxrcTags[] = { { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND }, @@ -93,7 +94,6 @@ LexerKeyword lyxrcTags[] = { { "\\copier", LyXRC::RC_COPIER }, { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR }, { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH }, - { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT }, { "\\def_file", LyXRC::RC_DEFFILE }, { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT }, { "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT }, @@ -107,7 +107,6 @@ LexerKeyword lyxrcTags[] = { { "\\escape_chars", LyXRC::RC_ESC_CHARS }, { "\\example_path", LyXRC::RC_EXAMPLEPATH }, { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE }, - { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FILEFORMAT }, { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI }, { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF }, @@ -195,7 +194,7 @@ LexerKeyword lyxrcTags[] = { { "\\use_converter_needauth", LyXRC::RC_USE_CONVERTER_NEEDAUTH }, { "\\use_converter_needauth_forbidden", LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, - { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE }, + { "\\use_native_filedialog", LyXRC::RC_USE_NATIVE_FILEDIALOG }, // compatibility with versions older than 1.4.0 only { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS }, { "\\use_system_theme_icons", LyXRC::RC_USE_SYSTEM_THEME_ICONS }, @@ -212,160 +211,6 @@ LexerKeyword lyxrcTags[] = { const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]); -} // namespace - - -LyXRC::LyXRC() -{ - setDefaults(); -} - - -void LyXRC::setDefaults() -{ - icon_set = string(); - use_system_theme_icons = false; - bind_file = "cua"; - def_file = "default"; - ui_file = "default"; - // The current document directory - texinputs_prefix = "."; - print_landscape_flag = "-t landscape"; - print_paper_flag = "-t"; - print_paper_dimension_flag = "-T"; - document_path.erase(); - view_dvi_paper_option.erase(); - default_view_format = "pdf2"; - default_otf_view_format = "pdf4"; - default_platex_view_format = "pdf3"; - chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; - bibtex_command = "automatic"; - fontenc = "default"; - index_command = "makeindex -c -q"; - nomencl_command = "makeindex -s nomencl.ist"; - pygmentize_command = string(); - dpi = 75; - // Because a screen is typically wider than a piece of paper: - defaultZoom = 150; - currentZoom = defaultZoom; - allow_geometry_session = true; - // Default LaTeX font size: - font_sizes[FONT_SIZE_TINY] = "5.0"; - font_sizes[FONT_SIZE_SCRIPT] = "7.0"; - font_sizes[FONT_SIZE_FOOTNOTE] = "8.0"; - font_sizes[FONT_SIZE_SMALL] = "9.0"; - font_sizes[FONT_SIZE_NORMAL] = "10.0"; - font_sizes[FONT_SIZE_LARGE] = "12.0"; - font_sizes[FONT_SIZE_LARGER] = "14.4"; - font_sizes[FONT_SIZE_LARGEST] = "17.26"; - font_sizes[FONT_SIZE_HUGE] = "20.74"; - font_sizes[FONT_SIZE_HUGER] = "24.88"; - use_scalable_fonts = true; - roman_font_name = ""; - sans_font_name = ""; - typewriter_font_name = ""; - autosave = 300; - auto_region_delete = true; - auto_reset_options = false; - plaintext_linelen = 65; - mouse_wheel_speed = 1.0; - num_lastfiles = 20; - check_lastfiles = true; - use_lastfilepos = true; - load_session = false; - make_backup = true; - save_compressed = false; - save_origin = false; - backupdir_path.erase(); - display_graphics = true; - // Spellchecker settings: -// FIXME: this check should test the target platform (darwin) -#if defined(USE_MACOSX_PACKAGING) - spellchecker = "native"; -#elif defined(USE_ASPELL) - spellchecker = "aspell"; -#elif defined(USE_HUNSPELL) - spellchecker = "hunspell"; -#else - spellchecker = "aspell"; -#endif - spellchecker_accept_compound = false; - spellcheck_continuously = false; - completion_minlength = 6; - spellcheck_notes = true; - use_kbmap = false; - visual_cursor = false; - auto_number = true; - mark_foreign_language = true; - language_auto_begin = true; - language_auto_end = true; - language_global_options = true; - language_package_selection = LP_AUTO; - language_custom_package = "\\usepackage{babel}"; - language_command_begin = "\\selectlanguage{$$lang}"; - language_command_local = "\\foreignlanguage{$$lang}{"; - sort_layouts = false; - group_layouts = true; - gui_language = "auto"; - show_banner = true; - windows_style_tex_paths = false; - tex_allows_spaces = false; - date_insert_format = "%x"; - cursor_follows_scrollbar = false; - scroll_below_document = false; - scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL; - paragraph_markers = false; - mac_dontswap_ctrl_meta = false; - mac_like_cursor_movement = false; - macro_edit_style = MACRO_EDIT_INLINE_BOX; - dialogs_iconify_with_main = false; - preview = PREVIEW_OFF; - preview_hashed_labels = false; - preview_scale_factor = 1.0; - use_converter_cache = true; - use_converter_needauth_forbidden = true; - use_converter_needauth = true; - use_system_colors = false; - use_tooltip = true; - use_pixmap_cache = false; - converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months - user_name = to_utf8(support::user_name()); - user_email = to_utf8(support::user_email()); - open_buffers_in_tabs = true; - single_close_tab_button = false; - single_instance = true; - forward_search_dvi = string(); - forward_search_pdf = string(); - export_overwrite = NO_FILES; - - // Fullscreen settings - full_screen_limit = false; - full_screen_toolbars = true; - full_screen_tabbar = true; - full_screen_menubar = true; - full_screen_statusbar = true; - full_screen_scrollbar = true; - full_screen_width = 700; - - completion_cursor_text = true; - completion_popup_math = true; - completion_popup_text = false; - completion_popup_delay = 2.0; - completion_popup_after_complete = true; - autocorrection_math = false; - completion_inline_math = true; - completion_inline_text = false; - completion_inline_dots = -1; - completion_inline_delay = 0.2; - default_decimal_point = "."; - default_length_unit = Length::CM; - cursor_width = 1; - close_buffer_with_last_view = "yes"; - mouse_middlebutton_paste = true; -} - - -namespace { void oldFontFormat(string & family, string & foundry) { @@ -405,6 +250,8 @@ bool LyXRC::read(FileName const & filename, bool check_format) lexrc2.setFile(tempfile); LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'..."); retval = read(lexrc2, check_format); + if (retval == FormatMismatch) + LYXERR0("Conversion failed for " << filename.absFileName()); } return retval == ReadOK; } @@ -430,7 +277,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) return ReadError; // format prior to 2.0 and introduction of format tag - unsigned int format = 0; + unsigned int rc_format = 0; while (lexrc.isOK()) { // By using two switches we take advantage of the compiler @@ -453,7 +300,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) switch (static_cast(le)) { case RC_LYXRCFORMAT: if (lexrc.next()) - format = lexrc.getInteger(); + rc_format = lexrc.getInteger(); break; case RC_INPUT: // Include file if (lexrc.next()) { @@ -530,10 +377,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } break; - case RC_FONT_ENCODING: - lexrc >> fontenc; - break; - case RC_PRINTLANDSCAPEFLAG: lexrc >> print_landscape_flag; break; @@ -871,15 +714,15 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_ACCEPT_COMPOUND: lexrc >> spellchecker_accept_compound; break; + case RC_USE_NATIVE_FILEDIALOG: + lexrc >> use_native_filedialog; + break; case RC_USE_SYSTEM_COLORS: lexrc >> use_system_colors; break; case RC_USE_TOOLTIP: lexrc >> use_tooltip; break; - case RC_USE_PIXMAP_CACHE: - lexrc >> use_pixmap_cache; - break; case RC_SPELLCHECKER: lexrc >> spellchecker; break; @@ -915,9 +758,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) if (lexrc.next()) default_length_unit = (Length::UNIT) lexrc.getInteger(); break; - case RC_DATE_INSERT_FORMAT: - lexrc >> date_insert_format; - break; case RC_LANGUAGE_CUSTOM_PACKAGE: lexrc >> language_custom_package; break; @@ -1232,7 +1072,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) // This is triggered the first time through the loop unless // we hit a format tag. - if (check_format && format != LYXRC_FILEFORMAT) + if (check_format && rc_format != LYXRC_FILEFORMAT) return FormatMismatch; } @@ -1590,15 +1430,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through - case RC_DATE_INSERT_FORMAT: - if (ignore_system_lyxrc || - date_insert_format != system_lyxrc.date_insert_format) { - os << "\\date_insert_format \"" << date_insert_format - << "\"\n"; - } - if (tag != RC_LAST) - break; - // fall through case RC_USER_NAME: os << "\\user_name \"" << user_name << "\"\n"; if (tag != RC_LAST) @@ -2112,18 +1943,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through - case RC_FONT_ENCODING: - if (ignore_system_lyxrc || - fontenc != system_lyxrc.fontenc) { - os << "\\font_encoding \"" << fontenc << "\"\n"; - } - if (tag != RC_LAST) - break; - os << "\n#\n" << "# FILE SECTION ######################################\n" << "#\n\n"; - // fall through case RC_DOCUMENTPATH: if (ignore_system_lyxrc || @@ -2405,6 +2227,16 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through + case RC_USE_NATIVE_FILEDIALOG: + if (ignore_system_lyxrc || + use_native_filedialog != system_lyxrc.use_native_filedialog) { + os << "\\use_native_filedialog " + << convert(use_native_filedialog) + << '\n'; + } + if (tag != RC_LAST) + break; + // fall through case RC_USE_SYSTEM_COLORS: if (ignore_system_lyxrc || use_system_colors != system_lyxrc.use_system_colors) { @@ -2425,16 +2257,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; // fall through - case RC_USE_PIXMAP_CACHE: - if (ignore_system_lyxrc || - use_pixmap_cache != system_lyxrc.use_pixmap_cache) { - os << "\\use_pixmap_cache " - << convert(use_pixmap_cache) - << '\n'; - } - if (tag != RC_LAST) - break; - // fall through os << "\n#\n" << "# LANGUAGE SUPPORT SECTION ##########################\n" @@ -2910,7 +2732,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_COPIER: case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR: case LyXRC::RC_SCROLL_BELOW_DOCUMENT: - case LyXRC::RC_DATE_INSERT_FORMAT: case LyXRC::RC_GUI_LANGUAGE: case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT: case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT: @@ -2928,7 +2749,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_EDITOR_ALTERNATIVES: case LyXRC::RC_ESC_CHARS: case LyXRC::RC_EXAMPLEPATH: - case LyXRC::RC_FONT_ENCODING: case LyXRC::RC_FILEFORMAT: case LyXRC::RC_GROUP_LAYOUTS: case LyXRC::RC_HUNSPELLDIR_PATH: @@ -2964,12 +2784,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_PARAGRAPH_MARKERS: case LyXRC::RC_PATH_PREFIX: if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) { - prependEnvPath("PATH", lyxrc_new.path_prefix); + prependEnvPath("PATH", replaceEnvironmentPath(lyxrc_new.path_prefix)); // Resets python path support::os::python(true); } // fall through case LyXRC::RC_PREVIEW: + if (lyxrc_orig.preview != lyxrc_new.preview) { + // Update all previews of all documents. + /* FIXME: this can be very expensive. It would be cheaper + * to kill all existing previews and update visible + * previews.*/ + theBufferList().updatePreviews(); + } + // fall through case LyXRC::RC_PREVIEW_HASHED_LABELS: case LyXRC::RC_PREVIEW_SCALE_FACTOR: case LyXRC::RC_PRINTLANDSCAPEFLAG: @@ -2978,6 +2806,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SAVE_COMPRESSED: case LyXRC::RC_SAVE_ORIGIN: case LyXRC::RC_SCREEN_DPI: + case LyXRC::RC_SCREEN_FONT_ROMAN: case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY: case LyXRC::RC_SCREEN_FONT_SANS: @@ -2986,8 +2815,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SCREEN_FONT_SIZES: case LyXRC::RC_SCREEN_FONT_TYPEWRITER: case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY: - case LyXRC::RC_GEOMETRY_SESSION: case LyXRC::RC_SCREEN_ZOOM: + if (lyxrc_orig.roman_font_name != lyxrc_new.roman_font_name + || lyxrc_orig.sans_font_name != lyxrc_new.sans_font_name + || lyxrc_orig.typewriter_font_name != lyxrc_new.typewriter_font_name + || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry + || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry + || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts + || lyxrc_orig.font_sizes != lyxrc_new.font_sizes + || lyxrc_orig.typewriter_font_foundry != lyxrc_new.typewriter_font_foundry + || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) { + dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + } + // fall through + case LyXRC::RC_GEOMETRY_SESSION: case LyXRC::RC_SERVERPIPE: case LyXRC::RC_SET_COLOR: case LyXRC::RC_SHOW_BANNER: @@ -3015,9 +2856,9 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_USE_CONVERTER_CACHE: case LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN: case LyXRC::RC_USE_CONVERTER_NEEDAUTH: + case LyXRC::RC_USE_NATIVE_FILEDIALOG: case LyXRC::RC_USE_SYSTEM_COLORS: case LyXRC::RC_USE_TOOLTIP: - case LyXRC::RC_USE_PIXMAP_CACHE: case LyXRC::RC_USE_SYSTEM_THEME_ICONS: case LyXRC::RC_VIEWDVI_PAPEROPTION: case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON: @@ -3046,6 +2887,15 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) } +set LyXRC::getRCs() +{ + set res; + for (int i = 0; i != lyxrcCount; ++i) + res.insert(ltrim(lyxrcTags[i].tag, "\\")); + return res; +} + + #if 0 string const LyXRC::getDescription(LyXRCTags tag) { @@ -3141,11 +2991,6 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Show a small box around a Math Macro with the macro name when the cursor is inside."); break; - case RC_DATE_INSERT_FORMAT: - //xgettext:no-c-format - str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\"."); - break; - case RC_DEFFILE: str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories."); break; @@ -3178,10 +3023,6 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from."); break; - case RC_FONT_ENCODING: - str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); - break; - case RC_FILEFORMAT: break; @@ -3431,10 +3272,6 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Enable the automatic appearance of tool tips in the work area."); break; - case RC_USE_PIXMAP_CACHE: - str = _("Enable the pixmap cache that might improve performance on Mac and Windows."); - break; - case RC_VIEWDVI_PAPEROPTION: _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")"); break;