+2003-10-13 Angus Leeming <leeming@lyx.org>
+
+ * lyx_main.C (LyX): remove call to setDisplayTranslator().
+
+ * lyxrc.C: displayTranslator is now a function,
+ declared in GraphicsTypes.h.
+
2003-10-13 Joao Luis Meloni Assirati <assirati@fma.if.usp.br>
* lyxsocket.[Ch]: new files. A simple local socket interface for lyx.
+2003-10-13 Angus Leeming <leeming@lyx.org>
+
+ * GraphicsTypes.[Ch] (setDisplayTranslator): removed.
+ Make displayTranslator a function,
+
2003-10-10 Angus Leeming <leeming@lyx.org>
* PreviewedInset.[Ch]: removed.
#include <config.h>
#include "graphics/GraphicsTypes.h"
-#include "support/translator.h"
-
using std::string;
namespace lyx {
namespace graphics {
+namespace {
+
/// The translator between the Display enum and corresponding lyx string.
-Translator<DisplayType, string> displayTranslator(DefaultDisplay, "default");
+Translator<DisplayType, string> const initTranslator()
+{
+ Translator<DisplayType, string> translator(DefaultDisplay, "default");
+
+ // Fill the display translator
+ translator.addPair(MonochromeDisplay, "monochrome");
+ translator.addPair(GrayscaleDisplay, "grayscale");
+ translator.addPair(ColorDisplay, "color");
+ translator.addPair(NoDisplay, "none");
+
+ return translator;
+}
+
+} // namespace anon
-void setDisplayTranslator()
+Translator<DisplayType, string> const & displayTranslator()
{
- /// This variable keeps a tab on whether the translator is set.
- static bool done = false;
-
- if (!done) {
- done = true;
-
- // Fill the display translator
- displayTranslator.addPair(DefaultDisplay, "default");
- displayTranslator.addPair(MonochromeDisplay, "monochrome");
- displayTranslator.addPair(GrayscaleDisplay, "grayscale");
- displayTranslator.addPair(ColorDisplay, "color");
- displayTranslator.addPair(NoDisplay, "none");
-
- // backward compatibility for old lyxrc.display_graphics
- displayTranslator.addPair(MonochromeDisplay, "mono");
- displayTranslator.addPair(GrayscaleDisplay, "gray");
- displayTranslator.addPair(NoDisplay, "no");
- }
+ static Translator<DisplayType, string> const translator =
+ initTranslator();
+ return translator;
}
} // namespace graphics
#ifndef GRAPHICSTYPES_H
#define GRAPHICSTYPES_H
+#include "support/translator.h"
+
namespace lyx {
namespace graphics {
};
-///
-void setDisplayTranslator();
+/// The translator between the Display enum and corresponding lyx string.
+Translator<DisplayType, std::string> const & displayTranslator();
} // namespace graphics
} // namespace lyx
+2003-10-13 Angus Leeming <leeming@lyx.org>
+
+ * insetexternal.C:
+ * insetgraphicsParams.C: displayTranslator is now a function.
+
2003-10-13 Angus Leeming <leeming@lyx.org>
* insetinclude.C: remove #include "PreviewImage.h".
using std::vector;
-namespace lyx {
-namespace graphics {
-
-/// The translator between the DisplayType and the corresponding lyx string.
-extern Translator<DisplayType, string> displayTranslator;
-
-} // namespace graphics
-} // namespace lyx
-
-
namespace {
lyx::graphics::DisplayType const defaultDisplayType = lyx::graphics::NoDisplay;
if (display != defaultDisplayType)
os << "\tdisplay "
- << lyx::graphics::displayTranslator.find(display)
+ << lyx::graphics::displayTranslator().find(display)
<< '\n';
if (lyxscale != defaultLyxScale)
case EX_DISPLAY: {
lex.next();
string const name = lex.getString();
- display = lyx::graphics::displayTranslator.find(name);
+ display = lyx::graphics::displayTranslator().find(name);
break;
}
using std::ostream;
-namespace lyx {
-namespace graphics {
-/// The translator between the DisplayType and the corresponding lyx string.
-extern Translator<DisplayType, string> displayTranslator;
-}
-}
-
-
InsetGraphicsParams::InsetGraphicsParams()
{
init();
if (lyxscale != 100)
os << "\tlyxscale " << lyxscale << '\n';
if (display != lyx::graphics::DefaultDisplay)
- os << "\tdisplay " << lyx::graphics::displayTranslator.find(display) << '\n';
+ os << "\tdisplay " << lyx::graphics::displayTranslator().find(display) << '\n';
if (!float_equal(scale, 0.0, 0.05)) {
if (!float_equal(scale, 100.0, 0.05))
os << "\tscale " << scale << '\n';
} else if (token == "display") {
lex.next();
string const type = lex.getString();
- display = lyx::graphics::displayTranslator.find(type);
+ display = lyx::graphics::displayTranslator().find(type);
} else if (token == "scale") {
lex.next();
scale = lex.getFloat();
// we need to parse for "-dbg" and "-help"
bool const want_gui = easyParse(argc, argv);
- // set the DisplayTranslator only once; should that be done here??
- // if this should not be in this file, please also remove
- // #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
- lyx::graphics::setDisplayTranslator();
-
if (want_gui)
lyx_gui::parse_init(argc, argv);
#include "lyxlex.h"
#include "lyxfont.h"
+#include "graphics/GraphicsTypes.h"
+
#include "support/filetools.h"
#include "support/lstrings.h"
#include "support/translator.h"
using std::string;
-namespace lyx {
-namespace graphics {
-/// The translator between the DisplayType and the corresponding lyx string.
-extern Translator<DisplayType, string> displayTranslator;
-}
-}
-
namespace {
// when adding something to this array keep it sorted!
case RC_DISPLAY_GRAPHICS:
if (lexrc.next()) {
- display_graphics = lyx::graphics::displayTranslator.find(lexrc.getString());
+ display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
}
break;
os << "# Display graphics within LyX\n"
<< "# monochrome|grayscale|color|none\n"
<< "\\display_graphics "
- << lyx::graphics::displayTranslator.find(display_graphics)
+ << lyx::graphics::displayTranslator().find(display_graphics)
<< '\n';
}