X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView_pimpl.C;h=34b5a478e357034a93c92d4a0ff62c214eb557a7;hb=dad1fc66e44a4dad94eb1e9ffd5736bf8f59ae6d;hp=6ffe90292132a884f270c4a358b4d381cb1ba8e3;hpb=53274e31ec1cc715c0b48921ee67818790c2e99a;p=lyx.git diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 6ffe902921..34b5a478e3 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -8,10 +8,6 @@ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "BufferView_pimpl.h" #include "frontends/WorkArea.h" #include "frontends/screen.h" @@ -41,6 +37,8 @@ #include "ParagraphParameters.h" #include "undo_funcs.h" #include "funcrequest.h" +#include "iterators.h" +#include "lyxfind.h" #include "insets/insetbib.h" #include "insets/insettext.h" @@ -172,7 +170,9 @@ void BufferView::Pimpl::buffer(Buffer * b) // set current buffer buffer_ = b; - if (bufferlist.getState() == BufferList::CLOSING) return; + // if we're quitting lyx, don't bother updating stuff + if (quitting) + return; // if we are closing the buffer, use the first buffer as current if (!buffer_) { @@ -265,8 +265,8 @@ int BufferView::Pimpl::resizeCurrentBuffer() bool selection = false; bool mark_set = false; - owner_->prohibitInput(); - + owner_->busy(true); + owner_->message(_("Formatting document...")); if (bv_->text) { @@ -330,7 +330,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); switchKeyMap(); - owner_->allowInput(); + owner_->busy(false); updateScrollbar(); @@ -356,9 +356,9 @@ void BufferView::Pimpl::updateScrollbar() LyXText const & t = *bv_->text; lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", first_y " - << t.first_y << ", default height " << t.defaultHeight() << endl; + << t.first_y << ", default height " << defaultRowHeight() << endl; - workarea().setScrollbarParams(t.height, t.first_y, t.defaultHeight()); + workarea().setScrollbarParams(t.height, t.first_y, defaultRowHeight()); } @@ -376,7 +376,7 @@ void BufferView::Pimpl::scrollDocView(int value) LyXText * vbt = bv_->text; - int const height = vbt->defaultHeight(); + int const height = defaultRowHeight(); int const first = static_cast((bv_->text->first_y + height)); int const last = static_cast((bv_->text->first_y + workarea().workHeight() - height)); @@ -394,7 +394,7 @@ void BufferView::Pimpl::scroll(int lines) } LyXText const * t = bv_->text; - int const line_height = t->defaultHeight(); + int const line_height = defaultRowHeight(); // The new absolute coordinate int new_first_y = t->first_y + lines * line_height; @@ -406,7 +406,7 @@ void BufferView::Pimpl::scroll(int lines) scrollDocView(new_first_y); // Update the scrollbar. - workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight()); + workarea().setScrollbarParams(t->height, t->first_y, defaultRowHeight()); } @@ -624,6 +624,21 @@ bool BufferView::Pimpl::available() const } +Change const BufferView::Pimpl::getCurrentChange() +{ + if (!bv_->buffer()->params.tracking_changes) + return Change(Change::UNCHANGED); + + LyXText * t(bv_->getLyXText()); + + if (!t->selection.set()) + return Change(Change::UNCHANGED); + + LyXCursor const & cur(t->selection.start); + return cur.par()->lookupChangeFull(cur.pos()); +} + + void BufferView::Pimpl::beforeChange(LyXText * text) { toggleSelection(); @@ -889,9 +904,9 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) ostringstream s1; #if USE_BOOST_FORMAT - s1 << boost::format(_("Inserting document %1$s ...")) % disp_fn; + s1 << boost::format(_("Inserting document %1$s...")) % disp_fn; #else - s1 << _("Inserting document ") << disp_fn << _(" ..."); + s1 << _("Inserting document ") << disp_fn << _("..."); #endif owner_->message(STRCONV(s1.str())); bool const res = bv_->insertLyXFile(filename); @@ -915,6 +930,43 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) } +void BufferView::Pimpl::trackChanges() +{ + Buffer * buf(bv_->buffer()); + 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; + + // we cannot allow undos beyond the freeze point + buf->undostack.clear(); + } else { + bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + bv_->text->setCursor(bv_, &(*buf->paragraphs.begin()), 0); +#warning changes FIXME + //moveCursorUpdate(false); + + bool found = lyxfind::findNextChange(bv_); + if (found) { + owner_->getDialogs().showMergeChanges(); + return; + } + + 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->redostack.clear(); +} + + bool BufferView::Pimpl::dispatch(FuncRequest const & ev) { lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:" @@ -1249,6 +1301,56 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev) } break; + case LFUN_TRACK_CHANGES: + trackChanges(); + break; + + case LFUN_MERGE_CHANGES: + owner_->getDialogs().showMergeChanges(); + break; + + case LFUN_ACCEPT_ALL_CHANGES: { + bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + bv_->text->setCursor(bv_, &(*bv_->buffer()->paragraphs.begin()), 0); +#warning FIXME changes + //moveCursorUpdate(false); + + while (lyxfind::findNextChange(bv_)) { + bv_->getLyXText()->acceptChange(bv_); + } + update(bv_->text, + BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + break; + } + + case LFUN_REJECT_ALL_CHANGES: { + bv_->update(bv_->text, BufferView::SELECT | BufferView::FITCUR); + bv_->text->setCursor(bv_, &(*bv_->buffer()->paragraphs.begin()), 0); +#warning FIXME changes + //moveCursorUpdate(false); + + while (lyxfind::findNextChange(bv_)) { + bv_->getLyXText()->rejectChange(bv_); + } + update(bv_->text, + BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + break; + } + + case LFUN_ACCEPT_CHANGE: { + bv_->getLyXText()->acceptChange(bv_); + update(bv_->text, + BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + break; + } + + case LFUN_REJECT_CHANGE: { + bv_->getLyXText()->rejectChange(bv_); + update(bv_->text, + BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); + break; + } + case LFUN_UNKNOWN_ACTION: ev.errorMessage(N_("Unknown function!")); break;