Finally I got it working! Patch attached. Problems still:
- Can be inserted anywhere, not only in sectioning headers. Will give latexing error then. - No user interface yet, just M-x shorttitle-insert <RET>. - Captions??? but IT WORKS! Martin PS I'm going off-line now because of power cuts. Dunno when back.
Index: BufferView_pimpl.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.279 diff -u -p -r1.279 BufferView_pimpl.C --- BufferView_pimpl.C 2002/08/12 09:35:51 1.279 +++ BufferView_pimpl.C 2002/08/15 10:24:04 @@ -67,6 +67,7 @@ #include "insets/insetcaption.h" #include "insets/insetfloatlist.h" #include "insets/insetspecialchar.h" +#include "insets/insetshorttitle.h" #include "mathed/formulabase.h" @@ -2761,6 +2766,10 @@ bool BufferView::Pimpl::dispatch(FuncReq insertAndEditInset(new InsetNote(buffer_->params)); break; + case LFUN_INSET_SHORTTITLE: + insertAndEditInset(new InsetShortTitle(buffer_->params)); + break; + case LFUN_INSET_FLOAT: // check if the float type exist if (floatList.typeExist(ev.argument)) { Index: LyXAction.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LyXAction.C,v retrieving revision 1.129 diff -u -p -r1.129 LyXAction.C --- LyXAction.C 2002/08/08 22:03:27 1.129 +++ LyXAction.C 2002/08/15 10:24:05 @@ -249,6 +249,8 @@ void LyXAction::init() ReadOnly }, { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"), Noop }, + { LFUN_INSET_SHORTTITLE, "shorttitle-insert", N_("Insert Short Title"), + Noop }, { LFUN_LANGUAGE, "language", N_("Change language"), Noop }, { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"), ReadOnly }, Index: buffer.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/buffer.C,v retrieving revision 1.367 diff -u -p -r1.367 buffer.C --- buffer.C 2002/08/12 00:15:16 1.367 +++ buffer.C 2002/08/15 10:24:08 @@ -70,6 +70,7 @@ #include "insets/insetgraphics.h" #include "insets/insetfoot.h" #include "insets/insetmarginal.h" +#include "insets/insetshorttitle.h" #include "insets/insetminipage.h" #include "insets/insetfloat.h" #include "insets/insettabular.h" @@ -1631,6 +1632,8 @@ void Buffer::readInset(LyXLex & lex, Par inset = new InsetFoot(params); } else if (tmptok == "Marginal") { inset = new InsetMarginal(params); + } else if (tmptok == "ShortTitle") { + inset = new InsetShortTitle(params); } else if (tmptok == "Minipage") { inset = new InsetMinipage(params); } else if (tmptok == "Float") { Index: commandtags.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/commandtags.h,v retrieving revision 1.96 diff -u -p -r1.96 commandtags.h --- commandtags.h 2002/08/12 09:53:03 1.96 +++ commandtags.h 2002/08/15 10:24:08 @@ -289,6 +289,7 @@ enum kb_action { LFUN_FORKS_SHOW, // Angus 16 Feb 2002 LFUN_FORKS_KILL, // Angus 16 Feb 2002 LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002 + LFUN_INSET_SHORTTITLE, // Martin 12 Aug 2002 LFUN_MOUSE_PRESS, // André 9 Aug 2002 LFUN_MOUSE_MOTION, // André 9 Aug 2002 LFUN_MOUSE_RELEASE, // André 9 Aug 2002 Index: lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.364 diff -u -p -r1.364 lyxfunc.C --- lyxfunc.C 2002/08/11 16:27:09 1.364 +++ lyxfunc.C 2002/08/15 10:24:09 @@ -542,6 +542,9 @@ FuncStatus LyXFunc::getStatus(FuncReques case LFUN_INSERT_LABEL: code = Inset::LABEL_CODE; break; + case LFUN_INSET_SHORTTITLE: + code = Inset::SHORTTITLE_CODE; + break; case LFUN_REF_INSERT: code = Inset::REF_CODE; break; Index: paragraph.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/paragraph.C,v retrieving revision 1.219 diff -u -p -r1.219 paragraph.C --- paragraph.C 2002/08/11 20:34:20 1.219 +++ paragraph.C 2002/08/15 10:24:12 @@ -32,6 +32,7 @@ #include "insets/insetinclude.h" #include "insets/insetbib.h" #include "insets/insettext.h" +#include "insets/insetshorttitle.h" #include "support/filetools.h" #include "support/lstrings.h" void Paragraph::applyLayout(LyXLayout_ptr const & new_layout) { @@ -1114,6 +1127,18 @@ int Paragraph::getPositionOfInset(Inset return -1; } +InsetList::iterator Paragraph::shortTitleInset() const +{ + // Find the entry. + InsetList::iterator it = insetlist.begin(); + InsetList::iterator end = insetlist.end(); + for (; it != end; ++it) { + if (it.getInset()->lyxCode() == Inset::SHORTTITLE_CODE) { + return it; + } + } + return 0; +} Paragraph * Paragraph::TeXOnePar(Buffer const * buf, BufferParams const & bparams, @@ -1212,8 +1237,17 @@ Paragraph * Paragraph::TeXOnePar(Buffer switch (style->latextype) { case LATEX_COMMAND: os << '\\' - << style->latexname() - << style->latexparam(); + << style->latexname(); + + // This means you can put the shorttitle inset into ANY LaTeX cmd + if (shortTitleInset() != 0) { + os << '['; // count on the inset itself putting out +"abc]{" + } + else { + if (style->latexparam() != "void") + os << style->latexparam(); + os << '{'; // Always in case of LATEX_COMMAND + } break; case LATEX_ITEM_ENVIRONMENT: if (bibkey) { @@ -1506,15 +1543,19 @@ bool Paragraph::simpleTeXOnePar(Buffer c // if the paragraph is empty, the loop will not be entered at all if (empty()) { if (style->isCommand()) { - os << '{'; - ++column; + // In case of LATEX_COMMAND was already output + if (style->latextype != LATEX_COMMAND) { + os << '{'; + ++column; + } } if (!asdefault) column += startTeXParParams(bparams, os, moving_arg); } - for (pos_type i = 0; i < size(); ++i) { + pos_type last = size(); + for (pos_type i = 0; i < last; ++i) { ++column; // First char in paragraph or after label? if (i == main_body) { @@ -1526,11 +1567,15 @@ bool Paragraph::simpleTeXOnePar(Buffer c basefont = getLayoutFont(bparams); running_font = basefont; os << ']'; + ++column; } if (style->isCommand()) { - os << '{'; - ++column; + // In case of LATEX_COMMAND was already output + if (style->latextype != LATEX_COMMAND) { + os << '{'; + ++column; + } } if (!asdefault) Index: paragraph.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/paragraph.h,v retrieving revision 1.43 diff -u -p -r1.43 paragraph.h --- paragraph.h 2002/08/11 20:34:20 1.43 +++ paragraph.h 2002/08/15 10:24:12 @@ -27,6 +27,7 @@ class BufferParams; class BufferView; class Counters; class InsetBibKey; +class InsetShortTitle; class Language; class LaTeXFeatures; class ParagraphParameters; @@ -180,6 +181,8 @@ public: /// InsetBibKey * bibkey; // ale970302 + /// + InsetShortTitle * shorttitle; // mv020809 /// void next(Paragraph *); @@ -310,6 +318,9 @@ public: /// returns -1 if inset not found int getPositionOfInset(Inset const * inset) const; + /// MV + InsetList::iterator shortTitleInset() const; + /// some good comment here John? Paragraph * getParFromID(int id) const; Index: text.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text.C,v retrieving revision 1.265 diff -u -p -r1.265 text.C --- text.C 2002/08/10 15:21:03 1.265 +++ text.C 2002/08/15 10:24:17 @@ -30,6 +30,7 @@ #include "undo_funcs.h" #include "insets/insetbib.h" +#include "insets/insetshorttitle.h" #include "insets/insettext.h" #include "support/textutils.h" Index: text2.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text2.C,v retrieving revision 1.246 diff -u -p -r1.246 text2.C --- text2.C 2002/08/12 00:15:17 1.246 +++ text2.C 2002/08/15 10:24:19 @@ -39,6 +43,7 @@ #include "insets/insetspecialchar.h" #include "insets/insettext.h" #include "insets/insetfloat.h" +#include "insets/insetshorttitle.h" #include "support/LAssert.h" #include "support/textutils.h" Index: insets/Makefile.am =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/Makefile.am,v retrieving revision 1.47 diff -u -p -r1.47 Makefile.am --- insets/Makefile.am 2002/07/04 13:54:28 1.47 +++ insets/Makefile.am 2002/08/15 10:24:24 @@ -69,6 +69,8 @@ libinsets_la_SOURCES = \ insetquotes.h \ insetref.C \ insetref.h \ + insetshorttitle.C \ + insetshorttitle.h \ insetspecialchar.C \ insetspecialchar.h \ insettabular.C \ Index: insets/inset.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/inset.h,v retrieving revision 1.53 diff -u -p -r1.53 inset.h --- insets/inset.h 2002/08/07 08:11:38 1.53 +++ insets/inset.h 2002/08/15 10:24:25 @@ -115,7 +115,9 @@ public: /// FLOAT_LIST_CODE, /// - INDEX_PRINT_CODE + INDEX_PRINT_CODE, + /// + SHORTTITLE_CODE }; ///
msg42830/pgp00000.pgp
Description: PGP signature