#include "format.h"
#include "funcrequest.h"
#include "gettext.h"
+#include "insetiterator.h"
#include "iterators.h"
#include "language.h"
#include "LaTeX.h"
#include "support/path.h"
#include "support/textutils.h"
#include "support/tostr.h"
+#include "support/std_sstream.h"
#include <boost/bind.hpp>
-#include "support/std_sstream.h"
-
#include <iomanip>
#include <stack>
bool space_inserted = true;
bool autobreakrows = !pars[par].inInset() ||
static_cast<InsetText *>(pars[par].inInset())->getAutoBreakRows();
- for(string::const_iterator cit = str.begin();
+ for (string::const_iterator cit = str.begin();
cit != str.end(); ++cit) {
if (*cit == '\n') {
if (autobreakrows && (!pars[par].empty() || pars[par].allowEmpty())) {
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990407]
Buffer const * tmp = getMasterBuffer();
+ if (!tmp) {
+ lyxerr << "getMasterBuffer() failed!" << endl;
+ BOOST_ASSERT(tmp);
+ }
if (tmp != this) {
tmp->getLabelList(list);
return;
}
- for (inset_iterator it = inset_const_iterator_begin();
- it != inset_const_iterator_end(); ++it) {
- it->getLabelList(*this, list);
- }
+ for (InsetIterator it(inset()); it; ++it)
+ it.nextInset()->getLabelList(*this, list);
}
/// if this is a child document and the parent is already loaded
/// use the parent's list instead [ale990412]
Buffer const * tmp = getMasterBuffer();
+ BOOST_ASSERT(tmp);
if (tmp != this) {
tmp->fillWithBibKeys(keys);
return;
}
- for (inset_iterator it = inset_const_iterator_begin();
- it != inset_const_iterator_end(); ++it) {
+ for (InsetIterator it(inset()); it; ++it) {
if (it->lyxCode() == InsetOld::BIBTEX_CODE) {
InsetBibtex const & inset =
dynamic_cast<InsetBibtex const &>(*it);
}
-void Buffer::inset_iterator::setParagraph()
-{
- while (pit != par_type(pars_->size())) {
- it = (*pars_)[pit].insetlist.begin();
- if (it != (*pars_)[pit].insetlist.end())
- return;
- ++pit;
- }
-}
-
-
ParIterator Buffer::getParFromID(int id) const
{
#warning FIXME: const correctness! (Andre)
return this;
}
-
-
-Buffer::inset_iterator::inset_iterator(ParagraphList & pars, base_type p)
- : pit(p), pars_(&pars)
-{
- setParagraph();
-}
-
-
-Buffer::inset_iterator Buffer::inset_iterator_begin()
-{
- return inset_iterator(paragraphs(), 0);
-}
-
-
-Buffer::inset_iterator Buffer::inset_iterator_end()
-{
- return inset_iterator(paragraphs(), paragraphs().size());
-}
-
-
-Buffer::inset_iterator Buffer::inset_const_iterator_begin() const
-{
- ParagraphList & pars = const_cast<ParagraphList&>(paragraphs());
- return inset_iterator(pars, 0);
-}
-
-
-Buffer::inset_iterator Buffer::inset_const_iterator_end() const
-{
- ParagraphList & pars = const_cast<ParagraphList&>(paragraphs());
- return inset_iterator(pars, pars.size());
-}
-
-
-Buffer::inset_iterator & Buffer::inset_iterator::operator++()
-{
- if (pit != par_type(pars_->size())) {
- ++it;
- if (it == (*pars_)[pit].insetlist.end()) {
- ++pit;
- setParagraph();
- }
- }
- return *this;
-}
-
-
-Buffer::inset_iterator Buffer::inset_iterator::operator++(int)
-{
- inset_iterator tmp = *this;
- ++*this;
- return tmp;
-}
-
-
-Buffer::inset_iterator::reference Buffer::inset_iterator::operator*()
-{
- return *it->inset;
-}
-
-
-Buffer::inset_iterator::pointer Buffer::inset_iterator::operator->()
-{
- return it->inset;
-}
-
-
-lyx::par_type Buffer::inset_iterator::getPar() const
-{
- return pit;
-}
-
-
-lyx::pos_type Buffer::inset_iterator::getPos() const
-{
- return it->pos;
-}
-
-
-bool operator==(Buffer::inset_iterator const & iter1,
- Buffer::inset_iterator const & iter2)
-{
- return iter1.pit == iter2.pit && iter1.it == iter2.it;
-}
-
-
-bool operator!=(Buffer::inset_iterator const & iter1,
- Buffer::inset_iterator const & iter2)
-{
- return !(iter1 == iter2);
-}
TexRow & texrow();
TexRow const & texrow() const;
- class inset_iterator {
- public:
- typedef std::input_iterator_tag iterator_category;
- typedef InsetBase value_type;
- typedef ptrdiff_t difference_type;
- typedef InsetBase * pointer;
- typedef InsetBase & reference;
- typedef lyx::par_type base_type;
-
- ///
- inset_iterator(ParagraphList & pars, base_type p);
-
- /// prefix ++
- inset_iterator & operator++();
- /// postfix ++
- inset_iterator operator++(int);
- ///
- reference operator*();
- ///
- pointer operator->();
-
- ///
- lyx::par_type getPar() const;
- ///
- lyx::pos_type getPos() const;
- ///
- friend
- bool operator==(inset_iterator const & iter1,
- inset_iterator const & iter2);
- private:
- ///
- void setParagraph();
- ///
- lyx::par_type pit;
- ///
- InsetList::iterator it;
- public:
- ParagraphList * pars_;
- };
-
- /// return an iterator to all *top-level* insets in the buffer
- inset_iterator inset_iterator_begin();
-
- /// return the end of all *top-level* insets in the buffer
- inset_iterator inset_iterator_end();
-
- /// return a const iterator to all *top-level* insets in the buffer
- inset_iterator inset_const_iterator_begin() const;
-
- /// return the const end of all *top-level* insets in the buffer
- inset_iterator inset_const_iterator_end() const;
-
///
ParIterator par_iterator_begin();
///
boost::scoped_ptr<Impl> const pimpl_;
};
-bool operator==(Buffer::inset_iterator const & iter1,
- Buffer::inset_iterator const & iter2);
-
-bool operator!=(Buffer::inset_iterator const & iter1,
- Buffer::inset_iterator const & iter2);
-
#endif
}
+void LCursor::dispatched()
+{
+ disp_.dispatched(true);
+}
+
+
void LCursor::noUpdate()
{
disp_.update(false);
void update();
/// the event was not (yet) dispatched
void undispatched();
+ /// the event was already dispatched
+ void dispatched();
/// don't call update() when done
void noUpdate();
#include "converter.h"
#include "debug.h"
#include "format.h"
+#include "insetiterator.h"
#include "LColor.h"
#include "lyxrc.h"
#include "outputparams.h"
<< "\n";
// Loop over the insets in the buffer and dump all the math-macros.
- Buffer::inset_iterator it = buffer_.inset_const_iterator_begin();
- Buffer::inset_iterator end = buffer_.inset_const_iterator_end();
-
- for (; it != end; ++it)
+ for (InsetIterator it(buffer_.inset()); it; ++it)
if (it->lyxCode() == InsetOld::MATHMACRO_CODE)
it->latex(buffer_, os, runparams);
#include "PreviewLoader.h"
#include "buffer.h"
+#include "insetiterator.h"
#include "lyxrc.h"
#include "paragraph.h"
{
PreviewLoader & ploader = loader(buffer);
- Buffer::inset_iterator it = buffer.inset_const_iterator_begin();
- Buffer::inset_iterator end = buffer.inset_const_iterator_end();
-
- for (; it != end; ++it)
+ for (InsetIterator it(buffer.inset()); it; ++it)
it->addPreview(ploader);
ploader.startLoading();
#include "math_macrotemplate.h"
#include "debug.h"
+#include <boost/assert.hpp>
+
using std::string;
using std::endl;
if (pos == macro_table.end()) {
lyxerr << "MathMacroTable::provideTemplate: no template with name '"
<< name << "' available." << endl;
+ BOOST_ASSERT(false);
}
return pos->second;
}
void MathMacroTable::create(MathAtom const & at)
{
+ lyxerr << "MathMacroTable::create: '"
+ << at->asMacroTemplate()->name() << "'" << endl;
macro_table[at->asMacroTemplate()->name()] = at;
}
{
cell(0).metrics(mi);
cell(1).metrics(mi);
- dim_.wid = cell(0).width() + cell(1).width() + 10;
- dim_.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 2;
- dim_.des = std::max(cell(0).descent(), cell(1).descent()) + 2;
- dim = dim_;
+ dim.wid = cell(0).width() + cell(1).width() + 10;
+ dim.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 2;
+ dim.des = std::max(cell(0).descent(), cell(1).descent()) + 2;
+ dim_ = dim;
}
void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
- lyxerr << "MathNestInset: request: " << cmd << std::endl;
+ //lyxerr << "MathNestInset: request: " << cmd << std::endl;
//CursorSlice sl = cur.current();
switch (cmd.action) {
cur.insert(MathAtom(new MathSpaceInset(",")));
break;
- case LFUN_UNDO:
-#warning look here
- //cur.bv().owner()->message(_("Invalid action in math mode!"));
- break;
-
case LFUN_INSET_ERT:
// interpret this as if a backslash was typed
recordUndo(cur, Undo::ATOMIC);
return ret;
}
+
void MathNestInset::edit(LCursor & cur, bool left)
{
cur.push(*this);
cur.idx() = left ? 0 : cur.lastidx();
cur.pos() = left ? 0 : cur.lastpos();
cur.resetAnchor();
+ lyxerr << "MathNestInset::edit, cur:\n" << cur << endl;
}
using lyx::par_type;
+using std::endl;
+
namespace {
DocumentIterator dit =
undo.cursor.asDocumentIterator(&bv.buffer()->inset());
if (dit.inMathed()) {
- // not much to be done
+ // Easy way out: store a full cell.
+ otherstack.top().array = asString(dit.cell());
} else {
+ // As cells might be too large in texted, store just a part
+ // of the paragraph list.
otherstack.top().pars.clear();
LyXText * text = dit.text();
BOOST_ASSERT(text);