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"
26 #include "coordcache.h"
29 #include "dispatchresult.h"
31 #include "FloatList.h"
32 #include "funcrequest.h"
33 #include "FuncStatus.h"
36 #include "insetiterator.h"
37 #include "lyx_cb.h" // added for Dispatch functions
43 #include "lastfiles.h"
44 #include "paragraph.h"
45 #include "paragraph_funcs.h"
46 #include "ParagraphParameters.h"
47 #include "pariterator.h"
48 #include "rowpainter.h"
52 #include "insets/insetref.h"
53 #include "insets/insettext.h"
55 #include "frontends/Alert.h"
56 #include "frontends/Dialogs.h"
57 #include "frontends/FileDialog.h"
58 #include "frontends/LyXView.h"
59 #include "frontends/LyXScreenFactory.h"
60 #include "frontends/screen.h"
61 #include "frontends/WorkArea.h"
62 #include "frontends/WorkAreaFactory.h"
64 #include "graphics/Previews.h"
66 #include "support/filetools.h"
67 #include "support/forkedcontr.h"
68 #include "support/globbing.h"
69 #include "support/path_defines.h"
70 #include "support/tostr.h"
71 #include "support/types.h"
73 #include <boost/bind.hpp>
79 using lyx::support::AddPath;
80 using lyx::support::bformat;
81 using lyx::support::FileFilterList;
82 using lyx::support::FileSearch;
83 using lyx::support::ForkedcallsController;
84 using lyx::support::IsDirWriteable;
85 using lyx::support::MakeDisplayPath;
86 using lyx::support::MakeAbsPath;
87 using lyx::support::strToUnsignedInt;
88 using lyx::support::system_lyxdir;
91 using std::istringstream;
95 using std::mem_fun_ref;
98 extern BufferList bufferlist;
103 unsigned int const saved_positions_num = 20;
105 // All the below connection objects are needed because of a bug in some
106 // versions of GCC (<=2.96 are on the suspects list.) By having and assigning
107 // to these connections we avoid a segfault upon startup, and also at exit.
110 boost::signals::connection dispatchcon;
111 boost::signals::connection timecon;
112 boost::signals::connection doccon;
113 boost::signals::connection resizecon;
114 boost::signals::connection kpresscon;
115 boost::signals::connection selectioncon;
116 boost::signals::connection lostcon;
119 /// Get next inset of this class from current cursor position
121 T * getInsetByCode(LCursor & cur, InsetBase::Code code)
124 DocIterator it = cur;
125 if (it.nextInset() &&
126 it.nextInset()->lyxCode() == code) {
127 inset = static_cast<T*>(it.nextInset());
136 BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
137 int width, int height)
138 : bv_(&bv), owner_(owner), buffer_(0), cursor_timeout(400),
139 using_xterm_cursor(false), cursor_(bv)
141 xsel_cache_.set = false;
143 workarea_.reset(WorkAreaFactory::create(*owner_, width, height));
144 screen_.reset(LyXScreenFactory::create(workarea()));
147 doccon = workarea().scrollDocView
148 .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
149 resizecon = workarea().workAreaResize
150 .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
151 dispatchcon = workarea().dispatch
152 .connect(boost::bind(&BufferView::Pimpl::workAreaDispatch, this, _1));
153 kpresscon = workarea().workAreaKeyPress
154 .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
155 selectioncon = workarea().selectionRequested
156 .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
157 lostcon = workarea().selectionLost
158 .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
160 timecon = cursor_timeout.timeout
161 .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
162 cursor_timeout.start();
163 saved_positions.resize(saved_positions_num);
167 void BufferView::Pimpl::addError(ErrorItem const & ei)
169 errorlist_.push_back(ei);
173 void BufferView::Pimpl::showReadonly(bool)
175 owner_->updateWindowTitle();
176 owner_->getDialogs().updateBufferDependent(false);
180 void BufferView::Pimpl::connectBuffer(Buffer & buf)
182 if (errorConnection_.connected())
187 boost::bind(&BufferView::Pimpl::addError, this, _1));
191 boost::bind(&LyXView::message, owner_, _1));
195 boost::bind(&LyXView::busy, owner_, _1));
198 buf.updateTitles.connect(
199 boost::bind(&LyXView::updateWindowTitle, owner_));
202 buf.resetAutosaveTimers.connect(
203 boost::bind(&LyXView::resetAutosaveTimer, owner_));
205 readonlyConnection_ =
206 buf.readonly.connect(
207 boost::bind(&BufferView::Pimpl::showReadonly, this, _1));
211 boost::bind(&BufferView::Pimpl::setBuffer, this, (Buffer *)0));
215 void BufferView::Pimpl::disconnectBuffer()
217 errorConnection_.disconnect();
218 messageConnection_.disconnect();
219 busyConnection_.disconnect();
220 titleConnection_.disconnect();
221 timerConnection_.disconnect();
222 readonlyConnection_.disconnect();
223 closingConnection_.disconnect();
227 void BufferView::Pimpl::newFile(string const & filename, string const & tname,
230 setBuffer(::newFile(filename, tname, isNamed));
234 bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
236 // get absolute path of file and add ".lyx" to the filename if
238 string s = FileSearch(string(), filename, "lyx");
240 bool const found = !s.empty();
245 // file already open?
246 if (bufferlist.exists(s)) {
247 string const file = MakeDisplayPath(s, 20);
248 string text = bformat(_("The document %1$s is already "
249 "loaded.\n\nDo you want to revert "
250 "to the saved version?"), file);
251 int const ret = Alert::prompt(_("Revert to saved document?"),
252 text, 0, 1, _("&Revert"), _("&Switch to document"));
255 setBuffer(bufferlist.getBuffer(s));
258 // FIXME: should be LFUN_REVERT
259 if (!bufferlist.close(bufferlist.getBuffer(s), false))
261 // Fall through to new load. (Asger)
267 b = bufferlist.newBuffer(s);
269 if (!::loadLyXFile(b, s)) {
270 bufferlist.release(b);
274 string text = bformat(_("The document %1$s does not yet "
275 "exist.\n\nDo you want to create "
276 "a new document?"), s);
277 int const ret = Alert::prompt(_("Create new document?"),
278 text, 0, 1, _("&Create"), _("Cancel"));
281 b = ::newFile(s, string(), true);
287 bv_->showErrorList(_("Parse"));
290 LyX::ref().lastfiles().newFile(b->fileName());
296 WorkArea & BufferView::Pimpl::workarea() const
298 return *workarea_.get();
302 LyXScreen & BufferView::Pimpl::screen() const
304 return *screen_.get();
308 Painter & BufferView::Pimpl::painter() const
310 return workarea().getPainter();
314 void BufferView::Pimpl::top_y(int y)
320 int BufferView::Pimpl::top_y() const
326 void BufferView::Pimpl::setBuffer(Buffer * b)
328 lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
333 // if we are closing current buffer, switch to the first in
336 lyxerr[Debug::INFO] << " No Buffer!" << endl;
337 // we are closing the buffer, use the first buffer as current
338 buffer_ = bufferlist.first();
339 owner_->getDialogs().hideBufferDependent();
341 // set current buffer
347 cursor_ = LCursor(*bv_);
349 // if we're quitting lyx, don't bother updating stuff
354 lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
355 connectBuffer(*buffer_);
357 cursor_.push(buffer_->inset());
358 cursor_.resetAnchor();
359 buffer_->text().init(bv_);
360 buffer_->text().setCurrentFont(cursor_);
362 // If we don't have a text object for this, we make one
363 //if (bv_->text() == 0)
364 // resizeCurrentBuffer();
366 // Buffer-dependent dialogs should be updated or
367 // hidden. This should go here because some dialogs (eg ToC)
368 // require bv_->text.
369 owner_->getDialogs().updateBufferDependent(true);
374 owner_->updateMenubar();
375 owner_->updateToolbars();
376 owner_->updateLayoutChoice();
377 owner_->updateWindowTitle();
379 // This is done after the layout combox has been populated
381 owner_->setLayout(cursor_.paragraph().layout()->name());
383 if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
384 lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
388 bool BufferView::Pimpl::fitCursor()
390 // to get the correct y cursor info
391 lyxerr[Debug::DEBUG] << "BufferView::fitCursor" << std::endl;
392 lyx::par_type const pit = bv_->cursor().bottom().par();
393 bv_->text()->redoParagraph(pit);
394 refreshPar(*bv_, *bv_->text(), pit);
396 if (!screen().fitCursor(bv_))
403 void BufferView::Pimpl::redoCurrentBuffer()
405 lyxerr[Debug::DEBUG] << "BufferView::redoCurrentBuffer" << endl;
406 if (buffer_ && bv_->text()) {
407 resizeCurrentBuffer();
409 owner_->updateLayoutChoice();
414 void BufferView::Pimpl::resizeCurrentBuffer()
416 lyxerr[Debug::DEBUG] << "resizeCurrentBuffer" << endl;
418 owner_->message(_("Formatting document..."));
420 LyXText * text = bv_->text();
431 // reset the "Formatting..." message
432 owner_->clearMessage();
438 void BufferView::Pimpl::updateScrollbar()
441 lyxerr[Debug::DEBUG] << "no text in updateScrollbar" << endl;
442 workarea().setScrollbarParams(0, 0, 0);
446 LyXText const & t = *bv_->text();
449 << "Updating scrollbar: height: " << t.height()
450 << " top_y: " << top_y()
451 << " default height " << defaultRowHeight() << endl;
453 workarea().setScrollbarParams(t.height(), top_y(), defaultRowHeight());
457 void BufferView::Pimpl::scrollDocView(int value)
459 lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
464 screen().hideCursor();
467 screen().redraw(*bv_);
469 if (!lyxrc.cursor_follows_scrollbar)
472 int const height = defaultRowHeight();
473 int const first = top_y() + height;
474 int const last = top_y() + workarea().workHeight() - height;
476 bv_->cursor().reset(bv_->buffer()->inset());
477 LyXText * text = bv_->text();
478 int y = text->cursorY(bv_->cursor().front());
483 text->setCursorFromCoordinates(bv_->cursor(), 0, y);
485 owner_->updateLayoutChoice();
489 void BufferView::Pimpl::scroll(int lines)
494 LyXText const * t = bv_->text();
495 int const line_height = defaultRowHeight();
497 // The new absolute coordinate
498 int new_top_y = top_y() + lines * line_height;
500 // Restrict to a valid value
501 new_top_y = std::min(t->height() - 4 * line_height, new_top_y);
502 new_top_y = std::max(0, new_top_y);
504 scrollDocView(new_top_y);
506 // Update the scrollbar.
507 workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
511 void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
512 key_modifier::state state)
514 bv_->owner()->getLyXFunc().processKeySym(key, state);
516 /* This is perhaps a bit of a hack. When we move
517 * around, or type, it's nice to be able to see
518 * the cursor immediately after the keypress. So
519 * we reset the toggle timeout and force the visibility
520 * of the cursor. Note we cannot do this inside
521 * dispatch() itself, because that's called recursively.
524 cursor_timeout.restart();
525 screen().showCursor(*bv_);
530 void BufferView::Pimpl::selectionRequested()
537 LCursor & cur = bv_->cursor();
539 if (!cur.selection()) {
540 xsel_cache_.set = false;
544 if (!xsel_cache_.set ||
545 cur.back() != xsel_cache_.cursor ||
546 cur.anchor_.back() != xsel_cache_.anchor)
548 xsel_cache_.cursor = cur.back();
549 xsel_cache_.anchor = cur.anchor_.back();
550 xsel_cache_.set = cur.selection();
551 sel = cur.selectionAsString(false);
553 workarea().putClipboard(sel);
558 void BufferView::Pimpl::selectionLost()
561 screen().hideCursor();
562 bv_->cursor().clearSelection();
563 xsel_cache_.set = false;
568 void BufferView::Pimpl::workAreaResize()
570 static int work_area_width;
571 static int work_area_height;
573 bool const widthChange = workarea().workWidth() != work_area_width;
574 bool const heightChange = workarea().workHeight() != work_area_height;
576 // update from work area
577 work_area_width = workarea().workWidth();
578 work_area_height = workarea().workHeight();
580 if (buffer_ && widthChange) {
581 // The visible LyXView need a resize
582 resizeCurrentBuffer();
585 if (widthChange || heightChange)
588 // always make sure that the scrollbar is sane.
590 owner_->updateLayoutChoice();
594 void BufferView::Pimpl::update()
596 //lyxerr << "BufferView::Pimpl::update(), buffer: " << buffer_ << endl;
597 // fix cursor coordinate cache in case something went wrong
599 // check needed to survive LyX startup
601 // update macro store
602 buffer_->buildMacros();
604 // update all 'visible' paragraphs
605 lyx::par_type beg, end;
606 getParsInRange(buffer_->paragraphs(),
607 top_y(), top_y() + workarea().workHeight(),
609 bv_->text()->redoParagraphs(beg, end);
615 // remove old position cache
618 // The real, big redraw.
619 screen().redraw(*bv_);
621 bv_->owner()->view_state_changed();
625 // Callback for cursor timer
626 void BufferView::Pimpl::cursorToggle()
629 screen().toggleCursor(*bv_);
631 // Use this opportunity to deal with any child processes that
632 // have finished but are waiting to communicate this fact
633 // to the rest of LyX.
634 ForkedcallsController & fcc = ForkedcallsController::get();
635 if (fcc.processesCompleted())
636 fcc.handleCompletedProcesses();
639 cursor_timeout.restart();
643 bool BufferView::Pimpl::available() const
645 return buffer_ && bv_->text();
649 Change const BufferView::Pimpl::getCurrentChange()
651 if (!bv_->buffer()->params().tracking_changes)
652 return Change(Change::UNCHANGED);
654 LyXText * text = bv_->getLyXText();
655 LCursor & cur = bv_->cursor();
657 if (!cur.selection())
658 return Change(Change::UNCHANGED);
660 return text->getPar(cur.selBegin().par()).
661 lookupChangeFull(cur.selBegin().pos());
665 void BufferView::Pimpl::savePosition(unsigned int i)
667 if (i >= saved_positions_num)
669 BOOST_ASSERT(bv_->cursor().inTexted());
670 saved_positions[i] = Position(buffer_->fileName(),
671 bv_->cursor().paragraph().id(),
672 bv_->cursor().pos());
674 owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
678 void BufferView::Pimpl::restorePosition(unsigned int i)
680 if (i >= saved_positions_num)
683 string const fname = saved_positions[i].filename;
685 bv_->cursor().clearSelection();
687 if (fname != buffer_->fileName()) {
689 if (bufferlist.exists(fname))
690 b = bufferlist.getBuffer(fname);
692 b = bufferlist.newBuffer(fname);
693 ::loadLyXFile(b, fname); // don't ask, just load it
699 ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
700 if (par == buffer_->par_iterator_end())
703 bv_->text()->setCursor(bv_->cursor(), par.pit(),
704 min(par->size(), saved_positions[i].par_pos));
707 owner_->message(bformat(_("Moved to bookmark %1$s"), tostr(i)));
711 bool BufferView::Pimpl::isSavedPosition(unsigned int i)
713 return i < saved_positions_num && !saved_positions[i].filename.empty();
717 void BufferView::Pimpl::switchKeyMap()
719 if (!lyxrc.rtl_support)
722 Intl & intl = owner_->getIntl();
723 if (bv_->getLyXText()->real_current_font.isRightToLeft()) {
724 if (intl.keymap == Intl::PRIMARY)
727 if (intl.keymap == Intl::SECONDARY)
733 void BufferView::Pimpl::center()
735 LyXText * text = bv_->text();
737 bv_->cursor().clearSelection();
738 int const half_height = workarea().workHeight() / 2;
739 int new_y = text->cursorY(bv_->cursor().front()) - half_height;
743 // FIXME: look at this comment again ...
744 // This updates top_y() but means the fitCursor() call
745 // from the update(FITCUR) doesn't realise that we might
746 // have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
747 // the scrollbar to be updated as it should, so we have
748 // to do it manually. Any operation that does a center()
749 // and also might have moved top_y() must make sure to call
750 // updateScrollbar() currently. Never mind that this is a
751 // pretty obfuscated way of updating text->top_y()
756 void BufferView::Pimpl::stuffClipboard(string const & stuff) const
758 workarea().putClipboard(stuff);
762 void BufferView::Pimpl::MenuInsertLyXFile(string const & filenm)
764 string filename = filenm;
766 if (filename.empty()) {
767 // Launch a file browser
768 string initpath = lyxrc.document_path;
771 string const trypath = owner_->buffer()->filePath();
772 // If directory is writeable, use this as default.
773 if (IsDirWriteable(trypath))
777 FileDialog fileDlg(_("Select LyX document to insert"),
779 make_pair(string(_("Documents|#o#O")),
780 string(lyxrc.document_path)),
781 make_pair(string(_("Examples|#E#e")),
782 string(AddPath(system_lyxdir(), "examples"))));
784 FileDialog::Result result =
785 fileDlg.open(initpath,
786 FileFilterList(_("LyX Documents (*.lyx)")),
789 if (result.first == FileDialog::Later)
792 filename = result.second;
794 // check selected filename
795 if (filename.empty()) {
796 owner_->message(_("Canceled."));
801 // get absolute path of file and add ".lyx" to the filename if
803 filename = FileSearch(string(), filename, "lyx");
805 string const disp_fn = MakeDisplayPath(filename);
806 owner_->message(bformat(_("Inserting document %1$s..."), disp_fn));
808 bv_->cursor().clearSelection();
809 bv_->text()->breakParagraph(bv_->cursor());
811 BOOST_ASSERT(bv_->cursor().inTexted());
813 string const fname = MakeAbsPath(filename);
814 bool const res = bv_->buffer()->readFile(fname, bv_->cursor().par());
817 string s = res ? _("Document %1$s inserted.")
818 : _("Could not insert document %1$s");
819 owner_->message(bformat(s, disp_fn));
823 void BufferView::Pimpl::trackChanges()
825 Buffer * buf = bv_->buffer();
826 bool const tracking = buf->params().tracking_changes;
829 for_each(buf->par_iterator_begin(),
830 buf->par_iterator_end(),
831 bind(&Paragraph::trackChanges, _1, Change::UNCHANGED));
832 buf->params().tracking_changes = true;
834 // we cannot allow undos beyond the freeze point
835 buf->undostack().clear();
838 bv_->text()->setCursor(bv_->cursor(), 0, 0);
840 #warning changes FIXME
842 bool found = lyx::find::findNextChange(bv_);
844 owner_->getDialogs().show("changes");
848 for_each(buf->par_iterator_begin(),
849 buf->par_iterator_end(),
850 mem_fun_ref(&Paragraph::untrackChanges));
852 buf->params().tracking_changes = false;
855 buf->redostack().clear();
859 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
861 lyxerr << "BufferView::Pimpl::workAreaDispatch: request: "
862 << cmd0 << std::endl;
863 // this is only called for mouse related events including
864 // LFUN_FILE_OPEN generated by drag-and-drop.
865 FuncRequest cmd = cmd0;
868 if (cmd.action == LFUN_FILE_OPEN) {
869 owner_->dispatch(cmd);
873 cmd.y += bv_->top_y();
878 cur.push(bv_->buffer()->inset());
879 cur.selection() = bv_->cursor().selection();
881 // Doesn't go through lyxfunc, so we need to update
882 // the layout choice etc. ourselves
884 // e.g. Qt mouse press when no buffer
888 screen().hideCursor();
890 // Either the inset under the cursor or the
891 // surrounding LyXText will handle this event.
893 // Build temporary cursor.
894 InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
895 lyxerr << " * created temp cursor: " << inset << endl;
896 lyxerr << " * hit inset at tip: " << inset << endl;
897 lyxerr << " * created temp cursor:" << cur << endl;
899 // Put anchor at the same position.
902 // Try to dispatch to an non-editable inset near this position
903 // via the temp cursor. If the inset wishes to change the real
904 // cursor it has to do so explicitly by using
905 // cur.bv().cursor() = cur; (or similar)
907 inset->dispatch(cur, cmd);
909 // Now dispatch to the temporary cursor. If the real cursor should
910 // be modified, the inset's dispatch has to do so explicitly.
911 if (!cur.result().dispatched())
914 if (cur.result().dispatched()) {
915 // Redraw if requested or necessary.
916 if (fitCursor() || cur.result().update())
920 // see workAreaKeyPress
921 cursor_timeout.restart();
922 screen().showCursor(*bv_);
924 // skip these when selecting
925 if (cmd.action != LFUN_MOUSE_MOTION) {
926 owner_->updateLayoutChoice();
927 owner_->updateToolbars();
930 // slight hack: this is only called currently when we
931 // clicked somewhere, so we force through the display
932 // of the new status here.
933 owner_->clearMessage();
938 FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
940 Buffer * buf = bv_->buffer();
944 switch (cmd.action) {
947 flag.enabled(!buf->undostack().empty());
950 flag.enabled(!buf->redostack().empty());
952 case LFUN_FILE_INSERT:
953 case LFUN_FILE_INSERT_ASCII_PARA:
954 case LFUN_FILE_INSERT_ASCII:
955 case LFUN_FONT_STATE:
956 case LFUN_INSERT_LABEL:
957 case LFUN_BOOKMARK_SAVE:
960 case LFUN_WORD_REPLACE:
965 case LFUN_BEGINNINGBUF:
967 case LFUN_BEGINNINGBUFSEL:
971 case LFUN_BOOKMARK_GOTO:
972 flag.enabled(bv_->isSavedPosition(strToUnsignedInt(cmd.argument)));
974 case LFUN_TRACK_CHANGES:
976 flag.setOnOff(buf->params().tracking_changes);
979 case LFUN_MERGE_CHANGES:
980 case LFUN_ACCEPT_CHANGE: // what about these two
981 case LFUN_REJECT_CHANGE: // what about these two
982 case LFUN_ACCEPT_ALL_CHANGES:
983 case LFUN_REJECT_ALL_CHANGES:
984 flag.enabled(buf && buf->params().tracking_changes);
995 bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
997 //lyxerr << "BufferView::Pimpl::dispatch cmd: " << cmd << std::endl;
998 // Make sure that the cached BufferView is correct.
999 lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
1000 << " action[" << cmd.action << ']'
1001 << " arg[" << cmd.argument << ']'
1002 << " x[" << cmd.x << ']'
1003 << " y[" << cmd.y << ']'
1004 << " button[" << cmd.button() << ']'
1007 LCursor & cur = bv_->cursor();
1009 switch (cmd.action) {
1013 cur.message(_("Undo"));
1014 cur.clearSelection();
1015 if (!textUndo(*bv_))
1016 cur.message(_("No further undo information"));
1024 cur.message(_("Redo"));
1025 cur.clearSelection();
1026 if (!textRedo(*bv_))
1027 cur.message(_("No further redo information"));
1033 case LFUN_FILE_INSERT:
1034 MenuInsertLyXFile(cmd.argument);
1037 case LFUN_FILE_INSERT_ASCII_PARA:
1038 InsertAsciiFile(bv_, cmd.argument, true);
1041 case LFUN_FILE_INSERT_ASCII:
1042 InsertAsciiFile(bv_, cmd.argument, false);
1045 case LFUN_FONT_STATE:
1046 cur.message(cur.currentState());
1049 case LFUN_BOOKMARK_SAVE:
1050 savePosition(strToUnsignedInt(cmd.argument));
1053 case LFUN_BOOKMARK_GOTO:
1054 restorePosition(strToUnsignedInt(cmd.argument));
1057 case LFUN_REF_GOTO: {
1058 string label = cmd.argument;
1059 if (label.empty()) {
1061 getInsetByCode<InsetRef>(bv_->cursor(),
1062 InsetBase::REF_CODE);
1064 label = inset->getContents();
1070 bv_->gotoLabel(label);
1074 case LFUN_TRACK_CHANGES:
1078 case LFUN_MERGE_CHANGES:
1079 owner_->getDialogs().show("changes");
1082 case LFUN_ACCEPT_ALL_CHANGES: {
1083 bv_->cursor().reset(bv_->buffer()->inset());
1084 #ifdef WITH_WARNINGS
1085 #warning FIXME changes
1087 while (lyx::find::findNextChange(bv_))
1088 bv_->getLyXText()->acceptChange(bv_->cursor());
1093 case LFUN_REJECT_ALL_CHANGES: {
1094 bv_->cursor().reset(bv_->buffer()->inset());
1095 #ifdef WITH_WARNINGS
1096 #warning FIXME changes
1098 while (lyx::find::findNextChange(bv_))
1099 bv_->getLyXText()->rejectChange(bv_->cursor());
1103 case LFUN_WORD_FIND:
1104 lyx::find::find(bv_, cmd);
1107 case LFUN_WORD_REPLACE:
1108 lyx::find::replace(bv_, cmd);
1112 cur.clearSelection();
1114 cur.message(N_("Mark off"));
1118 cur.clearSelection();
1121 cur.message(N_("Mark on"));
1125 cur.clearSelection();
1128 cur.message(N_("Mark removed"));
1131 cur.message(N_("Mark set"));
1140 case LFUN_BEGINNINGBUFSEL:
1141 bv_->cursor().reset(bv_->buffer()->inset());
1142 if (!cur.selection())
1144 bv_->text()->cursorTop(cur);
1148 case LFUN_ENDBUFSEL:
1149 bv_->cursor().reset(bv_->buffer()->inset());
1150 if (!cur.selection())
1152 bv_->text()->cursorBottom(cur);