X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.C;h=8a7bee84b17775a0551cb9843ed534cf10371ba5;hb=5eb1059f506d5db92d85e93057e752422e014ec2;hp=7bd571ed9a4268b983470a39309af8e0208c8bff;hpb=314b4903ac59480d26eab3ba869e6e154d7bb858;p=lyx.git diff --git a/src/BufferView.C b/src/BufferView.C index 7bd571ed9a..8a7bee84b1 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -3,7 +3,7 @@ * Copyright 1995-2002 the LyX Team * Read the file COPYING * - * \author unknown + * \author Lars Gullik Bjønnes * \author John Levon */ @@ -36,12 +36,10 @@ #include "frontends/screen.h" #include "insets/insetcommand.h" // ChangeRefs -#include "insets/inseterror.h" #include "insets/updatableinset.h" #include "support/FileInfo.h" #include "support/filetools.h" -#include "support/lyxfunctional.h" // equal_1st_in_pair #include "support/types.h" #include "support/lyxalgo.h" // lyx_count @@ -50,6 +48,7 @@ extern BufferList bufferlist; using lyx::pos_type; +using namespace lyx::support; using std::pair; using std::endl; @@ -104,19 +103,30 @@ void BufferView::buffer(Buffer * b) } +bool BufferView::newFile(string const & fn, string const & tn, bool named) +{ + return pimpl_->newFile(fn, tn, named); +} + + +bool BufferView::loadLyXFile(string const & fn, bool tl) +{ + return pimpl_->loadLyXFile(fn, tl); +} + + void BufferView::reload() { string const fn = buffer()->fileName(); if (bufferlist.close(buffer(), false)) - buffer(bufferlist.loadLyXFile(fn)); + loadLyXFile(fn); } void BufferView::resize() { - if (pimpl_->buffer_) { + if (pimpl_->buffer_) pimpl_->resizeCurrentBuffer(); - } } @@ -228,12 +238,6 @@ void BufferView::toggleSelection(bool b) } -void BufferView::toggleToggle() -{ - pimpl_->toggleToggle(); -} - - void BufferView::center() { pimpl_->center(); @@ -316,6 +320,8 @@ bool BufferView::insertLyXFile(string const & filen) bool res = true; + text->breakParagraph(buffer()->paragraphs); + if (c == '#') { // FIXME: huh ? No we won't ! lyxerr[Debug::INFO] << "Will insert file with header" << endl; @@ -331,30 +337,12 @@ bool BufferView::insertLyXFile(string const & filen) } -void BufferView::resetErrorList() -{ - pimpl_->errorlist_.clear(); -} - - -void BufferView::setErrorList(ErrorList const & el) -{ - pimpl_->errorlist_ = el; -} - - -void BufferView::addError(ErrorItem const & ei) -{ - pimpl_->errorlist_.push_back(ei); - -} - - void BufferView::showErrorList(string const & action) const { if (getErrorList().size()) { string const title = bformat(_("LyX: %1$s errors (%2$s)"), action, buffer()->fileName()); owner()->getDialogs().show("errorlist", title); + pimpl_->errorlist_.clear(); } } @@ -379,13 +367,13 @@ void BufferView::setCursorFromRow(int row) texrowpar = text->ownerParagraphs().begin(); tmppos = 0; } else { - texrowpar = *buffer()->getParFromID(tmpid); + texrowpar = buffer()->getParFromID(tmpid).pit(); } text->setCursor(texrowpar, tmppos); } -bool BufferView::insertInset(Inset * inset, string const & lout) +bool BufferView::insertInset(InsetOld * inset, string const & lout) { return pimpl_->insertInset(inset, lout); } @@ -395,7 +383,8 @@ void BufferView::gotoLabel(string const & label) { for (Buffer::inset_iterator it = buffer()->inset_iterator_begin(); it != buffer()->inset_iterator_end(); ++it) { - vector labels = it->getLabelList(); + vector labels; + it->getLabelList(labels); if (find(labels.begin(),labels.end(),label) != labels.end()) { beforeChange(text); @@ -521,7 +510,7 @@ bool BufferView::lockInset(UpdatableInset * inset) if (text->cursor.pos() < text->cursor.par()->size() && text->cursor.par()->getChar(text->cursor.pos()) == Paragraph::META_INSET) { - Inset * in = text->cursor.par()->getInset(text->cursor.pos()); + InsetOld * in = text->cursor.par()->getInset(text->cursor.pos()); if (inset == in) { theLockingInset(inset); return true; @@ -535,15 +524,15 @@ bool BufferView::lockInset(UpdatableInset * inset) InsetList::iterator it = pit->insetlist.begin(); InsetList::iterator end = pit->insetlist.end(); for (; it != end; ++it) { - if (it.getInset() == inset) { - text->setCursorIntern(pit, it.getPos()); + if (it->inset == inset) { + text->setCursorIntern(pit, it->pos); theLockingInset(inset); return true; } - if (it.getInset()->getInsetFromID(id)) { - text->setCursorIntern(pit, it.getPos()); + if (it->inset->getInsetFromID(id)) { + text->setCursorIntern(pit, it->pos); FuncRequest cmd(this, LFUN_INSET_EDIT, "left"); - it.getInset()->localDispatch(cmd); + it->inset->localDispatch(cmd); return theLockingInset()->lockInsetInInset(this, inset); } } @@ -598,25 +587,13 @@ int BufferView::unlockInset(UpdatableInset * inset) } -void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind) -{ - if (!theLockingInset()) - return; // shouldn't happen - if (kind == Undo::EDIT) // in this case insets would not be stored! - kind = Undo::FINISH; - setUndo(this, kind, - text->cursor.par(), - boost::next(text->cursor.par())); -} - - -void BufferView::updateInset(Inset * inset) +void BufferView::updateInset(InsetOld * inset) { pimpl_->updateInset(inset); } -bool BufferView::ChangeInsets(Inset::Code code, +bool BufferView::ChangeInsets(InsetOld::Code code, string const & from, string const & to) { bool need_update = false; @@ -631,8 +608,8 @@ bool BufferView::ChangeInsets(Inset::Code code, bool changed_inset = false; for (InsetList::iterator it2 = it->insetlist.begin(); it2 != it->insetlist.end(); ++it2) { - if (it2.getInset()->lyxCode() == code) { - InsetCommand * inset = static_cast(it2.getInset()); + if (it2->inset->lyxCode() == code) { + InsetCommand * inset = static_cast(it2->inset); if (inset->getContents() == from) { inset->setContents(to); changed_inset = true; @@ -647,10 +624,9 @@ bool BufferView::ChangeInsets(Inset::Code code, // The test it.size()==1 was needed to prevent crashes. // How to set the cursor corretly when it.size()>1 ?? if (it.size() == 1) { - text->setCursorIntern(*it, 0); - text->redoParagraphs(text->cursor, - boost::next(text->cursor.par())); - text->fullRebreak(); + text->setCursorIntern(it.pit(), 0); + text->redoParagraph(text->cursor.par()); + text->partialRebreak(); } } } @@ -662,27 +638,13 @@ bool BufferView::ChangeInsets(Inset::Code code, bool BufferView::ChangeRefsIfUnique(string const & from, string const & to) { // Check if the label 'from' appears more than once - vector labels = buffer()->getLabelList(); + vector labels; + buffer()->getLabelList(labels); if (lyx::count(labels.begin(), labels.end(), from) > 1) return false; - return ChangeInsets(Inset::REF_CODE, from, to); -} - - -bool BufferView::ChangeCitationsIfUnique(string const & from, string const & to) -{ - typedef pair StringPair; - - vector keys; - buffer()->fillWithBibKeys(keys); - if (count_if(keys.begin(), keys.end(), - lyx::equal_1st_in_pair(from)) - > 1) - return false; - - return ChangeInsets(Inset::CITE_CODE, from, to); + return ChangeInsets(InsetOld::REF_CODE, from, to); } @@ -712,7 +674,7 @@ LyXText * BufferView::getLyXText() const } -LyXText * BufferView::getParentText(Inset * inset) const +LyXText * BufferView::getParentText(InsetOld * inset) const { if (inset->owner()) { LyXText * txt = inset->getLyXText(this); @@ -726,7 +688,7 @@ LyXText * BufferView::getParentText(Inset * inset) const } -Language const * BufferView::getParentLanguage(Inset * inset) const +Language const * BufferView::getParentLanguage(InsetOld * inset) const { LyXText * text = getParentText(inset); return text->cursor.par()->getFontSettings(buffer()->params,