From 6b9e0044d3cbbabb28ef50424badfcd795056b66 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 4 Sep 2002 06:52:26 +0000 Subject: [PATCH] floats in layout files git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5202 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 76 ++++++++++++++------------ lib/layouts/stdclass.inc | 1 + lib/layouts/stdfloats.inc | 38 +++++++++++++ src/ChangeLog | 50 ++++++++++------- src/FloatList.C | 5 +- src/lyxtextclass.C | 109 +++++++++++++++++++++++++++++++++++++- src/lyxtextclass.h | 2 + 7 files changed, 223 insertions(+), 58 deletions(-) create mode 100644 lib/layouts/stdfloats.inc diff --git a/lib/ChangeLog b/lib/ChangeLog index 95510a8ccb..d214aaa8a5 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2002-09-04 Lars Gullik Bjønnes + + * layouts/stdclass.inc: include stdfloats.h + + * layouts/stdfloats.inc: new file + 2002-09-03 Angus Leeming * scripts/lyxpreview2ppm.sh: test expects integer arguments. @@ -26,13 +32,13 @@ 2002-08-29 John Levon * images/math/: add AMS nrel - + 2002-08-29 John Levon * images/: add math sub/super script * images/math/: add \brace, \vec etc. - + 2002-08-29 John Levon * Makefile.am: install mathed icons @@ -40,11 +46,11 @@ 2002-08-29 John Levon * images/math/: add all icons except AMS nrel - + 2002-08-29 John Levon * images/math/: add most of the normal XPMs - + 2002-08-28 Rob Lahaye * lyx2lyx/lyx2lyx: add new format number "221" @@ -52,7 +58,7 @@ 2002-08-25 John Levon * images/find-replace.xpm: add - + 2002-08-23 Jean-Marc Lasgouttes * configure.m4: fix epsi->eps converter @@ -81,7 +87,7 @@ 2002-08-15 John Levon * scripts/convertDefault.sh: use /bin/sh not /bin/bash - + 2002-08-15 Jean-Marc Lasgouttes * doc/LaTeXConfig.lyx.in: add description of cl2emult class @@ -101,20 +107,20 @@ 2002-08-08 Herbert Voss * ui/default.ui: put gather into math menu - + 2002-08-07 John Levon * images/layout_LaTeX.xpm: remove - obsolete - + 2002-08-05 John Levon * images/dialog-tabular-insert.xpm: remove unneeded xpm - + 2002-08-05 John Levon * ui/default.ui: * bind/xemacs.bind: back to tabular-insert - + 2002-08-03 Dekel Tsur * lyx2lyx/lyxconvert_218.py (remove_oldert): Few fixes. @@ -126,7 +132,7 @@ * lyx2lyx/lyxconvert_218.py: Convert ERT and figinsets. 2002-07-30 André Pönitz - + * configure.m4: * ui/default.ui: make math-extern a bit more visible in Edit->Math @@ -153,13 +159,13 @@ * scripts/convertDefault.sh: defines a converter which is used when no userdefined was found - + 2002-07-20 Jean-Marc Lasgouttes * ui/default.ui: cleanup after change of Menu syntax. the foo_nobuffer menus are gone - * bind/sv_menus.bind: + * bind/sv_menus.bind: * bind/sciword.bind: remove some cruft * tex/iletter.cls: @@ -176,10 +182,10 @@ 2002-07-18 Angus Leeming * scripts/lyxpreview2ppm.sh: clean-up. Get it to work with - scary_eqns.lyx. + scary_eqns.lyx. 2002-07-17 André Pönitz - + * configure.m4: fix typo in last change * symbols: add \hbar @@ -194,9 +200,9 @@ 2002-07-16 Andrew Zabolotny - * bind/emacs.bind: - * bind/xemacs.bind: - * bind/sciword.bind: + * bind/emacs.bind: + * bind/xemacs.bind: + * bind/sciword.bind: * bind/cua.bind: include greekkeys and cyrkeys bindings * bind/greekkeys.bind: @@ -221,15 +227,15 @@ * lyxpreview2ppm.sh: use the pnmraw device in preference to pnm. 2002-07-12 André Pönitz - + * ui/default.ui: add menu for font changes * symbols: add textt 2002-07-10 Andrew Zabolotny - * bind/emacs.bind: - * bind/xemacs.bind: - * bind/sciword.bind: + * bind/emacs.bind: + * bind/xemacs.bind: + * bind/sciword.bind: * bind/cua.bind: better support for selection from numeric keypad * kbd/cp1251.cdef: @@ -248,7 +254,7 @@ as it's not portable apparently. 2002-07-09 André Pönitz - + * symbols: use it to define insets, too * configure.m4: * symbols: wasy symbols added @@ -259,7 +265,7 @@ left and right if so desired. 2002-07-08 André Pönitz - + * symbols: more stuff missing from the Porto changes 2002-07-05 Angus Leeming @@ -270,7 +276,7 @@ 2002-06-19 Herbert Voss * configure.m4: add converters for epsi and (x)fig - + 2002-07-03 Vitaly Lipatov * languages: add support for belarusian and kazakh @@ -278,7 +284,7 @@ * encodings: add pt154 2002-06-27 André Pönitz - + * configure.m4: add support for lyxpreview "format" * scripts/lyxpreview2xpm: add file @@ -295,23 +301,23 @@ 2002-06-21 John Levon * ui/default.ui: fix ellipses - + 2002-06-20 John Levon * ui/default.ui: remove Index Entry of last word * ui/old-default.ui: remove - + 2002-06-19 Dekel Tsur * examples/mathed.lyx: Remove obsolete part. 2002-06-17 Herbert Voss - - * configure.m4: install only those converters which are different - to convert, because this is taken as the default. SO we can get - rid of all problems when user do not have installed the right - converters. + + * configure.m4: install only those converters which are different + to convert, because this is taken as the default. SO we can get + rid of all problems when user do not have installed the right + converters. 2002-06-16 Adrien Rebollo @@ -336,7 +342,7 @@ 2002-05-30 Jean-Marc Lasgouttes * templates/IEEEtran.lyx: update to 1.2.0 format from Michael - Schmitt + Schmitt * reLyX/reLyX.in: honor variable LYX_DIR_13x @@ -352,7 +358,7 @@ 2002-05-28 John Levon * images/buffer-new.xpm: icon from Vitaly Lipatov - + 2002-05-24 John Levon * CREDITS: kill mention of KDE diff --git a/lib/layouts/stdclass.inc b/lib/layouts/stdclass.inc index 17a7498e32..bb1700e72d 100644 --- a/lib/layouts/stdclass.inc +++ b/lib/layouts/stdclass.inc @@ -42,4 +42,5 @@ Input stdtitle.inc Input stdstruct.inc Input lyxmacros.inc Input stdlayouts.inc +Input stdfloats.inc Input obsolete.inc diff --git a/lib/layouts/stdfloats.inc b/lib/layouts/stdfloats.inc new file mode 100644 index 0000000000..54a2384942 --- /dev/null +++ b/lib/layouts/stdfloats.inc @@ -0,0 +1,38 @@ +# Author : Lars Gullik Bjønnes + +# This include file contains all the floats that are defined as standard +# in most LyX layouts. + + +Float + Type table + GuiName Table + Placement tbp + Extension lot + NumberWithin none + Style plain + ListName "List of Tables" + LaTeXBuiltin true +End + +Float + Type figure + GuiName Figure + Placement tbp + Extension lof + NumberWithin none + Style plain + ListName "List of Figures" + LaTeXBuiltin true +End + +Float + Type algorithm + GuiName Algorithm + Placement tbp + Extension loa + NumberWithin none + Style ruled + ListName "List of Algorithms" + LaTeXBuiltin false +End diff --git a/src/ChangeLog b/src/ChangeLog index 761f4758e3..6c81472a7f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2002-09-04 Lars Gullik Bjønnes + + * lyxtextclass.C (TextClassTags): add TC_FLOAT + (Read): add float->TC_FLOAT to textclassTags + (Read): and handle it in the switch + (readFloat): new function + + * FloatList.C (FloatList): comment out the hardcoded float + definitions. + + * lyxlayout.h: ws change. + 2002-08-29 Dekel Tsur * buffer.C (readFile): Look for lyx2lyx in LYXDIR/lyx2lyx/ @@ -34,7 +46,7 @@ * BufferView_pimpl.C (dispatch): do not continue when no buffer - + 2002-08-28 André Pönitz * commandtags.h: new LFUN_MOUSE_DOUBLE, LFUN_MOUSE_TRIPLE @@ -48,23 +60,23 @@ * lyxrc.[Ch]: declare display_graphics as grfx::DisplayType and use grfx::displayTranslator.find(foo); include graphics/GraphicsTypes.h. - + * lyxrc.C: use more "if (...) { } else { }" style (John's advice). * lyx_main.C: call once the setDisplayTranslator(); is that okay here? - + 2002-08-27 Jean-Marc Lasgouttes * factory.C (createInset): use LyXTextClass::floats - * MenuBackend.C (expandFloatListInsert): - (expandFloatInsert): - (expandToc): + * MenuBackend.C (expandFloatListInsert): + (expandFloatInsert): + (expandToc): - * text2.C (setCounter): + * text2.C (setCounter): - * LaTeXFeatures.C (useFloat): - (getFloatDefinitions): + * LaTeXFeatures.C (useFloat): + (getFloatDefinitions): * BufferView_pimpl.C (dispatch): use LyXTextClass::floats() @@ -85,7 +97,7 @@ 2002-08-25 John Levon * LyXAction.C: fix margin note description - + 2002-08-24 John Levon * buffer.C: @@ -95,15 +107,15 @@ * undo_funcs.C: cleanups * lyxfunc.C: disable CUT/COPY when no selection - + 2002-08-23 Rob Lahaye - - * lyxlength.[Ch]: use better (three letters) mnemonics for percentage units - in "enum UNIT"; e.g. PTW for Percent of TextWidth - - * lyxrc.C: graphics display is now monochrome|grayscale|color|none. - Add backward compatibility to "mono", "gray" and "no". - + + * lyxlength.[Ch]: use better (three letters) mnemonics for percentage units + in "enum UNIT"; e.g. PTW for Percent of TextWidth + + * lyxrc.C: graphics display is now monochrome|grayscale|color|none. + Add backward compatibility to "mono", "gray" and "no". + 2002-08-24 Dekel Tsur * buffer.C (readFile): Always run lyx2lyx if file_format < LYX_FORMAT @@ -140,7 +152,7 @@ 2002-08-22 Martin Vermeer - * text2.C (setCounter): fixed enumeration mis-count as reported by + * text2.C (setCounter): fixed enumeration mis-count as reported by Dr. Richard Hawkins. 2002-08-21 Lars Gullik Bjønnes diff --git a/src/FloatList.C b/src/FloatList.C index 932eda5e86..2e12fcf31f 100644 --- a/src/FloatList.C +++ b/src/FloatList.C @@ -26,6 +26,7 @@ FloatList::FloatList() { +#if 0 // Insert the latex builtin float-types // (these will later be read from a layout file) @@ -36,7 +37,7 @@ FloatList::FloatList() // figure Floating figure("figure", "tbp", "lof", - "", "plain", N_("Figure"), + "", "plain", N_("Figure"), N_("List of Figures"), true); newFloat(figure); @@ -47,6 +48,7 @@ FloatList::FloatList() "", "ruled", N_("Algorithm"), N_("List of Algorithms")); newFloat(algorithm); +#endif } @@ -103,4 +105,3 @@ FloatList::const_iterator FloatList::operator[](string const & t) const { return list.find(t); } - diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 63c6f92bb8..5d87ca71aa 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -107,7 +107,8 @@ enum TextClassTags { TC_PROVIDESMAKEIDX, TC_PROVIDESURL, TC_LEFTMARGIN, - TC_RIGHTMARGIN + TC_RIGHTMARGIN, + TC_FLOAT }; @@ -119,6 +120,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) { "columns", TC_COLUMNS }, { "defaultfont", TC_DEFAULTFONT }, { "defaultstyle", TC_DEFAULTSTYLE }, + { "float", TC_FLOAT }, { "input", TC_INPUT }, { "leftmargin", TC_LEFTMARGIN }, { "maxcounter", TC_MAXCOUNTER }, @@ -146,7 +148,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) << MakeDisplayPath(filename) << endl; - LyXLex lexrc(textClassTags, TC_RIGHTMARGIN); + LyXLex lexrc(textClassTags, TC_FLOAT); bool error = false; lexrc.setFile(filename); @@ -322,6 +324,9 @@ bool LyXTextClass::Read(string const & filename, bool merge) if (lexrc.next()) rightmargin_ = lexrc.getString(); break; + case TC_FLOAT: + readFloat(lexrc); + break; } } @@ -495,6 +500,106 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc) } +enum FloatTags { + FT_TYPE = 1, + FT_NAME, + FT_PLACEMENT, + FT_EXT, + FT_WITHIN, + FT_STYLE, + FT_LISTNAME, + FT_BUILTIN, + FT_END +}; + +void LyXTextClass::readFloat(LyXLex & lexrc) +{ + keyword_item floatTags[] = { + { "end", FT_END }, + { "extension", FT_EXT }, + { "guiname", FT_NAME }, + { "latexbuiltin", FT_BUILTIN }, + { "listname", FT_LISTNAME }, + { "numberwithin", FT_WITHIN }, + { "placement", FT_PLACEMENT }, + { "style", FT_STYLE }, + { "type", FT_TYPE } + }; + + lexrc.pushTable(floatTags, FT_END); + + string type; + string placement; + string ext; + string within; + string style; + string name; + string listname; + bool builtin = false; + + bool getout = false; + while (!getout && lexrc.isOK()) { + int le = lexrc.lex(); + switch (le) { + case LyXLex::LEX_UNDEF: + lexrc.printError("Unknown ClassOption tag `$$Token'"); + continue; + default: break; + } + switch (static_cast(le)) { + case FT_TYPE: + lexrc.next(); + type = lexrc.getString(); + // Here we could check if this type is already defined + // and modify it with the rest of the vars instead. + break; + case FT_NAME: + lexrc.next(); + name = lexrc.getString(); + break; + case FT_PLACEMENT: + lexrc.next(); + placement = lexrc.getString(); + break; + case FT_EXT: + lexrc.next(); + ext = lexrc.getString(); + break; + case FT_WITHIN: + lexrc.next(); + within = lexrc.getString(); + if (within == "none") + within.erase(); + break; + case FT_STYLE: + lexrc.next(); + style = lexrc.getString(); + break; + case FT_LISTNAME: + lexrc.next(); + listname = lexrc.getString(); + break; + case FT_BUILTIN: + lexrc.next(); + builtin = lexrc.getBool(); + break; + case FT_END: + getout = true; + break; + } + } + + // Here if have a full float if getout == true + if (getout) { + Floating newfloat(type, placement, ext, within, + style, name, listname, builtin); + floatlist_.newFloat(newfloat); + } + + lexrc.popTable(); +} + + LyXFont const & LyXTextClass::defaultfont() const { return defaultfont_; diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index 2d1021f792..33cc930851 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -54,6 +54,8 @@ public: /// void readClassOptions(LyXLex &); /// + void readFloat(LyXLex &); + /// bool hasLayout(string const & name) const; /// -- 2.39.2