From: Jean-Marc Lasgouttes Date: Sat, 26 Jul 2003 23:04:39 +0000 (+0000) Subject: move reading of bind files from lyxrc.C to kbmap.C; do not read bindings or menus... X-Git-Tag: 1.6.10~16459 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=80d7f70dc340e8b1ab29d38284b8327d13757196;p=features.git 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 --- diff --git a/lib/ChangeLog b/lib/ChangeLog index ac5d602982..9957af2914 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,6 +1,11 @@ +2003-07-26 Jean-Marc Lasgouttes + + * ui/stdmenus.ui: fix mnemonic for "Display Tooltips" + 2003-07-27 José Matos - * 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 diff --git a/lib/ui/stdmenus.ui b/lib/ui/stdmenus.ui index 3bfde10ccb..8c3134d3c0 100644 --- a/lib/ui/stdmenus.ui +++ b/lib/ui/stdmenus.ui @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index 49ef22ee51..8f2cf258ef 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,35 @@ +2003-07-27 Jean-Marc Lasgouttes + + * 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 - * 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 diff --git a/src/buffer.C b/src/buffer.C index efb8945115..b7afa7c11a 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -55,6 +55,7 @@ #include "graphics/Previews.h" +#include "support/LAssert.h" #include "support/textutils.h" #include "support/filetools.h" #include "support/path.h" diff --git a/src/bufferparams.C b/src/bufferparams.C index 7743aa2c69..d560eaff6c 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -119,7 +119,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token) if (tmpret == -1) ++tmpret; paragraph_separation = - static_cast(tmpret); + static_cast(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( + use_amsmath = static_cast( 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(tmpret); + static_cast(tmpret); } else if (token == "\\paperwidth") { lex.next(); paperwidth = lex.getString(); diff --git a/src/bufferparams.h b/src/bufferparams.h index 23ba28c271..dc0782d5d1 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -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 diff --git a/src/converter.C b/src/converter.C index 482059b7c1..9de2dc5ed7 100644 --- a/src/converter.C +++ b/src/converter.C @@ -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"; } diff --git a/src/encoding.h b/src/encoding.h index 15684639e7..c64a84517a 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -15,6 +15,8 @@ #include "LString.h" #include "lyxrc.h" +#include + /// typedef unsigned short int Uchar; diff --git a/src/format.C b/src/format.C index b8a0844bd1..a84ec86d56 100644 --- a/src/format.C +++ b/src/format.C @@ -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'; } diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index f344c80a08..d118a302d2 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-07-26 Jean-Marc Lasgouttes + + * ControlTabular.C (useMetricUnits): adapt PAPER_* enums + 2003-07-23 Angus Leeming * ControlExternal.C: pass a Buffer const & rather than a Buffer const * diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C index d403a09de1..40d4854fb0 100644 --- a/src/frontends/controllers/ControlTabular.C +++ b/src/frontends/controllers/ControlTabular.C @@ -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; } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 3b75a43a45..4f935a69b3 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2003-07-26 Jean-Marc Lasgouttes + + * QPrefs.C: + * QDocumentDialog.C: + * QDocument.C: + * QGraphics.C: adapt PAPER_* enums + 2003-07-25 Jean-Marc Lasgouttes * QLMenubar.h: diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 4207074450..f88c46dd2a 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -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); diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index 10956f6101..2715ae0451 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -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")); diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C index 2528fc6a80..bb05c5b666 100644 --- a/src/frontends/qt2/QGraphics.C +++ b/src/frontends/qt2/QGraphics.C @@ -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; } diff --git a/src/frontends/qt2/QPrefs.C b/src/frontends/qt2/QPrefs.C index d8d9ef4387..8c20752708 100644 --- a/src/frontends/qt2/QPrefs.C +++ b/src/frontends/qt2/QPrefs.C @@ -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(latexmod->latexPaperSizeCO->currentItem()); - + static_cast(latexmod->latexPaperSizeCO->currentItem()); QPrefDisplayModule * displaymod(dialog_->displayModule); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index c1cd64ac4d..9c398de5ca 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2003-07-27 Jean-Marc Lasgouttes + + * XPainter.C: include lyxfont.h + + * FormParagraph.C: + * FormGraphics.C: + * FormDocument.C: adapt PAPER_* enums + 2003-07-25 Jean-Marc Lasgouttes * XFormsMenubar.h: diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 276c7d48ea..4799da4227 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -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 ¶ms) 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, diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index dcdc701fd2..de005b8904 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -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; } } diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 6b45eb0f25..c2a99adbc4 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -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; } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index b80e30eca8..3ba45d7652 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -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(choice); + rc.default_papersize = static_cast(choice); rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff); rc.chktex_command = fl_get_input(dialog_->input_checktex); diff --git a/src/frontends/xforms/XPainter.C b/src/frontends/xforms/XPainter.C index 2849928b8e..2ddedc1a7e 100644 --- a/src/frontends/xforms/XPainter.C +++ b/src/frontends/xforms/XPainter.C @@ -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" diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 787bf3c3a9..9f82eb3abe 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2003-07-26 Jean-Marc Lasgouttes + + * GraphicsTypes.h: do not declare displayTranstor here (and remove + extra include) + 2003-07-27 José Matos * PreviewLoader.C (Impl::dumpPreamble): comply with makeLaTeXFile diff --git a/src/graphics/GraphicsTypes.C b/src/graphics/GraphicsTypes.C index bb79a8b3a3..9b54901488 100644 --- a/src/graphics/GraphicsTypes.C +++ b/src/graphics/GraphicsTypes.C @@ -12,7 +12,7 @@ #include #include "graphics/GraphicsTypes.h" - +#include "support/translator.h" namespace lyx { namespace graphics { diff --git a/src/graphics/GraphicsTypes.h b/src/graphics/GraphicsTypes.h index 5893c529e0..a11f80c952 100644 --- a/src/graphics/GraphicsTypes.h +++ b/src/graphics/GraphicsTypes.h @@ -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 displayTranslator; /// void setDisplayTranslator(); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 9355d078a9..65895918e4 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,9 +1,18 @@ +2003-07-26 Jean-Marc Lasgouttes + + * insetgraphicsParams.C: + * insetexternal.C: declare extern displayTranslator + + * insetexternal.C: + * renderers.C: add #include "support/LAssert.h" + 2003-07-27 José Matos * 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 diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index c04fb78434..5d660a98a0 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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 @@ -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 displayTranslator; +} +} + namespace { lyx::graphics::DisplayType const defaultDisplayType = lyx::graphics::NoDisplay; diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index 60aae033ee..12ab717770 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -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 displayTranslator; +} +} + InsetGraphicsParams::InsetGraphicsParams() { diff --git a/src/insets/renderers.C b/src/insets/renderers.C index e62d777654..b9c52c1920 100644 --- a/src/insets/renderers.C +++ b/src/insets/renderers.C @@ -24,7 +24,7 @@ #include "graphics/GraphicsImage.h" #include "support/filetools.h" - +#include "support/LAssert.h" using namespace lyx::support; diff --git a/src/ispell.C b/src/ispell.C index c04e1a38e3..419623033b 100644 --- a/src/ispell.C +++ b/src/ispell.C @@ -17,6 +17,7 @@ #include "ispell.h" #include "WordLangTuple.h" #include "gettext.h" +#include "bufferparams.h" #include "support/forkedcall.h" #include "support/lstrings.h" diff --git a/src/kbmap.C b/src/kbmap.C index 9ac6de0943..e1a0cce71e 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -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 { diff --git a/src/kbmap.h b/src/kbmap.h index 70dc5e8192..3b1818e5fb 100644 --- a/src/kbmap.h +++ b/src/kbmap.h @@ -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; diff --git a/src/lyx_main.C b/src/lyx_main.C index 20ba091dd9..eb44e0bb29 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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(); diff --git a/src/lyxrc.C b/src/lyxrc.C index 70f3d0ab85..f768bbe806 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -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 toplevel_keymap; +namespace lyx { +namespace graphics { +/// The translator between the DisplayType and the corresponding lyx string. +extern Translator 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"; } diff --git a/src/lyxrc.h b/src/lyxrc.h index 9d70eacee8..0be918fb90 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -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 @@ -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); }; /// diff --git a/src/paper.h b/src/paper.h new file mode 100644 index 0000000000..07c2f524da --- /dev/null +++ b/src/paper.h @@ -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 diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index 6d9ba1d79e..5971822b06 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,7 @@ +2003-07-26 Jean-Marc Lasgouttes + + * text.C (parse_text): fix handling of \LaTeXe macro + 2003-07-26 Angus Leeming * Spacing.h: diff --git a/src/tex2lyx/text.C b/src/tex2lyx/text.C index 524605b529..79ad1057d8 100644 --- a/src/tex2lyx/text.C +++ b/src/tex2lyx/text.C @@ -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); diff --git a/src/text3.C b/src/text3.C index 7ae6c2bafb..647ccbb0eb 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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"