move reading of bind files from lyxrc.C to kbmap.C; do not read bindings or menus when not using gui; move paper related enums to a new paper.h; remove dependency on bufferparams.h from lyxrc.h; small bugfix to tex2lyx; fix bad menu shortcut

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7372 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2003-07-26 23:04:39 +00:00
parent 6a2f81278d
commit 80d7f70dc3
39 changed files with 385 additions and 261 deletions

View File

@ -1,6 +1,11 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ui/stdmenus.ui: fix mnemonic for "Display Tooltips"
2003-07-27 José Matos <jamatos@fep.up.pt>
* layouts/linuxdoc.layout: add support for tables and figures (linuxdoc).
* layouts/linuxdoc.layout: add support for tables and figures
(linuxdoc).
2003-07-22 John Levon <levon@movementarian.org>

View File

@ -196,7 +196,7 @@ Menuset
# A common feature request JMarc wants to see
# Item "Open All Footnotes|F" "open-footnotes"
# Item "Close All Footnotes|C" "close-footnotes"
Item "Display Tooltips|D" "toggle-tooltips"
Item "Display Tooltips|i" "toggle-tooltips"
Separator
Submenu "Update|U" "document_update"
ViewFormats

View File

@ -1,6 +1,35 @@
2003-07-27 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ispell.C:
* encoding.h: add includes
* lyxrc.C: remove reading of bind files
* lyx_main.C (init): setup bindings and menus only if we have a
gui.
* kbmap.C (read): new method. Do the actual reading of bind
files.
* converter.C (dvipdfm_options):
* bufferparams.C:
* lyxrc.C (read):
(output): adapt PAPER_* enums.
* lyxrc.h: include paper.h instead of bufferparams.h (mucho lighter)
* bufferparams.h: remove paper-related enums from there
* paper.h: New file. A trivial header file to hold paper-related
enums. It should later expand to contain many paper-related
horrors access.
* lyxrc.C: declare extern displayTranslator
2003-07-27 José Matos <jamatos@fep.up.pt>
* tabular.[Ch] (linuxdoc): add support for tables and figures (linuxdoc).
* tabular.[Ch] (linuxdoc): add support for tables and figures
(linuxdoc).
2003-07-27 José Matos <jamatos@fep.up.pt>

View File

@ -55,6 +55,7 @@
#include "graphics/Previews.h"
#include "support/LAssert.h"
#include "support/textutils.h"
#include "support/filetools.h"
#include "support/path.h"

View File

@ -119,7 +119,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
if (tmpret == -1)
++tmpret;
paragraph_separation =
static_cast<BufferParams::PARSEP>(tmpret);
static_cast<PARSEP>(tmpret);
} else if (token == "\\defskip") {
lex.nextToken();
defskip = VSpace(lex.getString());
@ -172,7 +172,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
int tmpret = lex.findToken(string_paperpackages);
if (tmpret == -1) {
++tmpret;
paperpackage = BufferParams::PACKAGE_NONE;
paperpackage = PACKAGE_NONE;
} else
paperpackage = PAPER_PACKAGES(tmpret);
} else if (token == "\\use_geometry") {
@ -180,7 +180,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
use_geometry = lex.getInteger();
} else if (token == "\\use_amsmath") {
lex.nextToken();
use_amsmath = static_cast<BufferParams::AMS>(
use_amsmath = static_cast<AMS>(
lex.getInteger());
} else if (token == "\\use_natbib") {
lex.nextToken();
@ -202,7 +202,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
if (tmpret == -1)
++tmpret;
orientation =
static_cast<BufferParams::PAPER_ORIENTATION>(tmpret);
static_cast<PAPER_ORIENTATION>(tmpret);
} else if (token == "\\paperwidth") {
lex.next();
paperwidth = lex.getString();

View File

@ -20,6 +20,7 @@
#include "LaTeXFeatures.h"
#include "texrow.h"
#include "author.h"
#include "paper.h"
#include "insets/insetquotes.h"
@ -38,61 +39,6 @@ struct Language;
*/
class BufferParams {
public:
///
enum PAPER_SIZE {
///
PAPER_DEFAULT,
///
PAPER_USLETTER,
///
PAPER_LEGALPAPER,
///
PAPER_EXECUTIVEPAPER,
///
PAPER_A3PAPER,
///
PAPER_A4PAPER,
///
PAPER_A5PAPER,
///
PAPER_B5PAPER
};
///
enum PAPER_PACKAGES {
///
PACKAGE_NONE,
///
PACKAGE_A4,
///
PACKAGE_A4WIDE,
///
PACKAGE_WIDEMARGINSA4
};
///
enum VMARGIN_PAPER_TYPE {
///
VM_PAPER_DEFAULT,
///
VM_PAPER_CUSTOM,
///
VM_PAPER_USLETTER,
///
VM_PAPER_USLEGAL,
///
VM_PAPER_USEXECUTIVE,
///
VM_PAPER_A3,
///
VM_PAPER_A4,
///
VM_PAPER_A5,
///
VM_PAPER_B3,
///
VM_PAPER_B4,
///
VM_PAPER_B5
};
///
enum PARSEP {
///
@ -101,13 +47,6 @@ public:
PARSEP_SKIP
};
///
enum PAPER_ORIENTATION {
///
ORIENTATION_PORTRAIT,
///
ORIENTATION_LANDSCAPE
};
///
BufferParams();
/// read a header token, if unrecognised, return it or an unknown class name

View File

@ -68,12 +68,12 @@ string const dvipdfm_options(BufferParams const & bp)
{
string result;
if (bp.papersize2 != BufferParams::VM_PAPER_CUSTOM) {
if (bp.papersize2 != VM_PAPER_CUSTOM) {
string const paper_size = bp.paperSizeName();
if (paper_size != "b5" && paper_size != "foolscap")
result = "-p "+ paper_size;
if (bp.orientation == BufferParams::ORIENTATION_LANDSCAPE)
if (bp.orientation == ORIENTATION_LANDSCAPE)
result += " -l";
}

View File

@ -15,6 +15,8 @@
#include "LString.h"
#include "lyxrc.h"
#include <map>
///
typedef unsigned short int Uchar;

View File

@ -179,7 +179,7 @@ bool Formats::view(Buffer const * buffer, string const & filename,
paper_size = "us";
command += ' ' + paper_size;
if (buffer->params.orientation
== BufferParams::ORIENTATION_LANDSCAPE)
== ORIENTATION_LANDSCAPE)
command += 'r';
}

View File

@ -1,3 +1,7 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ControlTabular.C (useMetricUnits): adapt PAPER_* enums
2003-07-23 Angus Leeming <leeming@lyx.org>
* ControlExternal.C: pass a Buffer const & rather than a Buffer const *

View File

@ -70,7 +70,7 @@ void ControlTabular::set(LyXTabular::Feature f, string const & arg)
bool ControlTabular::useMetricUnits() const
{
return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
return lyxrc.default_papersize > PAPER_EXECUTIVEPAPER;
}

View File

@ -1,3 +1,10 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QPrefs.C:
* QDocumentDialog.C:
* QDocument.C:
* QGraphics.C: adapt PAPER_* enums
2003-07-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QLMenubar.h:

View File

@ -335,7 +335,7 @@ void QDocument::apply()
params.float_placement = dialog_->floatModule->get();
// paper
params.papersize2 = BufferParams::VMARGIN_PAPER_TYPE(
params.papersize2 = VMARGIN_PAPER_TYPE(
dialog_->pageLayoutModule->papersizeCO->currentItem());
params.paperwidth = widgetsToLength(dialog_->pageLayoutModule->paperwidthLE,
@ -350,9 +350,9 @@ void QDocument::apply()
params.sides = LyXTextClass::OneSide;
if (dialog_->pageLayoutModule->landscapeRB->isChecked())
params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
params.orientation = ORIENTATION_LANDSCAPE;
else
params.orientation = BufferParams::ORIENTATION_PORTRAIT;
params.orientation = ORIENTATION_PORTRAIT;
// margins
params.use_geometry =
@ -362,7 +362,7 @@ void QDocument::apply()
if (margin > 0) {
margin = margin - 1;
}
params.paperpackage = BufferParams::PAPER_PACKAGES(margin);
params.paperpackage = PAPER_PACKAGES(margin);
// set params.papersize from params.papersize2
// and params.paperpackage
@ -416,18 +416,18 @@ void QDocument::update_contents()
// FIXME: move to controller
LyXLength::UNIT defaultUnit = LyXLength::CM;
switch (lyxrc.default_papersize) {
case BufferParams::PAPER_DEFAULT: break;
case PAPER_DEFAULT: break;
case BufferParams::PAPER_USLETTER:
case BufferParams::PAPER_LEGALPAPER:
case BufferParams::PAPER_EXECUTIVEPAPER:
case PAPER_USLETTER:
case PAPER_LEGALPAPER:
case PAPER_EXECUTIVEPAPER:
defaultUnit = LyXLength::IN;
break;
case BufferParams::PAPER_A3PAPER:
case BufferParams::PAPER_A4PAPER:
case BufferParams::PAPER_A5PAPER:
case BufferParams::PAPER_B5PAPER:
case PAPER_A3PAPER:
case PAPER_A4PAPER:
case PAPER_A5PAPER:
case PAPER_B5PAPER:
defaultUnit = LyXLength::CM;
break;
}
@ -581,7 +581,7 @@ void QDocument::update_contents()
dialog_->setCustomPapersize(psize);
bool const landscape =
params.orientation == BufferParams::ORIENTATION_LANDSCAPE;
params.orientation == ORIENTATION_LANDSCAPE;
dialog_->pageLayoutModule->landscapeRB->setChecked(landscape);
dialog_->pageLayoutModule->portraitRB->setChecked(!landscape);

View File

@ -243,7 +243,7 @@ void QDocumentDialog::setMargins(int papersize)
marginsModule->marginCO->insertItem(qt_("Default"));
marginsModule->marginCO->insertItem(qt_("Custom"));
bool a4size = (papersize == 6 || papersize == 0
&& lyxrc.default_papersize == BufferParams::PAPER_A4PAPER);
&& lyxrc.default_papersize == PAPER_A4PAPER);
if (a4size && pageLayoutModule->portraitRB->isChecked()) {
marginsModule->marginCO->insertItem(qt_("Small margins"));
marginsModule->marginCO->insertItem(qt_("Very small margins"));

View File

@ -21,7 +21,7 @@
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "insets/insetgraphicsParams.h"
#include "bufferparams.h"
//#include "bufferparams.h"
#include "lyxrc.h"
#include "lengthcombo.h"
#include "qt_helpers.h"
@ -144,18 +144,18 @@ void QGraphics::update_contents()
// set the right default unit
LyXLength::UNIT unitDefault = LyXLength::CM;
switch (lyxrc.default_papersize) {
case BufferParams::PAPER_DEFAULT: break;
case PAPER_DEFAULT: break;
case BufferParams::PAPER_USLETTER:
case BufferParams::PAPER_LEGALPAPER:
case BufferParams::PAPER_EXECUTIVEPAPER:
case PAPER_USLETTER:
case PAPER_LEGALPAPER:
case PAPER_EXECUTIVEPAPER:
unitDefault = LyXLength::IN;
break;
case BufferParams::PAPER_A3PAPER:
case BufferParams::PAPER_A4PAPER:
case BufferParams::PAPER_A5PAPER:
case BufferParams::PAPER_B5PAPER:
case PAPER_A3PAPER:
case PAPER_A4PAPER:
case PAPER_A5PAPER:
case PAPER_B5PAPER:
unitDefault = LyXLength::CM;
break;
}

View File

@ -36,6 +36,7 @@
#include "QPrefs.h"
#include "Qt2BC.h"
#include "lyxrc.h"
#include "lyxfont.h"
#include "frnt_lang.h"
#include "helper_funcs.h"
#include "qt_helpers.h"
@ -164,8 +165,7 @@ void QPrefs::apply()
rc.auto_reset_options = latexmod->latexAutoresetCB->isChecked();
rc.view_dvi_paper_option = fromqstr(latexmod->latexDviPaperED->text());
rc.default_papersize =
static_cast<BufferParams::PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
static_cast<PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
QPrefDisplayModule * displaymod(dialog_->displayModule);

View File

@ -1,3 +1,11 @@
2003-07-27 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XPainter.C: include lyxfont.h
* FormParagraph.C:
* FormGraphics.C:
* FormDocument.C: adapt PAPER_* enums
2003-07-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XFormsMenubar.h:

View File

@ -444,7 +444,7 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
// Default unit choice is cm if metric, inches if US paper.
// If papersize is default, check the lyxrc-settings
int const paperchoice = fl_get_choice(paper_->choice_papersize);
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER)
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
|| paperchoice == 2 || paperchoice > 5;
string const default_unit = metric ? "cm" : "in";
if (getString(class_->input_skip).empty())
@ -467,7 +467,7 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
} else if (ob == paper_->radio_landscape) {
fl_set_choice(paper_->choice_paperpackage,
BufferParams::PACKAGE_NONE + 1);
PACKAGE_NONE + 1);
} else if (ob == paper_->choice_papersize) {
int const paperchoice = fl_get_choice(paper_->choice_papersize);
@ -510,7 +510,7 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
// Default unit choice is cm if metric, inches if US paper.
// If papersize is default, use the lyxrc-settings
bool const metric = (defsize && lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER)
bool const metric = (defsize && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
|| paperchoice == 2 || paperchoice > 5;
string const default_unit = metric ? "cm" : "in";
if (getString(paper_->input_custom_width).empty())
@ -568,7 +568,7 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
fl_set_button(paper_->check_use_geometry, 1);
fl_set_choice(paper_->choice_paperpackage,
BufferParams::PACKAGE_NONE + 1);
PACKAGE_NONE + 1);
bool const use_geom = fl_get_button(paper_->check_use_geometry);
setEnabled(paper_->input_top_margin, use_geom);
@ -592,11 +592,11 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
// either default papersize (preferences) or document
// papersize has to be A4
bool const enable = ( fl_get_choice(paper_->choice_papersize) == 1
&& lyxrc.default_papersize == BufferParams::PAPER_A4PAPER )
&& lyxrc.default_papersize == PAPER_A4PAPER )
|| fl_get_choice(paper_->choice_papersize) == 7;
if (!enable)
fl_set_choice(paper_->choice_paperpackage,
BufferParams::PACKAGE_NONE + 1);
PACKAGE_NONE + 1);
setEnabled(paper_->choice_paperpackage,
enable && fl_get_button(paper_->radio_portrait));
}
@ -697,10 +697,10 @@ bool FormDocument::class_apply(BufferParams &params)
void FormDocument::paper_apply(BufferParams & params)
{
params.papersize2 = BufferParams::VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
params.papersize2 = VMARGIN_PAPER_TYPE(fl_get_choice(paper_->choice_papersize) - 1);
params.paperpackage =
BufferParams::PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
PAPER_PACKAGES(fl_get_choice(paper_->choice_paperpackage) - 1);
// set params.papersize from params.papersize2 and params.paperpackage
params.setPaperStuff();
@ -708,9 +708,9 @@ void FormDocument::paper_apply(BufferParams & params)
params.use_geometry = fl_get_button(paper_->check_use_geometry);
if (fl_get_button(paper_->radio_landscape))
params.orientation = BufferParams::ORIENTATION_LANDSCAPE;
params.orientation = ORIENTATION_LANDSCAPE;
else
params.orientation = BufferParams::ORIENTATION_PORTRAIT;
params.orientation = ORIENTATION_PORTRAIT;
params.paperwidth =
getLengthFromWidgets(paper_->input_custom_width,
@ -890,7 +890,7 @@ void FormDocument::class_update(BufferParams const & params)
bool const length_input = pos == 4;
if (length_input) {
int const paperchoice = fl_get_choice(paper_->choice_papersize);
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER)
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
|| paperchoice == 2 || paperchoice > 5;
string const default_unit = metric ? "cm" : "in";
string const length = params.getDefSkip().asLyXCommand();
@ -999,7 +999,7 @@ void FormDocument::paper_update(BufferParams const & params)
fl_set_button(paper_->radio_landscape, 0);
setEnabled(paper_->radio_landscape, !useCustom);
if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
if (params.orientation == ORIENTATION_LANDSCAPE)
fl_set_button(paper_->radio_landscape, 1);
else
fl_set_button(paper_->radio_portrait, 1);
@ -1007,11 +1007,11 @@ void FormDocument::paper_update(BufferParams const & params)
//either default papersize (preferences)
//or document papersize has to be A4
(paperchoice == 7
|| paperchoice == 1 && lyxrc.default_papersize == BufferParams::PAPER_A4PAPER)
|| paperchoice == 1 && lyxrc.default_papersize == PAPER_A4PAPER)
&& fl_get_button(paper_->radio_portrait));
// Default unit choice is cm if metric, inches if US paper.
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER)
bool const metric = (paperchoice == 1 && lyxrc.default_papersize > PAPER_EXECUTIVEPAPER)
|| paperchoice == 2 || paperchoice > 5;
string const default_unit = metric ? "cm" : "in";
updateWidgetsFromLengthString(paper_->input_custom_width,

View File

@ -274,14 +274,14 @@ void FormGraphics::build()
// set the right default unit
switch (lyxrc.default_papersize) {
case BufferParams::PAPER_DEFAULT: break;
case BufferParams::PAPER_USLETTER:
case BufferParams::PAPER_LEGALPAPER:
case BufferParams::PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
case BufferParams::PAPER_A3PAPER:
case BufferParams::PAPER_A4PAPER:
case BufferParams::PAPER_A5PAPER:
case BufferParams::PAPER_B5PAPER: defaultUnit = "cm"; break;
case PAPER_DEFAULT: break;
case PAPER_USLETTER:
case PAPER_LEGALPAPER:
case PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
case PAPER_A3PAPER:
case PAPER_A4PAPER:
case PAPER_A5PAPER:
case PAPER_B5PAPER: defaultUnit = "cm"; break;
}
}

View File

@ -167,16 +167,16 @@ void FormParagraph::build()
// set default unit for custom length
switch (lyxrc.default_papersize) {
case BufferParams::PAPER_DEFAULT:
case BufferParams::PAPER_USLETTER:
case BufferParams::PAPER_LEGALPAPER:
case BufferParams::PAPER_EXECUTIVEPAPER:
case PAPER_DEFAULT:
case PAPER_USLETTER:
case PAPER_LEGALPAPER:
case PAPER_EXECUTIVEPAPER:
defaultUnit = "in";
break;
case BufferParams::PAPER_A3PAPER:
case BufferParams::PAPER_A4PAPER:
case BufferParams::PAPER_A5PAPER:
case BufferParams::PAPER_B5PAPER:
case PAPER_A3PAPER:
case PAPER_A4PAPER:
case PAPER_A5PAPER:
case PAPER_B5PAPER:
defaultUnit = "cm";
break;
}

View File

@ -1753,7 +1753,7 @@ void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
int const choice =
fl_get_choice(dialog_->choice_default_papersize) - 1;
rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
rc.default_papersize = static_cast<PAPER_SIZE>(choice);
rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
rc.chktex_command = fl_get_input(dialog_->input_checktex);

View File

@ -16,6 +16,7 @@
#include "debug.h"
#include "XWorkArea.h"
#include "xfont_metrics.h"
#include "lyxfont.h"
#include "ColorHandler.h"
#include "lyxrc.h"
#include "encoding.h"

View File

@ -1,3 +1,8 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* GraphicsTypes.h: do not declare displayTranstor here (and remove
extra include)
2003-07-27 José Matos <jamatos@fep.up.pt>
* PreviewLoader.C (Impl::dumpPreamble): comply with makeLaTeXFile

View File

@ -12,7 +12,7 @@
#include <config.h>
#include "graphics/GraphicsTypes.h"
#include "support/translator.h"
namespace lyx {
namespace graphics {

View File

@ -16,7 +16,6 @@
#define GRAPHICSTYPES_H
#include "LString.h"
#include "support/translator.h"
namespace lyx {
namespace graphics {
@ -63,8 +62,6 @@ enum DisplayType {
NoDisplay
};
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
///
void setDisplayTranslator();

View File

@ -1,9 +1,18 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetgraphicsParams.C:
* insetexternal.C: declare extern displayTranslator
* insetexternal.C:
* renderers.C: add #include "support/LAssert.h"
2003-07-27 José Matos <jamatos@fep.up.pt>
* insetfloat.[Ch] (linuxdoc):
* insetgraphics.C (linuxdoc):
* insettabular.C (linuxdoc):
* insettext.[Ch] (linuxdoc): add support for tables and figures (linuxdoc).
* insettext.[Ch] (linuxdoc): add support for tables and figures
(linuxdoc).
2003-07-27 José Matos <jamatos@fep.up.pt>

View File

@ -38,6 +38,8 @@
#include "support/lyxalgo.h"
#include "support/path.h"
#include "support/tostr.h"
#include "support/LAssert.h"
#include "support/translator.h"
#include <boost/bind.hpp>
@ -50,6 +52,13 @@ using std::ostream;
using std::endl;
using std::auto_ptr;
namespace lyx {
namespace graphics {
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
}
}
namespace {
lyx::graphics::DisplayType const defaultDisplayType = lyx::graphics::NoDisplay;

View File

@ -21,6 +21,7 @@
#include "support/LOstream.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "support/translator.h"
#include "lyxrc.h"
#include "debug.h"
#include "lyxlex.h"
@ -30,6 +31,13 @@ using namespace lyx::support;
using std::ostream;
namespace lyx {
namespace graphics {
/// The translator between the DisplayType and the corresponding lyx string.
extern Translator<DisplayType, string> displayTranslator;
}
}
InsetGraphicsParams::InsetGraphicsParams()
{

View File

@ -24,7 +24,7 @@
#include "graphics/GraphicsImage.h"
#include "support/filetools.h"
#include "support/LAssert.h"
using namespace lyx::support;

View File

@ -17,6 +17,7 @@
#include "ispell.h"
#include "WordLangTuple.h"
#include "gettext.h"
#include "bufferparams.h"
#include "support/forkedcall.h"
#include "support/lstrings.h"

View File

@ -12,9 +12,13 @@
#include "kbmap.h"
#include "lfuns.h"
#include "kbsequence.h"
#include "LyXAction.h"
#include "support/filetools.h"
#include "lyxlex.h"
#include "debug.h"
using std::endl;
using lyx::support::i18nLibFileSearch;
string const kb_keymap::printKeysym(LyXKeySymPtr key,
key_modifier::state mod)
@ -64,6 +68,93 @@ string::size_type kb_keymap::bind(string const & seq, int action)
}
namespace {
enum BindTags {
BN_BIND,
BN_BINDFILE
};
keyword_item bindTags[] = {
{ "\\bind", BN_BIND },
{ "\\bind_file", BN_BINDFILE }
};
}
bool kb_keymap::read(string const & bind_file)
{
const int bindCount = sizeof(bindTags) / sizeof(keyword_item);
LyXLex lexrc(bindTags, bindCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
string const tmp = i18nLibFileSearch("bind", bind_file, "bind");
lexrc.setFile(tmp);
if (!lexrc.isOK()) return false;
lyxerr[Debug::KBMAP] << "Reading bindfile:" << tmp << endl;
bool error = false;
while (lexrc.isOK()) {
switch (lexrc.lex()) {
case LyXLex::LEX_UNDEF:
lexrc.printError("Unknown tag `$$Token'");
continue;
case LyXLex::LEX_FEOF:
continue;
case BN_BIND:
{
string seq, cmd;
if (lexrc.next()) {
seq = lexrc.getString();
} else {
lexrc.printError("BN_BIND: Missing key sequence");
break;
}
if (lexrc.next(true)) {
cmd = lexrc.getString();
} else {
lexrc.printError("BN_BIND: missing command");
break;
}
int action = lyxaction.LookupFunc(cmd);
if (!action == LFUN_UNKNOWN_ACTION) {
lexrc.printError("BN_BIND: Unknown LyX"
" function `$$Token'");
break;
}
error = (bind(seq, kb_action(action)) != string::npos);
break;
}
case BN_BINDFILE:
if (lexrc.next()) {
string const tmp(lexrc.getString());
error = read(tmp);
} else {
lexrc.printError("BN_BINDFILE: Missing file name");
error = true;
break;
}
break;
}
}
if (error) {
lyxerr << "Error reading bind file: " << tmp << endl;
}
return error;
}
int kb_keymap::lookup(LyXKeySymPtr key,
key_modifier::state mod, kb_sequence * seq) const
{

View File

@ -30,6 +30,9 @@ public:
*/
string::size_type bind(string const & seq, int action);
// Parse a bind file
bool kb_keymap::read(string const & bind_file);
/// print all available keysyms
string const print() const;

View File

@ -96,10 +96,6 @@ LyX::LyX(int & argc, char * argv[])
// we need to parse for "-dbg" and "-help"
bool const want_gui = easyParse(argc, argv);
// Global bindings (this must be done as early as possible.) (Lgb)
toplevel_keymap.reset(new kb_keymap);
defaultKeyBindings(toplevel_keymap.get());
// 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.
@ -470,12 +466,15 @@ void LyX::init(bool gui)
lyxerr[Debug::INIT] << "Reading layouts..." << endl;
LyXSetStyle();
// Ensure that we have really read a bind file, so that LyX is
// usable.
lyxrc.readBindFileIfNeeded();
if (gui) {
// Set up bindings
toplevel_keymap.reset(new kb_keymap);
defaultKeyBindings(toplevel_keymap.get());
toplevel_keymap->read(lyxrc.bind_file);
// Read menus
readUIFile(lyxrc.ui_file);
// Read menus
readUIFile(lyxrc.ui_file);
}
if (lyxerr.debugging(Debug::LYXRC))
lyxrc.print();

View File

@ -16,13 +16,12 @@
#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"
@ -30,6 +29,7 @@
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "support/userinfo.h"
#include "support/translator.h"
using namespace lyx::support;
@ -40,9 +40,12 @@ using std::ios;
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 {
@ -57,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 },
@ -170,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.
@ -194,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";
@ -271,25 +272,6 @@ void LyXRC::setDefaults() {
}
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;
@ -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";
@ -1219,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";
}

View File

@ -10,7 +10,7 @@
#ifndef LYXRC_H
#define LYXRC_H
#include "bufferparams.h" // Just to get the enum BufferParams::PAPER_SIZE (sic)
#include "paper.h"
#include "graphics/GraphicsTypes.h"
// #include <boost/utility.hpp>
@ -65,7 +65,6 @@ enum LyXRCTags {
RC_LASTFILES,
RC_AUTOREGIONDELETE,
RC_AUTORESET_OPTIONS,
RC_BIND,
RC_SERVERPIPE,
RC_INPUT,
RC_BINDFILE,
@ -132,8 +131,6 @@ enum LyXRCTags {
///
int read(string const & filename);
///
void readBindFileIfNeeded();
///
void write(string const & filename) const;
///
void print() const;
@ -190,7 +187,7 @@ enum LyXRCTags {
/// option for telling the dvi viewer about the paper size
string view_dvi_paper_option;
/// default paper size for local xdvi/dvips/ghostview/whatever
BufferParams::PAPER_SIZE default_papersize;
PAPER_SIZE default_papersize;
/// command to run chktex incl. options
string chktex_command;
///
@ -350,12 +347,6 @@ enum LyXRCTags {
string user_name;
/// user email
string user_email;
private:
/// Is a bind file already (or currently) read?
bool hasBindFile;
///
int ReadBindFile(string const & name);
};
///

83
src/paper.h Normal file
View File

@ -0,0 +1,83 @@
// -*- C++ -*-
/**
* \file paper.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Jean-Marc Lasgouttes
*
* Full author contact details are available in file CREDITS
*
* A trivial header file to hold paper-related enums. It should later
* expand to contain many paper-related horrors access.
*/
#ifndef PAPER_H
#define PAPER_H
///
enum PAPER_SIZE {
///
PAPER_DEFAULT,
///
PAPER_USLETTER,
///
PAPER_LEGALPAPER,
///
PAPER_EXECUTIVEPAPER,
///
PAPER_A3PAPER,
///
PAPER_A4PAPER,
///
PAPER_A5PAPER,
///
PAPER_B5PAPER
};
///
enum PAPER_PACKAGES {
///
PACKAGE_NONE,
///
PACKAGE_A4,
///
PACKAGE_A4WIDE,
///
PACKAGE_WIDEMARGINSA4
};
///
enum VMARGIN_PAPER_TYPE {
///
VM_PAPER_DEFAULT,
///
VM_PAPER_CUSTOM,
///
VM_PAPER_USLETTER,
///
VM_PAPER_USLEGAL,
///
VM_PAPER_USEXECUTIVE,
///
VM_PAPER_A3,
///
VM_PAPER_A4,
///
VM_PAPER_A5,
///
VM_PAPER_B3,
///
VM_PAPER_B4,
///
VM_PAPER_B5
};
///
enum PAPER_ORIENTATION {
///
ORIENTATION_PORTRAIT,
///
ORIENTATION_LANDSCAPE
};
#endif

View File

@ -1,3 +1,7 @@
2003-07-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* text.C (parse_text): fix handling of \LaTeXe macro
2003-07-26 Angus Leeming <leeming@lyx.org>
* Spacing.h:

View File

@ -510,12 +510,17 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
os << "\n\\size " << known_coded_sizes[where - known_sizes] << "\n";
}
else if (t.cs() == "LyX" || t.cs() == "TeX"
|| t.cs() == "LaTeX" || t.cs() == "LaTeXe") {
else if (t.cs() == "LyX" || t.cs() == "TeX"
|| t.cs() == "LaTeX") {
os << t.cs();
skip_braces(p); // eat {}
}
else if (t.cs() == "LaTeXe") {
os << "LaTeX2e";
skip_braces(p); // eat {}
}
else if (t.cs() == "lyxarrow") {
os << "\\SpecialChar \\menuseparator\n";
skip_braces(p);

View File

@ -29,6 +29,7 @@
#include "language.h"
#include "support/tostr.h"
#include "support/lstrings.h"
#include "support/LAssert.h"
#include "frontends/LyXView.h"
#include "frontends/screen.h"
#include "frontends/Dialogs.h"