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;
117 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
118 int width, int height)
119 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
120 using_xterm_cursor(false), cursor_(bv)
122 xsel_cache_.set = false;
124 workarea_.reset(WorkAreaFactory::create(*owner_, width, height));
125 screen_.reset(LyXScreenFactory::create(workarea()));
128 doccon = workarea().scrollDocView
129 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
130 resizecon = workarea().workAreaResize
131 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
132 dispatchcon = workarea().dispatch
133 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
134 kpresscon = workarea().workAreaKeyPress
135 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
136 selectioncon = workarea().selectionRequested
137 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
138 lostcon = workarea().selectionLost
139 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
141 timecon = cursor_timeout.timeout
142 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
143 cursor_timeout.start();
144 saved_positions.resize(saved_positions_num);
148 void BufferView::Pimpl::addError(ErrorItem const & ei)
150 errorlist_.push_back(ei);
154 void BufferView::Pimpl::showReadonly(bool)
156 owner_->updateWindowTitle();
157 owner_->getDialogs().updateBufferDependent(false);
161 void BufferView::Pimpl::connectBuffer(Buffer & buf)
163 if (errorConnection_.connected())
168 boost::bind(&BufferView::Pimpl::addError, this, _1));
172 boost::bind(&LyXView::message, owner_, _1));
176 boost::bind(&LyXView::busy, owner_, _1));
179 buf.updateTitles.connect(
180 boost::bind(&LyXView::updateWindowTitle, owner_));
183 buf.resetAutosaveTimers.connect(
184 boost::bind(&LyXView::resetAutosaveTimer, owner_));
186 readonlyConnection_ =
187 buf.readonly.connect(
188 boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
192 boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
196 void BufferView::Pimpl::disconnectBuffer()
198 errorConnection_.disconnect();
199 messageConnection_.disconnect();
200 busyConnection_.disconnect();
201 titleConnection_.disconnect();
202 timerConnection_.disconnect();
203 readonlyConnection_.disconnect();
204 closingConnection_.disconnect();
208 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
211 setBuffer(::newFile(filename, tname, isNamed));
215 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
217 // get absolute path of file and add ".lyx" to the filename if
219 string s = FileSearch(string(), filename, "lyx");
221 bool const found = !s.empty();
226 // file already open?
227 if (bufferlist.exists(s)) {
228 string const file = MakeDisplayPath(s, 20);
229 string text = bformat(_("The document %1$s is already "
230 "loaded.\n\nDo you want to revert "
231 "to the saved version?"), file);
232 int const ret = Alert::prompt(_("Revert to saved document?"),
233 text, 0, 1, _("&Revert"), _("&Switch to document"));
236 setBuffer(bufferlist.getBuffer(s));
239 // FIXME: should be LFUN_REVERT
240 if (!bufferlist.close(bufferlist.getBuffer(s), false))
242 // Fall through to new load. (Asger)
248 b = bufferlist.newBuffer(s);
250 if (!::loadLyXFile(b, s)) {
251 bufferlist.release(b);
255 string text = bformat(_("The document %1$s does not yet "
256 "exist.\n\nDo you want to create "
257 "a new document?"), s);
258 int const ret = Alert::prompt(_("Create new document?"),
259 text, 0, 1, _("&Create"), _("Cancel"));
262 b = ::newFile(s, string(), true);
268 bv_->showErrorList(_("Parse"));
271 LyX::ref().lastfiles().newFile(b->fileName());
277 WorkArea & BufferView::Pimpl::workarea() const
279 return *workarea_.get();
283 LyXScreen & BufferView::Pimpl::screen() const
285 return *screen_.get();
289 Painter & BufferView::Pimpl::painter() const
291 return workarea().getPainter();
295 void BufferView::Pimpl::top_y(int y)
301 int BufferView::Pimpl::top_y() const
307 void BufferView::Pimpl::setBuffer(Buffer * b)
309 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
314 // set current buffer
319 cursor_ = LCursor(*bv_);
321 // if we're quitting lyx, don't bother updating stuff
326 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
327 connectBuffer(*buffer_);
329 cursor_.push(buffer_->inset());
330 cursor_.resetAnchor();
331 buffer_->text().init(bv_);
333 // If we don't have a text object for this, we make one
334 //if (bv_->text() == 0)
335 // resizeCurrentBuffer();
337 // Buffer-dependent dialogs should be updated or
338 // hidden. This should go here because some dialogs (eg ToC)
339 // require bv_->text.
340 owner_->getDialogs().updateBufferDependent(true);
342 lyxerr[Debug::INFO] << " No Buffer!" << endl;
343 // we are closing the buffer, use the first buffer as current
344 buffer_ = bufferlist.first();
345 owner_->getDialogs().hideBufferDependent();
350 owner_->updateMenubar();
351 owner_->updateToolbars();
352 owner_->updateLayoutChoice();
353 owner_->updateWindowTitle();
355 // This is done after the layout combox has been populated
357 owner_->setLayout(cursor_.paragraph().layout()->name());
359 if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
360 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
364 bool BufferView::Pimpl::fitCursor()
366 // to get the correct y cursor info
367 lyxerr[Debug::DEBUG] << "BufferView::fitCursor" << std::endl;
368 lyx::par_type const pit = bv_->cursor().bottom().par();
369 bv_->text()->redoParagraph(pit);
370 refreshPar(*bv_, *bv_->text(), pit);
372 if (!screen().fitCursor(bv_))
379 void BufferView::Pimpl::redoCurrentBuffer()
381 lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
382 if (buffer_ && bv_->text()) {
383 resizeCurrentBuffer();
385 owner_->updateLayoutChoice();
390 void BufferView::Pimpl::resizeCurrentBuffer()
392 lyxerr[Debug::DEBUG] << "resizeCurrentBuffer" << endl;
394 owner_->message(_("Formatting document..."));
396 LyXText * text = bv_->text();
407 // reset the "Formatting..." message
408 owner_->clearMessage();
414 void BufferView::Pimpl::updateScrollbar()
417 lyxerr[Debug::DEBUG] << "no text in updateScrollbar" << endl;
418 workarea().setScrollbarParams(0, 0, 0);
422 LyXText const & t = *bv_->text();
425 << "Updating scrollbar: height: " << t.height()
426 << " top_y: " << top_y()
427 << " default height " << defaultRowHeight() << endl;
429 workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
433 void BufferView::Pimpl::scrollDocView(int value)
435 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
440 screen().hideCursor();
443 screen().redraw(*bv_);
445 if (!lyxrc.cursor_follows_scrollbar)
448 int const height = defaultRowHeight();
449 int const first = top_y() + height;
450 int const last = top_y() + workarea().workHeight() - height;
452 bv_->cursor().reset(bv_->buffer()->inset());
453 LyXText * text = bv_->text();
454 int y = text->cursorY(bv_->cursor().front());
459 text->setCursorFromCoordinates(bv_->cursor(), 0, y);
461 owner_->updateLayoutChoice();
465 void BufferView::Pimpl::scroll(int lines)
470 LyXText const * t = bv_->text();
471 int const line_height = defaultRowHeight();
473 // The new absolute coordinate
474 int new_top_y = top_y() + lines * line_height;
476 // Restrict to a valid value
477 new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
478 new_top_y = std::max(0, new_top_y);
480 scrollDocView(new_top_y);
482 // Update the scrollbar.
483 workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
487 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
488 key_modifier::state state)
490 bv_->owner()->getLyXFunc().processKeySym(key, state);
492 /* This is perhaps a bit of a hack. When we move
493 * around, or type, it's nice to be able to see
494 * the cursor immediately after the keypress. So
495 * we reset the toggle timeout and force the visibility
496 * of the cursor. Note we cannot do this inside
497 * dispatch() itself, because that's called recursively.
500 cursor_timeout.restart();
501 screen().showCursor(*bv_);
506 void BufferView::Pimpl::selectionRequested()
513 LCursor & cur = bv_->cursor();
515 if (!cur.selection()) {
516 xsel_cache_.set = false;
520 if (!xsel_cache_.set ||
521 cur.back() != xsel_cache_.cursor ||
522 cur.anchor_.back() != xsel_cache_.anchor)
524 xsel_cache_.cursor = cur.back();
525 xsel_cache_.anchor = cur.anchor_.back();
526 xsel_cache_.set = cur.selection();
527 sel = cur.selectionAsString(false);
529 workarea().putClipboard(sel);
534 void BufferView::Pimpl::selectionLost()
537 screen().hideCursor();
538 bv_->cursor().clearSelection();
539 xsel_cache_.set = false;
544 void BufferView::Pimpl::workAreaResize()
546 static int work_area_width;
547 static int work_area_height;
549 bool const widthChange = workarea().workWidth() != work_area_width;
550 bool const heightChange = workarea().workHeight() != work_area_height;
552 // update from work area
553 work_area_width = workarea().workWidth();
554 work_area_height = workarea().workHeight();
556 if (buffer_ && widthChange) {
557 // The visible LyXView need a resize
558 resizeCurrentBuffer();
561 if (widthChange || heightChange)
564 // always make sure that the scrollbar is sane.
566 owner_->updateLayoutChoice();
570 void BufferView::Pimpl::update()
572 //lyxerr << "BufferView::Pimpl::update(), buffer: " << buffer_ << endl;
573 // fix cursor coordinate cache in case something went wrong
575 // check needed to survive LyX startup
577 // update macro store
578 buffer_->buildMacros();
580 // update all 'visible' paragraphs
581 lyx::par_type beg, end;
582 getParsInRange(buffer_->paragraphs(),
583 top_y(), top_y() + workarea().workHeight(),
585 bv_->text()->redoParagraphs(beg, end);
590 screen().redraw(*bv_);
591 bv_->owner()->view_state_changed();
595 // Callback for cursor timer
596 void BufferView::Pimpl::cursorToggle()
599 screen().toggleCursor(*bv_);
601 // Use this opportunity to deal with any child processes that
602 // have finished but are waiting to communicate this fact
603 // to the rest of LyX.
604 ForkedcallsController & fcc = ForkedcallsController::get();
605 if (fcc.processesCompleted())
606 fcc.handleCompletedProcesses();
609 cursor_timeout.restart();
613 bool BufferView::Pimpl::available() const
615 return buffer_ && bv_->text();
619 Change const BufferView::Pimpl::getCurrentChange()
621 if (!bv_->buffer()->params().tracking_changes)
622 return Change(Change::UNCHANGED);
624 LyXText * text = bv_->getLyXText();
625 LCursor & cur = bv_->cursor();
627 if (!cur.selection())
628 return Change(Change::UNCHANGED);
630 return text->getPar(cur.selBegin().par()).
631 lookupChangeFull(cur.selBegin().pos());
635 void BufferView::Pimpl::savePosition(unsigned int i)
637 if (i >= saved_positions_num)
639 BOOST_ASSERT(bv_->cursor().inTexted());
640 saved_positions[i] = Position(buffer_->fileName(),
641 bv_->cursor().paragraph().id(),
642 bv_->cursor().pos());
644 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
648 void BufferView::Pimpl::restorePosition(unsigned int i)
650 if (i >= saved_positions_num)
653 string const fname = saved_positions[i].filename;
655 bv_->cursor().clearSelection();
657 if (fname != buffer_->fileName()) {
659 if (bufferlist.exists(fname))
660 b = bufferlist.getBuffer(fname);
662 b = bufferlist.newBuffer(fname);
663 ::loadLyXFile(b, fname); // don't ask, just load it
669 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
670 if (par == buffer_->par_iterator_end())
673 bv_->text()->setCursor(bv_->cursor(), par.pit(),
674 min(par->size(), saved_positions[i].par_pos));
677 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
681 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
683 return i < saved_positions_num && !saved_positions[i].filename.empty();
687 void BufferView::Pimpl::switchKeyMap()
689 if (!lyxrc.rtl_support)
692 Intl & intl = owner_->getIntl();
693 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
694 if (intl.keymap == Intl::PRIMARY)
697 if (intl.keymap == Intl::SECONDARY)
703 void BufferView::Pimpl::center()
705 LyXText * text = bv_->text();
707 bv_->cursor().clearSelection();
708 int const half_height = workarea().workHeight() / 2;
709 int new_y = text->cursorY(bv_->cursor().front()) - half_height;
713 // FIXME: look at this comment again ...
714 // This updates top_y() but means the fitCursor() call
715 // from the update(FITCUR) doesn't realise that we might
716 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
717 // the scrollbar to be updated as it should, so we have
718 // to do it manually. Any operation that does a center()
719 // and also might have moved top_y() must make sure to call
720 // updateScrollbar() currently. Never mind that this is a
721 // pretty obfuscated way of updating text->top_y()
726 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
728 workarea().putClipboard(stuff);
732 InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
735 #warning Does not work for mathed. (Still true?)
737 // Ok, this is a little bit too brute force but it
738 // should work for now. Better infrastructure is coming. (Lgb)
739 LCursor & cur = bv_->cursor();
740 DocIterator it = cur;
741 for (it.forwardInset(); it; it.forwardInset()) {
742 BOOST_ASSERT(it.nextInset());
743 if (it.nextInset()->lyxCode() == code)
744 return it.nextInset();
750 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
752 string filename = filenm;
754 if (filename.empty()) {
755 // Launch a file browser
756 string initpath = lyxrc.document_path;
759 string const trypath = owner_->buffer()->filePath();
760 // If directory is writeable, use this as default.
761 if (IsDirWriteable(trypath))
765 FileDialog fileDlg(_("Select LyX document to insert"),
767 make_pair(string(_("Documents|#o#O")),
768 string(lyxrc.document_path)),
769 make_pair(string(_("Examples|#E#e")),
770 string(AddPath(system_lyxdir(), "examples"))));
772 FileDialog::Result result =
773 fileDlg.open(initpath,
774 FileFilterList(_("LyX Documents (*.lyx)")),
777 if (result.first == FileDialog::Later)
780 filename = result.second;
782 // check selected filename
783 if (filename.empty()) {
784 owner_->message(_("Canceled."));
789 // get absolute path of file and add ".lyx" to the filename if
791 filename = FileSearch(string(), filename, "lyx");
793 string const disp_fn = MakeDisplayPath(filename);
794 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
795 if (bv_->insertLyXFile(filename))
796 owner_->message(bformat(_("Document %1$s inserted."),
799 owner_->message(bformat(_("Could not insert document %1$s"),
804 void BufferView::Pimpl::trackChanges()
806 Buffer * buf = bv_->buffer();
807 bool const tracking = buf->params().tracking_changes;
810 ParIterator const end = buf->par_iterator_end();
811 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
813 buf->params().tracking_changes = true;
815 // we cannot allow undos beyond the freeze point
816 buf->undostack().clear();
819 bv_->text()->setCursor(bv_->cursor(), 0, 0);
821 #warning changes FIXME
823 bool found = lyx::find::findNextChange(bv_);
825 owner_->getDialogs().show("changes");
829 ParIterator const end = buf->par_iterator_end();
830 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
831 it->untrackChanges();
832 buf->params().tracking_changes = false;
835 buf->redostack().clear();
839 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
841 //lyxerr << "BufferView::Pimpl::workAreaDispatch: request: "
842 // << cmd << std::endl;
843 // this is only called for mouse related events including
844 // LFUN_FILE_OPEN generated by drag-and-drop.
845 FuncRequest cmd = cmd0;
848 if (cmd.action == LFUN_FILE_OPEN) {
849 owner_->dispatch(cmd);
853 cmd.y += bv_->top_y();
858 cur.push(bv_->buffer()->inset());
859 cur.selection() = bv_->cursor().selection();
861 // Doesn't go through lyxfunc, so we need to update
862 // the layout choice etc. ourselves
864 // e.g. Qt mouse press when no buffer
868 screen().hideCursor();
870 // Either the inset under the cursor or the
871 // surrounding LyXText will handle this event.
873 // Build temporary cursor.
874 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
875 lyxerr << "hit inset at tip: " << inset << endl;
876 lyxerr << "created temp cursor:\n" << cur << endl;
878 // Put anchor at the same position.
881 // Try to dispatch to an non-editable inset near this position
882 // via the temp cursor. If the inset wishes to change the real
883 // cursor it has to do so explicitly by using
884 // cur.bv().cursor() = cur; (or similar)'
887 inset->dispatch(cur, cmd);
889 // Now dispatch to the temporary cursor. If the real cursor should
890 // be modified, the inset's dispatch has to do so explicitly.
891 if (!res.dispatched())
892 res = cur.dispatch(cmd);
894 if (res.dispatched()) {
895 // Redraw if requested or necessary.
896 if (fitCursor() || res.update())
900 // see workAreaKeyPress
901 cursor_timeout.restart();
902 screen().showCursor(*bv_);
904 // skip these when selecting
905 if (cmd.action != LFUN_MOUSE_MOTION) {
906 owner_->updateLayoutChoice();
907 owner_->updateToolbars();
910 // slight hack: this is only called currently when we
911 // clicked somewhere, so we force through the display
912 // of the new status here.
913 owner_->clearMessage();
918 FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
920 Buffer * buf = bv_->buffer();
924 switch (cmd.action) {
927 flag.enabled(!buf->undostack().empty());
930 flag.enabled(!buf->redostack().empty());
932 case LFUN_FILE_INSERT:
933 case LFUN_FILE_INSERT_ASCII_PARA:
934 case LFUN_FILE_INSERT_ASCII:
935 case LFUN_FONT_STATE:
936 case LFUN_INSERT_LABEL:
937 case LFUN_BOOKMARK_SAVE:
940 case LFUN_WORD_REPLACE:
945 case LFUN_BEGINNINGBUFSEL:
949 case LFUN_BOOKMARK_GOTO:
950 flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument)));
952 case LFUN_TRACK_CHANGES:
954 flag.setOnOff(buf->params().tracking_changes);
957 case LFUN_MERGE_CHANGES:
958 case LFUN_ACCEPT_CHANGE: // what about these two
959 case LFUN_REJECT_CHANGE: // what about these two
960 case LFUN_ACCEPT_ALL_CHANGES:
961 case LFUN_REJECT_ALL_CHANGES:
962 flag.enabled(buf && buf->params().tracking_changes);
973 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
975 //lyxerr << "BufferView::Pimpl::dispatch cmd: " << cmd << std::endl;
976 // Make sure that the cached BufferView is correct.
977 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
978 << " action[" << cmd.action << ']'
979 << " arg[" << cmd.argument << ']'
980 << " x[" << cmd.x << ']'
981 << " y[" << cmd.y << ']'
982 << " button[" << cmd.button() << ']'
985 LCursor & cur = bv_->cursor();
987 switch (cmd.action) {
991 cur.message(_("Undo"));
992 cur.clearSelection();
994 cur.message(_("No further undo information"));
1002 cur.message(_("Redo"));
1003 cur.clearSelection();
1004 if (!textRedo(*bv_))
1005 cur.message(_("No further redo information"));
1011 case LFUN_FILE_INSERT:
1012 MenuInsertLyXFile(cmd.argument);
1015 case LFUN_FILE_INSERT_ASCII_PARA:
1016 InsertAsciiFile(bv_, cmd.argument, true);
1019 case LFUN_FILE_INSERT_ASCII:
1020 InsertAsciiFile(bv_, cmd.argument, false);
1023 case LFUN_FONT_STATE:
1024 cur.message(cur.currentState());
1027 case LFUN_BOOKMARK_SAVE:
1028 savePosition(strToUnsignedInt(cmd.argument));
1031 case LFUN_BOOKMARK_GOTO:
1032 restorePosition(strToUnsignedInt(cmd.argument));
1035 case LFUN_REF_GOTO: {
1036 string label = cmd.argument;
1037 if (label.empty()) {
1039 static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
1041 label = inset->getContents();
1047 bv_->gotoLabel(label);
1051 case LFUN_TRACK_CHANGES:
1055 case LFUN_MERGE_CHANGES:
1056 owner_->getDialogs().show("changes");
1059 case LFUN_ACCEPT_ALL_CHANGES: {
1060 bv_->cursor().reset(bv_->buffer()->inset());
1061 #ifdef WITH_WARNINGS
1062 #warning FIXME changes
1064 while (lyx::find::findNextChange(bv_))
1065 bv_->getLyXText()->acceptChange(bv_->cursor());
1070 case LFUN_REJECT_ALL_CHANGES: {
1071 bv_->cursor().reset(bv_->buffer()->inset());
1072 #ifdef WITH_WARNINGS
1073 #warning FIXME changes
1075 while (lyx::find::findNextChange(bv_))
1076 bv_->getLyXText()->rejectChange(bv_->cursor());
1080 case LFUN_WORD_FIND:
1081 lyx::find::find(bv_, cmd);
1084 case LFUN_WORD_REPLACE:
1085 lyx::find::replace(bv_, cmd);
1089 cur.clearSelection();
1091 cur.message(N_("Mark off"));
1095 cur.clearSelection();
1098 cur.message(N_("Mark on"));
1102 cur.clearSelection();
1105 cur.message(N_("Mark removed"));
1108 cur.message(N_("Mark set"));
1117 case LFUN_BEGINNINGBUFSEL:
1118 bv_->cursor().reset(bv_->buffer()->inset());
1119 if (!cur.selection())
1121 bv_->text()->cursorTop(cur);
1125 case LFUN_ENDBUFSEL:
1126 bv_->cursor().reset(bv_->buffer()->inset());
1127 if (!cur.selection())
1129 bv_->text()->cursorBottom(cur);