+
+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>
* 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>
* BufferView.C:
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
os << endl;
-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:
* insetminimpage.[Ch]:
* insetcollapsable.[Ch]: fix #832
-2003-05-16 André Pönitz <poenitz@gmx.net>
+2003-05-16 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:
* insetbibitem.[Ch]:
* inseturl.[Ch]:
* 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:
* insetcollapsable.C:
* insetwrap.C: STRCONV
-2003-05-12 André Pönitz <poenitz@gmx.net>
+2003-05-12 André Pönitz <poenitz@gmx.net>
* insetcaption.C:
* insetexternal.C:
* insettext.C:
* 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>
* insetfloat.h:
* 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:
* insettext.[Ch]:
hideInsetCursor(), toggleInsetCursor(), isCursorVisible(). Add
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 &*
(setFont): 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.
-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
Changes
* insettabular.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
* insettext.C (edit): replace Dialogs::updateParagraph with
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
* 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
* insetinclude.C (loadIfNeeded): ensure loading also works when
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
* insetcite.C (getNatbibLabel): correct logic of when and when not to
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
#include "insetenv.h"
#include "gettext.h"
#include "lyxtextclass.h"
+#include "paragraph_funcs.h"
#include "lyxlayout.h"
#include "bufferparams.h"
#include "support/LOstream.h"
InsetEnvironment::InsetEnvironment
(BufferParams const & bp, string const & name)
- : InsetText(bp)
+ : InsetText(bp), layout_(bp.getLyXTextClass()[name])
{
- //setLabel(name);
setInsetName(name);
autoBreakRows = true;
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)
- : InsetText(in, same_id), header_(in.header_), footer_(in.footer_)
+ : InsetText(in, same_id), layout_(in.layout_)
{}
int InsetEnvironment::latex(Buffer const * buf,
- ostream & os, bool fragile, bool fp) const
+ ostream & os, bool fragile, bool) const
{
- os << header_;
- int i = InsetText::latex(buf, os, fragile, fp);
- os << footer_;
- return i;
+ os << layout_->latexheader;
+ TexRow texrow;
+ latexParagraphs(buf, paragraphs, os, texrow, fragile,
+ layout_->latexparagraph);
+ os << layout_->latexfooter;
+ return texrow.rows();
+}
+
+
+LyXLayout_ptr const & InsetEnvironment::layout() const
+{
+ return layout_;
}
#define INSETENVIRONMENT_H
#include "insettext.h"
+#include "lyxlayout_ptr_fwd.h"
class InsetEnvironment : public InsetText {
public:
///
bool isTextInset() const { return true; }
///
+ LyXLayout_ptr const & layout() const;
+ ///
bool needFullRow() const { return true; }
/** returns true if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
bool noFontChange() const { return true; }
private:
- /// LaTeX footer
- string header_;
- /// LaTeX footer
- string footer_;
+ /// the layout
+ LyXLayout_ptr layout_;
};
#endif
}
-int InsetText::latex(Buffer const * buf, ostream & os,
- bool moving_arg, bool) const
+int InsetText::latex(Buffer const * buf, ostream & os, bool fragile, bool) const
{
TexRow texrow;
- latexParagraphs(buf, paragraphs,
- paragraphs.begin(), paragraphs.end(),
- os, texrow, moving_arg);
+ latexParagraphs(buf, paragraphs, os, texrow, fragile);
return texrow.rows();
}
LT_LATEXTYPE,
LT_LATEXHEADER,
LT_LATEXFOOTER,
+ LT_LATEXPARAGRAPH,
LT_LEFTMARGIN,
LT_NEED_PROTECT,
LT_NEWLINE,
newline_allowed = true;
free_spacing = false;
pass_thru = false;
+ is_environment = false;
}
{ "latexfooter", LT_LATEXFOOTER },
{ "latexheader", LT_LATEXHEADER },
{ "latexname", LT_LATEXNAME },
+ { "latexparagraph", LT_LATEXPARAGRAPH },
{ "latexparam", LT_LATEXPARAM },
{ "latextype", LT_LATEXTYPE },
{ "leftmargin", LT_LEFTMARGIN },
}
break;
- case LT_MARGIN: // Margin style definition.
+ case LT_MARGIN: // margin style definition.
readMargin(lexrc);
break;
- case LT_LATEXTYPE: // Latex style definition.
+ case LT_LATEXTYPE: // LaTeX style definition.
readLatexType(lexrc);
break;
- case LT_LATEXHEADER: // Latex style definition.
+ case LT_LATEXHEADER: // header for environments
lexrc.next();
latexheader = lexrc.getString();
break;
- case LT_LATEXFOOTER: // Latex style definition.
+ case LT_LATEXFOOTER: // footer for environments
lexrc.next();
latexfooter = lexrc.getString();
break;
+ case LT_LATEXPARAGRAPH:
+ lexrc.next();
+ latexparagraph = lexrc.getString();
+ break;
+
case LT_INTITLE:
intitle = lexrc.next() && lexrc.getInteger();
break;
bool free_spacing;
///
bool pass_thru;
+ ///
+ bool is_environment;
/// for new environment insets
string latexheader;
/// for new environment insets
string latexfooter;
+ /// for new environment insets
+ string latexparagraph;
/** true when the fragile commands in the paragraph need to be
\protect'ed. */
}
break;
+ case TC_ENVIRONMENT:
case TC_STYLE:
if (lexrc.next()) {
string const name = subst(lexrc.getString(),
} else {
LyXLayout lay;
lay.setName(name);
+ if (le == TC_ENVIRONMENT)
+ lay.is_environment = true;
if (!(error = do_readStyle(lexrc, lay)))
layoutlist_.push_back
(boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
}
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:
if (lexrc.next()) {
string const style = subst(lexrc.getString(),
}
+
LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
{
lyx::Assert(!n.empty());
lyxerr << "We failed to find the layout '" << name
<< "' in the layout list. You MUST investigate!"
<< endl;
+ for (LayoutList::const_iterator it = layoutlist_.begin();
+ it != layoutlist_.end(); ++it)
+ lyxerr << " " << it->get()->name() << endl;
// we require the name to exist
lyx::Assert(false);
}
-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)
{
///
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
bool load() const;
///
bool delete_layout(string const &);
///
- bool delete_env(string const &);
- ///
bool do_readStyle(LyXLex &, LyXLayout &);
/// Layout file name
string name_;
/// Paragraph styles used in this layout
LayoutList layoutlist_;
- /// Environment styles used in this layout
- LayoutList envlist_;
-
/// available types of float, eg. figure, algorithm.
boost::shared_ptr<FloatList> floatlist_;
#include "insets/insetbibitem.h"
#include "insets/insetoptarg.h"
+#include "insets/insetenv.h"
#include "support/filetools.h"
#include "support/lstrings.h"
LyXLayout_ptr const & Paragraph::layout() const
{
+ Inset * inset = inInset();
+ if (inset && inset->lyxCode() == Inset::ENVIRONMENT_CODE)
+ return static_cast<InsetEnvironment*>(inset)->layout();
return layout_;
}
}
-int getEndLabel(ParagraphList::iterator p,
- ParagraphList const & plist)
+int getEndLabel(ParagraphList::iterator p, ParagraphList const & plist)
{
ParagraphList::iterator pit = p;
Paragraph::depth_type par_depth = p->getDepth();
ParagraphList const & paragraphs,
ParagraphList::iterator pit,
ostream & os, TexRow & texrow,
- bool moving_arg);
+ bool moving_arg,
+ string const & everypar = string());
ParagraphList::iterator
ParagraphList const & paragraphs,
ParagraphList::iterator pit,
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;
Inset const * in = pit->inInset();
break;
}
+ os << everypar;
bool need_par = pit->simpleTeXOnePar(buf, bparams,
outerFont(pit, paragraphs),
os, texrow, moving_arg);
//
void latexParagraphs(Buffer const * buf,
ParagraphList const & paragraphs,
- ParagraphList::iterator par,
- ParagraphList::iterator endpar,
- ostream & ofs,
+ ostream & os,
TexRow & texrow,
- bool moving_arg)
+ bool moving_arg,
+ string const & everypar)
{
bool was_title = false;
bool already_title = false;
LyXTextClass const & tclass = buf->params.getLyXTextClass();
+ ParagraphList::iterator par = paragraphs.begin();
+ ParagraphList::iterator endpar = paragraphs.end();
// if only_body
while (par != endpar) {
} else if (!was_title) {
was_title = true;
if (tclass.titletype() == TITLE_ENVIRONMENT) {
- ofs << "\\begin{"
+ os << "\\begin{"
<< tclass.titlename()
<< "}\n";
texrow.newline();
}
} else if (was_title && !already_title) {
if (tclass.titletype() == TITLE_ENVIRONMENT) {
- ofs << "\\end{" << tclass.titlename()
+ os << "\\end{" << tclass.titlename()
<< "}\n";
}
else {
- ofs << "\\" << tclass.titlename()
+ os << "\\" << tclass.titlename()
<< "\n";
}
texrow.newline();
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 = TeXEnvironment(buf, paragraphs, par, ofs, texrow);
+ par = TeXEnvironment(buf, paragraphs, par, os, texrow);
} else {
- par = TeXOnePar(buf, paragraphs, par, ofs, texrow, moving_arg);
+ par = TeXOnePar(buf, paragraphs, par, os, texrow,
+ moving_arg, everypar);
}
} 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
if (was_title && !already_title) {
if (tclass.titletype() == TITLE_ENVIRONMENT) {
- ofs << "\\end{" << tclass.titlename()
+ os << "\\end{" << tclass.titlename()
<< "}\n";
}
else {
- ofs << "\\" << tclass.titlename()
+ os << "\\" << tclass.titlename()
<< "\n";
}
texrow.newline();
void latexParagraphs(Buffer const * buf,
ParagraphList const & paragraphs,
- ParagraphList::iterator par,
- ParagraphList::iterator endpar,
std::ostream & ofs,
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
int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex);
#include "paragraph_funcs.h"
#include "insets/insetbibitem.h"
+#include "insets/insetenv.h"
#include "insets/insetfloat.h"
#include "insets/insetwrap.h"
// set layout over selection and make a total rebreak of those paragraphs
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
- // of the current paragraph */
+ // of the current paragraph
if (!selection.set()) {
selection.start = cursor; // dummy selection
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,
selection.end, layout);
redoParagraphs(selection.start, endpit);
// we have to reset the selection, because the
// geometry could have changed
- setCursor(selection.start.par(),
- selection.start.pos(), false);
+ setCursor(selection.start.par(), selection.start.pos(), false);
selection.cursor = cursor;
setCursor(selection.end.par(), selection.end.pos(), false);
updateCounters();
}
bool change_layout = (current_layout != layout);
+
if (!change_layout && selection.set() &&
selection.start.par() != selection.end.par())
{
++spit;
}
}
+
if (change_layout) {
current_layout = layout;
update();