X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxrc.C;h=f768bbe806000caa0ef2d11559467076d6b0bc74;hb=09e01879979643949f1f2c7216023f1f35d5ada2;hp=7cc8beb20058f4334ac5a703eafba76a194e3553;hpb=737c9af407d639f940b098fbf93cf9654ac14b96;p=lyx.git diff --git a/src/lyxrc.C b/src/lyxrc.C index 7cc8beb200..f768bbe806 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -1,35 +1,37 @@ -/* This file is part of - * ====================================================== +/** + * \file lyxrc.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * Full author contact details are available in file CREDITS + */ #include -#ifdef __GNUG__ -#pragma implementation "lyxrc.h" -#endif - #include #include #include #include -#include "debug.h" - #include "lyxrc.h" -#include "kbmap.h" -#include "LyXAction.h" + +#include "debug.h" #include "intl.h" -#include "support/path.h" -#include "support/filetools.h" #include "converter.h" +#include "format.h" #include "gettext.h" #include "lyxlex.h" +#include "lyxfont.h" + +#include "support/path.h" +#include "support/tostr.h" +#include "support/filetools.h" +#include "support/LAssert.h" +#include "support/lstrings.h" +#include "support/userinfo.h" +#include "support/translator.h" + +using namespace lyx::support; using std::ostream; using std::ofstream; @@ -38,9 +40,12 @@ using std::ios; using std::endl; using std::vector; -class kb_keymap; - -extern boost::scoped_ptr toplevel_keymap; +namespace lyx { +namespace graphics { +/// The translator between the DisplayType and the corresponding lyx string. +extern Translator displayTranslator; +} +} namespace { @@ -55,7 +60,6 @@ keyword_item lyxrcTags[] = { { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS }, { "\\autosave", LyXRC::RC_AUTOSAVE }, { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH }, - { "\\bind", LyXRC::RC_BIND }, { "\\bind_file", LyXRC::RC_BINDFILE }, { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES }, { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND }, @@ -144,10 +148,12 @@ keyword_item lyxrcTags[] = { { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS }, { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC }, { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT }, -#ifdef USE_PSPELL - { "\\use_pspell", LyXRC::RC_USE_PSPELL }, -#endif + // compatibility with versions older than 1.4.0 only + { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB }, + { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB }, { "\\use_tempdir", LyXRC::RC_USETEMPDIR }, + { "\\user_email", LyXRC::RC_USER_EMAIL }, + { "\\user_name", LyXRC::RC_USER_NAME }, { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION }, { "\\viewer" ,LyXRC::RC_VIEWER}, { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP } @@ -166,7 +172,6 @@ LyXRC::LyXRC() void LyXRC::setDefaults() { bind_file = "cua"; - hasBindFile = false; ui_file = "default"; // Get printer from the environment. If fail, use default "", // assuming that everything is set up correctly. @@ -190,14 +195,14 @@ void LyXRC::setDefaults() { use_tempdir = true; ps_command = "gs"; view_dvi_paper_option.erase(); - default_papersize = BufferParams::PAPER_USLETTER; + default_papersize = PAPER_USLETTER; custom_export_format = "ps"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; fontenc = "default"; dpi = 75; // Because a screen typically is wider than a piece of paper: zoom = 150; - wheel_jump = 100; + wheel_jump = 5; // Default LaTeX font size: font_sizes[LyXFont::SIZE_TINY] = 5.0; font_sizes[LyXFont::SIZE_SCRIPT] = 7.0; @@ -210,9 +215,9 @@ void LyXRC::setDefaults() { font_sizes[LyXFont::SIZE_HUGE] = 20.74; font_sizes[LyXFont::SIZE_HUGER] = 24.88; use_scalable_fonts = true; - roman_font_name = "times"; - sans_font_name = "helvetica"; - typewriter_font_name = "courier"; + roman_font_name = ""; + sans_font_name = ""; + typewriter_font_name = ""; popup_bold_font = "-*-helvetica-bold-r"; popup_normal_font = "-*-helvetica-medium-r"; font_norm = "iso8859-1"; @@ -226,11 +231,9 @@ void LyXRC::setDefaults() { check_lastfiles = true; make_backup = true; backupdir_path.erase(); - display_graphics = grfx::ColorDisplay; + display_graphics = lyx::graphics::ColorDisplay; // Spellchecker settings: -#ifdef USE_PSPELL - use_pspell = true; -#endif + use_spell_lib = true; isp_command = "ispell"; isp_accept_compound = false; isp_use_input_encoding = false; @@ -260,29 +263,12 @@ void LyXRC::setDefaults() { preview_hashed_labels = false; preview_scale_factor = 0.9; - /// These variables are not stored on disk (perhaps they - // should be moved from the LyXRC class). - use_gui = true; - pdf_mode = false; -} - + user_name = lyx::support::user_name(); -int LyXRC::ReadBindFile(string const & name) -{ - hasBindFile = true; - string const tmp = i18nLibFileSearch("bind", name, "bind"); - lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl; - int const result = read(tmp); - if (result) { - lyxerr << "Error reading bind file: " << tmp << endl; - } - return result; -} + user_email = lyx::support::user_email(); -void LyXRC::readBindFileIfNeeded() -{ - if (!hasBindFile) - ReadBindFile(bind_file); + if (user_email.empty()) + user_email = _("email address unknown"); } @@ -343,18 +329,7 @@ int LyXRC::read(string const & filename) break; case RC_BINDFILE: // RVDK_PATCH_5 if (lexrc.next()) { - string const tmp(lexrc.getString()); - if (hasBindFile) { - // We are already in the - // "actually read bind file" - // mode. - ReadBindFile(tmp); - } else { - // We are still in the "just - // remember the name of the - // bind file" mode. - bind_file = tmp; - } + bind_file = lexrc.getString(); } break; @@ -372,7 +347,7 @@ int LyXRC::read(string const & filename) case RC_DISPLAY_GRAPHICS: if (lexrc.next()) { - display_graphics = grfx::displayTranslator.find(lexrc.getString()); + display_graphics = lyx::graphics::displayTranslator.find(lexrc.getString()); } break; @@ -542,25 +517,25 @@ int LyXRC::read(string const & filename) ascii_lowercase(lexrc.getString()); if (size == "usletter") default_papersize = - BufferParams::PAPER_USLETTER; + PAPER_USLETTER; else if (size == "legal") default_papersize = - BufferParams::PAPER_LEGALPAPER; + PAPER_LEGALPAPER; else if (size == "executive") - default_papersize = - BufferParams::PAPER_EXECUTIVEPAPER; + default_papersize = + PAPER_EXECUTIVEPAPER; else if (size == "a3") default_papersize = - BufferParams::PAPER_A3PAPER; + PAPER_A3PAPER; else if (size == "a4") default_papersize = - BufferParams::PAPER_A4PAPER; + PAPER_A4PAPER; else if (size == "a5") default_papersize = - BufferParams::PAPER_A5PAPER; + PAPER_A5PAPER; else if (size == "b5") default_papersize = - BufferParams::PAPER_B5PAPER; + PAPER_B5PAPER; } break; @@ -779,7 +754,7 @@ int LyXRC::read(string const & filename) if (lexrc.next()) { x11_name = lexrc.getString(); } else { - lexrc.printError("Missing color name for color : `$$Token'"); + lexrc.printError("Missing color name for color: `$$Token'"); break; } @@ -797,53 +772,6 @@ int LyXRC::read(string const & filename) } break; - case RC_BIND: - { - // we should not do an explicit binding before - // loading a bind file. So, in this case, load - // the default bind file. - readBindFileIfNeeded(); - - // !!!chb, dynamic key binding... - int action = 0; - string::size_type res = 0; - string seq, cmd; - - if (lexrc.next()) { - seq = lexrc.getString(); - } else { - lexrc.printError("RC_BIND: Missing key sequence"); - break; - } - - if (lexrc.next(true)) { - cmd = lexrc.getString(); - } else { - lexrc.printError("RC_BIND: missing command"); - break; - } - - if ((action = lyxaction.LookupFunc(cmd)) >= 0) { - if (lyxerr.debugging(Debug::LYXRC)) { - lyxerr << "RC_BIND: Sequence `" - << seq << "' Command `" - << cmd << "' Action `" - << action << '\'' << endl; - } - res = toplevel_keymap->bind(seq, kb_action(action)); - if (res != string::npos - && lyxerr.debugging(Debug::LYXRC)) { - lexrc.printError( - "RC_BIND: " - "Invalid key sequence `" - + seq + '\''); - } - } else {// cmd is the last token read. - lexrc.printError( - "Unknown LyX function `$$Token'"); - } - break; - } case RC_SERVERPIPE: if (lexrc.next()) { lyxpipes = ExpandPath(lexrc.getString()); @@ -873,13 +801,11 @@ int LyXRC::read(string const & filename) } break; // Spellchecker settings: -#ifdef USE_PSPELL - case RC_USE_PSPELL: + case RC_USE_SPELL_LIB: if (lexrc.next()) { - use_pspell = lexrc.getBool(); + use_spell_lib = lexrc.getBool(); } break; -#endif case RC_SPELL_COMMAND: if (lexrc.next()) { isp_command = lexrc.getString(); @@ -1094,6 +1020,16 @@ int LyXRC::read(string const & filename) } break; + case RC_USER_NAME: + if (lexrc.next()) + user_name = lexrc.getString(); + break; + + case RC_USER_EMAIL: + if (lexrc.next()) + user_email = lexrc.getString(); + break; + case RC_LAST: break; // this is just a dummy } } @@ -1148,8 +1084,6 @@ void LyXRC::output(ostream & os) const case RC_LAST: case RC_INPUT: // input/include files are not done here - case RC_BIND: - // bindings is not written to the preferences file. case RC_BINDFILE: if (bind_file != system_lyxrc.bind_file) { os << "\\bind_file " << bind_file << "\n"; @@ -1189,7 +1123,8 @@ void LyXRC::output(ostream & os) const if (display_graphics != system_lyxrc.display_graphics) { os << "# Display graphics within LyX\n" << "# monochrome|grayscale|color|none\n" - << "\\display_graphics " << grfx::displayTranslator.find(display_graphics) + << "\\display_graphics " + << lyx::graphics::displayTranslator.find(display_graphics) << '\n'; } @@ -1206,21 +1141,21 @@ void LyXRC::output(ostream & os) const os << "# The default papersize to use.\n" << "\\default_papersize \""; switch (default_papersize) { - case BufferParams::PAPER_USLETTER: + case PAPER_USLETTER: os << "usletter"; break; - case BufferParams::PAPER_LEGALPAPER: + case PAPER_LEGALPAPER: os << "legal"; break; - case BufferParams::PAPER_EXECUTIVEPAPER: + case PAPER_EXECUTIVEPAPER: os << "executive"; break; - case BufferParams::PAPER_A3PAPER: + case PAPER_A3PAPER: os << "a3"; break; - case BufferParams::PAPER_A4PAPER: + case PAPER_A4PAPER: os << "a4"; break; - case BufferParams::PAPER_A5PAPER: + case PAPER_A5PAPER: os << "a5"; break; - case BufferParams::PAPER_B5PAPER: + case PAPER_B5PAPER: os << "b5"; break; - case BufferParams::PAPER_DEFAULT: break; + case PAPER_DEFAULT: break; } os << "\"\n"; } @@ -1261,6 +1196,12 @@ void LyXRC::output(ostream & os) const << '\n'; } + case RC_USER_NAME: + os << "\\user_name \"" << user_name << "\"\n"; + + case RC_USER_EMAIL: + os << "\\user_email \"" << user_email << "\"\n"; + case RC_SHOW_BANNER: if (show_banner != system_lyxrc.show_banner) { os << "\\show_banner " << tostr(show_banner) << '\n'; @@ -1606,12 +1547,10 @@ void LyXRC::output(ostream & os) const os << "\n#\n" << "# SPELLCHECKER SECTION ##############################\n" << "#\n\n"; -#ifdef USE_PSPELL - case RC_USE_PSPELL: - if (use_pspell != system_lyxrc.use_pspell) { - os << "\\use_pspell " << tostr(use_pspell) << '\n'; + case RC_USE_SPELL_LIB: + if (use_spell_lib != system_lyxrc.use_spell_lib) { + os << "\\use_spell_lib " << tostr(use_spell_lib) << '\n'; } -#endif case RC_SPELL_COMMAND: if (isp_command != system_lyxrc.isp_command) { os << "\\spell_command \"" << isp_command << "\"\n"; @@ -1798,6 +1737,7 @@ void LyXRC::output(ostream & os) const if (!converters.getConverter(cit->from, cit->to)) os << "\\converter \"" << cit->from << "\" \"" << cit->to << "\" \"\" \"\"\n"; + } os.flush(); } @@ -2083,7 +2023,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_LANGUAGE_PACKAGE: - str = _("The latex command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\"."); + str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\"."); break; case RC_LANGUAGE_GLOBAL_OPTIONS: @@ -2103,15 +2043,15 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_LANGUAGE_COMMAND_BEGIN: - str = _("The latex command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language."); + str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language."); break; case RC_LANGUAGE_COMMAND_END: - str = _("The latex command for changing back to the language of the document."); + str = _("The LaTeX command for changing back to the language of the document."); break; case RC_LANGUAGE_COMMAND_LOCAL: - str = _("The latex command for local changing of the language."); + str = _("The LaTeX command for local changing of the language."); break; case RC_DATE_INSERT_FORMAT: @@ -2124,7 +2064,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_WHEEL_JUMP: - str = _("The wheel movement factor (for mice with wheels or five button mice)."); + str = _("The number of lines that are scrolled by mice with wheels or five button mice."); break; case RC_CONVERTER: