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"
32 #include "FuncStatus.h"
35 #include "insetiterator.h"
36 #include "lyx_cb.h" // added for Dispatch functions
42 #include "lastfiles.h"
43 #include "paragraph.h"
44 #include "paragraph_funcs.h"
45 #include "ParagraphParameters.h"
46 #include "pariterator.h"
47 #include "rowpainter.h"
51 #include "insets/insetref.h"
52 #include "insets/insettext.h"
54 #include "frontends/Alert.h"
55 #include "frontends/Dialogs.h"
56 #include "frontends/FileDialog.h"
57 #include "frontends/LyXView.h"
58 #include "frontends/LyXScreenFactory.h"
59 #include "frontends/screen.h"
60 #include "frontends/WorkArea.h"
61 #include "frontends/WorkAreaFactory.h"
63 #include "graphics/Previews.h"
65 #include "support/filetools.h"
66 #include "support/forkedcontr.h"
67 #include "support/globbing.h"
68 #include "support/path_defines.h"
69 #include "support/tostr.h"
70 #include "support/types.h"
72 #include <boost/bind.hpp>
76 using lyx::support::AddPath;
77 using lyx::support::bformat;
78 using lyx::support::FileFilterList;
79 using lyx::support::FileSearch;
80 using lyx::support::ForkedcallsController;
81 using lyx::support::IsDirWriteable;
82 using lyx::support::MakeDisplayPath;
83 using lyx::support::strToUnsignedInt;
84 using lyx::support::system_lyxdir;
87 using std::istringstream;
93 extern BufferList bufferlist;
98 unsigned int const saved_positions_num = 20;
100 // All the below connection objects are needed because of a bug in some
101 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
102 // to these connections we avoid a segfault upon startup, and also at exit.
105 boost::signals::connection dispatchcon;
106 boost::signals::connection timecon;
107 boost::signals::connection doccon;
108 boost::signals::connection resizecon;
109 boost::signals::connection kpresscon;
110 boost::signals::connection selectioncon;
111 boost::signals::connection lostcon;
114 /// Get next inset of this class from current cursor position
116 T * getInsetByCode(LCursor & cur, InsetBase::Code code)
119 DocIterator it = cur;
120 if (it.nextInset() &&
121 it.nextInset()->lyxCode() == code) {
122 inset = static_cast<T*>(it.nextInset());
131 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
132 int width, int height)
133 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
134 using_xterm_cursor(false), cursor_(bv)
136 xsel_cache_.set = false;
138 workarea_.reset(WorkAreaFactory::create(*owner_, width, height));
139 screen_.reset(LyXScreenFactory::create(workarea()));
142 doccon = workarea().scrollDocView
143 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
144 resizecon = workarea().workAreaResize
145 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
146 dispatchcon = workarea().dispatch
147 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
148 kpresscon = workarea().workAreaKeyPress
149 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
150 selectioncon = workarea().selectionRequested
151 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
152 lostcon = workarea().selectionLost
153 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
155 timecon = cursor_timeout.timeout
156 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
157 cursor_timeout.start();
158 saved_positions.resize(saved_positions_num);
162 void BufferView::Pimpl::addError(ErrorItem const & ei)
164 errorlist_.push_back(ei);
168 void BufferView::Pimpl::showReadonly(bool)
170 owner_->updateWindowTitle();
171 owner_->getDialogs().updateBufferDependent(false);
175 void BufferView::Pimpl::connectBuffer(Buffer & buf)
177 if (errorConnection_.connected())
182 boost::bind(&BufferView::Pimpl::addError, this, _1));
186 boost::bind(&LyXView::message, owner_, _1));
190 boost::bind(&LyXView::busy, owner_, _1));
193 buf.updateTitles.connect(
194 boost::bind(&LyXView::updateWindowTitle, owner_));
197 buf.resetAutosaveTimers.connect(
198 boost::bind(&LyXView::resetAutosaveTimer, owner_));
200 readonlyConnection_ =
201 buf.readonly.connect(
202 boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
206 boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
210 void BufferView::Pimpl::disconnectBuffer()
212 errorConnection_.disconnect();
213 messageConnection_.disconnect();
214 busyConnection_.disconnect();
215 titleConnection_.disconnect();
216 timerConnection_.disconnect();
217 readonlyConnection_.disconnect();
218 closingConnection_.disconnect();
222 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
225 setBuffer(::newFile(filename, tname, isNamed));
229 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
231 // get absolute path of file and add ".lyx" to the filename if
233 string s = FileSearch(string(), filename, "lyx");
235 bool const found = !s.empty();
240 // file already open?
241 if (bufferlist.exists(s)) {
242 string const file = MakeDisplayPath(s, 20);
243 string text = bformat(_("The document %1$s is already "
244 "loaded.\n\nDo you want to revert "
245 "to the saved version?"), file);
246 int const ret = Alert::prompt(_("Revert to saved document?"),
247 text, 0, 1, _("&Revert"), _("&Switch to document"));
250 setBuffer(bufferlist.getBuffer(s));
253 // FIXME: should be LFUN_REVERT
254 if (!bufferlist.close(bufferlist.getBuffer(s), false))
256 // Fall through to new load. (Asger)
262 b = bufferlist.newBuffer(s);
264 if (!::loadLyXFile(b, s)) {
265 bufferlist.release(b);
269 string text = bformat(_("The document %1$s does not yet "
270 "exist.\n\nDo you want to create "
271 "a new document?"), s);
272 int const ret = Alert::prompt(_("Create new document?"),
273 text, 0, 1, _("&Create"), _("Cancel"));
276 b = ::newFile(s, string(), true);
282 bv_->showErrorList(_("Parse"));
285 LyX::ref().lastfiles().newFile(b->fileName());
291 WorkArea & BufferView::Pimpl::workarea() const
293 return *workarea_.get();
297 LyXScreen & BufferView::Pimpl::screen() const
299 return *screen_.get();
303 Painter & BufferView::Pimpl::painter() const
305 return workarea().getPainter();
309 void BufferView::Pimpl::top_y(int y)
315 int BufferView::Pimpl::top_y() const
321 void BufferView::Pimpl::setBuffer(Buffer * b)
323 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
328 // set current buffer
333 cursor_ = LCursor(*bv_);
335 // if we're quitting lyx, don't bother updating stuff
340 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
341 connectBuffer(*buffer_);
343 cursor_.push(buffer_->inset());
344 cursor_.resetAnchor();
345 buffer_->text().init(bv_);
346 buffer_->text().setCurrentFont(cursor_);
348 // If we don't have a text object for this, we make one
349 //if (bv_->text() == 0)
350 // resizeCurrentBuffer();
352 // Buffer-dependent dialogs should be updated or
353 // hidden. This should go here because some dialogs (eg ToC)
354 // require bv_->text.
355 owner_->getDialogs().updateBufferDependent(true);
357 lyxerr[Debug::INFO] << " No Buffer!" << endl;
358 // we are closing the buffer, use the first buffer as current
359 buffer_ = bufferlist.first();
360 owner_->getDialogs().hideBufferDependent();
365 owner_->updateMenubar();
366 owner_->updateToolbars();
367 owner_->updateLayoutChoice();
368 owner_->updateWindowTitle();
370 // This is done after the layout combox has been populated
372 owner_->setLayout(cursor_.paragraph().layout()->name());
374 if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
375 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
379 bool BufferView::Pimpl::fitCursor()
381 // to get the correct y cursor info
382 lyxerr[Debug::DEBUG] << "BufferView::fitCursor" << std::endl;
383 lyx::par_type const pit = bv_->cursor().bottom().par();
384 bv_->text()->redoParagraph(pit);
385 refreshPar(*bv_, *bv_->text(), pit);
387 if (!screen().fitCursor(bv_))
394 void BufferView::Pimpl::redoCurrentBuffer()
396 lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
397 if (buffer_ && bv_->text()) {
398 resizeCurrentBuffer();
400 owner_->updateLayoutChoice();
405 void BufferView::Pimpl::resizeCurrentBuffer()
407 lyxerr[Debug::DEBUG] << "resizeCurrentBuffer" << endl;
409 owner_->message(_("Formatting document..."));
411 LyXText * text = bv_->text();
422 // reset the "Formatting..." message
423 owner_->clearMessage();
429 void BufferView::Pimpl::updateScrollbar()
432 lyxerr[Debug::DEBUG] << "no text in updateScrollbar" << endl;
433 workarea().setScrollbarParams(0, 0, 0);
437 LyXText const & t = *bv_->text();
440 << "Updating scrollbar: height: " << t.height()
441 << " top_y: " << top_y()
442 << " default height " << defaultRowHeight() << endl;
444 workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
448 void BufferView::Pimpl::scrollDocView(int value)
450 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
455 screen().hideCursor();
458 screen().redraw(*bv_);
460 if (!lyxrc.cursor_follows_scrollbar)
463 int const height = defaultRowHeight();
464 int const first = top_y() + height;
465 int const last = top_y() + workarea().workHeight() - height;
467 bv_->cursor().reset(bv_->buffer()->inset());
468 LyXText * text = bv_->text();
469 int y = text->cursorY(bv_->cursor().front());
474 text->setCursorFromCoordinates(bv_->cursor(), 0, y);
476 owner_->updateLayoutChoice();
480 void BufferView::Pimpl::scroll(int lines)
485 LyXText const * t = bv_->text();
486 int const line_height = defaultRowHeight();
488 // The new absolute coordinate
489 int new_top_y = top_y() + lines * line_height;
491 // Restrict to a valid value
492 new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
493 new_top_y = std::max(0, new_top_y);
495 scrollDocView(new_top_y);
497 // Update the scrollbar.
498 workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
502 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
503 key_modifier::state state)
505 bv_->owner()->getLyXFunc().processKeySym(key, state);
507 /* This is perhaps a bit of a hack. When we move
508 * around, or type, it's nice to be able to see
509 * the cursor immediately after the keypress. So
510 * we reset the toggle timeout and force the visibility
511 * of the cursor. Note we cannot do this inside
512 * dispatch() itself, because that's called recursively.
515 cursor_timeout.restart();
516 screen().showCursor(*bv_);
521 void BufferView::Pimpl::selectionRequested()
528 LCursor & cur = bv_->cursor();
530 if (!cur.selection()) {
531 xsel_cache_.set = false;
535 if (!xsel_cache_.set ||
536 cur.back() != xsel_cache_.cursor ||
537 cur.anchor_.back() != xsel_cache_.anchor)
539 xsel_cache_.cursor = cur.back();
540 xsel_cache_.anchor = cur.anchor_.back();
541 xsel_cache_.set = cur.selection();
542 sel = cur.selectionAsString(false);
544 workarea().putClipboard(sel);
549 void BufferView::Pimpl::selectionLost()
552 screen().hideCursor();
553 bv_->cursor().clearSelection();
554 xsel_cache_.set = false;
559 void BufferView::Pimpl::workAreaResize()
561 static int work_area_width;
562 static int work_area_height;
564 bool const widthChange = workarea().workWidth() != work_area_width;
565 bool const heightChange = workarea().workHeight() != work_area_height;
567 // update from work area
568 work_area_width = workarea().workWidth();
569 work_area_height = workarea().workHeight();
571 if (buffer_ && widthChange) {
572 // The visible LyXView need a resize
573 resizeCurrentBuffer();
576 if (widthChange || heightChange)
579 // always make sure that the scrollbar is sane.
581 owner_->updateLayoutChoice();
585 void BufferView::Pimpl::update()
587 //lyxerr << "BufferView::Pimpl::update(), buffer: " << buffer_ << endl;
588 // fix cursor coordinate cache in case something went wrong
590 // check needed to survive LyX startup
592 // update macro store
593 buffer_->buildMacros();
595 // update all 'visible' paragraphs
596 lyx::par_type beg, end;
597 getParsInRange(buffer_->paragraphs(),
598 top_y(), top_y() + workarea().workHeight(),
600 bv_->text()->redoParagraphs(beg, end);
605 screen().redraw(*bv_);
606 bv_->owner()->view_state_changed();
610 // Callback for cursor timer
611 void BufferView::Pimpl::cursorToggle()
614 screen().toggleCursor(*bv_);
616 // Use this opportunity to deal with any child processes that
617 // have finished but are waiting to communicate this fact
618 // to the rest of LyX.
619 ForkedcallsController & fcc = ForkedcallsController::get();
620 if (fcc.processesCompleted())
621 fcc.handleCompletedProcesses();
624 cursor_timeout.restart();
628 bool BufferView::Pimpl::available() const
630 return buffer_ && bv_->text();
634 Change const BufferView::Pimpl::getCurrentChange()
636 if (!bv_->buffer()->params().tracking_changes)
637 return Change(Change::UNCHANGED);
639 LyXText * text = bv_->getLyXText();
640 LCursor & cur = bv_->cursor();
642 if (!cur.selection())
643 return Change(Change::UNCHANGED);
645 return text->getPar(cur.selBegin().par()).
646 lookupChangeFull(cur.selBegin().pos());
650 void BufferView::Pimpl::savePosition(unsigned int i)
652 if (i >= saved_positions_num)
654 BOOST_ASSERT(bv_->cursor().inTexted());
655 saved_positions[i] = Position(buffer_->fileName(),
656 bv_->cursor().paragraph().id(),
657 bv_->cursor().pos());
659 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
663 void BufferView::Pimpl::restorePosition(unsigned int i)
665 if (i >= saved_positions_num)
668 string const fname = saved_positions[i].filename;
670 bv_->cursor().clearSelection();
672 if (fname != buffer_->fileName()) {
674 if (bufferlist.exists(fname))
675 b = bufferlist.getBuffer(fname);
677 b = bufferlist.newBuffer(fname);
678 ::loadLyXFile(b, fname); // don't ask, just load it
684 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
685 if (par == buffer_->par_iterator_end())
688 bv_->text()->setCursor(bv_->cursor(), par.pit(),
689 min(par->size(), saved_positions[i].par_pos));
692 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
696 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
698 return i < saved_positions_num && !saved_positions[i].filename.empty();
702 void BufferView::Pimpl::switchKeyMap()
704 if (!lyxrc.rtl_support)
707 Intl & intl = owner_->getIntl();
708 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
709 if (intl.keymap == Intl::PRIMARY)
712 if (intl.keymap == Intl::SECONDARY)
718 void BufferView::Pimpl::center()
720 LyXText * text = bv_->text();
722 bv_->cursor().clearSelection();
723 int const half_height = workarea().workHeight() / 2;
724 int new_y = text->cursorY(bv_->cursor().front()) - half_height;
728 // FIXME: look at this comment again ...
729 // This updates top_y() but means the fitCursor() call
730 // from the update(FITCUR) doesn't realise that we might
731 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
732 // the scrollbar to be updated as it should, so we have
733 // to do it manually. Any operation that does a center()
734 // and also might have moved top_y() must make sure to call
735 // updateScrollbar() currently. Never mind that this is a
736 // pretty obfuscated way of updating text->top_y()
741 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
743 workarea().putClipboard(stuff);
747 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
749 string filename = filenm;
751 if (filename.empty()) {
752 // Launch a file browser
753 string initpath = lyxrc.document_path;
756 string const trypath = owner_->buffer()->filePath();
757 // If directory is writeable, use this as default.
758 if (IsDirWriteable(trypath))
762 FileDialog fileDlg(_("Select LyX document to insert"),
764 make_pair(string(_("Documents|#o#O")),
765 string(lyxrc.document_path)),
766 make_pair(string(_("Examples|#E#e")),
767 string(AddPath(system_lyxdir(), "examples"))));
769 FileDialog::Result result =
770 fileDlg.open(initpath,
771 FileFilterList(_("LyX Documents (*.lyx)")),
774 if (result.first == FileDialog::Later)
777 filename = result.second;
779 // check selected filename
780 if (filename.empty()) {
781 owner_->message(_("Canceled."));
786 // get absolute path of file and add ".lyx" to the filename if
788 filename = FileSearch(string(), filename, "lyx");
790 string const disp_fn = MakeDisplayPath(filename);
791 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
792 if (bv_->insertLyXFile(filename))
793 owner_->message(bformat(_("Document %1$s inserted."),
796 owner_->message(bformat(_("Could not insert document %1$s"),
801 void BufferView::Pimpl::trackChanges()
803 Buffer * buf = bv_->buffer();
804 bool const tracking = buf->params().tracking_changes;
807 ParIterator const end = buf->par_iterator_end();
808 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
810 buf->params().tracking_changes = true;
812 // we cannot allow undos beyond the freeze point
813 buf->undostack().clear();
816 bv_->text()->setCursor(bv_->cursor(), 0, 0);
818 #warning changes FIXME
820 bool found = lyx::find::findNextChange(bv_);
822 owner_->getDialogs().show("changes");
826 ParIterator const end = buf->par_iterator_end();
827 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
828 it->untrackChanges();
829 buf->params().tracking_changes = false;
832 buf->redostack().clear();
836 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
838 //lyxerr << "BufferView::Pimpl::workAreaDispatch: request: "
839 // << cmd << std::endl;
840 // this is only called for mouse related events including
841 // LFUN_FILE_OPEN generated by drag-and-drop.
842 FuncRequest cmd = cmd0;
845 if (cmd.action == LFUN_FILE_OPEN) {
846 owner_->dispatch(cmd);
850 cmd.y += bv_->top_y();
855 cur.push(bv_->buffer()->inset());
856 cur.selection() = bv_->cursor().selection();
858 // Doesn't go through lyxfunc, so we need to update
859 // the layout choice etc. ourselves
861 // e.g. Qt mouse press when no buffer
865 screen().hideCursor();
867 // Either the inset under the cursor or the
868 // surrounding LyXText will handle this event.
870 // Build temporary cursor.
871 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
872 lyxerr << "hit inset at tip: " << inset << endl;
873 lyxerr << "created temp cursor:\n" << cur << endl;
875 // Put anchor at the same position.
878 // Try to dispatch to an non-editable inset near this position
879 // via the temp cursor. If the inset wishes to change the real
880 // cursor it has to do so explicitly by using
881 // cur.bv().cursor() = cur; (or similar)'
883 inset->dispatch(cur, cmd);
885 // Now dispatch to the temporary cursor. If the real cursor should
886 // be modified, the inset's dispatch has to do so explicitly.
887 if (!cur.result().dispatched())
890 if (cur.result().dispatched()) {
891 // Redraw if requested or necessary.
892 if (fitCursor() || cur.result().update())
896 // see workAreaKeyPress
897 cursor_timeout.restart();
898 screen().showCursor(*bv_);
900 // skip these when selecting
901 if (cmd.action != LFUN_MOUSE_MOTION) {
902 owner_->updateLayoutChoice();
903 owner_->updateToolbars();
906 // slight hack: this is only called currently when we
907 // clicked somewhere, so we force through the display
908 // of the new status here.
909 owner_->clearMessage();
914 FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
916 Buffer * buf = bv_->buffer();
920 switch (cmd.action) {
923 flag.enabled(!buf->undostack().empty());
926 flag.enabled(!buf->redostack().empty());
928 case LFUN_FILE_INSERT:
929 case LFUN_FILE_INSERT_ASCII_PARA:
930 case LFUN_FILE_INSERT_ASCII:
931 case LFUN_FONT_STATE:
932 case LFUN_INSERT_LABEL:
933 case LFUN_BOOKMARK_SAVE:
936 case LFUN_WORD_REPLACE:
941 case LFUN_BEGINNINGBUF:
943 case LFUN_BEGINNINGBUFSEL:
947 case LFUN_BOOKMARK_GOTO:
948 flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument)));
950 case LFUN_TRACK_CHANGES:
952 flag.setOnOff(buf->params().tracking_changes);
955 case LFUN_MERGE_CHANGES:
956 case LFUN_ACCEPT_CHANGE: // what about these two
957 case LFUN_REJECT_CHANGE: // what about these two
958 case LFUN_ACCEPT_ALL_CHANGES:
959 case LFUN_REJECT_ALL_CHANGES:
960 flag.enabled(buf && buf->params().tracking_changes);
971 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
973 //lyxerr << "BufferView::Pimpl::dispatch cmd: " << cmd << std::endl;
974 // Make sure that the cached BufferView is correct.
975 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
976 << " action[" << cmd.action << ']'
977 << " arg[" << cmd.argument << ']'
978 << " x[" << cmd.x << ']'
979 << " y[" << cmd.y << ']'
980 << " button[" << cmd.button() << ']'
983 LCursor & cur = bv_->cursor();
985 switch (cmd.action) {
989 cur.message(_("Undo"));
990 cur.clearSelection();
992 cur.message(_("No further undo information"));
1000 cur.message(_("Redo"));
1001 cur.clearSelection();
1002 if (!textRedo(*bv_))
1003 cur.message(_("No further redo information"));
1009 case LFUN_FILE_INSERT:
1010 MenuInsertLyXFile(cmd.argument);
1013 case LFUN_FILE_INSERT_ASCII_PARA:
1014 InsertAsciiFile(bv_, cmd.argument, true);
1017 case LFUN_FILE_INSERT_ASCII:
1018 InsertAsciiFile(bv_, cmd.argument, false);
1021 case LFUN_FONT_STATE:
1022 cur.message(cur.currentState());
1025 case LFUN_BOOKMARK_SAVE:
1026 savePosition(strToUnsignedInt(cmd.argument));
1029 case LFUN_BOOKMARK_GOTO:
1030 restorePosition(strToUnsignedInt(cmd.argument));
1033 case LFUN_REF_GOTO: {
1034 string label = cmd.argument;
1035 if (label.empty()) {
1037 getInsetByCode<InsetRef>(bv_->cursor(),
1038 InsetBase::REF_CODE);
1040 label = inset->getContents();
1046 bv_->gotoLabel(label);
1050 case LFUN_TRACK_CHANGES:
1054 case LFUN_MERGE_CHANGES:
1055 owner_->getDialogs().show("changes");
1058 case LFUN_ACCEPT_ALL_CHANGES: {
1059 bv_->cursor().reset(bv_->buffer()->inset());
1060 #ifdef WITH_WARNINGS
1061 #warning FIXME changes
1063 while (lyx::find::findNextChange(bv_))
1064 bv_->getLyXText()->acceptChange(bv_->cursor());
1069 case LFUN_REJECT_ALL_CHANGES: {
1070 bv_->cursor().reset(bv_->buffer()->inset());
1071 #ifdef WITH_WARNINGS
1072 #warning FIXME changes
1074 while (lyx::find::findNextChange(bv_))
1075 bv_->getLyXText()->rejectChange(bv_->cursor());
1079 case LFUN_WORD_FIND:
1080 lyx::find::find(bv_, cmd);
1083 case LFUN_WORD_REPLACE:
1084 lyx::find::replace(bv_, cmd);
1088 cur.clearSelection();
1090 cur.message(N_("Mark off"));
1094 cur.clearSelection();
1097 cur.message(N_("Mark on"));
1101 cur.clearSelection();
1104 cur.message(N_("Mark removed"));
1107 cur.message(N_("Mark set"));
1116 case LFUN_BEGINNINGBUFSEL:
1117 bv_->cursor().reset(bv_->buffer()->inset());
1118 if (!cur.selection())
1120 bv_->text()->cursorTop(cur);
1124 case LFUN_ENDBUFSEL:
1125 bv_->cursor().reset(bv_->buffer()->inset());
1126 if (!cur.selection())
1128 bv_->text()->cursorBottom(cur);