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"
50 #include "insets/insetref.h"
51 #include "insets/insettext.h"
53 #include "frontends/Alert.h"
54 #include "frontends/Dialogs.h"
55 #include "frontends/FileDialog.h"
56 #include "frontends/LyXView.h"
57 #include "frontends/LyXScreenFactory.h"
58 #include "frontends/screen.h"
59 #include "frontends/WorkArea.h"
60 #include "frontends/WorkAreaFactory.h"
62 #include "graphics/Previews.h"
64 #include "support/filetools.h"
65 #include "support/forkedcontr.h"
66 #include "support/globbing.h"
67 #include "support/path_defines.h"
68 #include "support/tostr.h"
70 #include <boost/bind.hpp>
74 using lyx::support::AddPath;
75 using lyx::support::bformat;
76 using lyx::support::FileFilterList;
77 using lyx::support::FileSearch;
78 using lyx::support::ForkedcallsController;
79 using lyx::support::IsDirWriteable;
80 using lyx::support::MakeDisplayPath;
81 using lyx::support::strToUnsignedInt;
82 using lyx::support::system_lyxdir;
85 using std::istringstream;
91 extern BufferList bufferlist;
96 unsigned int const saved_positions_num = 20;
98 // All the below connection objects are needed because of a bug in some
99 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
100 // to these connections we avoid a segfault upon startup, and also at exit.
103 boost::signals::connection dispatchcon;
104 boost::signals::connection timecon;
105 boost::signals::connection doccon;
106 boost::signals::connection resizecon;
107 boost::signals::connection kpresscon;
108 boost::signals::connection selectioncon;
109 boost::signals::connection lostcon;
115 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
116 int xpos, int ypos, int width, int height)
117 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
118 using_xterm_cursor(false), cursor_(bv)
120 xsel_cache_.set = false;
122 workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
123 screen_.reset(LyXScreenFactory::create(workarea()));
126 doccon = workarea().scrollDocView
127 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
128 resizecon = workarea().workAreaResize
129 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
130 dispatchcon = workarea().dispatch
131 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
132 kpresscon = workarea().workAreaKeyPress
133 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
134 selectioncon = workarea().selectionRequested
135 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
136 lostcon = workarea().selectionLost
137 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
139 timecon = cursor_timeout.timeout
140 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
141 cursor_timeout.start();
142 saved_positions.resize(saved_positions_num);
146 void BufferView::Pimpl::addError(ErrorItem const & ei)
148 errorlist_.push_back(ei);
152 void BufferView::Pimpl::showReadonly(bool)
154 owner_->updateWindowTitle();
155 owner_->getDialogs().updateBufferDependent(false);
159 void BufferView::Pimpl::connectBuffer(Buffer & buf)
161 if (errorConnection_.connected())
166 boost::bind(&BufferView::Pimpl::addError, this, _1));
170 boost::bind(&LyXView::message, owner_, _1));
174 boost::bind(&LyXView::busy, owner_, _1));
177 buf.updateTitles.connect(
178 boost::bind(&LyXView::updateWindowTitle, owner_));
181 buf.resetAutosaveTimers.connect(
182 boost::bind(&LyXView::resetAutosaveTimer, owner_));
184 readonlyConnection_ =
185 buf.readonly.connect(
186 boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
190 boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
194 void BufferView::Pimpl::disconnectBuffer()
196 errorConnection_.disconnect();
197 messageConnection_.disconnect();
198 busyConnection_.disconnect();
199 titleConnection_.disconnect();
200 timerConnection_.disconnect();
201 readonlyConnection_.disconnect();
202 closingConnection_.disconnect();
206 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
209 setBuffer(::newFile(filename, tname, isNamed));
213 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
215 // get absolute path of file and add ".lyx" to the filename if
217 string s = FileSearch(string(), filename, "lyx");
219 bool const found = !s.empty();
224 // file already open?
225 if (bufferlist.exists(s)) {
226 string const file = MakeDisplayPath(s, 20);
227 string text = bformat(_("The document %1$s is already "
228 "loaded.\n\nDo you want to revert "
229 "to the saved version?"), file);
230 int const ret = Alert::prompt(_("Revert to saved document?"),
231 text, 0, 1, _("&Revert"), _("&Switch to document"));
234 setBuffer(bufferlist.getBuffer(s));
237 // FIXME: should be LFUN_REVERT
238 if (!bufferlist.close(bufferlist.getBuffer(s), false))
240 // Fall through to new load. (Asger)
246 b = bufferlist.newBuffer(s);
248 if (!::loadLyXFile(b, s)) {
249 bufferlist.release(b);
253 string text = bformat(_("The document %1$s does not yet "
254 "exist.\n\nDo you want to create "
255 "a new document?"), s);
256 int const ret = Alert::prompt(_("Create new document?"),
257 text, 0, 1, _("&Create"), _("Cancel"));
260 b = ::newFile(s, string(), true);
266 bv_->showErrorList(_("Parse"));
269 LyX::ref().lastfiles().newFile(b->fileName());
275 WorkArea & BufferView::Pimpl::workarea() const
277 return *workarea_.get();
281 LyXScreen & BufferView::Pimpl::screen() const
283 return *screen_.get();
287 Painter & BufferView::Pimpl::painter() const
289 return workarea().getPainter();
293 void BufferView::Pimpl::top_y(int y)
299 int BufferView::Pimpl::top_y() const
305 void BufferView::Pimpl::setBuffer(Buffer * b)
307 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
312 // set current buffer
317 cursor_ = LCursor(*bv_);
319 // if we're quitting lyx, don't bother updating stuff
324 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
325 connectBuffer(*buffer_);
327 cursor_.push(buffer_->inset());
328 cursor_.resetAnchor();
329 buffer_->text().init(bv_);
331 // If we don't have a text object for this, we make one
332 //if (bv_->text() == 0)
333 // resizeCurrentBuffer();
335 // Buffer-dependent dialogs should be updated or
336 // hidden. This should go here because some dialogs (eg ToC)
337 // require bv_->text.
338 owner_->getDialogs().updateBufferDependent(true);
339 owner_->setLayout(bv_->text()->getPar(0).layout()->name());
341 lyxerr[Debug::INFO] << " No Buffer!" << endl;
342 // we are closing the buffer, use the first buffer as current
343 buffer_ = bufferlist.first();
344 owner_->getDialogs().hideBufferDependent();
349 owner_->updateMenubar();
350 owner_->updateToolbar();
351 owner_->updateLayoutChoice();
352 owner_->updateWindowTitle();
354 if (lyx::graphics::Previews::activated() && buffer_)
355 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
359 bool BufferView::Pimpl::fitCursor()
361 // this is enough to get the right y cursor info for fitCursor
362 cursor_[0].text()->redoParagraph(cursor_[0].par());
364 if (!screen().fitCursor(bv_))
372 void BufferView::Pimpl::redoCurrentBuffer()
374 lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
375 if (buffer_ && bv_->text()) {
376 resizeCurrentBuffer();
378 owner_->updateLayoutChoice();
383 void BufferView::Pimpl::resizeCurrentBuffer()
385 lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
387 owner_->message(_("Formatting document..."));
389 LyXText * text = bv_->text();
400 // reset the "Formatting..." message
401 owner_->clearMessage();
407 void BufferView::Pimpl::updateScrollbar()
410 lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
411 lyxerr << "no text in updateScrollbar" << endl;
412 workarea().setScrollbarParams(0, 0, 0);
416 LyXText const & t = *bv_->text();
419 << "Updating scrollbar: height: " << t.height()
420 << " top_y: " << top_y()
421 << " default height " << defaultRowHeight() << endl;
423 workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
427 void BufferView::Pimpl::scrollDocView(int value)
429 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
434 screen().hideCursor();
437 screen().redraw(*bv_);
439 if (!lyxrc.cursor_follows_scrollbar)
442 int const height = defaultRowHeight();
443 int const first = top_y() + height;
444 int const last = top_y() + workarea().workHeight() - height;
446 bv_->cursor().reset(bv_->buffer()->inset());
447 LyXText * text = bv_->text();
448 int y = text->cursorY(bv_->cursor().front());
453 text->setCursorFromCoordinates(bv_->cursor(), 0, y);
455 owner_->updateLayoutChoice();
459 void BufferView::Pimpl::scroll(int lines)
464 LyXText const * t = bv_->text();
465 int const line_height = defaultRowHeight();
467 // The new absolute coordinate
468 int new_top_y = top_y() + lines * line_height;
470 // Restrict to a valid value
471 new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
472 new_top_y = std::max(0, new_top_y);
474 scrollDocView(new_top_y);
476 // Update the scrollbar.
477 workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
481 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
482 key_modifier::state state)
484 bv_->owner()->getLyXFunc().processKeySym(key, state);
486 /* This is perhaps a bit of a hack. When we move
487 * around, or type, it's nice to be able to see
488 * the cursor immediately after the keypress. So
489 * we reset the toggle timeout and force the visibility
490 * of the cursor. Note we cannot do this inside
491 * dispatch() itself, because that's called recursively.
494 cursor_timeout.restart();
495 screen().showCursor(*bv_);
500 void BufferView::Pimpl::selectionRequested()
507 LCursor & cur = bv_->cursor();
509 if (!cur.selection()) {
510 xsel_cache_.set = false;
514 if (!xsel_cache_.set ||
515 cur.back() != xsel_cache_.cursor ||
516 cur.anchor_.back() != xsel_cache_.anchor)
518 xsel_cache_.cursor = cur.back();
519 xsel_cache_.anchor = cur.anchor_.back();
520 xsel_cache_.set = cur.selection();
521 sel = cur.selectionAsString(false);
523 workarea().putClipboard(sel);
528 void BufferView::Pimpl::selectionLost()
531 screen().hideCursor();
532 bv_->cursor().clearSelection();
533 xsel_cache_.set = false;
538 void BufferView::Pimpl::workAreaResize()
540 static int work_area_width;
541 static int work_area_height;
543 bool const widthChange = workarea().workWidth() != work_area_width;
544 bool const heightChange = workarea().workHeight() != work_area_height;
546 // update from work area
547 work_area_width = workarea().workWidth();
548 work_area_height = workarea().workHeight();
550 if (buffer_ && widthChange) {
551 // The visible LyXView need a resize
552 resizeCurrentBuffer();
555 if (widthChange || heightChange)
558 // always make sure that the scrollbar is sane.
560 owner_->updateLayoutChoice();
564 void BufferView::Pimpl::update()
566 //lyxerr << "BufferView::Pimpl::update(), buffer: " << buffer_ << endl;
567 // fix cursor coordinate cache in case something went wrong
569 // check needed to survive LyX startup
571 // update all 'visible' paragraphs
572 lyx::par_type beg, end;
573 getParsInRange(buffer_->paragraphs(),
574 top_y(), top_y() + workarea().workHeight(),
576 bv_->text()->redoParagraphs(beg, end);
579 screen().redraw(*bv_);
580 bv_->owner()->view_state_changed();
584 // Callback for cursor timer
585 void BufferView::Pimpl::cursorToggle()
588 screen().toggleCursor(*bv_);
590 // Use this opportunity to deal with any child processes that
591 // have finished but are waiting to communicate this fact
592 // to the rest of LyX.
593 ForkedcallsController & fcc = ForkedcallsController::get();
594 if (fcc.processesCompleted())
595 fcc.handleCompletedProcesses();
598 cursor_timeout.restart();
602 bool BufferView::Pimpl::available() const
604 return buffer_ && bv_->text();
608 Change const BufferView::Pimpl::getCurrentChange()
610 if (!bv_->buffer()->params().tracking_changes)
611 return Change(Change::UNCHANGED);
613 LyXText * text = bv_->getLyXText();
614 LCursor & cur = bv_->cursor();
616 if (!cur.selection())
617 return Change(Change::UNCHANGED);
619 return text->getPar(cur.selBegin().par()).
620 lookupChangeFull(cur.selBegin().pos());
624 void BufferView::Pimpl::savePosition(unsigned int i)
626 if (i >= saved_positions_num)
628 BOOST_ASSERT(bv_->cursor().inTexted());
629 saved_positions[i] = Position(buffer_->fileName(),
630 bv_->cursor().paragraph().id(),
631 bv_->cursor().pos());
633 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
637 void BufferView::Pimpl::restorePosition(unsigned int i)
639 if (i >= saved_positions_num)
642 string const fname = saved_positions[i].filename;
644 bv_->cursor().clearSelection();
646 if (fname != buffer_->fileName()) {
648 if (bufferlist.exists(fname))
649 b = bufferlist.getBuffer(fname);
651 b = bufferlist.newBuffer(fname);
652 ::loadLyXFile(b, fname); // don't ask, just load it
658 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
659 if (par == buffer_->par_iterator_end())
662 bv_->text()->setCursor(bv_->cursor(), par.pit(),
663 min(par->size(), saved_positions[i].par_pos));
666 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
670 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
672 return i < saved_positions_num && !saved_positions[i].filename.empty();
676 void BufferView::Pimpl::switchKeyMap()
678 if (!lyxrc.rtl_support)
681 Intl & intl = owner_->getIntl();
682 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
683 if (intl.keymap == Intl::PRIMARY)
686 if (intl.keymap == Intl::SECONDARY)
692 void BufferView::Pimpl::center()
694 LyXText * text = bv_->text();
696 bv_->cursor().clearSelection();
697 int const half_height = workarea().workHeight() / 2;
698 int new_y = text->cursorY(bv_->cursor().front()) - half_height;
702 // FIXME: look at this comment again ...
703 // This updates top_y() but means the fitCursor() call
704 // from the update(FITCUR) doesn't realise that we might
705 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
706 // the scrollbar to be updated as it should, so we have
707 // to do it manually. Any operation that does a center()
708 // and also might have moved top_y() must make sure to call
709 // updateScrollbar() currently. Never mind that this is a
710 // pretty obfuscated way of updating text->top_y()
715 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
717 workarea().putClipboard(stuff);
721 InsetBase * BufferView::Pimpl::getInsetByCode(InsetBase::Code /*code*/)
723 #warning Does not work for mathed
724 // Ok, this is a little bit too brute force but it
725 // should work for now. Better infrastructure is coming. (Lgb)
729 Buffer * buf = bv_->buffer();
730 InsetIterator beg = inset_iterator_begin(buf->inset());
732 bool cursor_par_seen = false;
734 LCursor & cur = bv_->cursor();
735 LyXText * = bv_->getLyXText();
736 ParagraphList::iterator pit = text->getPar(cur.par());
739 if (beg.par() == pit)
740 cursor_par_seen = true;
741 if (cursor_par_seen) {
742 if (beg.par() == pit && beg.pos() >= cur.pos())
744 if (beg.getPar() != pit)
749 // Now find the first inset that matches code.
751 if (beg->lyxCode() == code)
760 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
762 string filename = filenm;
764 if (filename.empty()) {
765 // Launch a file browser
766 string initpath = lyxrc.document_path;
769 string const trypath = owner_->buffer()->filePath();
770 // If directory is writeable, use this as default.
771 if (IsDirWriteable(trypath))
775 FileDialog fileDlg(_("Select LyX document to insert"),
777 make_pair(string(_("Documents|#o#O")),
778 string(lyxrc.document_path)),
779 make_pair(string(_("Examples|#E#e")),
780 string(AddPath(system_lyxdir(), "examples"))));
782 FileDialog::Result result =
783 fileDlg.open(initpath,
784 FileFilterList(_("LyX Documents (*.lyx)")),
787 if (result.first == FileDialog::Later)
790 filename = result.second;
792 // check selected filename
793 if (filename.empty()) {
794 owner_->message(_("Canceled."));
799 // get absolute path of file and add ".lyx" to the filename if
801 filename = FileSearch(string(), filename, "lyx");
803 string const disp_fn = MakeDisplayPath(filename);
804 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
805 if (bv_->insertLyXFile(filename))
806 owner_->message(bformat(_("Document %1$s inserted."),
809 owner_->message(bformat(_("Could not insert document %1$s"),
814 void BufferView::Pimpl::trackChanges()
816 Buffer * buf = bv_->buffer();
817 bool const tracking = buf->params().tracking_changes;
820 ParIterator const end = buf->par_iterator_end();
821 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
823 buf->params().tracking_changes = true;
825 // we cannot allow undos beyond the freeze point
826 buf->undostack().clear();
829 bv_->text()->setCursor(bv_->cursor(), 0, 0);
830 #warning changes FIXME
831 bool found = lyx::find::findNextChange(bv_);
833 owner_->getDialogs().show("changes");
837 ParIterator const end = buf->par_iterator_end();
838 for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
839 it->untrackChanges();
840 buf->params().tracking_changes = false;
843 buf->redostack().clear();
847 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
849 // this is only called for mouse related events including
850 // LFUN_FILE_OPEN generated by drag-and-drop.
851 FuncRequest cmd = cmd0;
854 if (cmd.action == LFUN_FILE_OPEN) {
855 owner_->dispatch(cmd);
859 cmd.y += bv_->top_y();
860 //lyxerr << "*** workAreaDispatch: request: " << cmd << std::endl;
862 cur.push(bv_->buffer()->inset());
864 cur.selection() = bv_->cursor().selection();
866 // Doesn't go through lyxfunc, so we need to update
867 // the layout choice etc. ourselves
869 // e.g. Qt mouse press when no buffer
873 screen().hideCursor();
875 // either the inset under the cursor or the
876 // surrounding LyXText will handle this event.
878 // built temporary path to inset
879 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
880 lyxerr << "hit inset at tip: " << inset << endl;
881 lyxerr << "created temp cursor:\n" << cur << endl;
883 // Try to dispatch to an non-editable inset near this position
884 // via the temp cursor. If the inset wishes to change the real
885 // cursor it has to do so explicitly by using
886 // cur.bv().cursor() = cur; (or similar)'
889 inset->dispatch(cur, cmd);
891 // Now dispatch to the real cursor. Any change to the cursor
893 if (!res.dispatched())
894 res = cur.dispatch(cmd);
896 // If the request was dispatched the temp cursor should have been
897 // in a way to be used as new 'real' cursor.
898 if (res.dispatched()) {
900 // Redraw if requested or necessary.
901 if (fitCursor() || res.update())
905 // see workAreaKeyPress
906 cursor_timeout.restart();
907 screen().showCursor(*bv_);
909 // skip these when selecting
910 if (cmd.action != LFUN_MOUSE_MOTION) {
911 owner_->updateLayoutChoice();
912 owner_->updateToolbar();
915 // slight hack: this is only called currently when we
916 // clicked somewhere, so we force through the display
917 // of the new status here.
918 owner_->clearMessage();
923 FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
925 Buffer * buf = bv_->buffer();
929 switch (cmd.action) {
932 flag.enabled(!buf->undostack().empty());
935 flag.enabled(!buf->redostack().empty());
937 case LFUN_FILE_INSERT:
938 case LFUN_FILE_INSERT_ASCII_PARA:
939 case LFUN_FILE_INSERT_ASCII:
940 case LFUN_FONT_STATE:
941 case LFUN_INSERT_LABEL:
942 case LFUN_BOOKMARK_SAVE:
945 case LFUN_WORD_REPLACE:
950 case LFUN_BEGINNINGBUFSEL:
954 case LFUN_BOOKMARK_GOTO:
955 flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument)));
957 case LFUN_TRACK_CHANGES:
959 flag.setOnOff(buf->params().tracking_changes);
962 case LFUN_MERGE_CHANGES:
963 case LFUN_ACCEPT_CHANGE: // what about these two
964 case LFUN_REJECT_CHANGE: // what about these two
965 case LFUN_ACCEPT_ALL_CHANGES:
966 case LFUN_REJECT_ALL_CHANGES:
967 flag.enabled(buf && buf->params().tracking_changes);
978 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
980 //lyxerr << "BufferView::Pimpl::dispatch cmd: " << cmd << std::endl;
981 // Make sure that the cached BufferView is correct.
982 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
983 << " action[" << cmd.action << ']'
984 << " arg[" << cmd.argument << ']'
985 << " x[" << cmd.x << ']'
986 << " y[" << cmd.y << ']'
987 << " button[" << cmd.button() << ']'
990 LCursor & cur = bv_->cursor();
992 switch (cmd.action) {
996 cur.message(_("Undo"));
997 cur.clearSelection();
999 cur.message(_("No further undo information"));
1007 cur.message(_("Redo"));
1008 cur.clearSelection();
1009 if (!textRedo(*bv_))
1010 cur.message(_("No further redo information"));
1016 case LFUN_FILE_INSERT:
1017 MenuInsertLyXFile(cmd.argument);
1020 case LFUN_FILE_INSERT_ASCII_PARA:
1021 InsertAsciiFile(bv_, cmd.argument, true);
1024 case LFUN_FILE_INSERT_ASCII:
1025 InsertAsciiFile(bv_, cmd.argument, false);
1028 case LFUN_FONT_STATE:
1029 cur.message(cur.currentState());
1032 case LFUN_INSERT_LABEL: {
1033 // Try and generate a valid label
1034 string const contents = cmd.argument.empty() ?
1035 cur.getPossibleLabel() : cmd.argument;
1036 InsetCommandParams icp("label", contents);
1037 string data = InsetCommandMailer::params2string("label", icp);
1038 owner_->getDialogs().show("label", data, 0);
1042 case LFUN_BOOKMARK_SAVE:
1043 savePosition(strToUnsignedInt(cmd.argument));
1046 case LFUN_BOOKMARK_GOTO:
1047 restorePosition(strToUnsignedInt(cmd.argument));
1050 case LFUN_REF_GOTO: {
1051 string label = cmd.argument;
1052 if (label.empty()) {
1054 static_cast<InsetRef*>(getInsetByCode(InsetBase::REF_CODE));
1056 label = inset->getContents();
1062 bv_->gotoLabel(label);
1066 case LFUN_TRACK_CHANGES:
1070 case LFUN_MERGE_CHANGES:
1071 owner_->getDialogs().show("changes");
1074 case LFUN_ACCEPT_ALL_CHANGES: {
1075 bv_->cursor().reset(bv_->buffer()->inset());
1076 #warning FIXME changes
1077 while (lyx::find::findNextChange(bv_))
1078 bv_->getLyXText()->acceptChange(bv_->cursor());
1083 case LFUN_REJECT_ALL_CHANGES: {
1084 bv_->cursor().reset(bv_->buffer()->inset());
1085 #warning FIXME changes
1086 while (lyx::find::findNextChange(bv_))
1087 bv_->getLyXText()->rejectChange(bv_->cursor());
1092 case LFUN_WORD_FIND:
1093 lyx::find::find(bv_, cmd);
1096 case LFUN_WORD_REPLACE:
1097 lyx::find::replace(bv_, cmd);
1101 cur.clearSelection();
1104 cur.message(N_("Mark off"));
1108 cur.clearSelection();
1112 cur.message(N_("Mark on"));
1116 cur.clearSelection();
1119 cur.message(N_("Mark removed"));
1122 cur.message(N_("Mark set"));
1132 case LFUN_BEGINNINGBUFSEL:
1133 bv_->cursor().reset(bv_->buffer()->inset());
1134 if (!cur.selection())
1136 bv_->text()->cursorTop(cur);
1140 case LFUN_ENDBUFSEL:
1141 bv_->cursor().reset(bv_->buffer()->inset());
1142 if (!cur.selection())
1144 bv_->text()->cursorBottom(cur);