#include "buffer.h"
#include "buffer_funcs.h"
#include "bufferlist.h"
+#include "bufferparams.h"
+#include "cursor.h"
#include "debug.h"
#include "factory.h"
#include "FloatList.h"
#include "ParagraphParameters.h"
#include "TextCache.h"
#include "undo_funcs.h"
+#include "vspace.h"
#include "insets/insetfloatlist.h"
#include "insets/insetref.h"
#include <boost/bind.hpp>
+using bv_funcs::bold;
+using bv_funcs::code;
+using bv_funcs::currentState;
+using bv_funcs::emph;
+using bv_funcs::fontSize;
+using bv_funcs::lang;
+using bv_funcs::noun;
+using bv_funcs::roman;
+using bv_funcs::sans;
+using bv_funcs::styleReset;
+using bv_funcs::underline;
+
+using lyx::pos_type;
+
+using lyx::support::AddPath;
+using lyx::support::bformat;
+using lyx::support::FileSearch;
+using lyx::support::IsDirWriteable;
+using lyx::support::MakeDisplayPath;
+using lyx::support::strToUnsignedInt;
+using lyx::support::system_lyxdir;
using std::endl;
using std::make_pair;
using std::min;
+using std::string;
-using lyx::pos_type;
-using namespace lyx::support;
-using namespace bv_funcs;
extern BufferList bufferlist;
if (buffer_) {
// Don't forget to update the Layout
string const layoutname =
- bv_->text->cursor.par()->layout()->name();
+ bv_->text->cursorPar()->layout()->name();
owner_->setLayout(layoutname);
}
{
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
- ParagraphList::iterator par;
- ParagraphList::iterator selstartpar;
- ParagraphList::iterator selendpar;
+ int par = -1;
+ int selstartpar = -1;
+ int selendpar = -1;
UpdatableInset * the_locking_inset = 0;
pos_type pos = 0;
textcache.show(lyxerr, "resizeCurrentBuffer");
} else {
lyxerr << "no text in cache!" << endl;
- bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs);
+ bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
bv_->text->init(bv_);
}
-
- par = bv_->text->ownerParagraphs().end();
- selstartpar = bv_->text->ownerParagraphs().end();
- selendpar = bv_->text->ownerParagraphs().end();
}
#warning does not help much
- bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
- bv_->text->ownerParagraphs().end());
+ //bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
+ // bv_->text->ownerParagraphs().end());
- if (par != bv_->text->ownerParagraphs().end()) {
+ if (par != -1) {
bv_->text->selection.set(true);
// At this point just to avoid the Delete-Empty-Paragraph-
// Mechanism when setting the cursor.
void BufferView::Pimpl::update()
{
- lyxerr << "BufferView::update()" << endl;
+ //lyxerr << "BufferView::update()" << endl;
// fix cursor coordinate cache in case something went wrong
if (bv_->getLyXText()) {
// check needed to survive LyX startup
Change const BufferView::Pimpl::getCurrentChange()
{
- if (!bv_->buffer()->params.tracking_changes)
+ if (!bv_->buffer()->params().tracking_changes)
return Change(Change::UNCHANGED);
LyXText * text = bv_->getLyXText();
if (!text->selection.set())
return Change(Change::UNCHANGED);
- LyXCursor const & cur = text->selection.start;
- return cur.par()->lookupChangeFull(cur.pos());
+ return text->getPar(text->selection.start)
+ ->lookupChangeFull(text->selection.start.pos());
}
if (i >= saved_positions_num)
return;
saved_positions[i] = Position(buffer_->fileName(),
- bv_->text->cursor.par()->id(),
+ bv_->text->cursorPar()->id(),
bv_->text->cursor.pos());
if (i > 0)
owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
beforeChange(bv_->text);
if (fname != buffer_->fileName()) {
- Buffer * b;
+ Buffer * b = 0;
if (bufferlist.exists(fname))
b = bufferlist.getBuffer(fname);
else {
b = bufferlist.newBuffer(fname);
::loadLyXFile(b, fname); // don't ask, just load it
}
- if (b != 0)
+ if (b)
buffer(b);
}
LyXCursor cursor = bv_->getLyXText()->cursor;
Buffer::inset_iterator it =
find_if(Buffer::inset_iterator(
- cursor.par(), cursor.pos()),
+ cursorPar(), cursor.pos()),
buffer_->inset_iterator_end(),
lyx::compare_memfun(&Inset::lyxCode, code));
return it != buffer_->inset_iterator_end() ? (*it) : 0;
// should work for now. Better infrastructure is coming. (Lgb)
Buffer * b = bv_->buffer();
- LyXCursor cursor = bv_->getLyXText()->cursor;
+ LyXText * text = bv_->getLyXText();
Buffer::inset_iterator beg = b->inset_iterator_begin();
Buffer::inset_iterator end = b->inset_iterator_end();
- bool cursor_par_seen = false;
+ bool cursorPar_seen = false;
for (; beg != end; ++beg) {
- if (beg.getPar() == cursor.par()) {
- cursor_par_seen = true;
+ if (beg.getPar() == text->cursorPar()) {
+ cursorPar_seen = true;
}
- if (cursor_par_seen) {
- if (beg.getPar() == cursor.par()
- && beg.getPos() >= cursor.pos()) {
+ if (cursorPar_seen) {
+ if (beg.getPar() == text->cursorPar()
+ && beg.getPos() >= text->cursor.pos()) {
break;
- } else if (beg.getPar() != cursor.par()) {
+ } else if (beg.getPar() != text->cursorPar()) {
break;
}
}
void BufferView::Pimpl::trackChanges()
{
Buffer * buf(bv_->buffer());
- bool const tracking(buf->params.tracking_changes);
+ bool const tracking(buf->params().tracking_changes);
if (!tracking) {
ParIterator const end = buf->par_iterator_end();
for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
it->trackChanges();
- buf->params.tracking_changes = true;
+ buf->params().tracking_changes = true;
// we cannot allow undos beyond the freeze point
- buf->undostack.clear();
+ buf->undostack().clear();
} else {
update();
- bv_->text->setCursor(buf->paragraphs.begin(), 0);
+ bv_->text->setCursor(0, 0);
#warning changes FIXME
//moveCursorUpdate(false);
ParIterator const end = buf->par_iterator_end();
for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
it->untrackChanges();
- buf->params.tracking_changes = false;
+ buf->params().tracking_changes = false;
}
- buf->redostack.clear();
+ buf->redostack().clear();
}
<< " button[" << ev.button() << ']'
<< endl;
- LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
+ LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
switch (ev.action) {
case LFUN_LAYOUT_PARAGRAPH: {
string data;
- params2string(*bv_->getLyXText()->cursor.par(), data);
+ params2string(*bv_->getLyXText()->cursorPar(), data);
data = "show\n" + data;
bv_->owner()->getDialogs().show("paragraph", data);
case LFUN_PARAGRAPH_UPDATE: {
if (!bv_->owner()->getDialogs().visible("paragraph"))
break;
- Paragraph const & par = *bv_->getLyXText()->cursor.par();
+ Paragraph const & par = *bv_->getLyXText()->cursorPar();
string data;
params2string(par, data);
break;
case LFUN_ACCEPT_ALL_CHANGES: {
- bv_->text->setCursor(bv_->buffer()->paragraphs.begin(), 0);
+ bv_->text->setCursor(0, 0);
#warning FIXME changes
//moveCursorUpdate(false);
}
case LFUN_REJECT_ALL_CHANGES: {
- bv_->text->setCursor(bv_->buffer()->paragraphs.begin(), 0);
+ bv_->text->setCursor(0, 0);
#warning FIXME changes
//moveCursorUpdate(false);
beforeChange(bv_->text);
if (!lout.empty()) {
- bv_->text->breakParagraph(bv_->buffer()->paragraphs);
+ bv_->text->breakParagraph(bv_->buffer()->paragraphs());
- if (!bv_->text->cursor.par()->empty()) {
+ if (!bv_->text->cursorPar()->empty()) {
bv_->text->cursorLeft(bv_);
- bv_->text->breakParagraph(bv_->buffer()->paragraphs);
+ bv_->text->breakParagraph(bv_->buffer()->paragraphs());
}
string lres = lout;
- LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
+ LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
bool hasLayout = tclass.hasLayout(lres);
string lay = tclass.defaultLayoutName();
bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
// this should not be needed, but it is...
- // bv_->text->redoParagraph(bv_->text->cursor.par());
+ // bv_->text->redoParagraph(bv_->text->cursorPar());
// bv_->text->fullRebreak();
update();
// FIXME
// The test it.size()==1 was needed to prevent crashes.
- // How to set the cursor corretly when it.size()>1 ??
+ // How to set the cursor correctly when it.size()>1 ??
if (it.size() == 1) {
- bv_->text->setCursorIntern(it.pit(), 0);
- bv_->text->redoParagraph(bv_->text->cursor.par());
+ bv_->text->setCursorIntern(bv_->text->parOffset(it.pit()), 0);
+ bv_->text->redoParagraph(bv_->text->cursorPar());
}
}
}