}
}
// Then do a deep look of the inset and lock the right one
- Paragraph * par = &*(buffer()->paragraphs.begin());
int const id = inset->id();
- while (par) {
- InsetList::iterator it =
- par->insetlist.begin();
- InsetList::iterator const end =
- par->insetlist.end();
+ ParagraphList::iterator pit = buffer()->paragraphs.begin();
+ ParagraphList::iterator pend = buffer()->paragraphs.end();
+ for (; pit != pend; ++pit) {
+ InsetList::iterator it = pit->insetlist.begin();
+ InsetList::iterator end = pit->insetlist.end();
for (; it != end; ++it) {
if (it.getInset() == inset) {
- text->setCursorIntern(this, par, it.getPos());
+ text->setCursorIntern(this, &*pit, it.getPos());
theLockingInset(inset);
return true;
}
if (it.getInset()->getInsetFromID(id)) {
- text->setCursorIntern(this, par, it.getPos());
+ text->setCursorIntern(this, &*pit, it.getPos());
it.getInset()->edit(this);
return theLockingInset()->lockInsetInInset(this, inset);
}
}
- par = par->next();
}
return false;
}
+2002-08-15 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * paragraph.C (Paragraph): reformat a bit
+ (cutIntoMinibuffer): use builtin InsetList function instad of
+ doing it manually.
+ (getInset): ditto
+
+ * buffer.C: include boost/bind.hpp, add using std::for_each
+ (writeFileAscii): use ParagraphList iterators
+ (validate): use for_each for validate traversal of paragraphs
+ (getBibkeyList): use ParagraphList iterators
+ (resizeInsets): use for_each to resizeInsetsLyXText for all
+ paragraphs.
+ (getParFromID): use ParagraphList iterators
+
+ * BufferView2.C (lockInset): use paragraph list and iterators
+
2002-08-14 John Levon <levon@movementarian.org>
* lyxserver.C: remove spurious xforms include
-
+
2002-08-14 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* lyxfunc.C (getStatus): disable math-extern outside of math mode
* funcrequest.C: move stuff here from .h
- * Makefile.am:
+ * Makefile.am:
* BufferView_pimpl.C:
* LyXAction.C:
* toc.C:
* paragraph_pimpl.h: remove inclusion of boost/array.hpp, remove
unused class variable counter_,
- * paragraph.[Ch] (getFirstCounter): delete unused function
+ * paragraph.[Ch] (getFirstCounter): delete unused function
* counters.C: include LAssert.h
(reset): add a new function with no arg, change other version to
#include "support/lyxmanip.h"
#include "support/lyxalgo.h" // for lyx::count
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
+
#include <fstream>
#include <iomanip>
#include <map>
#include <sys/types.h>
#include <utime.h>
-#include <boost/tuple/tuple.hpp>
-
#ifdef HAVE_LOCALE
#include <locale>
#endif
using std::set;
using std::stack;
using std::list;
+using std::for_each;
using lyx::pos_type;
using lyx::textclass_type;
void Buffer::writeFileAscii(ostream & ofs, int linelen)
{
- Paragraph * par = &*(paragraphs.begin());
- while (par) {
- ofs << asciiParagraph(par, linelen, par->previous() == 0);
- par = par->next();
+ ParagraphList::iterator beg = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator it = beg;
+ for (; it != end; ++it) {
+ ofs << asciiParagraph(&*it, linelen, it == beg);
}
ofs << "\n";
}
void Buffer::validate(LaTeXFeatures & features) const
{
- Paragraph * par = &*(paragraphs.begin());
LyXTextClass const & tclass = params.getLyXTextClass();
// AMS Style is at document level
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
features.require("amsmath");
- while (par) {
- // We don't use "lyxerr.debug" because of speed. (Asger)
- if (lyxerr.debugging(Debug::LATEX))
- lyxerr << "Paragraph: " << par << endl;
-
- // Now just follow the list of paragraphs and run
- // validate on each of them.
- par->validate(features);
-
- // and then the next paragraph
- par = par->next();
- }
+ for_each(paragraphs.begin(), paragraphs.end(),
+ boost::bind(&Paragraph::validate, _1, boost::ref(features)));
// the bullet shapes are buffer level not paragraph level
// so they are tested here
}
vector<StringPair> keys;
- Paragraph * par = &*(paragraphs.begin());
- while (par) {
- if (par->bibkey) {
- string const key = par->bibkey->getContents();
- string const opt = par->bibkey->getOptions();
- string const ref = par->asString(this, false);
+ ParagraphList::iterator pit = paragraphs.begin();
+ ParagraphList::iterator pend = paragraphs.end();
+ for (; pit != pend; ++pit) {
+ if (pit->bibkey) {
+ string const key = pit->bibkey->getContents();
+ string const opt = pit->bibkey->getOptions();
+ string const ref = pit->asString(this, false);
string const info = opt + "TheBibliographyRef" + ref;
keys.push_back(StringPair(key, info));
}
- par = par->next();
}
// Might be either using bibtex or a child has bibliography
void Buffer::resizeInsets(BufferView * bv)
{
/// then remove all LyXText in text-insets
- Paragraph * par = &*(paragraphs.begin());
- for (; par; par = par->next()) {
- par->resizeInsetsLyXText(bv);
- }
+ for_each(paragraphs.begin(), paragraphs.end(),
+ boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
}
Paragraph * Buffer::getParFromID(int id) const
{
- if (id < 0) return 0;
- Paragraph * par = &*(paragraphs.begin());
- while (par) {
- if (par->id() == id) {
- return par;
+ if (id < 0)
+ return 0;
+
+ ParagraphList::iterator it = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ for (; it != end; ++it) {
+ if (it->id() == id) {
+ return &*it;
}
- Paragraph * tmp = par->getParFromID(id);
+ Paragraph * tmp = it->getParFromID(id);
if (tmp) {
return tmp;
}
- par = par->next();
}
return 0;
}
+2002-08-15 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * insettext.C (edit): use ParagraphList iterators
+
+ * insetbib.C (bibitemMaxWidth): use ParagraphList iterators
+ (bibitemWidest): ditto
+
2002-08-14 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C: include <boost/bind.hpp>
int w = 0;
// Ha, now we are mainly at 1.2.0 and it is still here (Jug)
// Does look like a hack? It is! (but will change at 0.13)
- Paragraph * par = &*(bv->buffer()->paragraphs.begin());
-
- while (par) {
- if (par->bibkey) {
- int const wx = par->bibkey->width(bv, font);
- if (wx > w) w = wx;
+ ParagraphList::iterator it = bv->buffer()->paragraphs.begin();
+ ParagraphList::iterator end = bv->buffer()->paragraphs.end();
+ for (; it != end; ++it) {
+ if (it->bibkey) {
+ int const wx = it->bibkey->width(bv, font);
+ if (wx > w)
+ w = wx;
}
- par = par->next();
}
return w;
}
{
int w = 0;
// Does look like a hack? It is! (but will change at 0.13)
- Paragraph * par = &*(buffer->paragraphs.begin());
+
InsetBibKey * bkey = 0;
LyXFont font;
- while (par) {
- if (par->bibkey) {
+ ParagraphList::iterator it = buffer->paragraphs.begin();
+ ParagraphList::iterator end = buffer->paragraphs.end();
+ for (; it != end; ++it) {
+ if (it->bibkey) {
int const wx =
- font_metrics::width(par->bibkey->getBibLabel(),
- font);
+ font_metrics::width(it->bibkey->getBibLabel(),
+ font);
if (wx > w) {
w = wx;
- bkey = par->bibkey;
+ bkey = it->bibkey;
}
}
- par = par->next();
}
if (bkey && !bkey->getBibLabel().empty())
if (front)
lt->setCursor(bv, &*(paragraphs.begin()), 0);
else {
- Paragraph * p = &*(paragraphs.begin());
- while (p->next())
- p = p->next();
+ ParagraphList::iterator it = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ while (boost::next(it) != end)
+ ++it;
// int const pos = (p->size() ? p->size()-1 : p->size());
- lt->setCursor(bv, p, p->size());
+ lt->setCursor(bv, &*it, it->size());
}
lt->clearSelection();
finishUndo();
// copy everything behind the break-position to the new paragraph
insetlist = lp.insetlist;
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it)
- {
- it.setInset(it.getInset()->clone(*current_view->buffer(), same_ids));
+ InsetList::iterator it = insetlist.begin();
+ InsetList::iterator end = insetlist.end();
+ for (; it != end; ++it) {
+ it.setInset(it.getInset()->clone(*current_view->buffer(),
+ same_ids));
// tell the new inset who is the boss now
it.getInset()->parOwner(this);
}
minibuffer_inset = 0;
if (minibuffer_char == Paragraph::META_INSET) {
if (getInset(pos)) {
- minibuffer_inset = getInset(pos);
- // This is a little hack since I want exactly
- // the inset, not just a clone. Otherwise
- // the inset would be deleted when calling Erase(pos)
- // find the entry
- InsetList::iterator it = insetlist.begin();
- InsetList::iterator end = insetlist.end();
- for (; it != end; ++it) {
- if (it.getPos() == pos)
- break;
- }
-
- if (it != end && it.getPos() == pos)
- it.setInset(0);
// the inset is not in a paragraph anymore
+ minibuffer_inset = insetlist.release(pos);
minibuffer_inset->parOwner(0);
} else {
minibuffer_inset = 0;
{
lyx::Assert(pos < size());
- // Find the inset.
- InsetList::iterator it = insetlist.begin();
- InsetList::iterator end = insetlist.end();
- for (; it != end; ++it) {
- if (it.getPos() == pos)
- break;
- }
-
- if (it != end && it.getPos() == pos)
- return it.getInset();
-
- lyxerr << "ERROR (Paragraph::getInset): "
- << "Inset does not exist: " << pos << endl;
- //::raise(SIGSTOP);
-
- // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
- // Did this commenting out introduce a bug? So far I have not
- // see any, please enlighten me. (Lgb)
- // My guess is that since the inset does not exist, we might
- // as well replace it with a space to prevent craches. (Asger)
- return 0;
+ return insetlist.get(pos);
}
return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
return false;
}
-
-