2 * \file BufferView_pimpl.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Alfredo Braunstein
8 * \author Lars Gullik Bjønnes
9 * \author Jean-Marc Lasgouttes
10 * \author Angus Leeming
12 * \author André Pönitz
14 * \author Jürgen Vigna
16 * Full author contact details are available in file CREDITS.
21 #include "BufferView_pimpl.h"
23 #include "buffer_funcs.h"
24 #include "bufferlist.h"
25 #include "bufferparams.h"
28 #include "dispatchresult.h"
30 #include "FloatList.h"
31 #include "funcrequest.h"
34 #include "iterators.h"
35 #include "lyx_cb.h" // added for Dispatch functions
41 #include "lastfiles.h"
42 #include "paragraph.h"
43 #include "paragraph_funcs.h"
44 #include "ParagraphParameters.h"
48 #include "insets/insetref.h"
49 #include "insets/insettext.h"
51 #include "frontends/Alert.h"
52 #include "frontends/Dialogs.h"
53 #include "frontends/FileDialog.h"
54 #include "frontends/LyXView.h"
55 #include "frontends/LyXScreenFactory.h"
56 #include "frontends/screen.h"
57 #include "frontends/WorkArea.h"
58 #include "frontends/WorkAreaFactory.h"
60 #include "graphics/Previews.h"
62 #include "support/filetools.h"
63 #include "support/forkedcontr.h"
64 #include "support/globbing.h"
65 #include "support/path_defines.h"
66 #include "support/tostr.h"
68 #include <boost/bind.hpp>
72 using lyx::support::AddPath;
73 using lyx::support::bformat;
74 using lyx::support::FileFilterList;
75 using lyx::support::FileSearch;
76 using lyx::support::ForkedcallsController;
77 using lyx::support::IsDirWriteable;
78 using lyx::support::MakeDisplayPath;
79 using lyx::support::strToUnsignedInt;
80 using lyx::support::system_lyxdir;
83 using std::istringstream;
89 extern BufferList bufferlist;
94 unsigned int const saved_positions_num = 20;
96 // All the below connection objects are needed because of a bug in some
97 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
98 // to these connections we avoid a segfault upon startup, and also at exit.
101 boost::signals::connection dispatchcon;
102 boost::signals::connection timecon;
103 boost::signals::connection doccon;
104 boost::signals::connection resizecon;
105 boost::signals::connection kpresscon;
106 boost::signals::connection selectioncon;
107 boost::signals::connection lostcon;
113 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
114 int xpos, int ypos, int width, int height)
115 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
116 using_xterm_cursor(false), cursor_(bv)
118 xsel_cache_.set = false;
120 workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
121 screen_.reset(LyXScreenFactory::create(workarea()));
124 doccon = workarea().scrollDocView
125 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
126 resizecon = workarea().workAreaResize
127 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
128 dispatchcon = workarea().dispatch
129 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
130 kpresscon = workarea().workAreaKeyPress
131 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
132 selectioncon = workarea().selectionRequested
133 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
134 lostcon = workarea().selectionLost
135 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
137 timecon = cursor_timeout.timeout
138 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
139 cursor_timeout.start();
140 saved_positions.resize(saved_positions_num);
144 void BufferView::Pimpl::addError(ErrorItem const & ei)
146 errorlist_.push_back(ei);
150 void BufferView::Pimpl::showReadonly(bool)
152 owner_->updateWindowTitle();
153 owner_->getDialogs().updateBufferDependent(false);
157 void BufferView::Pimpl::connectBuffer(Buffer & buf)
159 if (errorConnection_.connected())
164 boost::bind(&BufferView::Pimpl::addError, this, _1));
168 boost::bind(&LyXView::message, owner_, _1));
172 boost::bind(&LyXView::busy, owner_, _1));
175 buf.updateTitles.connect(
176 boost::bind(&LyXView::updateWindowTitle, owner_));
179 buf.resetAutosaveTimers.connect(
180 boost::bind(&LyXView::resetAutosaveTimer, owner_));
182 readonlyConnection_ =
183 buf.readonly.connect(
184 boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
188 boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
192 void BufferView::Pimpl::disconnectBuffer()
194 errorConnection_.disconnect();
195 messageConnection_.disconnect();
196 busyConnection_.disconnect();
197 titleConnection_.disconnect();
198 timerConnection_.disconnect();
199 readonlyConnection_.disconnect();
200 closingConnection_.disconnect();
204 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
207 setBuffer(::newFile(filename, tname, isNamed));
211 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
213 // get absolute path of file and add ".lyx" to the filename if
215 string s = FileSearch(string(), filename, "lyx");
217 bool const found = !s.empty();
222 // file already open?
223 if (bufferlist.exists(s)) {
224 string const file = MakeDisplayPath(s, 20);
225 string text = bformat(_("The document %1$s is already "
226 "loaded.\n\nDo you want to revert "
227 "to the saved version?"), file);
228 int const ret = Alert::prompt(_("Revert to saved document?"),
229 text, 0, 1, _("&Revert"), _("&Switch to document"));
232 setBuffer(bufferlist.getBuffer(s));
235 // FIXME: should be LFUN_REVERT
236 if (!bufferlist.close(bufferlist.getBuffer(s), false))
238 // Fall through to new load. (Asger)
244 b = bufferlist.newBuffer(s);
246 if (!::loadLyXFile(b, s)) {
247 bufferlist.release(b);
251 string text = bformat(_("The document %1$s does not yet "
252 "exist.\n\nDo you want to create "
253 "a new document?"), s);
254 int const ret = Alert::prompt(_("Create new document?"),
255 text, 0, 1, _("&Create"), _("Cancel"));
258 b = ::newFile(s, string(), true);
264 bv_->showErrorList(_("Parse"));
267 LyX::ref().lastfiles().newFile(b->fileName());
273 WorkArea & BufferView::Pimpl::workarea() const
275 return *workarea_.get();
279 LyXScreen & BufferView::Pimpl::screen() const
281 return *screen_.get();
285 Painter & BufferView::Pimpl::painter() const
287 return workarea().getPainter();
291 void BufferView::Pimpl::top_y(int y)
297 int BufferView::Pimpl::top_y() const
303 void BufferView::Pimpl::setBuffer(Buffer * b)
305 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
310 // set current buffer
315 cursor_ = LCursor(*bv_);
317 // if we're quitting lyx, don't bother updating stuff
322 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
323 connectBuffer(*buffer_);
325 cursor_.push(buffer_->inset());
326 cursor_.resetAnchor();
327 buffer_->text().init(bv_);
329 // If we don't have a text object for this, we make one
330 //if (bv_->text() == 0)
331 // resizeCurrentBuffer();
333 // Buffer-dependent dialogs should be updated or
334 // hidden. This should go here because some dialogs (eg ToC)
335 // require bv_->text.
336 owner_->getDialogs().updateBufferDependent(true);
337 owner_->setLayout(bv_->text()->getPar(0)->layout()->name());
339 lyxerr[Debug::INFO] << " No Buffer!" << endl;
340 // we are closing the buffer, use the first buffer as current
341 buffer_ = bufferlist.first();
342 owner_->getDialogs().hideBufferDependent();
347 owner_->updateMenubar();
348 owner_->updateToolbar();
349 owner_->updateLayoutChoice();
350 owner_->updateWindowTitle();
352 if (lyx::graphics::Previews::activated() && buffer_)
353 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
357 bool BufferView::Pimpl::fitCursor()
359 if (!screen().fitCursor(bv_))
366 void BufferView::Pimpl::redoCurrentBuffer()
368 lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
369 if (buffer_ && bv_->text()) {
370 resizeCurrentBuffer();
372 owner_->updateLayoutChoice();
377 void BufferView::Pimpl::resizeCurrentBuffer()
379 lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
383 owner_->message(_("Formatting document..."));
385 LyXText * text = bv_->text();
386 lyxerr << "### resizeCurrentBuffer: text " << text << endl;
390 // save the cursor mangled in init
391 LCursor cur = bv_->cursor();
395 bv_->cursor().updatePos();
401 // reset the "Formatting..." message
402 owner_->clearMessage();
408 void BufferView::Pimpl::updateScrollbar()
411 lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
412 lyxerr << "no text in updateScrollbar" << endl;
413 workarea().setScrollbarParams(0, 0, 0);
417 LyXText const & t = *bv_->text();
420 << "Updating scrollbar: height: " << t.height()
421 << " top_y: " << top_y()
422 << " default height " << defaultRowHeight() << endl;
424 workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
428 void BufferView::Pimpl::scrollDocView(int value)
430 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
435 screen().hideCursor();
438 screen().redraw(*bv_);
440 if (!lyxrc.cursor_follows_scrollbar)
443 int const height = defaultRowHeight();
444 int const first = top_y() + height;
445 int const last = top_y() + workarea().workHeight() - height;
447 bv_->cursor().reset(bv_->buffer()->inset());
448 LyXText * text = bv_->text();
449 int y = text->cursorY(bv_->cursor().front());
454 text->setCursorFromCoordinates(bv_->cursor(), 0, y);
456 owner_->updateLayoutChoice();
460 void BufferView::Pimpl::scroll(int lines)
465 LyXText const * t = bv_->text();
466 int const line_height = defaultRowHeight();
468 // The new absolute coordinate
469 int new_top_y = top_y() + lines * line_height;
471 // Restrict to a valid value
472 new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
473 new_top_y = std::max(0, new_top_y);
475 scrollDocView(new_top_y);
477 // Update the scrollbar.
478 workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
482 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
483 key_modifier::state state)
485 bv_->owner()->getLyXFunc().processKeySym(key, state);
487 /* This is perhaps a bit of a hack. When we move
488 * around, or type, it's nice to be able to see
489 * the cursor immediately after the keypress. So
490 * we reset the toggle timeout and force the visibility
491 * of the cursor. Note we cannot do this inside
492 * dispatch() itself, because that's called recursively.
495 cursor_timeout.restart();
496 screen().showCursor(*bv_);
501 void BufferView::Pimpl::selectionRequested()
508 LCursor & cur = bv_->cursor();
510 if (!cur.selection()) {
511 xsel_cache_.set = false;
515 if (!xsel_cache_.set ||
516 cur.back() != xsel_cache_.cursor ||
517 cur.anchor_.back() != xsel_cache_.anchor)
519 xsel_cache_.cursor = cur.back();
520 xsel_cache_.anchor = cur.anchor_.back();
521 xsel_cache_.set = cur.selection();
522 sel = cur.selectionAsString(false);
524 workarea().putClipboard(sel);
529 void BufferView::Pimpl::selectionLost()
532 screen().hideCursor();
533 bv_->cursor().clearSelection();
534 xsel_cache_.set = false;
539 void BufferView::Pimpl::workAreaResize()
541 static int work_area_width;
542 static int work_area_height;
544 bool const widthChange = workarea().workWidth() != work_area_width;
545 bool const heightChange = workarea().workHeight() != work_area_height;
547 // update from work area
548 work_area_width = workarea().workWidth();
549 work_area_height = workarea().workHeight();
551 if (buffer_ && widthChange) {
552 // The visible LyXView need a resize
553 resizeCurrentBuffer();
556 if (widthChange || heightChange)
559 // always make sure that the scrollbar is sane.
561 owner_->updateLayoutChoice();
565 void BufferView::Pimpl::update()
567 //lyxerr << "BufferView::Pimpl::update(), buffer: " << buffer_ << endl;
568 // fix cursor coordinate cache in case something went wrong
570 // check needed to survive LyX startup
572 // update all 'visible' paragraphs
573 ParagraphList::iterator beg;
574 ParagraphList::iterator end;
575 getParsInRange(buffer_->paragraphs(),
576 top_y(), top_y() + workarea().workHeight(),
578 bv_->text()->redoParagraphs(beg, end);
581 screen().redraw(*bv_);
582 bv_->owner()->view_state_changed();
586 // Callback for cursor timer
587 void BufferView::Pimpl::cursorToggle()
590 screen().toggleCursor(*bv_);
592 // Use this opportunity to deal with any child processes that
593 // have finished but are waiting to communicate this fact
594 // to the rest of LyX.
595 ForkedcallsController & fcc = ForkedcallsController::get();
596 if (fcc.processesCompleted())
597 fcc.handleCompletedProcesses();
600 cursor_timeout.restart();
604 bool BufferView::Pimpl::available() const
606 return buffer_ && bv_->text();
610 Change const BufferView::Pimpl::getCurrentChange()
612 if (!bv_->buffer()->params().tracking_changes)
613 return Change(Change::UNCHANGED);
615 LyXText * text = bv_->getLyXText();
616 LCursor & cur = bv_->cursor();
618 if (!cur.selection())
619 return Change(Change::UNCHANGED);
621 return text->getPar(cur.selBegin())
622 ->lookupChangeFull(cur.selBegin().pos());
626 void BufferView::Pimpl::savePosition(unsigned int i)
628 if (i >= saved_positions_num)
630 BOOST_ASSERT(bv_->cursor().inTexted());
631 saved_positions[i] = Position(buffer_->fileName(),
632 bv_->cursor().paragraph().id(),
633 bv_->cursor().pos());
635 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
639 void BufferView::Pimpl::restorePosition(unsigned int i)
641 if (i >= saved_positions_num)
644 string const fname = saved_positions[i].filename;
646 bv_->cursor().clearSelection();
648 if (fname != buffer_->fileName()) {
650 if (bufferlist.exists(fname))
651 b = bufferlist.getBuffer(fname);
653 b = bufferlist.newBuffer(fname);
654 ::loadLyXFile(b, fname); // don't ask, just load it
660 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
661 if (par == buffer_->par_iterator_end())
664 bv_->text()->setCursor(
666 bv_->text()->parOffset(par.pit()),
667 min(par->size(), saved_positions[i].par_pos));
670 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
674 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
676 return i < saved_positions_num && !saved_positions[i].filename.empty();
680 void BufferView::Pimpl::switchKeyMap()
682 if (!lyxrc.rtl_support)
685 Intl & intl = owner_->getIntl();
686 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
687 if (intl.keymap == Intl::PRIMARY)
690 if (intl.keymap == Intl::SECONDARY)
696 void BufferView::Pimpl::center()
698 LyXText * text = bv_->text();
700 bv_->cursor().clearSelection();
701 int const half_height = workarea().workHeight() / 2;
702 int new_y = text->cursorY(bv_->cursor().front()) - half_height;
706 // FIXME: look at this comment again ...
707 // This updates top_y() but means the fitCursor() call
708 // from the update(FITCUR) doesn't realise that we might
709 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
710 // the scrollbar to be updated as it should, so we have
711 // to do it manually. Any operation that does a center()
712 // and also might have moved top_y() must make sure to call
713 // updateScrollbar() currently. Never mind that this is a
714 // pretty obfuscated way of updating text->top_y()
719 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
721 workarea().putClipboard(stuff);
725 InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
727 #warning Does not work for mathed
728 // Ok, this is a little bit too brute force but it
729 // should work for now. Better infrastructure is coming. (Lgb)
731 Buffer * buf = bv_->buffer();
732 Buffer::inset_iterator beg = buf->inset_iterator_begin();
733 Buffer::inset_iterator end = buf->inset_iterator_end();
735 bool cursor_par_seen = false;
737 LCursor & cur = bv_->cursor();
738 ParagraphList::iterator pit = bv_->getLyXText()->getPar(cur.par());
740 for (; beg != end; ++beg) {
741 if (beg.getPar() == pit)
742 cursor_par_seen = true;
743 if (cursor_par_seen) {
744 if (beg.getPar() == pit && beg.getPos() >= cur.pos())
746 if (beg.getPar() != pit)
751 // Now find the first inset that matches code.
752 for (; beg != end; ++beg) {
753 if (beg->lyxCode() == code)
761 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
763 string filename = filenm;
765 if (filename.empty()) {
766 // Launch a file browser
767 string initpath = lyxrc.document_path;
770 string const trypath = owner_->buffer()->filePath();
771 // If directory is writeable, use this as default.
772 if (IsDirWriteable(trypath))
776 FileDialog fileDlg(_("Select LyX document to insert"),
778 make_pair(string(_("Documents|#o#O")),
779 string(lyxrc.document_path)),
780 make_pair(string(_("Examples|#E#e")),
781 string(AddPath(system_lyxdir(), "examples"))));
783 FileDialog::Result result =
784 fileDlg.open(initpath,
785 FileFilterList(_("LyX Documents (*.lyx)")),
788 if (result.first == FileDialog::Later)
791 filename = result.second;
793 // check selected filename
794 if (filename.empty()) {
795 owner_->message(_("Canceled."));
800 // get absolute path of file and add ".lyx" to the filename if
802 filename = FileSearch(string(), filename, "lyx");
804 string const disp_fn = MakeDisplayPath(filename);
805 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
806 if (bv_->insertLyXFile(filename))
807 owner_->message(bformat(_("Document %1$s inserted."),
810 owner_->message(bformat(_("Could not insert document %1$s"),
815 void BufferView::Pimpl::trackChanges()
817 Buffer * buf = bv_->buffer();
818 bool const tracking = buf->params().tracking_changes;
821 ParIterator const end = buf->par_iterator_end();
822 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
824 buf->params().tracking_changes = true;
826 // we cannot allow undos beyond the freeze point
827 buf->undostack().clear();
830 bv_->text()->setCursor(bv_->cursor(), 0, 0);
831 #warning changes FIXME
832 bool found = lyx::find::findNextChange(bv_);
834 owner_->getDialogs().show("changes");
838 ParIterator const end = buf->par_iterator_end();
839 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
840 it->untrackChanges();
841 buf->params().tracking_changes = false;
844 buf->redostack().clear();
848 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
851 // this is only called for mouse related events (including
852 // LFUN_FILE_OPEN generated by drag-and-drop)
854 FuncRequest cmd = cmd0;
855 cmd.y += bv_->top_y();
856 //lyxerr << "*** workAreaDispatch: request: " << cmd << std::endl;
858 cur.push(bv_->buffer()->inset());
860 cur.selection() = bv_->cursor().selection();
861 switch (cmd.action) {
864 case LFUN_MOUSE_MOTION: {
867 FuncRequest cmd1 = cmd;
868 DispatchResult res = cur.inset().dispatch(cur, cmd);
869 if (fitCursor() || res.update()) {
876 case LFUN_MOUSE_MOTION:
879 case LFUN_MOUSE_PRESS:
880 case LFUN_MOUSE_RELEASE:
881 case LFUN_MOUSE_DOUBLE:
882 case LFUN_MOUSE_TRIPLE: {
883 // We pass those directly to the Bufferview, since
884 // otherwise selection handling breaks down
886 // Doesn't go through lyxfunc, so we need to update
887 // the layout choice etc. ourselves
889 // e.g. Qt mouse press when no buffer
893 screen().hideCursor();
895 // either the inset under the cursor or the
896 // surrounding LyXText will handle this event.
898 // built temporary path to inset
899 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
900 lyxerr << "hit inset at tip: " << inset << endl;
901 lyxerr << "created temp cursor:\n" << cur << endl;
903 // Try to dispatch to an non-editable inset near this position
906 inset->dispatch(cur, cmd);
908 // Dispatch to the temp cursor.
909 // An inset (or LyXText) can assign this to bv->cursor()
910 // if it wishes to do so.
911 if (!res.dispatched())
912 res = cur.dispatch(cmd);
914 if (fitCursor() || res.update())
917 // see workAreaKeyPress
918 cursor_timeout.restart();
919 screen().showCursor(*bv_);
921 // skip these when selecting
922 if (cmd.action != LFUN_MOUSE_MOTION) {
923 owner_->updateLayoutChoice();
924 owner_->updateToolbar();
927 // slight hack: this is only called currently when we
928 // clicked somewhere, so we force through the display
929 // of the new status here.
930 owner_->clearMessage();
935 owner_->dispatch(cmd);
945 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
947 //lyxerr << "BufferView::Pimpl::dispatch cmd: " << cmd << std::endl;
948 // Make sure that the cached BufferView is correct.
949 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
950 << " action[" << cmd.action << ']'
951 << " arg[" << cmd.argument << ']'
952 << " x[" << cmd.x << ']'
953 << " y[" << cmd.y << ']'
954 << " button[" << cmd.button() << ']'
957 LCursor & cur = bv_->cursor();
959 switch (cmd.action) {
963 cur.message(_("Undo"));
964 cur.clearSelection();
966 cur.message(_("No further undo information"));
974 cur.message(_("Redo"));
975 cur.clearSelection();
977 cur.message(_("No further redo information"));
983 case LFUN_FILE_INSERT:
984 MenuInsertLyXFile(cmd.argument);
987 case LFUN_FILE_INSERT_ASCII_PARA:
988 InsertAsciiFile(bv_, cmd.argument, true);
991 case LFUN_FILE_INSERT_ASCII:
992 InsertAsciiFile(bv_, cmd.argument, false);
995 case LFUN_FONT_STATE:
996 cur.message(cur.currentState());
999 case LFUN_INSERT_LABEL: {
1000 // Try and generate a valid label
1001 string const contents = cmd.argument.empty() ?
1002 cur.getPossibleLabel() : cmd.argument;
1003 InsetCommandParams icp("label", contents);
1004 string data = InsetCommandMailer::params2string("label", icp);
1005 owner_->getDialogs().show("label", data, 0);
1009 case LFUN_BOOKMARK_SAVE:
1010 savePosition(strToUnsignedInt(cmd.argument));
1013 case LFUN_BOOKMARK_GOTO:
1014 restorePosition(strToUnsignedInt(cmd.argument));
1017 case LFUN_REF_GOTO: {
1018 string label = cmd.argument;
1019 if (label.empty()) {
1021 static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
1023 label = inset->getContents();
1029 bv_->gotoLabel(label);
1033 case LFUN_TRACK_CHANGES:
1037 case LFUN_MERGE_CHANGES:
1038 owner_->getDialogs().show("changes");
1041 case LFUN_ACCEPT_ALL_CHANGES: {
1042 bv_->cursor().reset(bv_->buffer()->inset());
1043 #warning FIXME changes
1044 while (lyx::find::findNextChange(bv_))
1045 bv_->getLyXText()->acceptChange(bv_->cursor());
1050 case LFUN_REJECT_ALL_CHANGES: {
1051 bv_->cursor().reset(bv_->buffer()->inset());
1052 #warning FIXME changes
1053 while (lyx::find::findNextChange(bv_))
1054 bv_->getLyXText()->rejectChange(bv_->cursor());
1059 case LFUN_WORD_FIND:
1060 lyx::find::find(bv_, cmd);
1063 case LFUN_WORD_REPLACE:
1064 lyx::find::replace(bv_, cmd);
1068 cur.clearSelection();
1071 cur.message(N_("Mark off"));
1075 cur.clearSelection();
1079 cur.message(N_("Mark on"));
1083 cur.clearSelection();
1086 cur.message(N_("Mark removed"));
1089 cur.message(N_("Mark set"));
1095 case LFUN_UNKNOWN_ACTION:
1096 cur.errorMessage(N_("Unknown function!"));
1103 case LFUN_BEGINNINGBUFSEL:
1104 bv_->cursor().reset(bv_->buffer()->inset());
1105 if (!cur.selection())
1107 bv_->text()->cursorTop(cur);
1111 case LFUN_ENDBUFSEL:
1112 bv_->cursor().reset(bv_->buffer()->inset());
1113 if (!cur.selection())
1115 bv_->text()->cursorBottom(cur);