#include "lyxrc.h"
#include "debug.h"
-#include "kbmap.h"
-#include "LyXAction.h"
#include "intl.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;
using std::endl;
using std::vector;
-class kb_keymap;
-
-extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
+namespace lyx {
+namespace graphics {
+/// The translator between the DisplayType and the corresponding lyx string.
+extern Translator<DisplayType, string> displayTranslator;
+}
+}
namespace {
{ "\\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 },
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.
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";
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";
preview_hashed_labels = false;
preview_scale_factor = 0.9;
- 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)
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;
case RC_DISPLAY_GRAPHICS:
if (lexrc.next()) {
- display_graphics = grfx::displayTranslator.find(lexrc.getString());
+ display_graphics = lyx::graphics::displayTranslator.find(lexrc.getString());
}
break;
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;
}
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());
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";
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';
}
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";
}