mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
on the way to a usable insetenv
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6975 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a9d83a8583
commit
ff98dcea08
@ -1,7 +1,24 @@
|
|||||||
|
|
||||||
|
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* buffer.C:
|
||||||
|
* lyxlayout.[Ch]:
|
||||||
|
* lyxtextclass.[Ch]:
|
||||||
|
* paragraph.C:
|
||||||
|
* paragraph_funcs.[Ch]:
|
||||||
|
* text2.C:
|
||||||
|
* text3.C: more insetenv work
|
||||||
|
|
||||||
2003-05-16 Alfredo Braunstein <abraunst@libero.it>
|
2003-05-16 Alfredo Braunstein <abraunst@libero.it>
|
||||||
|
|
||||||
* ParagraphParameters.C (params2string): small bug fixed
|
* ParagraphParameters.C (params2string): small bug fixed
|
||||||
|
|
||||||
|
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* debug.C:
|
||||||
|
* bufferview_funcs.C: patch from Kornel Benko to prevent
|
||||||
|
crash when _(...) is called twice in a statement
|
||||||
|
|
||||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* BufferView.C:
|
* BufferView.C:
|
||||||
|
@ -1046,7 +1046,7 @@ void Buffer::makeLaTeXFile(ostream & os,
|
|||||||
texrow.newline();
|
texrow.newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
latexParagraphs(this, paragraphs, paragraphs.begin(), paragraphs.end(), os, texrow);
|
latexParagraphs(this, paragraphs, os, texrow, false);
|
||||||
|
|
||||||
// add this just in case after all the paragraphs
|
// add this just in case after all the paragraphs
|
||||||
os << endl;
|
os << endl;
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
|
|
||||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
2003-05-19 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* insetenv.[Ch]:
|
||||||
|
* insettext.C: more insetenv
|
||||||
|
|
||||||
|
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insetcommand.C:
|
* insetcommand.C:
|
||||||
* insetminimpage.[Ch]:
|
* insetminimpage.[Ch]:
|
||||||
* insetcollapsable.[Ch]: fix #832
|
* insetcollapsable.[Ch]: fix #832
|
||||||
|
|
||||||
2003-05-16 André Pönitz <poenitz@gmx.net>
|
2003-05-16 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* inset.[Ch]:
|
* inset.[Ch]:
|
||||||
* insetbibitem.[Ch]:
|
* insetbibitem.[Ch]:
|
||||||
@ -31,7 +36,7 @@
|
|||||||
* inseturl.[Ch]:
|
* inseturl.[Ch]:
|
||||||
* updatableinset.[Ch]: edit() -> LFUN_INSET_EDIT
|
* updatableinset.[Ch]: edit() -> LFUN_INSET_EDIT
|
||||||
|
|
||||||
2003-05-13 André Pönitz <poenitz@gmx.net>
|
2003-05-13 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insetbibitem.C:
|
* insetbibitem.C:
|
||||||
* insetcollapsable.C:
|
* insetcollapsable.C:
|
||||||
@ -53,7 +58,7 @@
|
|||||||
* insetwrap.C: STRCONV
|
* insetwrap.C: STRCONV
|
||||||
|
|
||||||
|
|
||||||
2003-05-12 André Pönitz <poenitz@gmx.net>
|
2003-05-12 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insetcaption.C:
|
* insetcaption.C:
|
||||||
* insetexternal.C:
|
* insetexternal.C:
|
||||||
@ -67,7 +72,7 @@
|
|||||||
* insettext.C:
|
* insettext.C:
|
||||||
* insetwwrap.C: boost::format -> bformat all over the place
|
* insetwwrap.C: boost::format -> bformat all over the place
|
||||||
|
|
||||||
2003-05-05 André Pönitz <poenitz@gmx.net>
|
2003-05-05 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insettext.h: add missing #include <map>
|
* insettext.h: add missing #include <map>
|
||||||
|
|
||||||
@ -92,7 +97,7 @@
|
|||||||
* insetfloat.h:
|
* insetfloat.h:
|
||||||
* insetfloat.C: remove unneeded type() function
|
* insetfloat.C: remove unneeded type() function
|
||||||
|
|
||||||
2003-05-05 André Pönitz <poenitz@gmx.net>
|
2003-05-05 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* inset.h:
|
* inset.h:
|
||||||
* insettext.[Ch]:
|
* insettext.[Ch]:
|
||||||
@ -113,7 +118,7 @@
|
|||||||
hideInsetCursor(), toggleInsetCursor(), isCursorVisible(). Add
|
hideInsetCursor(), toggleInsetCursor(), isCursorVisible(). Add
|
||||||
getCursor(). Remove explicit cursor hides.
|
getCursor(). Remove explicit cursor hides.
|
||||||
|
|
||||||
2003-05-02 André Pönitz <poenitz@gmx.net>
|
2003-05-02 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insettext.C: remove unneeded &*
|
* insettext.C: remove unneeded &*
|
||||||
|
|
||||||
@ -129,11 +134,11 @@
|
|||||||
(setFont): ditto
|
(setFont): ditto
|
||||||
(tabularFeatures): ditto
|
(tabularFeatures): ditto
|
||||||
|
|
||||||
2003-04-29 André Pönitz <poenitz@gmx.net>
|
2003-04-29 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* inset.h: introduce "haveParagraph" from Lars' parlist-14-b.
|
* inset.h: introduce "haveParagraph" from Lars' parlist-14-b.
|
||||||
|
|
||||||
2003-04-28 André Pönitz <poenitz@gmx.net>
|
2003-04-28 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insettext.[Ch]: part of Lars' Paragraph * -> ParagraphList::iterator
|
* insettext.[Ch]: part of Lars' Paragraph * -> ParagraphList::iterator
|
||||||
Changes
|
Changes
|
||||||
@ -155,7 +160,7 @@
|
|||||||
* insettabular.C (string2params): ditto
|
* insettabular.C (string2params): ditto
|
||||||
* insetwrap.C (string2params): ditto
|
* insetwrap.C (string2params): ditto
|
||||||
|
|
||||||
2003-04-24 André Pönitz <poenitz@gmx.net>
|
2003-04-24 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insetref.C: support for eqref
|
* insetref.C: support for eqref
|
||||||
|
|
||||||
@ -409,7 +414,7 @@
|
|||||||
* insettext.C (edit): replace Dialogs::updateParagraph with
|
* insettext.C (edit): replace Dialogs::updateParagraph with
|
||||||
BufferView::dispatch(LFUN_PARAGRAPH_UPDATE).
|
BufferView::dispatch(LFUN_PARAGRAPH_UPDATE).
|
||||||
|
|
||||||
2003-03-13 André Pönitz <poenitz@gmx.net>
|
2003-03-13 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* Makefile.am: insert insetenv
|
* Makefile.am: insert insetenv
|
||||||
|
|
||||||
@ -439,7 +444,7 @@
|
|||||||
|
|
||||||
* insettext.C: name change to readToken()
|
* insettext.C: name change to readToken()
|
||||||
|
|
||||||
2003-03-11 André Pönitz <poenitz@gmx.net>
|
2003-03-11 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* Makefile.am: insert insethfill
|
* Makefile.am: insert insethfill
|
||||||
|
|
||||||
@ -754,7 +759,7 @@
|
|||||||
* insetinclude.C (loadIfNeeded): ensure loading also works when
|
* insetinclude.C (loadIfNeeded): ensure loading also works when
|
||||||
child document is under version control.
|
child document is under version control.
|
||||||
|
|
||||||
2003-02-17 André Pönitz <poenitz@gmx.net>
|
2003-02-17 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insetbib.[Ch]: Adjust access to bibkeys
|
* insetbib.[Ch]: Adjust access to bibkeys
|
||||||
|
|
||||||
@ -955,7 +960,7 @@
|
|||||||
* insetcite.C (getNatbibLabel): correct logic of when and when not to
|
* insetcite.C (getNatbibLabel): correct logic of when and when not to
|
||||||
reload the BibTeX keys.
|
reload the BibTeX keys.
|
||||||
|
|
||||||
2002-10-11 André Pönitz <poenitz@gmx.net>
|
2002-10-11 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* insettext.h: handle LFUN_PRIOR/NEXT
|
* insettext.h: handle LFUN_PRIOR/NEXT
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "insetenv.h"
|
#include "insetenv.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "lyxtextclass.h"
|
#include "lyxtextclass.h"
|
||||||
|
#include "paragraph_funcs.h"
|
||||||
#include "lyxlayout.h"
|
#include "lyxlayout.h"
|
||||||
#include "bufferparams.h"
|
#include "bufferparams.h"
|
||||||
#include "support/LOstream.h"
|
#include "support/LOstream.h"
|
||||||
@ -26,24 +27,16 @@ using std::endl;
|
|||||||
|
|
||||||
InsetEnvironment::InsetEnvironment
|
InsetEnvironment::InsetEnvironment
|
||||||
(BufferParams const & bp, string const & name)
|
(BufferParams const & bp, string const & name)
|
||||||
: InsetText(bp)
|
: InsetText(bp), layout_(bp.getLyXTextClass()[name])
|
||||||
{
|
{
|
||||||
//setLabel(name);
|
|
||||||
setInsetName(name);
|
setInsetName(name);
|
||||||
autoBreakRows = true;
|
autoBreakRows = true;
|
||||||
drawFrame_ = ALWAYS;
|
drawFrame_ = ALWAYS;
|
||||||
// needs more stuff in lyxlayout. coming in later patches.
|
|
||||||
//LyXTextClass const & tc = bp.getLyXTextClass();
|
|
||||||
//LyXLayout_ptr const & layout = tc.getEnv(name);
|
|
||||||
//header_ = layout->latexheader;
|
|
||||||
//footer_ = layout->latexfooter;
|
|
||||||
header_ = "\\begin{" + name + "}";
|
|
||||||
footer_ = "\\end{" + name + "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
|
InsetEnvironment::InsetEnvironment(InsetEnvironment const & in, bool same_id)
|
||||||
: InsetText(in, same_id), header_(in.header_), footer_(in.footer_)
|
: InsetText(in, same_id), layout_(in.layout_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -73,10 +66,18 @@ string const InsetEnvironment::editMessage() const
|
|||||||
|
|
||||||
|
|
||||||
int InsetEnvironment::latex(Buffer const * buf,
|
int InsetEnvironment::latex(Buffer const * buf,
|
||||||
ostream & os, bool fragile, bool fp) const
|
ostream & os, bool fragile, bool) const
|
||||||
{
|
{
|
||||||
os << header_;
|
os << layout_->latexheader;
|
||||||
int i = InsetText::latex(buf, os, fragile, fp);
|
TexRow texrow;
|
||||||
os << footer_;
|
latexParagraphs(buf, paragraphs, os, texrow, fragile,
|
||||||
return i;
|
layout_->latexparagraph);
|
||||||
|
os << layout_->latexfooter;
|
||||||
|
return texrow.rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXLayout_ptr const & InsetEnvironment::layout() const
|
||||||
|
{
|
||||||
|
return layout_;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define INSETENVIRONMENT_H
|
#define INSETENVIRONMENT_H
|
||||||
|
|
||||||
#include "insettext.h"
|
#include "insettext.h"
|
||||||
|
#include "lyxlayout_ptr_fwd.h"
|
||||||
|
|
||||||
class InsetEnvironment : public InsetText {
|
class InsetEnvironment : public InsetText {
|
||||||
public:
|
public:
|
||||||
@ -37,6 +38,8 @@ public:
|
|||||||
///
|
///
|
||||||
bool isTextInset() const { return true; }
|
bool isTextInset() const { return true; }
|
||||||
///
|
///
|
||||||
|
LyXLayout_ptr const & layout() const;
|
||||||
|
///
|
||||||
bool needFullRow() const { return true; }
|
bool needFullRow() const { return true; }
|
||||||
/** returns true if, when outputing LaTeX, font changes should
|
/** returns true if, when outputing LaTeX, font changes should
|
||||||
be closed before generating this inset. This is needed for
|
be closed before generating this inset. This is needed for
|
||||||
@ -44,10 +47,8 @@ public:
|
|||||||
bool noFontChange() const { return true; }
|
bool noFontChange() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// LaTeX footer
|
/// the layout
|
||||||
string header_;
|
LyXLayout_ptr layout_;
|
||||||
/// LaTeX footer
|
|
||||||
string footer_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1467,13 +1467,10 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetText::latex(Buffer const * buf, ostream & os,
|
int InsetText::latex(Buffer const * buf, ostream & os, bool fragile, bool) const
|
||||||
bool moving_arg, bool) const
|
|
||||||
{
|
{
|
||||||
TexRow texrow;
|
TexRow texrow;
|
||||||
latexParagraphs(buf, paragraphs,
|
latexParagraphs(buf, paragraphs, os, texrow, fragile);
|
||||||
paragraphs.begin(), paragraphs.end(),
|
|
||||||
os, texrow, moving_arg);
|
|
||||||
return texrow.rows();
|
return texrow.rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ enum LayoutTags {
|
|||||||
LT_LATEXTYPE,
|
LT_LATEXTYPE,
|
||||||
LT_LATEXHEADER,
|
LT_LATEXHEADER,
|
||||||
LT_LATEXFOOTER,
|
LT_LATEXFOOTER,
|
||||||
|
LT_LATEXPARAGRAPH,
|
||||||
LT_LEFTMARGIN,
|
LT_LEFTMARGIN,
|
||||||
LT_NEED_PROTECT,
|
LT_NEED_PROTECT,
|
||||||
LT_NEWLINE,
|
LT_NEWLINE,
|
||||||
@ -107,6 +108,7 @@ LyXLayout::LyXLayout ()
|
|||||||
newline_allowed = true;
|
newline_allowed = true;
|
||||||
free_spacing = false;
|
free_spacing = false;
|
||||||
pass_thru = false;
|
pass_thru = false;
|
||||||
|
is_environment = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +142,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
|||||||
{ "latexfooter", LT_LATEXFOOTER },
|
{ "latexfooter", LT_LATEXFOOTER },
|
||||||
{ "latexheader", LT_LATEXHEADER },
|
{ "latexheader", LT_LATEXHEADER },
|
||||||
{ "latexname", LT_LATEXNAME },
|
{ "latexname", LT_LATEXNAME },
|
||||||
|
{ "latexparagraph", LT_LATEXPARAGRAPH },
|
||||||
{ "latexparam", LT_LATEXPARAM },
|
{ "latexparam", LT_LATEXPARAM },
|
||||||
{ "latextype", LT_LATEXTYPE },
|
{ "latextype", LT_LATEXTYPE },
|
||||||
{ "leftmargin", LT_LEFTMARGIN },
|
{ "leftmargin", LT_LEFTMARGIN },
|
||||||
@ -236,24 +239,29 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LT_MARGIN: // Margin style definition.
|
case LT_MARGIN: // margin style definition.
|
||||||
readMargin(lexrc);
|
readMargin(lexrc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LT_LATEXTYPE: // Latex style definition.
|
case LT_LATEXTYPE: // LaTeX style definition.
|
||||||
readLatexType(lexrc);
|
readLatexType(lexrc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LT_LATEXHEADER: // Latex style definition.
|
case LT_LATEXHEADER: // header for environments
|
||||||
lexrc.next();
|
lexrc.next();
|
||||||
latexheader = lexrc.getString();
|
latexheader = lexrc.getString();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LT_LATEXFOOTER: // Latex style definition.
|
case LT_LATEXFOOTER: // footer for environments
|
||||||
lexrc.next();
|
lexrc.next();
|
||||||
latexfooter = lexrc.getString();
|
latexfooter = lexrc.getString();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LT_LATEXPARAGRAPH:
|
||||||
|
lexrc.next();
|
||||||
|
latexparagraph = lexrc.getString();
|
||||||
|
break;
|
||||||
|
|
||||||
case LT_INTITLE:
|
case LT_INTITLE:
|
||||||
intitle = lexrc.next() && lexrc.getInteger();
|
intitle = lexrc.next() && lexrc.getInteger();
|
||||||
break;
|
break;
|
||||||
|
@ -136,10 +136,14 @@ public:
|
|||||||
bool free_spacing;
|
bool free_spacing;
|
||||||
///
|
///
|
||||||
bool pass_thru;
|
bool pass_thru;
|
||||||
|
///
|
||||||
|
bool is_environment;
|
||||||
/// for new environment insets
|
/// for new environment insets
|
||||||
string latexheader;
|
string latexheader;
|
||||||
/// for new environment insets
|
/// for new environment insets
|
||||||
string latexfooter;
|
string latexfooter;
|
||||||
|
/// for new environment insets
|
||||||
|
string latexparagraph;
|
||||||
|
|
||||||
/** true when the fragile commands in the paragraph need to be
|
/** true when the fragile commands in the paragraph need to be
|
||||||
\protect'ed. */
|
\protect'ed. */
|
||||||
|
@ -215,6 +215,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TC_ENVIRONMENT:
|
||||||
case TC_STYLE:
|
case TC_STYLE:
|
||||||
if (lexrc.next()) {
|
if (lexrc.next()) {
|
||||||
string const name = subst(lexrc.getString(),
|
string const name = subst(lexrc.getString(),
|
||||||
@ -225,6 +226,8 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
|||||||
} else {
|
} else {
|
||||||
LyXLayout lay;
|
LyXLayout lay;
|
||||||
lay.setName(name);
|
lay.setName(name);
|
||||||
|
if (le == TC_ENVIRONMENT)
|
||||||
|
lay.is_environment = true;
|
||||||
if (!(error = do_readStyle(lexrc, lay)))
|
if (!(error = do_readStyle(lexrc, lay)))
|
||||||
layoutlist_.push_back
|
layoutlist_.push_back
|
||||||
(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
|
(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
|
||||||
@ -243,29 +246,6 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TC_ENVIRONMENT:
|
|
||||||
if (lexrc.next()) {
|
|
||||||
string const name = subst(lexrc.getString(),
|
|
||||||
'_', ' ');
|
|
||||||
if (hasLayout(name)) {
|
|
||||||
LyXLayout * lay = operator[](name).get();
|
|
||||||
error = do_readStyle(lexrc, *lay);
|
|
||||||
} else {
|
|
||||||
LyXLayout lay;
|
|
||||||
lay.setName(name);
|
|
||||||
if (!(error = do_readStyle(lexrc, lay)))
|
|
||||||
envlist_.push_back
|
|
||||||
(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
|
|
||||||
else
|
|
||||||
lexrc.printError("Problems reading environment: `$$Token'.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lexrc.printError("No name given for style: `$$Token'.");
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_NOSTYLE:
|
case TC_NOSTYLE:
|
||||||
if (lexrc.next()) {
|
if (lexrc.next()) {
|
||||||
string const style = subst(lexrc.getString(),
|
string const style = subst(lexrc.getString(),
|
||||||
@ -772,6 +752,7 @@ bool LyXTextClass::hasLayout(string const & n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
||||||
{
|
{
|
||||||
lyx::Assert(!n.empty());
|
lyx::Assert(!n.empty());
|
||||||
@ -796,6 +777,9 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
|||||||
lyxerr << "We failed to find the layout '" << name
|
lyxerr << "We failed to find the layout '" << name
|
||||||
<< "' in the layout list. You MUST investigate!"
|
<< "' in the layout list. You MUST investigate!"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
for (LayoutList::const_iterator it = layoutlist_.begin();
|
||||||
|
it != layoutlist_.end(); ++it)
|
||||||
|
lyxerr << " " << it->get()->name() << endl;
|
||||||
|
|
||||||
// we require the name to exist
|
// we require the name to exist
|
||||||
lyx::Assert(false);
|
lyx::Assert(false);
|
||||||
@ -808,27 +792,6 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXLayout_ptr const & LyXTextClass::getEnv(string const & name) const
|
|
||||||
{
|
|
||||||
lyx::Assert(!name.empty());
|
|
||||||
|
|
||||||
if (name.empty())
|
|
||||||
lyxerr << "LyXTextClass::getEnv() called with empty n" << endl;
|
|
||||||
|
|
||||||
LayoutList::const_iterator cit =
|
|
||||||
find_if(envlist_.begin(), envlist_.end(), compare_name(name));
|
|
||||||
|
|
||||||
if (cit == envlist_.end()) {
|
|
||||||
lyxerr << "We failed to find the environment '" << name
|
|
||||||
<< "' in the layout list. You MUST investigate!"
|
|
||||||
<< endl;
|
|
||||||
// we require the name to exist
|
|
||||||
lyx::Assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *cit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool LyXTextClass::delete_layout(string const & name)
|
bool LyXTextClass::delete_layout(string const & name)
|
||||||
{
|
{
|
||||||
|
@ -65,8 +65,6 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
LyXLayout_ptr const & operator[](string const & vname) const;
|
LyXLayout_ptr const & operator[](string const & vname) const;
|
||||||
///
|
|
||||||
LyXLayout_ptr const & getEnv(string const & vname) const;
|
|
||||||
|
|
||||||
/// Sees to that the textclass structure has been loaded
|
/// Sees to that the textclass structure has been loaded
|
||||||
bool load() const;
|
bool load() const;
|
||||||
@ -155,8 +153,6 @@ private:
|
|||||||
///
|
///
|
||||||
bool delete_layout(string const &);
|
bool delete_layout(string const &);
|
||||||
///
|
///
|
||||||
bool delete_env(string const &);
|
|
||||||
///
|
|
||||||
bool do_readStyle(LyXLex &, LyXLayout &);
|
bool do_readStyle(LyXLex &, LyXLayout &);
|
||||||
/// Layout file name
|
/// Layout file name
|
||||||
string name_;
|
string name_;
|
||||||
@ -210,9 +206,6 @@ private:
|
|||||||
/// Paragraph styles used in this layout
|
/// Paragraph styles used in this layout
|
||||||
LayoutList layoutlist_;
|
LayoutList layoutlist_;
|
||||||
|
|
||||||
/// Environment styles used in this layout
|
|
||||||
LayoutList envlist_;
|
|
||||||
|
|
||||||
/// available types of float, eg. figure, algorithm.
|
/// available types of float, eg. figure, algorithm.
|
||||||
boost::shared_ptr<FloatList> floatlist_;
|
boost::shared_ptr<FloatList> floatlist_;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "insets/insetbibitem.h"
|
#include "insets/insetbibitem.h"
|
||||||
#include "insets/insetoptarg.h"
|
#include "insets/insetoptarg.h"
|
||||||
|
#include "insets/insetenv.h"
|
||||||
|
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
@ -1405,6 +1406,9 @@ int Paragraph::id() const
|
|||||||
|
|
||||||
LyXLayout_ptr const & Paragraph::layout() const
|
LyXLayout_ptr const & Paragraph::layout() const
|
||||||
{
|
{
|
||||||
|
Inset * inset = inInset();
|
||||||
|
if (inset && inset->lyxCode() == Inset::ENVIRONMENT_CODE)
|
||||||
|
return static_cast<InsetEnvironment*>(inset)->layout();
|
||||||
return layout_;
|
return layout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +237,7 @@ bool isFirstInSequence(ParagraphList::iterator pit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getEndLabel(ParagraphList::iterator p,
|
int getEndLabel(ParagraphList::iterator p, ParagraphList const & plist)
|
||||||
ParagraphList const & plist)
|
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = p;
|
ParagraphList::iterator pit = p;
|
||||||
Paragraph::depth_type par_depth = p->getDepth();
|
Paragraph::depth_type par_depth = p->getDepth();
|
||||||
@ -280,7 +279,8 @@ TeXOnePar(Buffer const * buf,
|
|||||||
ParagraphList const & paragraphs,
|
ParagraphList const & paragraphs,
|
||||||
ParagraphList::iterator pit,
|
ParagraphList::iterator pit,
|
||||||
ostream & os, TexRow & texrow,
|
ostream & os, TexRow & texrow,
|
||||||
bool moving_arg);
|
bool moving_arg,
|
||||||
|
string const & everypar = string());
|
||||||
|
|
||||||
|
|
||||||
ParagraphList::iterator
|
ParagraphList::iterator
|
||||||
@ -436,9 +436,11 @@ TeXOnePar(Buffer const * buf,
|
|||||||
ParagraphList const & paragraphs,
|
ParagraphList const & paragraphs,
|
||||||
ParagraphList::iterator pit,
|
ParagraphList::iterator pit,
|
||||||
ostream & os, TexRow & texrow,
|
ostream & os, TexRow & texrow,
|
||||||
bool moving_arg)
|
bool moving_arg,
|
||||||
|
string const & everypar)
|
||||||
{
|
{
|
||||||
lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << endl;
|
lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << " '" << everypar
|
||||||
|
<< "'" << endl;
|
||||||
BufferParams const & bparams = buf->params;
|
BufferParams const & bparams = buf->params;
|
||||||
|
|
||||||
Inset const * in = pit->inInset();
|
Inset const * in = pit->inInset();
|
||||||
@ -559,6 +561,7 @@ TeXOnePar(Buffer const * buf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os << everypar;
|
||||||
bool need_par = pit->simpleTeXOnePar(buf, bparams,
|
bool need_par = pit->simpleTeXOnePar(buf, bparams,
|
||||||
outerFont(pit, paragraphs),
|
outerFont(pit, paragraphs),
|
||||||
os, texrow, moving_arg);
|
os, texrow, moving_arg);
|
||||||
@ -682,15 +685,16 @@ TeXOnePar(Buffer const * buf,
|
|||||||
//
|
//
|
||||||
void latexParagraphs(Buffer const * buf,
|
void latexParagraphs(Buffer const * buf,
|
||||||
ParagraphList const & paragraphs,
|
ParagraphList const & paragraphs,
|
||||||
ParagraphList::iterator par,
|
ostream & os,
|
||||||
ParagraphList::iterator endpar,
|
|
||||||
ostream & ofs,
|
|
||||||
TexRow & texrow,
|
TexRow & texrow,
|
||||||
bool moving_arg)
|
bool moving_arg,
|
||||||
|
string const & everypar)
|
||||||
{
|
{
|
||||||
bool was_title = false;
|
bool was_title = false;
|
||||||
bool already_title = false;
|
bool already_title = false;
|
||||||
LyXTextClass const & tclass = buf->params.getLyXTextClass();
|
LyXTextClass const & tclass = buf->params.getLyXTextClass();
|
||||||
|
ParagraphList::iterator par = paragraphs.begin();
|
||||||
|
ParagraphList::iterator endpar = paragraphs.end();
|
||||||
|
|
||||||
// if only_body
|
// if only_body
|
||||||
while (par != endpar) {
|
while (par != endpar) {
|
||||||
@ -710,7 +714,7 @@ void latexParagraphs(Buffer const * buf,
|
|||||||
} else if (!was_title) {
|
} else if (!was_title) {
|
||||||
was_title = true;
|
was_title = true;
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
ofs << "\\begin{"
|
os << "\\begin{"
|
||||||
<< tclass.titlename()
|
<< tclass.titlename()
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
texrow.newline();
|
texrow.newline();
|
||||||
@ -718,11 +722,11 @@ void latexParagraphs(Buffer const * buf,
|
|||||||
}
|
}
|
||||||
} else if (was_title && !already_title) {
|
} else if (was_title && !already_title) {
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
ofs << "\\end{" << tclass.titlename()
|
os << "\\end{" << tclass.titlename()
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ofs << "\\" << tclass.titlename()
|
os << "\\" << tclass.titlename()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
texrow.newline();
|
texrow.newline();
|
||||||
@ -730,25 +734,30 @@ void latexParagraphs(Buffer const * buf,
|
|||||||
was_title = false;
|
was_title = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layout->isEnvironment() ||
|
if (layout->is_environment) {
|
||||||
|
par = TeXOnePar(buf, paragraphs, par, os, texrow,
|
||||||
|
moving_arg, everypar);
|
||||||
|
} else if (layout->isEnvironment() ||
|
||||||
!par->params().leftIndent().zero())
|
!par->params().leftIndent().zero())
|
||||||
{
|
{
|
||||||
par = TeXEnvironment(buf, paragraphs, par, ofs, texrow);
|
par = TeXEnvironment(buf, paragraphs, par, os, texrow);
|
||||||
} else {
|
} else {
|
||||||
par = TeXOnePar(buf, paragraphs, par, ofs, texrow, moving_arg);
|
par = TeXOnePar(buf, paragraphs, par, os, texrow,
|
||||||
|
moving_arg, everypar);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
par = TeXOnePar(buf, paragraphs, par, ofs, texrow, moving_arg);
|
par = TeXOnePar(buf, paragraphs, par, os, texrow,
|
||||||
|
moving_arg, everypar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// It might be that we only have a title in this document
|
// It might be that we only have a title in this document
|
||||||
if (was_title && !already_title) {
|
if (was_title && !already_title) {
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
ofs << "\\end{" << tclass.titlename()
|
os << "\\end{" << tclass.titlename()
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ofs << "\\" << tclass.titlename()
|
os << "\\" << tclass.titlename()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
texrow.newline();
|
texrow.newline();
|
||||||
|
@ -63,11 +63,10 @@ int getEndLabel(ParagraphList::iterator pit,
|
|||||||
|
|
||||||
void latexParagraphs(Buffer const * buf,
|
void latexParagraphs(Buffer const * buf,
|
||||||
ParagraphList const & paragraphs,
|
ParagraphList const & paragraphs,
|
||||||
ParagraphList::iterator par,
|
|
||||||
ParagraphList::iterator endpar,
|
|
||||||
std::ostream & ofs,
|
std::ostream & ofs,
|
||||||
TexRow & texrow,
|
TexRow & texrow,
|
||||||
bool moving_arg = false);
|
bool moving_arg,
|
||||||
|
string const & everypar = string());
|
||||||
|
|
||||||
/// read a paragraph from a .lyx file. Returns number of unrecognised tokens
|
/// read a paragraph from a .lyx file. Returns number of unrecognised tokens
|
||||||
int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex);
|
int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex);
|
||||||
|
28
src/text2.C
28
src/text2.C
@ -35,6 +35,7 @@
|
|||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
|
|
||||||
#include "insets/insetbibitem.h"
|
#include "insets/insetbibitem.h"
|
||||||
|
#include "insets/insetenv.h"
|
||||||
#include "insets/insetfloat.h"
|
#include "insets/insetfloat.h"
|
||||||
#include "insets/insetwrap.h"
|
#include "insets/insetwrap.h"
|
||||||
|
|
||||||
@ -425,22 +426,41 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
// set layout over selection and make a total rebreak of those paragraphs
|
// set layout over selection and make a total rebreak of those paragraphs
|
||||||
void LyXText::setLayout(string const & layout)
|
void LyXText::setLayout(string const & layout)
|
||||||
{
|
{
|
||||||
LyXCursor tmpcursor = cursor; /* store the current cursor */
|
LyXCursor tmpcursor = cursor; // store the current cursor
|
||||||
|
|
||||||
// if there is no selection just set the layout
|
// if there is no selection just set the layout
|
||||||
// of the current paragraph */
|
// of the current paragraph
|
||||||
if (!selection.set()) {
|
if (!selection.set()) {
|
||||||
selection.start = cursor; // dummy selection
|
selection.start = cursor; // dummy selection
|
||||||
selection.end = cursor;
|
selection.end = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special handling of new environment insets
|
||||||
|
BufferParams const & params = bv()->buffer()->params;
|
||||||
|
LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout];
|
||||||
|
if (lyxlayout->is_environment) {
|
||||||
|
// move everything in a new environment inset
|
||||||
|
lyxerr << "setting layout " << layout << endl;
|
||||||
|
bv()->owner()->dispatch(FuncRequest(LFUN_HOME));
|
||||||
|
bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
|
||||||
|
bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
|
||||||
|
Inset * inset = new InsetEnvironment(params, layout);
|
||||||
|
if (bv()->insertInset(inset)) {
|
||||||
|
//inset->edit(bv());
|
||||||
|
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
delete inset;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
||||||
selection.end, layout);
|
selection.end, layout);
|
||||||
redoParagraphs(selection.start, endpit);
|
redoParagraphs(selection.start, endpit);
|
||||||
|
|
||||||
// we have to reset the selection, because the
|
// we have to reset the selection, because the
|
||||||
// geometry could have changed
|
// geometry could have changed
|
||||||
setCursor(selection.start.par(),
|
setCursor(selection.start.par(), selection.start.pos(), false);
|
||||||
selection.start.pos(), false);
|
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
setCursor(selection.end.par(), selection.end.pos(), false);
|
setCursor(selection.end.par(), selection.end.pos(), false);
|
||||||
updateCounters();
|
updateCounters();
|
||||||
|
@ -1124,6 +1124,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool change_layout = (current_layout != layout);
|
bool change_layout = (current_layout != layout);
|
||||||
|
|
||||||
if (!change_layout && selection.set() &&
|
if (!change_layout && selection.set() &&
|
||||||
selection.start.par() != selection.end.par())
|
selection.start.par() != selection.end.par())
|
||||||
{
|
{
|
||||||
@ -1137,6 +1138,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
++spit;
|
++spit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_layout) {
|
if (change_layout) {
|
||||||
current_layout = layout;
|
current_layout = layout;
|
||||||
update();
|
update();
|
||||||
|
Loading…
Reference in New Issue
Block a user