1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
17 #include "bufferlist.h"
19 #include "buffer_funcs.h"
20 #include "BufferView.h"
21 #include "lyxserver.h"
25 #include "LyXAction.h"
31 #include "trans_mgr.h"
34 #include "bufferview_funcs.h"
35 #include "frontends/LyXView.h"
36 #include "frontends/lyx_gui.h"
38 #include "FloatList.h"
42 #include "TextCache.h"
44 #include "undo_funcs.h"
45 #include "ParagraphParameters.h"
47 #include "insets/insetcommand.h"
48 #include "insets/insetexternal.h"
49 #include "insets/insettabular.h"
51 #include "mathed/formulamacro.h"
52 #include "mathed/math_cursor.h"
53 #include "mathed/math_inset.h"
55 #include "frontends/FileDialog.h"
56 #include "frontends/Dialogs.h"
57 #include "frontends/Toolbar.h"
58 #include "frontends/Menubar.h"
59 #include "frontends/Alert.h"
61 #include "graphics/GraphicsCache.h"
63 #include "support/lyxalgo.h"
64 #include "support/LAssert.h"
65 #include "support/filetools.h"
66 #include "support/FileInfo.h"
67 #include "support/forkedcontr.h"
68 #include "support/lstrings.h"
69 #include "support/tostr.h"
70 #include "support/path.h"
71 #include "support/lyxfunctional.h"
81 using namespace lyx::support;
89 using std::back_inserter;
90 using namespace bv_funcs;
92 extern BufferList bufferlist;
93 extern LyXServer * lyxserver;
94 extern bool selection_possible;
96 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
99 extern tex_accent_struct get_accent(kb_action action);
101 extern void ShowLatexLog();
104 LyXFunc::LyXFunc(LyXView * o)
107 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
108 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
109 meta_fake_bit(key_modifier::none)
115 LyXText * LyXFunc::TEXT(bool flag = true) const
119 return view()->getLyXText();
124 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
126 if (selecting || TEXT(flag)->selection.mark()) {
127 TEXT(flag)->setSelection();
128 if (!TEXT(flag)->isInInset())
129 view()->toggleToggle();
131 view()->update(TEXT(flag), BufferView::SELECT);
133 view()->switchKeyMap();
137 void LyXFunc::handleKeyFunc(kb_action action)
139 char c = encoded_last_key;
141 if (keyseq.length()) {
145 owner->getIntl().getTransManager()
146 .deadkey(c, get_accent(action).accent, TEXT(false));
147 // Need to clear, in case the minibuffer calls these
150 // copied verbatim from do_accent_char
151 view()->update(TEXT(false), BufferView::SELECT);
152 TEXT(false)->selection.cursor = TEXT(false)->cursor;
156 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
157 key_modifier::state state)
161 if (lyxerr.debugging(Debug::KEY)) {
162 lyxerr << "KeySym is "
163 << keysym->getSymbolName()
167 // Do nothing if we have nothing (JMarc)
168 if (!keysym->isOK()) {
169 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
174 if (keysym->isModifier()) {
175 lyxerr[Debug::KEY] << "isModifier true" << endl;
179 Encoding const * encoding = view()->getEncoding();
181 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
183 // Do a one-deep top-level lookup for
184 // cancel and meta-fake keys. RVDK_PATCH_5
185 cancel_meta_seq.reset();
187 int action = cancel_meta_seq.addkey(keysym, state);
188 lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
190 // When not cancel or meta-fake, do the normal lookup.
191 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
192 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
193 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
194 // remove Caps Lock and Mod2 as a modifiers
195 action = keyseq.addkey(keysym, (state | meta_fake_bit));
196 lyxerr[Debug::KEY] << "action now set to ["
197 << action << ']' << endl;
200 // Dont remove this unless you know what you are doing.
201 meta_fake_bit = key_modifier::none;
203 // can this happen now ?
204 if (action == LFUN_NOACTION) {
205 action = LFUN_PREFIX;
208 if (lyxerr.debugging(Debug::KEY)) {
209 lyxerr << "Key [action="
211 << keyseq.print() << ']'
215 // already here we know if it any point in going further
216 // why not return already here if action == -1 and
217 // num_bytes == 0? (Lgb)
219 if (keyseq.length() > 1) {
220 owner->message(keyseq.print());
224 // Maybe user can only reach the key via holding down shift.
225 // Let's see. But only if shift is the only modifier
226 if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
227 lyxerr[Debug::KEY] << "Trying without shift" << endl;
228 action = keyseq.addkey(keysym, key_modifier::none);
229 lyxerr[Debug::KEY] << "Action now " << action << endl;
232 if (action == LFUN_UNKNOWN_ACTION) {
233 // Hmm, we didn't match any of the keysequences. See
234 // if it's normal insertable text not already covered
236 if (keysym->isText() && keyseq.length() == 1) {
237 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
238 action = LFUN_SELFINSERT;
240 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
241 owner->message(_("Unknown function."));
246 if (action == LFUN_SELFINSERT) {
247 if (encoded_last_key != 0) {
249 arg += encoded_last_key;
251 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
253 lyxerr[Debug::KEY] << "SelfInsert arg[`"
254 << argument << "']" << endl;
262 FuncStatus LyXFunc::getStatus(int ac) const
264 return getStatus(lyxaction.retrieveActionArg(ac));
268 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
271 Buffer * buf = owner->buffer();
273 if (ev.action == LFUN_NOACTION) {
274 setStatusMessage(N_("Nothing to do"));
275 return flag.disabled(true);
279 case LFUN_UNKNOWN_ACTION:
280 #ifndef HAVE_LIBAIKSAURUS
281 case LFUN_THESAURUS_ENTRY:
286 flag |= lyx_gui::getStatus(ev);
289 if (flag.unknown()) {
290 setStatusMessage(N_("Unknown action"));
294 // the default error message if we disable the command
295 setStatusMessage(N_("Command disabled"));
297 // Check whether we need a buffer
298 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
299 // Yes we need a buffer, do we have one?
302 // Can we use a readonly buffer?
303 if (buf->isReadonly() &&
304 !lyxaction.funcHasFlag(ev.action,
305 LyXAction::ReadOnly)) {
307 setStatusMessage(N_("Document is read-only"));
312 setStatusMessage(N_("Command not allowed with"
313 "out any document open"));
314 return flag.disabled(true);
318 UpdatableInset * tli = view()->theLockingInset();
320 // I would really like to avoid having this switch and rather try to
321 // encode this in the function itself.
322 bool disable = false;
325 disable = ev.argument != "custom"
326 && !Exporter::IsExportable(buf, ev.argument);
329 disable = buf->undostack.empty();
332 disable = buf->redostack.empty();
337 UpdatableInset * in = tli;
338 if (in->lyxCode() != Inset::TABULAR_CODE) {
339 in = tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
341 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
346 disable = !mathcursor && !view()->getLyXText()->selection.set();
349 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
352 disable = !Exporter::IsExportable(buf, "program");
355 case LFUN_LAYOUT_TABULAR:
357 || (tli->lyxCode() != Inset::TABULAR_CODE
358 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
362 disable = !changeDepth(view(), TEXT(false), DEC_DEPTH, true);
365 case LFUN_DEPTH_PLUS:
366 disable = !changeDepth(view(), TEXT(false), INC_DEPTH, true);
370 case LFUN_LAYOUT_PARAGRAPH: {
371 Inset * inset = TEXT(false)->cursor.par()->inInset();
372 disable = inset && inset->forceDefaultParagraphs(inset);
376 case LFUN_INSET_OPTARG:
377 disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
380 case LFUN_TABULAR_FEATURE:
383 // FIXME: check temporarily disabled
385 char align = mathcursor->valign();
390 if (ev.argument.empty()) {
394 if (!contains("tcb", ev.argument[0])) {
398 flag.setOnOff(ev.argument[0] == align);
402 char align = mathcursor->halign();
407 if (ev.argument.empty()) {
411 if (!contains("lcr", ev.argument[0])) {
415 flag.setOnOff(ev.argument[0] == align);
418 disable = !mathcursor->halign();
424 //ret.disabled(true);
425 if (tli->lyxCode() == Inset::TABULAR_CODE) {
426 ret = static_cast<InsetTabular *>(tli)
427 ->getStatus(ev.argument);
430 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
431 ret = static_cast<InsetTabular *>
432 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
433 ->getStatus(ev.argument);
440 static InsetTabular inset(*owner->buffer(), 1, 1);
444 ret = inset.getStatus(ev.argument);
445 if (ret.onoff(true) || ret.onoff(false))
446 flag.setOnOff(false);
450 case LFUN_VC_REGISTER:
451 disable = buf->lyxvc.inUse();
453 case LFUN_VC_CHECKIN:
454 disable = !buf->lyxvc.inUse() || buf->isReadonly();
456 case LFUN_VC_CHECKOUT:
457 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
461 disable = !buf->lyxvc.inUse();
463 case LFUN_MENURELOAD:
464 disable = buf->isUnnamed() || buf->isClean();
466 case LFUN_BOOKMARK_GOTO:
468 isSavedPosition(strToUnsignedInt(ev.argument));
470 case LFUN_MERGE_CHANGES:
471 case LFUN_ACCEPT_CHANGE:
472 case LFUN_REJECT_CHANGE:
473 case LFUN_ACCEPT_ALL_CHANGES:
474 case LFUN_REJECT_ALL_CHANGES:
475 disable = !buf->params.tracking_changes;
477 case LFUN_INSET_TOGGLE: {
478 LyXText * lt = view()->getLyXText();
479 disable = !(isEditableInset(lt->getInset())
481 && lt->inset_owner->owner()
482 && lt->inset_owner->owner()->isOpen()));
486 case LFUN_INSET_SETTINGS: {
488 UpdatableInset * inset = view()->theLockingInset();
493 // get the innermost inset
494 inset = inset->getLockingInset();
496 // jump back to owner if an InsetText, so
497 // we get back to the InsetTabular or whatever
498 if (inset->lyxCode() == Inset::TEXT_CODE)
499 inset = inset->owner();
501 Inset::Code code = inset->lyxCode();
503 case Inset::TABULAR_CODE:
504 disable = ev.argument != "tabular";
506 case Inset::ERT_CODE:
507 disable = ev.argument != "ert";
509 case Inset::FLOAT_CODE:
510 disable = ev.argument != "float";
512 case Inset::MINIPAGE_CODE:
513 disable = ev.argument != "minipage";
515 case Inset::WRAP_CODE:
516 disable = ev.argument != "wrap";
518 case Inset::NOTE_CODE:
519 disable = ev.argument != "note";
527 case LFUN_MATH_MUTATE:
529 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
530 flag.setOnOff(false);
535 // we just need to be in math mode to enable that
537 case LFUN_MATH_SPACE:
538 case LFUN_MATH_LIMITS:
539 case LFUN_MATH_NONUMBER:
540 case LFUN_MATH_NUMBER:
541 case LFUN_MATH_EXTERN:
542 disable = !mathcursor;
545 case LFUN_DIALOG_SHOW: {
546 string const name = ev.getArg(0);
548 disable = !(name == "aboutlyx" ||
551 name == "preferences" ||
556 if (name == "print") {
557 disable = !Exporter::IsExportable(buf, "dvi") ||
558 lyxrc.print_command == "none";
559 } else if (name == "character") {
560 UpdatableInset * tli = view()->theLockingInset();
561 disable = tli && tli->lyxCode() == Inset::ERT_CODE;
562 } else if (name == "vclog") {
563 disable = !buf->lyxvc.inUse();
564 } else if (name == "latexlog") {
565 disable = !IsFileReadable(buf->getLogName().second);
574 // the functions which insert insets
575 Inset::Code code = Inset::NO_CODE;
577 case LFUN_DIALOG_SHOW_NEW_INSET:
578 if (ev.argument == "bibitem")
579 code = Inset::BIBITEM_CODE;
580 else if (ev.argument == "bibtex")
581 code = Inset::BIBTEX_CODE;
582 else if (ev.argument == "citation")
583 code = Inset::CITE_CODE;
584 else if (ev.argument == "ert")
585 code = Inset::ERT_CODE;
586 else if (ev.argument == "external")
587 code = Inset::EXTERNAL_CODE;
588 else if (ev.argument == "float")
589 code = Inset::FLOAT_CODE;
590 else if (ev.argument == "graphics")
591 code = Inset::GRAPHICS_CODE;
592 else if (ev.argument == "include")
593 code = Inset::INCLUDE_CODE;
594 else if (ev.argument == "index")
595 code = Inset::INDEX_CODE;
596 else if (ev.argument == "label")
597 code = Inset::LABEL_CODE;
598 else if (ev.argument == "minipage")
599 code = Inset::MINIPAGE_CODE;
600 else if (ev.argument == "ref")
601 code = Inset::REF_CODE;
602 else if (ev.argument == "toc")
603 code = Inset::TOC_CODE;
604 else if (ev.argument == "url")
605 code = Inset::URL_CODE;
606 else if (ev.argument == "wrap")
607 code = Inset::WRAP_CODE;
611 code = Inset::ERT_CODE;
613 case LFUN_INSET_FOOTNOTE:
614 code = Inset::FOOT_CODE;
616 case LFUN_TABULAR_INSERT:
617 code = Inset::TABULAR_CODE;
619 case LFUN_INSET_MARGINAL:
620 code = Inset::MARGIN_CODE;
622 case LFUN_INSET_MINIPAGE:
623 code = Inset::MINIPAGE_CODE;
625 case LFUN_INSET_FLOAT:
626 case LFUN_INSET_WIDE_FLOAT:
627 code = Inset::FLOAT_CODE;
629 case LFUN_INSET_WRAP:
630 code = Inset::WRAP_CODE;
632 case LFUN_FLOAT_LIST:
633 code = Inset::FLOAT_LIST_CODE;
636 case LFUN_INSET_LIST:
637 code = Inset::LIST_CODE;
639 case LFUN_INSET_THEOREM:
640 code = Inset::THEOREM_CODE;
643 case LFUN_INSET_CAPTION:
644 code = Inset::CAPTION_CODE;
646 case LFUN_INSERT_NOTE:
647 code = Inset::NOTE_CODE;
649 case LFUN_INSERT_LABEL:
650 code = Inset::LABEL_CODE;
652 case LFUN_INSET_OPTARG:
653 code = Inset::OPTARG_CODE;
655 case LFUN_ENVIRONMENT_INSERT:
656 code = Inset::MINIPAGE_CODE;
658 case LFUN_INDEX_INSERT:
659 code = Inset::INDEX_CODE;
661 case LFUN_INDEX_PRINT:
662 code = Inset::INDEX_PRINT_CODE;
664 case LFUN_TOC_INSERT:
665 code = Inset::TOC_CODE;
669 code = Inset::URL_CODE;
672 // always allow this, since we will inset a raw quote
673 // if an inset is not allowed.
675 case LFUN_HYPHENATION:
676 case LFUN_LIGATURE_BREAK:
678 case LFUN_MENU_SEPARATOR:
680 case LFUN_END_OF_SENTENCE:
681 code = Inset::SPECIALCHAR_CODE;
683 case LFUN_SPACE_INSERT:
684 // slight hack: we know this is allowed in math mode
686 code = Inset::SPACE_CODE;
691 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code))
697 // A few general toggles
699 case LFUN_TOOLTIPS_TOGGLE:
700 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
703 case LFUN_READ_ONLY_TOGGLE:
704 flag.setOnOff(buf->isReadonly());
707 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
709 case LFUN_SWITCHBUFFER:
710 // toggle on the current buffer, but do not toggle off
711 // the other ones (is that a good idea?)
712 if (ev.argument == buf->fileName())
715 case LFUN_TRACK_CHANGES:
716 flag.setOnOff(buf->params.tracking_changes);
722 // the font related toggles
724 LyXFont const & font = TEXT(false)->real_current_font;
727 flag.setOnOff(font.emph() == LyXFont::ON);
730 flag.setOnOff(font.noun() == LyXFont::ON);
733 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
736 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
739 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
742 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
748 string tc = mathcursor->getLastCode();
751 flag.setOnOff(tc == "mathbf");
754 flag.setOnOff(tc == "mathsf");
757 flag.setOnOff(tc == "mathcal");
760 flag.setOnOff(tc == "mathrm");
763 flag.setOnOff(tc == "mathtt");
766 flag.setOnOff(tc == "mathbb");
769 flag.setOnOff(tc == "mathnormal");
776 // this one is difficult to get right. As a half-baked
777 // solution, we consider only the first action of the sequence
778 if (ev.action == LFUN_SEQUENCE) {
779 // argument contains ';'-terminated commands
780 flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
787 void LyXFunc::dispatch(string const & s, bool verbose)
789 int const action = lyxaction.LookupFunc(s);
791 if (action == LFUN_UNKNOWN_ACTION) {
792 owner->message(bformat(_("Unknown function (%1$s)"), s));
796 dispatch(action, verbose);
800 void LyXFunc::dispatch(int ac, bool verbose)
802 dispatch(lyxaction.retrieveActionArg(ac), verbose);
806 bool ensureBufferClean(BufferView * bv) {
808 Buffer & buf = *bv->buffer();
812 string const file = MakeDisplayPath(buf.fileName(), 30);
813 string text = bformat(_("The document %1$s has unsaved "
814 "changes.\n\nDo you want to save "
815 "the document?"), file);
816 int const ret = Alert::prompt(_("Save changed document?"),
817 text, 0, 1, _("&Save"),
821 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
823 return buf.isClean();
827 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
829 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
830 <<"] arg[" << ev.argument << ']' << endl;
832 // we have not done anything wrong yet.
834 dispatch_buffer.erase();
836 #ifdef NEW_DISPATCHER
837 // We try do call the most specific dispatcher first:
838 // 1. the lockinginset's dispatch
839 // 2. the bufferview's dispatch
840 // 3. the lyxview's dispatch
843 selection_possible = false;
845 string argument = ev.argument;
846 kb_action action = ev.action;
848 // We cannot use this function here
849 if (getStatus(ev).disabled()) {
850 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
851 << lyxaction.getActionName(action)
852 << " [" << action << "] is disabled at this location"
854 setErrorMessage(getStatusMessage());
855 goto exit_with_message;
858 if (view()->available())
859 view()->hideCursor();
861 if (view()->available() && view()->theLockingInset()) {
862 Inset::RESULT result;
863 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
864 (!keyseq.deleted())))
866 UpdatableInset * inset = view()->theLockingInset();
870 inset->getCursorPos(view(), inset_x, dummy_y);
872 if ((action == LFUN_UNKNOWN_ACTION)
873 && argument.empty()) {
874 argument = encoded_last_key;
877 // the insets can't try to handle this,
878 // a table cell in the dummy position will
879 // lock its insettext, the insettext will
880 // pass it the bufferview, and succeed,
881 // so it will stay not locked. Not good
882 // if we've just done LFUN_ESCAPE (which
883 // injects an LFUN_PARAGRAPH_UPDATE)
884 if (action == LFUN_PARAGRAPH_UPDATE) {
885 view()->dispatch(ev);
886 goto exit_with_message;
889 // Undo/Redo is a bit tricky for insets.
890 if (action == LFUN_UNDO) {
892 goto exit_with_message;
893 } else if (action == LFUN_REDO) {
895 goto exit_with_message;
896 } else if (((result=inset->
897 // Hand-over to inset's own dispatch:
898 localDispatch(FuncRequest(view(), action, argument))) ==
900 (result == DISPATCHED_NOUPDATE))
901 goto exit_with_message;
902 // If UNDISPATCHED, just soldier on
903 else if (result == FINISHED) {
904 owner->clearMessage();
905 goto exit_with_message;
906 // We do not need special RTL handling here:
907 // FINISHED means that the cursor should be
908 // one position after the inset.
909 } else if (result == FINISHED_RIGHT) {
910 TEXT()->cursorRight(view());
911 moveCursorUpdate(true, false);
912 owner->clearMessage();
913 goto exit_with_message;
914 } else if (result == FINISHED_UP) {
915 RowList::iterator const irow = TEXT()->cursorIRow();
916 if (irow != TEXT()->rows().begin()) {
918 TEXT()->setCursorFromCoordinates(
919 TEXT()->cursor.ix() + inset_x,
920 TEXT()->cursor.iy() -
921 irow->baseline() - 1);
922 TEXT()->cursor.x_fix(TEXT()->cursor.x());
924 TEXT()->cursorUp(view());
926 moveCursorUpdate(true, false);
928 view()->update(TEXT(), BufferView::SELECT);
930 owner->clearMessage();
931 goto exit_with_message;
932 } else if (result == FINISHED_DOWN) {
933 RowList::iterator const irow = TEXT()->cursorIRow();
934 if (boost::next(irow) != TEXT()->rows().end()) {
936 TEXT()->setCursorFromCoordinates(
937 TEXT()->cursor.ix() + inset_x,
938 TEXT()->cursor.iy() -
941 TEXT()->cursor.x_fix(TEXT()->cursor.x());
943 TEXT()->cursorDown(view());
946 TEXT()->cursorRight(view());
948 moveCursorUpdate(true, false);
949 owner->clearMessage();
950 goto exit_with_message;
952 #warning I am not sure this is still right, please have a look! (Jug 20020417)
953 else { // result == UNDISPATCHED
954 //setMessage(N_("Text mode"));
956 case LFUN_UNKNOWN_ACTION:
957 case LFUN_BREAKPARAGRAPH:
959 TEXT()->cursorRight(view());
960 view()->switchKeyMap();
961 owner->view_state_changed();
964 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
965 TEXT()->cursorRight(view());
966 moveCursorUpdate(true, false);
967 owner->view_state_changed();
969 goto exit_with_message;
971 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
972 TEXT()->cursorRight(view());
973 moveCursorUpdate(true, false);
974 owner->view_state_changed();
976 goto exit_with_message;
978 if (boost::next(TEXT()->cursorRow()) != TEXT()->rows().end())
979 TEXT()->cursorDown(view());
981 TEXT()->cursorRight(view());
982 moveCursorUpdate(true, false);
983 owner->view_state_changed();
984 goto exit_with_message;
996 if (!view()->available()) break;
997 // this function should be used always [asierra060396]
998 UpdatableInset * tli =
999 view()->theLockingInset();
1001 UpdatableInset * lock = tli->getLockingInset();
1004 view()->unlockInset(tli);
1005 TEXT()->cursorRight(view());
1006 moveCursorUpdate(true, false);
1007 owner->view_state_changed();
1009 tli->unlockInsetInInset(view(),
1014 // Tell the paragraph dialog that we changed paragraph
1015 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1020 // --- Misc -------------------------------------------
1021 case LFUN_WORDFINDFORWARD :
1022 case LFUN_WORDFINDBACKWARD : {
1023 static string last_search;
1024 string searched_string;
1026 if (!argument.empty()) {
1027 last_search = argument;
1028 searched_string = argument;
1030 searched_string = last_search;
1032 bool fw = (action == LFUN_WORDFINDFORWARD);
1033 if (!searched_string.empty()) {
1034 lyxfind::LyXFind(view(), searched_string, fw);
1041 if (view()->available() && !view()->theLockingInset()) {
1042 view()->update(TEXT(), BufferView::SELECT);
1044 owner->message(keyseq.printOptions());
1048 // --- Misc -------------------------------------------
1049 case LFUN_EXEC_COMMAND:
1050 owner->focus_command_buffer();
1053 case LFUN_CANCEL: // RVDK_PATCH_5
1055 meta_fake_bit = key_modifier::none;
1056 if (view()->available())
1057 // cancel any selection
1058 dispatch(LFUN_MARK_OFF);
1059 setMessage(N_("Cancel"));
1062 case LFUN_META_FAKE: // RVDK_PATCH_5
1064 meta_fake_bit = key_modifier::alt;
1065 setMessage(keyseq.print());
1069 case LFUN_READ_ONLY_TOGGLE:
1070 if (owner->buffer()->lyxvc.inUse()) {
1071 owner->buffer()->lyxvc.toggleReadOnly();
1073 owner->buffer()->setReadonly(
1074 !owner->buffer()->isReadonly());
1078 case LFUN_CENTER: // this is center and redraw.
1082 // --- Menus -----------------------------------------------
1084 menuNew(argument, false);
1087 case LFUN_MENUNEWTMPLT:
1088 menuNew(argument, true);
1091 case LFUN_CLOSEBUFFER:
1095 case LFUN_MENUWRITE:
1096 if (!owner->buffer()->isUnnamed()) {
1097 string const str = bformat(_("Saving document %1$s..."),
1098 MakeDisplayPath(owner->buffer()->fileName()));
1099 owner->message(str);
1100 MenuWrite(owner->buffer());
1101 owner->message(str + _(" done."));
1103 WriteAs(owner->buffer());
1107 WriteAs(owner->buffer(), argument);
1110 case LFUN_MENURELOAD: {
1111 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1112 string text = bformat(_("Any changes will be lost. Are you sure "
1113 "you want to revert to the saved version of the document %1$s?"), file);
1114 int const ret = Alert::prompt(_("Revert to saved document?"),
1115 text, 0, 1, _("&Revert"), _("&Cancel"));
1123 Exporter::Export(owner->buffer(), argument, true);
1124 view()->showErrorList(BufferFormat(*owner->buffer()));
1128 Exporter::Preview(owner->buffer(), argument);
1129 view()->showErrorList(BufferFormat(*owner->buffer()));
1132 case LFUN_BUILDPROG:
1133 Exporter::Export(owner->buffer(), "program", true);
1134 view()->showErrorList(_("Build"));
1137 case LFUN_RUNCHKTEX:
1138 owner->buffer()->runChktex();
1139 view()->showErrorList(_("ChkTeX"));
1143 if (argument == "custom")
1144 owner->getDialogs().showSendto();
1146 Exporter::Export(owner->buffer(), argument, false);
1147 view()->showErrorList(BufferFormat(*owner->buffer()));
1161 InsetCommandParams p("tableofcontents");
1162 string const data = InsetCommandMailer::params2string("toc", p);
1163 owner->getDialogs().show("toc", data, 0);
1179 case LFUN_DEPTH_MIN:
1180 changeDepth(view(), TEXT(false), DEC_DEPTH, false);
1181 owner->view_state_changed();
1184 case LFUN_DEPTH_PLUS:
1185 changeDepth(view(), TEXT(false), INC_DEPTH, false);
1186 owner->view_state_changed();
1189 case LFUN_FREEFONT_APPLY:
1190 apply_freefont(view());
1193 case LFUN_FREEFONT_UPDATE:
1194 update_and_apply_freefont(view(), argument);
1197 case LFUN_RECONFIGURE:
1198 Reconfigure(view());
1202 case LFUN_FLOATSOPERATE:
1203 if (argument == "openfoot")
1204 view()->allFloats(1,0);
1205 else if (argument == "closefoot")
1206 view()->allFloats(0,0);
1207 else if (argument == "openfig")
1208 view()->allFloats(1,1);
1209 else if (argument == "closefig")
1210 view()->allFloats(0,1);
1213 #ifdef WITH_WARNINGS
1214 //#warning Find another implementation here (or another lyxfunc)!
1217 case LFUN_HELP_OPEN:
1219 string const arg = argument;
1221 setErrorMessage(N_("Missing argument"));
1224 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1225 if (fname.empty()) {
1226 lyxerr << "LyX: unable to find documentation file `"
1227 << arg << "'. Bad installation?" << endl;
1230 owner->message(bformat(_("Opening help file %1$s..."),
1231 MakeDisplayPath(fname)));
1232 view()->loadLyXFile(fname, false);
1236 // --- version control -------------------------------
1237 case LFUN_VC_REGISTER:
1239 if (!ensureBufferClean(view()))
1241 if (!owner->buffer()->lyxvc.inUse()) {
1242 owner->buffer()->lyxvc.registrer();
1248 case LFUN_VC_CHECKIN:
1250 if (!ensureBufferClean(view()))
1252 if (owner->buffer()->lyxvc.inUse()
1253 && !owner->buffer()->isReadonly()) {
1254 owner->buffer()->lyxvc.checkIn();
1260 case LFUN_VC_CHECKOUT:
1262 if (!ensureBufferClean(view()))
1264 if (owner->buffer()->lyxvc.inUse()
1265 && owner->buffer()->isReadonly()) {
1266 owner->buffer()->lyxvc.checkOut();
1272 case LFUN_VC_REVERT:
1274 owner->buffer()->lyxvc.revert();
1281 owner->buffer()->lyxvc.undoLast();
1286 // --- buffers ----------------------------------------
1288 case LFUN_SWITCHBUFFER:
1289 view()->buffer(bufferlist.getBuffer(argument));
1293 NewFile(view(), argument);
1296 case LFUN_FILE_OPEN:
1300 case LFUN_LAYOUT_TABULAR:
1301 if (view()->theLockingInset()) {
1302 if (view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1303 InsetTabular * inset = static_cast<InsetTabular *>
1304 (view()->theLockingInset());
1305 inset->openLayoutDialog(view());
1306 } else if (view()->theLockingInset()->
1307 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1308 InsetTabular * inset = static_cast<InsetTabular *>(
1309 view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1310 inset->openLayoutDialog(view());
1315 case LFUN_DROP_LAYOUTS_CHOICE:
1316 owner->getToolbar().openLayoutList();
1319 case LFUN_MENU_OPEN_BY_NAME:
1320 owner->getMenubar().openByName(argument);
1321 break; // RVDK_PATCH_5
1323 // --- lyxserver commands ----------------------------
1327 setMessage(owner->buffer()->fileName());
1328 lyxerr[Debug::INFO] << "FNAME["
1329 << owner->buffer()->fileName()
1335 dispatch_buffer = keyseq.print();
1336 lyxserver->notifyClient(dispatch_buffer);
1340 case LFUN_GOTOFILEROW:
1344 istringstream istr(argument.c_str());
1345 istr >> file_name >> row;
1346 // Must replace extension of the file to be .lyx and get full path
1347 string const s(ChangeExtension(file_name, ".lyx"));
1349 // Either change buffer or load the file
1350 if (bufferlist.exists(s)) {
1351 view()->buffer(bufferlist.getBuffer(s));
1353 view()->loadLyXFile(s);
1356 view()->setCursorFromRow(row);
1359 // see BufferView_pimpl::center()
1360 view()->updateScrollbar();
1364 case LFUN_GOTO_PARAGRAPH:
1366 istringstream istr(argument.c_str());
1370 ParIterator par = owner->buffer()->getParFromID(id);
1371 if (par == owner->buffer()->par_iterator_end()) {
1372 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1373 << id << ']' << endl;
1376 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1377 << " found." << endl;
1380 if (view()->theLockingInset())
1381 view()->unlockInset(view()->theLockingInset());
1382 if (par->inInset()) {
1383 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1384 par->inInset()->localDispatch(cmd);
1387 view()->getLyXText()->setCursor(par.pit(), 0);
1388 view()->switchKeyMap();
1389 owner->view_state_changed();
1392 // see BufferView_pimpl::center()
1393 view()->updateScrollbar();
1397 // --- insert characters ----------------------------------------
1399 // --- Mathed stuff. If we are here, there is no locked inset yet.
1400 case LFUN_MATH_EXTERN:
1401 case LFUN_MATH_NUMBER:
1402 case LFUN_MATH_NONUMBER:
1403 case LFUN_MATH_LIMITS:
1405 setErrorMessage(N_("This is only allowed in math mode!"));
1409 // passthrough hat and underscore outside mathed:
1410 case LFUN_SUBSCRIPT:
1411 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1413 case LFUN_SUPERSCRIPT:
1414 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1417 case LFUN_DIALOG_SHOW: {
1418 string const name = ev.getArg(0);
1419 string data = trim(ev.argument.substr(name.size()));
1421 if (name == "character") {
1422 data = freefont2string();
1424 owner->getDialogs().show("character", data);
1425 } else if (name == "document")
1426 owner->getDialogs().showDocument();
1427 else if (name == "findreplace")
1428 owner->getDialogs().showSearch();
1429 else if (name == "forks")
1430 owner->getDialogs().showForks();
1431 else if (name == "preamble")
1432 owner->getDialogs().showPreamble();
1433 else if (name == "preferences")
1434 owner->getDialogs().showPreferences();
1435 else if (name == "print")
1436 owner->getDialogs().showPrint();
1437 else if (name == "spellchecker")
1438 owner->getDialogs().showSpellchecker();
1440 owner->getDialogs().show(name, data);
1444 case LFUN_DIALOG_SHOW_NEW_INSET: {
1445 string const & name = argument;
1447 if (name == "bibitem" ||
1449 name == "include" ||
1454 InsetCommandParams p(name);
1455 data = InsetCommandMailer::params2string(name, p);
1456 } else if (name == "citation") {
1457 InsetCommandParams p("cite");
1458 data = InsetCommandMailer::params2string(name, p);
1460 owner->getDialogs().show(name, data, 0);
1464 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1468 case LFUN_DIALOG_UPDATE: {
1469 string const & name = argument;
1470 // Can only update a dialog connected to an existing inset
1471 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1473 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1475 inset->localDispatch(fr);
1476 } else if (name == "paragraph") {
1477 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1482 case LFUN_DIALOG_HIDE:
1483 Dialogs::hide(argument, 0);
1486 case LFUN_DIALOG_DISCONNECT_INSET:
1487 owner->getDialogs().disconnect(argument);
1490 case LFUN_CHILDOPEN:
1492 string const filename =
1493 MakeAbsPath(argument,
1494 owner->buffer()->filePath());
1495 setMessage(N_("Opening child document ") +
1496 MakeDisplayPath(filename) + "...");
1497 view()->savePosition(0);
1498 if (bufferlist.exists(filename))
1499 view()->buffer(bufferlist.getBuffer(filename));
1501 view()->loadLyXFile(filename);
1505 case LFUN_TOGGLECURSORFOLLOW:
1506 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1510 owner->getIntl().KeyMapOn(false);
1513 case LFUN_KMAP_PRIM:
1514 owner->getIntl().KeyMapPrim();
1518 owner->getIntl().KeyMapSec();
1521 case LFUN_KMAP_TOGGLE:
1522 owner->getIntl().ToggleKeyMap();
1527 // argument contains ';'-terminated commands
1528 while (!argument.empty()) {
1530 argument = split(argument, first, ';');
1536 case LFUN_SAVEPREFERENCES:
1538 Path p(user_lyxdir);
1539 lyxrc.write("preferences");
1543 case LFUN_SCREEN_FONT_UPDATE:
1545 // handle the screen font changes.
1546 lyxrc.set_font_norm_type();
1547 lyx_gui::update_fonts();
1548 // We also need to empty the textcache so that
1549 // the buffer will be formatted correctly after
1552 // Of course we should only do the resize and the textcache.clear
1553 // if values really changed...but not very important right now. (Lgb)
1554 // All visible buffers will need resize
1560 case LFUN_SET_COLOR:
1563 string const x11_name = split(argument, lyx_name, ' ');
1564 if (lyx_name.empty() || x11_name.empty()) {
1565 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1570 bool const graphicsbg_changed =
1571 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1572 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1574 if (!lcolor.setColor(lyx_name, x11_name)) {
1576 bformat(_("Set-color \"%1$s\" failed "
1577 "- color is undefined or "
1578 "may not be redefined"), lyx_name));
1582 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1584 if (graphicsbg_changed) {
1585 #ifdef WITH_WARNINGS
1586 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1589 lyx::graphics::GCache & gc =
1590 lyx::graphics::GCache::get();
1591 gc.changeDisplay(true);
1600 owner->message(argument);
1603 case LFUN_FORKS_KILL:
1605 if (!isStrInt(argument))
1608 pid_t const pid = strToInt(argument);
1609 ForkedcallsController & fcc = ForkedcallsController::get();
1614 case LFUN_TOOLTIPS_TOGGLE:
1615 owner->getDialogs().toggleTooltips();
1618 case LFUN_EXTERNAL_EDIT: {
1620 .localDispatch(FuncRequest(view(), action, argument));
1625 // Then if it was none of the above
1626 // Trying the BufferView::pimpl dispatch:
1627 if (!view()->dispatch(ev))
1628 lyxerr << "A truly unknown func ["
1629 << lyxaction.getActionName(ev.action) << "]!"
1636 view()->owner()->updateLayoutChoice();
1638 if (view()->available()) {
1639 view()->fitCursor();
1641 // If we executed a mutating lfun, mark the buffer as dirty
1642 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1643 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1644 view()->buffer()->markDirty();
1647 sendDispatchMessage(getMessage(), ev, verbose);
1651 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1653 owner->updateMenubar();
1654 owner->updateToolbar();
1656 if (ev.action == LFUN_SELFINSERT || !verbose) {
1657 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1659 owner->message(msg);
1663 string dispatch_msg = msg;
1664 if (!dispatch_msg.empty())
1665 dispatch_msg += ' ';
1667 string comname = lyxaction.getActionName(ev.action);
1669 int pseudoaction = ev.action;
1670 bool argsadded = false;
1672 if (!ev.argument.empty()) {
1673 // the pseudoaction is useful for the bindings
1674 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1676 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1677 pseudoaction = ev.action;
1679 comname += ' ' + ev.argument;
1684 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1686 if (!shortcuts.empty()) {
1687 comname += ": " + shortcuts;
1688 } else if (!argsadded && !ev.argument.empty()) {
1689 comname += ' ' + ev.argument;
1692 if (!comname.empty()) {
1693 comname = rtrim(comname);
1694 dispatch_msg += '(' + comname + ')';
1697 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1698 if (!dispatch_msg.empty())
1699 owner->message(dispatch_msg);
1703 void LyXFunc::setupLocalKeymap()
1705 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1706 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1710 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1712 string initpath = lyxrc.document_path;
1713 string filename(name);
1715 if (view()->available()) {
1716 string const trypath = owner->buffer()->filePath();
1717 // If directory is writeable, use this as default.
1718 if (IsDirWriteable(trypath))
1722 static int newfile_number;
1724 if (filename.empty()) {
1725 filename = AddName(lyxrc.document_path,
1726 "newfile" + tostr(++newfile_number) + ".lyx");
1727 FileInfo fi(filename);
1728 while (bufferlist.exists(filename) || fi.readable()) {
1730 filename = AddName(lyxrc.document_path,
1731 "newfile" + tostr(newfile_number) +
1733 fi.newFile(filename);
1737 // The template stuff
1740 FileDialog fileDlg(_("Select template file"),
1741 LFUN_SELECT_FILE_SYNC,
1742 make_pair(string(_("Documents|#o#O")),
1743 string(lyxrc.document_path)),
1744 make_pair(string(_("Templates|#T#t")),
1745 string(lyxrc.template_path)));
1747 FileDialog::Result result =
1748 fileDlg.open(lyxrc.template_path,
1749 _("*.lyx| LyX Documents (*.lyx)"));
1751 if (result.first == FileDialog::Later)
1754 string const fname = result.second;
1761 view()->newFile(filename, templname, !name.empty());
1765 void LyXFunc::open(string const & fname)
1767 string initpath = lyxrc.document_path;
1769 if (view()->available()) {
1770 string const trypath = owner->buffer()->filePath();
1771 // If directory is writeable, use this as default.
1772 if (IsDirWriteable(trypath))
1778 if (fname.empty()) {
1779 FileDialog fileDlg(_("Select document to open"),
1781 make_pair(string(_("Documents|#o#O")),
1782 string(lyxrc.document_path)),
1783 make_pair(string(_("Examples|#E#e")),
1784 string(AddPath(system_lyxdir, "examples"))));
1786 FileDialog::Result result =
1787 fileDlg.open(initpath,
1788 _("*.lyx| LyX Documents (*.lyx)"));
1790 if (result.first == FileDialog::Later)
1793 filename = result.second;
1795 // check selected filename
1796 if (filename.empty()) {
1797 owner->message(_("Canceled."));
1803 // get absolute path of file and add ".lyx" to the filename if
1805 string const fullpath = FileSearch(string(), filename, "lyx");
1806 if (!fullpath.empty()) {
1807 filename = fullpath;
1810 string const disp_fn(MakeDisplayPath(filename));
1812 // if the file doesn't exist, let the user create one
1813 FileInfo const f(filename, true);
1815 // the user specifically chose this name. Believe them.
1816 view()->newFile(filename, "", true);
1820 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1823 if (view()->loadLyXFile(filename)) {
1824 str2 = bformat(_("Document %1$s opened."), disp_fn);
1826 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1828 owner->message(str2);
1832 void LyXFunc::doImport(string const & argument)
1835 string filename = split(argument, format, ' ');
1837 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1838 << " file: " << filename << endl;
1840 // need user interaction
1841 if (filename.empty()) {
1842 string initpath = lyxrc.document_path;
1844 if (view()->available()) {
1845 string const trypath = owner->buffer()->filePath();
1846 // If directory is writeable, use this as default.
1847 if (IsDirWriteable(trypath))
1851 string const text = bformat(_("Select %1$s file to import"),
1852 formats.prettyName(format));
1854 FileDialog fileDlg(text,
1856 make_pair(string(_("Documents|#o#O")),
1857 string(lyxrc.document_path)),
1858 make_pair(string(_("Examples|#E#e")),
1859 string(AddPath(system_lyxdir, "examples"))));
1861 string const extension = "*." + formats.extension(format)
1862 + "| " + formats.prettyName(format)
1863 + " (*." + formats.extension(format) + ')';
1865 FileDialog::Result result = fileDlg.open(initpath,
1868 if (result.first == FileDialog::Later)
1871 filename = result.second;
1873 // check selected filename
1874 if (filename.empty())
1875 owner->message(_("Canceled."));
1878 if (filename.empty())
1881 // get absolute path of file
1882 filename = MakeAbsPath(filename);
1884 string const lyxfile = ChangeExtension(filename, ".lyx");
1886 // Check if the document already is open
1887 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1888 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1889 owner->message(_("Canceled."));
1894 // if the file exists already, and we didn't do
1895 // -i lyx thefile.lyx, warn
1896 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1897 string const file = MakeDisplayPath(lyxfile, 30);
1899 string text = bformat(_("The document %1$s already exists.\n\n"
1900 "Do you want to over-write that document?"), file);
1901 int const ret = Alert::prompt(_("Over-write document?"),
1902 text, 0, 1, _("&Over-write"), _("&Cancel"));
1905 owner->message(_("Canceled."));
1910 Importer::Import(owner, filename, format);
1914 void LyXFunc::closeBuffer()
1916 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1917 if (bufferlist.empty()) {
1918 // need this otherwise SEGV may occur while
1919 // trying to set variables that don't exist
1920 // since there's no current buffer
1921 owner->getDialogs().hideBufferDependent();
1923 view()->buffer(bufferlist.first());
1929 // Each "owner" should have it's own message method. lyxview and
1930 // the minibuffer would use the minibuffer, but lyxserver would
1931 // send an ERROR signal to its client. Alejandro 970603
1932 // This func is bit problematic when it comes to NLS, to make the
1933 // lyx servers client be language indepenent we must not translate
1934 // strings sent to this func.
1935 void LyXFunc::setErrorMessage(string const & m) const
1937 dispatch_buffer = m;
1942 void LyXFunc::setMessage(string const & m) const
1944 dispatch_buffer = m;
1948 void LyXFunc::setStatusMessage(string const & m) const
1954 string const LyXFunc::view_status_message()
1956 // When meta-fake key is pressed, show the key sequence so far + "M-".
1958 return keyseq.print() + "M-";
1961 // Else, when a non-complete key sequence is pressed,
1962 // show the available options.
1963 if (keyseq.length() > 0 && !keyseq.deleted()) {
1964 return keyseq.printOptions();
1967 if (!view()->available())
1968 return _("Welcome to LyX!");
1970 return currentState(view());
1974 BufferView * LyXFunc::view() const
1977 return owner->view().get();