X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxrc.C;h=f768bbe806000caa0ef2d11559467076d6b0bc74;hb=09e01879979643949f1f2c7216023f1f35d5ada2;hp=1f9e957160b276b947a339ec1607600474a3ef91;hpb=99215ea58fc2b6088a71e71c02a4af9af5548133;p=lyx.git diff --git a/src/lyxrc.C b/src/lyxrc.C index 1f9e957160..f768bbe806 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -13,20 +13,25 @@ #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 "support/LAssert.h" -#include "support/userinfo.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; @@ -35,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 { @@ -52,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 }, @@ -165,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. @@ -189,7 +195,7 @@ 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"; @@ -209,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"; @@ -225,7 +231,7 @@ void LyXRC::setDefaults() { check_lastfiles = true; make_backup = true; backupdir_path.erase(); - display_graphics = grfx::ColorDisplay; + display_graphics = lyx::graphics::ColorDisplay; // Spellchecker settings: use_spell_lib = true; isp_command = "ispell"; @@ -257,39 +263,15 @@ 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::user_name(); + user_name = lyx::support::user_name(); - user_email = lyx::user_email(); + user_email = lyx::support::user_email(); if (user_email.empty()) user_email = _("email address unknown"); } -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; -} - -void LyXRC::readBindFileIfNeeded() -{ - if (!hasBindFile) - ReadBindFile(bind_file); -} - - namespace { void oldFontFormat(string & family, string & foundry) @@ -347,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; @@ -376,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; @@ -546,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; @@ -801,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()); @@ -1160,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"; @@ -1201,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'; } @@ -1218,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"; }