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"
50 #include "frontends/Alert.h"
51 #include "frontends/Dialogs.h"
52 #include "frontends/FileDialog.h"
53 #include "frontends/LyXView.h"
54 #include "frontends/LyXScreenFactory.h"
55 #include "frontends/screen.h"
56 #include "frontends/WorkArea.h"
57 #include "frontends/WorkAreaFactory.h"
59 #include "graphics/Previews.h"
61 #include "support/filetools.h"
62 #include "support/globbing.h"
63 #include "support/path_defines.h"
64 #include "support/tostr.h"
66 #include <boost/bind.hpp>
70 using lyx::support::AddPath;
71 using lyx::support::bformat;
72 using lyx::support::FileFilterList;
73 using lyx::support::FileSearch;
74 using lyx::support::IsDirWriteable;
75 using lyx::support::MakeDisplayPath;
76 using lyx::support::strToUnsignedInt;
77 using lyx::support::system_lyxdir;
80 using std::istringstream;
86 extern BufferList bufferlist;
91 unsigned int const saved_positions_num = 20;
93 // All the below connection objects are needed because of a bug in some
94 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
95 // to these connections we avoid a segfault upon startup, and also at exit.
98 boost::signals::connection dispatchcon;
99 boost::signals::connection timecon;
100 boost::signals::connection doccon;
101 boost::signals::connection resizecon;
102 boost::signals::connection kpresscon;
103 boost::signals::connection selectioncon;
104 boost::signals::connection lostcon;
110 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
111 int xpos, int ypos, int width, int height)
112 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
113 using_xterm_cursor(false), cursor_(bv)
115 xsel_cache_.set = false;
117 workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
118 screen_.reset(LyXScreenFactory::create(workarea()));
121 doccon = workarea().scrollDocView
122 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
123 resizecon = workarea().workAreaResize
124 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
125 dispatchcon = workarea().dispatch
126 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
127 kpresscon = workarea().workAreaKeyPress
128 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
129 selectioncon = workarea().selectionRequested
130 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
131 lostcon = workarea().selectionLost
132 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
134 timecon = cursor_timeout.timeout
135 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
136 cursor_timeout.start();
137 saved_positions.resize(saved_positions_num);
141 void BufferView::Pimpl::addError(ErrorItem const & ei)
143 errorlist_.push_back(ei);
147 void BufferView::Pimpl::showReadonly(bool)
149 owner_->updateWindowTitle();
150 owner_->getDialogs().updateBufferDependent(false);
154 void BufferView::Pimpl::connectBuffer(Buffer & buf)
156 if (errorConnection_.connected())
160 buf.error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1));
162 buf.message.connect(boost::bind(&LyXView::message, owner_, _1));
164 buf.busy.connect(boost::bind(&LyXView::busy, owner_, _1));
166 buf.updateTitles.connect(boost::bind(&LyXView::updateWindowTitle, owner_));
168 buf.resetAutosaveTimers.connect(boost::bind(&LyXView::resetAutosaveTimer, owner_));
169 readonlyConnection_ =
170 buf.readonly.connect(boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
172 buf.closing.connect(boost::bind(&BufferView::Pimpl::buffer, this, (Buffer *)0));
176 void BufferView::Pimpl::disconnectBuffer()
178 errorConnection_.disconnect();
179 messageConnection_.disconnect();
180 busyConnection_.disconnect();
181 titleConnection_.disconnect();
182 timerConnection_.disconnect();
183 readonlyConnection_.disconnect();
184 closingConnection_.disconnect();
188 bool BufferView::Pimpl::newFile(string const & filename,
189 string const & tname,
192 Buffer * b = ::newFile(filename, tname, isNamed);
198 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
200 // get absolute path of file and add ".lyx" to the filename if
202 string s = FileSearch(string(), filename, "lyx");
204 bool const found = !s.empty();
209 // file already open?
210 if (bufferlist.exists(s)) {
211 string const file = MakeDisplayPath(s, 20);
212 string text = bformat(_("The document %1$s is already "
213 "loaded.\n\nDo you want to revert "
214 "to the saved version?"), file);
215 int const ret = Alert::prompt(_("Revert to saved document?"),
216 text, 0, 1, _("&Revert"), _("&Switch to document"));
219 buffer(bufferlist.getBuffer(s));
222 // FIXME: should be LFUN_REVERT
223 if (!bufferlist.close(bufferlist.getBuffer(s), false))
225 // Fall through to new load. (Asger)
232 b = bufferlist.newBuffer(s);
234 if (!::loadLyXFile(b, s)) {
235 bufferlist.release(b);
239 string text = bformat(_("The document %1$s does not yet "
240 "exist.\n\nDo you want to create "
241 "a new document?"), s);
242 int const ret = Alert::prompt(_("Create new document?"),
243 text, 0, 1, _("&Create"), _("Cancel"));
246 b = ::newFile(s, string(), true);
252 bv_->showErrorList(_("Parse"));
255 LyX::ref().lastfiles().newFile(b->fileName());
261 WorkArea & BufferView::Pimpl::workarea() const
263 return *workarea_.get();
267 LyXScreen & BufferView::Pimpl::screen() const
269 return *screen_.get();
273 Painter & BufferView::Pimpl::painter() const
275 return workarea().getPainter();
279 void BufferView::Pimpl::top_y(int y)
285 int BufferView::Pimpl::top_y() const
291 void BufferView::Pimpl::buffer(Buffer * b)
293 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
297 //delete bv_->text();
304 // set current buffer
309 // if we're quitting lyx, don't bother updating stuff
313 // if we are closing the buffer, use the first buffer as current
315 buffer_ = bufferlist.first();
318 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
319 connectBuffer(*buffer_);
321 buffer_->text().init(bv_);
322 buffer_->text().textwidth_ = workarea().workWidth();
323 buffer_->text().fullRebreak();
325 // If we don't have a text object for this, we make one
326 if (bv_->text() == 0)
327 resizeCurrentBuffer();
329 // Buffer-dependent dialogs should be updated or
330 // hidden. This should go here because some dialogs (eg ToC)
331 // require bv_->text.
332 owner_->getDialogs().updateBufferDependent(true);
334 lyxerr[Debug::INFO] << " No Buffer!" << endl;
335 owner_->getDialogs().hideBufferDependent();
340 owner_->updateMenubar();
341 owner_->updateToolbar();
342 owner_->updateLayoutChoice();
343 owner_->updateWindowTitle();
345 // Don't forget to update the Layout
347 owner_->setLayout(bv_->text()->getPar(0)->layout()->name());
349 if (lyx::graphics::Previews::activated() && buffer_)
350 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
354 bool BufferView::Pimpl::fitCursor()
356 if (screen().fitCursor(bv_)) {
364 void BufferView::Pimpl::redoCurrentBuffer()
366 lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
367 if (buffer_ && bv_->text()) {
368 resizeCurrentBuffer();
370 owner_->updateLayoutChoice();
375 void BufferView::Pimpl::resizeCurrentBuffer()
377 lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
380 int selstartpar = -1;
384 pos_type selstartpos = 0;
385 pos_type selendpos = 0;
387 bool mark_set = false;
391 owner_->message(_("Formatting document..."));
393 LyXText * text = bv_->text();
394 lyxerr << "### resizeCurrentBuffer: text " << text << endl;
398 LCursor & cur = bv_->cursor();
401 selstartpar = cur.selBegin().par();
402 selstartpos = cur.selBegin().pos();
403 selendpar = cur.selEnd().par();
404 selendpos = cur.selEnd().pos();
405 sel = cur.selection();
406 mark_set = cur.mark();
407 text->textwidth_ = bv_->workWidth();
412 cur.selection() = true;
413 // At this point just to avoid the Delete-Empty-Paragraph-
414 // Mechanism when setting the cursor.
415 cur.mark() = mark_set;
417 text->setCursor(cur, selstartpar, selstartpos);
419 text->setCursor(cur, selendpar, selendpos);
421 text->setCursor(cur, par, pos);
423 text->setCursor(cur, par, pos);
425 cur.selection() = false;
434 // reset the "Formatting..." message
435 owner_->clearMessage();
441 void BufferView::Pimpl::updateScrollbar()
444 lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
445 workarea().setScrollbarParams(0, 0, 0);
449 LyXText const & t = *bv_->text();
451 lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
452 << top_y() << ", default height " << defaultRowHeight() << endl;
454 workarea().setScrollbarParams(t.height, top_y(), defaultRowHeight());
458 void BufferView::Pimpl::scrollDocView(int value)
460 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
465 screen().hideCursor();
468 screen().redraw(*bv_);
470 if (!lyxrc.cursor_follows_scrollbar)
473 int const height = defaultRowHeight();
474 int const first = top_y() + height;
475 int const last = top_y() + workarea().workHeight() - height;
477 bv_->cursor().reset();
478 LyXText * text = bv_->text();
479 CursorSlice & cur = bv_->cursor().cursor_.front();
480 int y = text->cursorY(cur);
482 text->setCursorFromCoordinates(bv_->cursor(), 0, first);
484 text->setCursorFromCoordinates(bv_->cursor(), 0, last);
486 owner_->updateLayoutChoice();
490 void BufferView::Pimpl::scroll(int lines)
495 LyXText const * t = bv_->text();
496 int const line_height = defaultRowHeight();
498 // The new absolute coordinate
499 int new_top_y = top_y() + lines * line_height;
501 // Restrict to a valid value
502 new_top_y = std::min(t->height - 4 * line_height, new_top_y);
503 new_top_y = std::max(0, new_top_y);
505 scrollDocView(new_top_y);
507 // Update the scrollbar.
508 workarea().setScrollbarParams(t->height, top_y(), defaultRowHeight());
512 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
513 key_modifier::state state)
515 bv_->owner()->getLyXFunc().processKeySym(key, state);
517 /* This is perhaps a bit of a hack. When we move
518 * around, or type, it's nice to be able to see
519 * the cursor immediately after the keypress. So
520 * we reset the toggle timeout and force the visibility
521 * of the cursor. Note we cannot do this inside
522 * dispatch() itself, because that's called recursively.
525 cursor_timeout.restart();
526 screen().showCursor(*bv_);
531 void BufferView::Pimpl::selectionRequested()
538 LCursor & cur = bv_->cursor();
540 if (!cur.selection()) {
541 xsel_cache_.set = false;
545 if (!xsel_cache_.set ||
546 cur.cursor_.back() != xsel_cache_.cursor ||
547 cur.anchor_.back() != xsel_cache_.anchor)
549 xsel_cache_.cursor = cur.cursor_.back();
550 xsel_cache_.anchor = cur.anchor_.back();
551 xsel_cache_.set = cur.selection();
552 sel = cur.selectionAsString(false);
554 workarea().putClipboard(sel);
559 void BufferView::Pimpl::selectionLost()
562 screen().hideCursor();
563 bv_->cursor().clearSelection();
564 xsel_cache_.set = false;
569 void BufferView::Pimpl::workAreaResize()
571 static int work_area_width;
572 static int work_area_height;
574 bool const widthChange = workarea().workWidth() != work_area_width;
575 bool const heightChange = workarea().workHeight() != work_area_height;
577 // update from work area
578 work_area_width = workarea().workWidth();
579 work_area_height = workarea().workHeight();
581 if (buffer_ && widthChange) {
582 // The visible LyXView need a resize
583 resizeCurrentBuffer();
586 if (widthChange || heightChange)
589 // always make sure that the scrollbar is sane.
591 owner_->updateLayoutChoice();
595 void BufferView::Pimpl::update()
597 //lyxerr << "BufferView::update()" << endl;
598 // fix cursor coordinate cache in case something went wrong
600 // check needed to survive LyX startup
601 if (bv_->getLyXText()) {
602 // update all 'visible' paragraphs
603 ParagraphList::iterator beg;
604 ParagraphList::iterator end;
605 getParsInRange(buffer_->paragraphs(),
606 top_y(), top_y() + workarea().workHeight(),
608 bv_->text()->redoParagraphs(beg, end);
611 screen().redraw(*bv_);
615 // Callback for cursor timer
616 void BufferView::Pimpl::cursorToggle()
619 cursor_timeout.restart();
623 screen().toggleCursor(*bv_);
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())
646 ->lookupChangeFull(cur.selBegin().pos());
650 void BufferView::Pimpl::savePosition(unsigned int i)
652 if (i >= saved_positions_num)
654 saved_positions[i] = Position(buffer_->fileName(),
655 bv_->text()->cursorPar()->id(),
656 bv_->text()->cursor().pos());
658 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
662 void BufferView::Pimpl::restorePosition(unsigned int i)
664 if (i >= saved_positions_num)
667 string const fname = saved_positions[i].filename;
669 bv_->cursor().clearSelection();
671 if (fname != buffer_->fileName()) {
673 if (bufferlist.exists(fname))
674 b = bufferlist.getBuffer(fname);
676 b = bufferlist.newBuffer(fname);
677 ::loadLyXFile(b, fname); // don't ask, just load it
683 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
684 if (par == buffer_->par_iterator_end())
687 bv_->text()->setCursor(
689 bv_->text()->parOffset(par.pit()),
690 min(par->size(), saved_positions[i].par_pos));
693 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
697 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
699 return i < saved_positions_num && !saved_positions[i].filename.empty();
703 void BufferView::Pimpl::switchKeyMap()
705 if (!lyxrc.rtl_support)
708 Intl & intl = owner_->getIntl();
709 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
710 if (intl.keymap == Intl::PRIMARY)
713 if (intl.keymap == Intl::SECONDARY)
719 void BufferView::Pimpl::center()
721 LyXText * text = bv_->text();
723 bv_->cursor().clearSelection();
724 int const half_height = workarea().workHeight() / 2;
725 int new_y = text->cursorY(bv_->cursor().cursor_.front()) - half_height;
729 // FIXME: look at this comment again ...
730 // This updates top_y() but means the fitCursor() call
731 // from the update(FITCUR) doesn't realise that we might
732 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
733 // the scrollbar to be updated as it should, so we have
734 // to do it manually. Any operation that does a center()
735 // and also might have moved top_y() must make sure to call
736 // updateScrollbar() currently. Never mind that this is a
737 // pretty obfuscated way of updating text->top_y()
742 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
744 workarea().putClipboard(stuff);
748 InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code code)
750 #warning Does not work for mathed
751 // Ok, this is a little bit too brute force but it
752 // should work for now. Better infrastructure is coming. (Lgb)
754 Buffer * buf = bv_->buffer();
755 Buffer::inset_iterator beg = buf->inset_iterator_begin();
756 Buffer::inset_iterator end = buf->inset_iterator_end();
758 bool cursor_par_seen = false;
760 LCursor & cur = bv_->cursor();
761 ParagraphList::iterator pit = bv_->getLyXText()->getPar(cur.par());
763 for (; beg != end; ++beg) {
764 if (beg.getPar() == pit)
765 cursor_par_seen = true;
766 if (cursor_par_seen) {
767 if (beg.getPar() == pit && beg.getPos() >= cur.pos())
769 if (beg.getPar() != pit)
774 // Now find the first inset that matches code.
775 for (; beg != end; ++beg) {
776 if (beg->lyxCode() == code)
784 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
786 string filename = filenm;
788 if (filename.empty()) {
789 // Launch a file browser
790 string initpath = lyxrc.document_path;
793 string const trypath = owner_->buffer()->filePath();
794 // If directory is writeable, use this as default.
795 if (IsDirWriteable(trypath))
799 FileDialog fileDlg(_("Select LyX document to insert"),
801 make_pair(string(_("Documents|#o#O")),
802 string(lyxrc.document_path)),
803 make_pair(string(_("Examples|#E#e")),
804 string(AddPath(system_lyxdir(), "examples"))));
806 FileDialog::Result result =
807 fileDlg.open(initpath,
808 FileFilterList(_("LyX Documents (*.lyx)")),
811 if (result.first == FileDialog::Later)
814 filename = result.second;
816 // check selected filename
817 if (filename.empty()) {
818 owner_->message(_("Canceled."));
823 // get absolute path of file and add ".lyx" to the filename if
825 filename = FileSearch(string(), filename, "lyx");
827 string const disp_fn = MakeDisplayPath(filename);
828 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
829 if (bv_->insertLyXFile(filename))
830 owner_->message(bformat(_("Document %1$s inserted."),
833 owner_->message(bformat(_("Could not insert document %1$s"),
838 void BufferView::Pimpl::trackChanges()
840 Buffer * buf = bv_->buffer();
841 bool const tracking = buf->params().tracking_changes;
844 ParIterator const end = buf->par_iterator_end();
845 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
847 buf->params().tracking_changes = true;
849 // we cannot allow undos beyond the freeze point
850 buf->undostack().clear();
853 bv_->text()->setCursor(bv_->cursor(), 0, 0);
854 #warning changes FIXME
855 bool found = lyx::find::findNextChange(bv_);
857 owner_->getDialogs().show("changes");
861 ParIterator const end = buf->par_iterator_end();
862 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
863 it->untrackChanges();
864 buf->params().tracking_changes = false;
867 buf->redostack().clear();
871 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
874 // this is only called for mouse related events.
876 FuncRequest cmd = cmd0;
877 cmd.y += bv_->top_y();
878 //lyxerr << "*** workAreaDispatch: request: " << cmd << std::endl;
880 cur.selection() = bv_->cursor().selection();
881 switch (cmd.action) {
884 case LFUN_MOUSE_MOTION: {
887 FuncRequest cmd1 = cmd;
888 InsetBase * inset = cur.inset();
891 res = inset->dispatch(cur, cmd);
893 res = bv_->text()->dispatch(cur, cmd);
896 if (fitCursor() || res.update()) {
903 case LFUN_MOUSE_MOTION:
906 case LFUN_MOUSE_PRESS:
907 case LFUN_MOUSE_RELEASE:
908 case LFUN_MOUSE_DOUBLE:
909 case LFUN_MOUSE_TRIPLE: {
910 // We pass those directly to the Bufferview, since
911 // otherwise selection handling breaks down
913 // Doesn't go through lyxfunc, so we need to update
914 // the layout choice etc. ourselves
916 // e.g. Qt mouse press when no buffer
920 screen().hideCursor();
922 // either the inset under the cursor or the
923 // surrounding LyXText will handle this event.
925 // built temporary path to inset
926 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
927 lyxerr << "hit inset at tip: " << inset << endl;
928 lyxerr << "created temp cursor:\n" << cur << endl;
930 // Try to dispatch to an non-editable inset near this position
933 inset->dispatch(cur, cmd);
935 // Dispatch to the temp cursor.
936 // An inset (or LyXText) can assign this to bv->cursor()
937 // if it wishes to do so.
938 if (!res.dispatched())
939 res = cur.dispatch(cmd);
941 if (fitCursor() || res.update())
944 // see workAreaKeyPress
945 cursor_timeout.restart();
946 screen().showCursor(*bv_);
948 // skip these when selecting
949 if (cmd.action != LFUN_MOUSE_MOTION) {
950 owner_->updateLayoutChoice();
951 owner_->updateToolbar();
954 // slight hack: this is only called currently when we
955 // clicked somewhere, so we force through the display
956 // of the new status here.
957 owner_->clearMessage();
968 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
970 //lyxerr << "*** BufferView::Pimpl: request: " << cmd << std::endl;
971 // Make sure that the cached BufferView is correct.
972 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
973 << " action[" << cmd.action << ']'
974 << " arg[" << cmd.argument << ']'
975 << " x[" << cmd.x << ']'
976 << " y[" << cmd.y << ']'
977 << " button[" << cmd.button() << ']'
980 LCursor & cur = bv_->cursor();
982 switch (cmd.action) {
985 if (bv_->cursor().depth() > 1) {
987 // Tell the paragraph dialog that we changed paragraph
988 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
995 cur.message(_("Undo"));
996 cur.clearSelection();
998 cur.message(_("No further undo information"));
1006 cur.message(_("Redo"));
1007 cur.clearSelection();
1008 if (!textRedo(*bv_))
1009 cur.message(_("No further redo information"));
1015 case LFUN_FILE_INSERT:
1016 MenuInsertLyXFile(cmd.argument);
1019 case LFUN_FILE_INSERT_ASCII_PARA:
1020 InsertAsciiFile(bv_, cmd.argument, true);
1023 case LFUN_FILE_INSERT_ASCII:
1024 InsertAsciiFile(bv_, cmd.argument, false);
1027 case LFUN_FONT_STATE:
1028 cur.message(cur.currentState());
1031 case LFUN_INSERT_LABEL: {
1032 // Try and generate a valid label
1033 string const contents = cmd.argument.empty() ?
1034 cur.getPossibleLabel() : cmd.argument;
1035 InsetCommandParams icp("label", contents);
1036 string data = InsetCommandMailer::params2string("label", icp);
1037 owner_->getDialogs().show("label", data, 0);
1041 case LFUN_BOOKMARK_SAVE:
1042 savePosition(strToUnsignedInt(cmd.argument));
1045 case LFUN_BOOKMARK_GOTO:
1046 restorePosition(strToUnsignedInt(cmd.argument));
1049 case LFUN_REF_GOTO: {
1050 string label = cmd.argument;
1051 if (label.empty()) {
1053 static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
1055 label = inset->getContents();
1061 bv_->gotoLabel(label);
1065 case LFUN_TRACK_CHANGES:
1069 case LFUN_MERGE_CHANGES:
1070 owner_->getDialogs().show("changes");
1073 case LFUN_ACCEPT_ALL_CHANGES: {
1074 bv_->cursor().reset();
1075 #warning FIXME changes
1076 while (lyx::find::findNextChange(bv_))
1077 bv_->getLyXText()->acceptChange(bv_->cursor());
1082 case LFUN_REJECT_ALL_CHANGES: {
1083 bv_->cursor().reset();
1084 #warning FIXME changes
1085 while (lyx::find::findNextChange(bv_))
1086 bv_->getLyXText()->rejectChange(bv_->cursor());
1091 case LFUN_WORD_FIND:
1092 lyx::find::find(bv_, cmd);
1095 case LFUN_WORD_REPLACE:
1096 lyx::find::replace(bv_, cmd);
1100 cur.clearSelection();
1103 cur.message(N_("Mark off"));
1107 cur.clearSelection();
1111 cur.message(N_("Mark on"));
1115 cur.clearSelection();
1117 cur.message(N_("Mark removed"));
1120 cur.message(N_("Mark set"));
1126 case LFUN_UNKNOWN_ACTION:
1127 cur.errorMessage(N_("Unknown function!"));