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() != InsetOld::TABULAR_CODE) {
339 in = tli->getFirstLockingInsetOfType(InsetOld::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() != InsetOld::TABULAR_CODE
358 && !tli->getFirstLockingInsetOfType(InsetOld::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 InsetOld * 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() == InsetOld::TABULAR_CODE) {
426 ret = static_cast<InsetTabular *>(tli)
427 ->getStatus(ev.argument);
430 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
431 ret = static_cast<InsetTabular *>
432 (tli->getFirstLockingInsetOfType(InsetOld::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() == InsetOld::TEXT_CODE)
499 inset = inset->owner();
501 InsetOld::Code code = inset->lyxCode();
503 case InsetOld::TABULAR_CODE:
504 disable = ev.argument != "tabular";
506 case InsetOld::ERT_CODE:
507 disable = ev.argument != "ert";
509 case InsetOld::FLOAT_CODE:
510 disable = ev.argument != "float";
512 case InsetOld::MINIPAGE_CODE:
513 disable = ev.argument != "minipage";
515 case InsetOld::WRAP_CODE:
516 disable = ev.argument != "wrap";
518 case InsetOld::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() == InsetOld::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 InsetOld::Code code = InsetOld::NO_CODE;
577 case LFUN_DIALOG_SHOW_NEW_INSET:
578 if (ev.argument == "bibitem")
579 code = InsetOld::BIBITEM_CODE;
580 else if (ev.argument == "bibtex")
581 code = InsetOld::BIBTEX_CODE;
582 else if (ev.argument == "citation")
583 code = InsetOld::CITE_CODE;
584 else if (ev.argument == "ert")
585 code = InsetOld::ERT_CODE;
586 else if (ev.argument == "external")
587 code = InsetOld::EXTERNAL_CODE;
588 else if (ev.argument == "float")
589 code = InsetOld::FLOAT_CODE;
590 else if (ev.argument == "graphics")
591 code = InsetOld::GRAPHICS_CODE;
592 else if (ev.argument == "include")
593 code = InsetOld::INCLUDE_CODE;
594 else if (ev.argument == "index")
595 code = InsetOld::INDEX_CODE;
596 else if (ev.argument == "label")
597 code = InsetOld::LABEL_CODE;
598 else if (ev.argument == "minipage")
599 code = InsetOld::MINIPAGE_CODE;
600 else if (ev.argument == "ref")
601 code = InsetOld::REF_CODE;
602 else if (ev.argument == "toc")
603 code = InsetOld::TOC_CODE;
604 else if (ev.argument == "url")
605 code = InsetOld::URL_CODE;
606 else if (ev.argument == "wrap")
607 code = InsetOld::WRAP_CODE;
611 code = InsetOld::ERT_CODE;
613 case LFUN_INSET_FOOTNOTE:
614 code = InsetOld::FOOT_CODE;
616 case LFUN_TABULAR_INSERT:
617 code = InsetOld::TABULAR_CODE;
619 case LFUN_INSET_MARGINAL:
620 code = InsetOld::MARGIN_CODE;
622 case LFUN_INSET_MINIPAGE:
623 code = InsetOld::MINIPAGE_CODE;
625 case LFUN_INSET_FLOAT:
626 case LFUN_INSET_WIDE_FLOAT:
627 code = InsetOld::FLOAT_CODE;
629 case LFUN_INSET_WRAP:
630 code = InsetOld::WRAP_CODE;
632 case LFUN_FLOAT_LIST:
633 code = InsetOld::FLOAT_LIST_CODE;
636 case LFUN_INSET_LIST:
637 code = InsetOld::LIST_CODE;
639 case LFUN_INSET_THEOREM:
640 code = InsetOld::THEOREM_CODE;
643 case LFUN_INSET_CAPTION:
644 code = InsetOld::CAPTION_CODE;
646 case LFUN_INSERT_NOTE:
647 code = InsetOld::NOTE_CODE;
649 case LFUN_INSERT_LABEL:
650 code = InsetOld::LABEL_CODE;
652 case LFUN_INSET_OPTARG:
653 code = InsetOld::OPTARG_CODE;
655 case LFUN_ENVIRONMENT_INSERT:
656 code = InsetOld::MINIPAGE_CODE;
658 case LFUN_INDEX_INSERT:
659 code = InsetOld::INDEX_CODE;
661 case LFUN_INDEX_PRINT:
662 code = InsetOld::INDEX_PRINT_CODE;
664 case LFUN_TOC_INSERT:
665 code = InsetOld::TOC_CODE;
669 code = InsetOld::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 = InsetOld::SPECIALCHAR_CODE;
683 case LFUN_SPACE_INSERT:
684 // slight hack: we know this is allowed in math mode
686 code = InsetOld::SPACE_CODE;
691 if (code != InsetOld::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();
829 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
831 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
832 <<"] arg[" << ev.argument << ']' << endl;
834 // we have not done anything wrong yet.
836 dispatch_buffer.erase();
838 #ifdef NEW_DISPATCHER
839 // We try do call the most specific dispatcher first:
840 // 1. the lockinginset's dispatch
841 // 2. the bufferview's dispatch
842 // 3. the lyxview's dispatch
845 selection_possible = false;
847 string argument = ev.argument;
848 kb_action action = ev.action;
850 // We cannot use this function here
851 if (getStatus(ev).disabled()) {
852 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
853 << lyxaction.getActionName(action)
854 << " [" << action << "] is disabled at this location"
856 setErrorMessage(getStatusMessage());
857 goto exit_with_message;
860 if (view()->available())
861 view()->hideCursor();
863 if (view()->available() && view()->theLockingInset()) {
864 InsetOld::RESULT result;
865 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
866 (!keyseq.deleted())))
868 UpdatableInset * inset = view()->theLockingInset();
872 inset->getCursorPos(view(), inset_x, dummy_y);
874 if ((action == LFUN_UNKNOWN_ACTION)
875 && argument.empty()) {
876 argument = encoded_last_key;
879 // the insets can't try to handle this,
880 // a table cell in the dummy position will
881 // lock its insettext, the insettext will
882 // pass it the bufferview, and succeed,
883 // so it will stay not locked. Not good
884 // if we've just done LFUN_ESCAPE (which
885 // injects an LFUN_PARAGRAPH_UPDATE)
886 if (action == LFUN_PARAGRAPH_UPDATE) {
887 view()->dispatch(ev);
888 goto exit_with_message;
891 // Undo/Redo is a bit tricky for insets.
892 if (action == LFUN_UNDO) {
894 goto exit_with_message;
895 } else if (action == LFUN_REDO) {
897 goto exit_with_message;
898 } else if (((result=inset->
899 // Hand-over to inset's own dispatch:
900 localDispatch(FuncRequest(view(), action, argument))) ==
902 (result == DISPATCHED_NOUPDATE))
903 goto exit_with_message;
904 // If UNDISPATCHED, just soldier on
905 else if (result == FINISHED) {
906 owner->clearMessage();
907 goto exit_with_message;
908 // We do not need special RTL handling here:
909 // FINISHED means that the cursor should be
910 // one position after the inset.
911 } else if (result == FINISHED_RIGHT) {
912 TEXT()->cursorRight(view());
913 moveCursorUpdate(true, false);
914 owner->clearMessage();
915 goto exit_with_message;
916 } else if (result == FINISHED_UP) {
917 RowList::iterator const irow = TEXT()->cursorIRow();
918 if (irow != TEXT()->rows().begin()) {
920 TEXT()->setCursorFromCoordinates(
921 TEXT()->cursor.ix() + inset_x,
922 TEXT()->cursor.iy() -
923 irow->baseline() - 1);
924 TEXT()->cursor.x_fix(TEXT()->cursor.x());
926 TEXT()->cursorUp(view());
928 moveCursorUpdate(true, false);
930 view()->update(TEXT(), BufferView::SELECT);
932 owner->clearMessage();
933 goto exit_with_message;
934 } else if (result == FINISHED_DOWN) {
935 RowList::iterator const irow = TEXT()->cursorIRow();
936 if (boost::next(irow) != TEXT()->rows().end()) {
938 TEXT()->setCursorFromCoordinates(
939 TEXT()->cursor.ix() + inset_x,
940 TEXT()->cursor.iy() -
943 TEXT()->cursor.x_fix(TEXT()->cursor.x());
945 TEXT()->cursorDown(view());
948 TEXT()->cursorRight(view());
950 moveCursorUpdate(true, false);
951 owner->clearMessage();
952 goto exit_with_message;
954 #warning I am not sure this is still right, please have a look! (Jug 20020417)
955 else { // result == UNDISPATCHED
956 //setMessage(N_("Text mode"));
958 case LFUN_UNKNOWN_ACTION:
959 case LFUN_BREAKPARAGRAPH:
961 TEXT()->cursorRight(view());
962 view()->switchKeyMap();
963 owner->view_state_changed();
966 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
967 TEXT()->cursorRight(view());
968 moveCursorUpdate(true, false);
969 owner->view_state_changed();
971 goto exit_with_message;
973 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
974 TEXT()->cursorRight(view());
975 moveCursorUpdate(true, false);
976 owner->view_state_changed();
978 goto exit_with_message;
980 if (boost::next(TEXT()->cursorRow()) != TEXT()->rows().end())
981 TEXT()->cursorDown(view());
983 TEXT()->cursorRight(view());
984 moveCursorUpdate(true, false);
985 owner->view_state_changed();
986 goto exit_with_message;
998 if (!view()->available()) break;
999 // this function should be used always [asierra060396]
1000 UpdatableInset * tli =
1001 view()->theLockingInset();
1003 UpdatableInset * lock = tli->getLockingInset();
1006 view()->unlockInset(tli);
1007 TEXT()->cursorRight(view());
1008 moveCursorUpdate(true, false);
1009 owner->view_state_changed();
1011 tli->unlockInsetInInset(view(),
1016 // Tell the paragraph dialog that we changed paragraph
1017 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1022 // --- Misc -------------------------------------------
1023 case LFUN_WORDFINDFORWARD :
1024 case LFUN_WORDFINDBACKWARD : {
1025 static string last_search;
1026 string searched_string;
1028 if (!argument.empty()) {
1029 last_search = argument;
1030 searched_string = argument;
1032 searched_string = last_search;
1034 bool fw = (action == LFUN_WORDFINDFORWARD);
1035 if (!searched_string.empty()) {
1036 lyx::find::find(view(), searched_string, fw);
1043 if (view()->available() && !view()->theLockingInset()) {
1044 view()->update(TEXT(), BufferView::SELECT);
1046 owner->message(keyseq.printOptions());
1050 // --- Misc -------------------------------------------
1051 case LFUN_EXEC_COMMAND:
1052 owner->focus_command_buffer();
1055 case LFUN_CANCEL: // RVDK_PATCH_5
1057 meta_fake_bit = key_modifier::none;
1058 if (view()->available())
1059 // cancel any selection
1060 dispatch(LFUN_MARK_OFF);
1061 setMessage(N_("Cancel"));
1064 case LFUN_META_FAKE: // RVDK_PATCH_5
1066 meta_fake_bit = key_modifier::alt;
1067 setMessage(keyseq.print());
1071 case LFUN_READ_ONLY_TOGGLE:
1072 if (owner->buffer()->lyxvc.inUse()) {
1073 owner->buffer()->lyxvc.toggleReadOnly();
1075 owner->buffer()->setReadonly(
1076 !owner->buffer()->isReadonly());
1080 case LFUN_CENTER: // this is center and redraw.
1084 // --- Menus -----------------------------------------------
1086 menuNew(argument, false);
1089 case LFUN_MENUNEWTMPLT:
1090 menuNew(argument, true);
1093 case LFUN_CLOSEBUFFER:
1097 case LFUN_MENUWRITE:
1098 if (!owner->buffer()->isUnnamed()) {
1099 string const str = bformat(_("Saving document %1$s..."),
1100 MakeDisplayPath(owner->buffer()->fileName()));
1101 owner->message(str);
1102 MenuWrite(owner->buffer());
1103 owner->message(str + _(" done."));
1105 WriteAs(owner->buffer());
1109 WriteAs(owner->buffer(), argument);
1112 case LFUN_MENURELOAD: {
1113 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1114 string text = bformat(_("Any changes will be lost. Are you sure "
1115 "you want to revert to the saved version of the document %1$s?"), file);
1116 int const ret = Alert::prompt(_("Revert to saved document?"),
1117 text, 0, 1, _("&Revert"), _("&Cancel"));
1125 Exporter::Export(owner->buffer(), argument, true);
1126 view()->showErrorList(BufferFormat(*owner->buffer()));
1130 Exporter::Preview(owner->buffer(), argument);
1131 view()->showErrorList(BufferFormat(*owner->buffer()));
1134 case LFUN_BUILDPROG:
1135 Exporter::Export(owner->buffer(), "program", true);
1136 view()->showErrorList(_("Build"));
1139 case LFUN_RUNCHKTEX:
1140 owner->buffer()->runChktex();
1141 view()->showErrorList(_("ChkTeX"));
1145 if (argument == "custom")
1146 owner->getDialogs().showSendto();
1148 Exporter::Export(owner->buffer(), argument, false);
1149 view()->showErrorList(BufferFormat(*owner->buffer()));
1163 InsetCommandParams p("tableofcontents");
1164 string const data = InsetCommandMailer::params2string("toc", p);
1165 owner->getDialogs().show("toc", data, 0);
1181 case LFUN_DEPTH_MIN:
1182 changeDepth(view(), TEXT(false), DEC_DEPTH, false);
1183 owner->view_state_changed();
1186 case LFUN_DEPTH_PLUS:
1187 changeDepth(view(), TEXT(false), INC_DEPTH, false);
1188 owner->view_state_changed();
1191 case LFUN_FREEFONT_APPLY:
1192 apply_freefont(view());
1195 case LFUN_FREEFONT_UPDATE:
1196 update_and_apply_freefont(view(), argument);
1199 case LFUN_RECONFIGURE:
1200 Reconfigure(view());
1204 case LFUN_FLOATSOPERATE:
1205 if (argument == "openfoot")
1206 view()->allFloats(1,0);
1207 else if (argument == "closefoot")
1208 view()->allFloats(0,0);
1209 else if (argument == "openfig")
1210 view()->allFloats(1,1);
1211 else if (argument == "closefig")
1212 view()->allFloats(0,1);
1215 #ifdef WITH_WARNINGS
1216 //#warning Find another implementation here (or another lyxfunc)!
1219 case LFUN_HELP_OPEN:
1221 string const arg = argument;
1223 setErrorMessage(N_("Missing argument"));
1226 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1227 if (fname.empty()) {
1228 lyxerr << "LyX: unable to find documentation file `"
1229 << arg << "'. Bad installation?" << endl;
1232 owner->message(bformat(_("Opening help file %1$s..."),
1233 MakeDisplayPath(fname)));
1234 view()->loadLyXFile(fname, false);
1238 // --- version control -------------------------------
1239 case LFUN_VC_REGISTER:
1241 if (!ensureBufferClean(view()))
1243 if (!owner->buffer()->lyxvc.inUse()) {
1244 owner->buffer()->lyxvc.registrer();
1250 case LFUN_VC_CHECKIN:
1252 if (!ensureBufferClean(view()))
1254 if (owner->buffer()->lyxvc.inUse()
1255 && !owner->buffer()->isReadonly()) {
1256 owner->buffer()->lyxvc.checkIn();
1262 case LFUN_VC_CHECKOUT:
1264 if (!ensureBufferClean(view()))
1266 if (owner->buffer()->lyxvc.inUse()
1267 && owner->buffer()->isReadonly()) {
1268 owner->buffer()->lyxvc.checkOut();
1274 case LFUN_VC_REVERT:
1276 owner->buffer()->lyxvc.revert();
1283 owner->buffer()->lyxvc.undoLast();
1288 // --- buffers ----------------------------------------
1290 case LFUN_SWITCHBUFFER:
1291 view()->buffer(bufferlist.getBuffer(argument));
1295 NewFile(view(), argument);
1298 case LFUN_FILE_OPEN:
1302 case LFUN_LAYOUT_TABULAR:
1303 if (view()->theLockingInset()) {
1304 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1305 InsetTabular * inset = static_cast<InsetTabular *>
1306 (view()->theLockingInset());
1307 inset->openLayoutDialog(view());
1308 } else if (view()->theLockingInset()->
1309 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1310 InsetTabular * inset = static_cast<InsetTabular *>(
1311 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1312 inset->openLayoutDialog(view());
1317 case LFUN_DROP_LAYOUTS_CHOICE:
1318 owner->getToolbar().openLayoutList();
1321 case LFUN_MENU_OPEN_BY_NAME:
1322 owner->getMenubar().openByName(argument);
1323 break; // RVDK_PATCH_5
1325 // --- lyxserver commands ----------------------------
1329 setMessage(owner->buffer()->fileName());
1330 lyxerr[Debug::INFO] << "FNAME["
1331 << owner->buffer()->fileName()
1337 dispatch_buffer = keyseq.print();
1338 lyxserver->notifyClient(dispatch_buffer);
1342 case LFUN_GOTOFILEROW:
1346 istringstream istr(argument.c_str());
1347 istr >> file_name >> row;
1348 // Must replace extension of the file to be .lyx and get full path
1349 string const s(ChangeExtension(file_name, ".lyx"));
1351 // Either change buffer or load the file
1352 if (bufferlist.exists(s)) {
1353 view()->buffer(bufferlist.getBuffer(s));
1355 view()->loadLyXFile(s);
1358 view()->setCursorFromRow(row);
1361 // see BufferView_pimpl::center()
1362 view()->updateScrollbar();
1366 case LFUN_GOTO_PARAGRAPH:
1368 istringstream istr(argument.c_str());
1372 ParIterator par = owner->buffer()->getParFromID(id);
1373 if (par == owner->buffer()->par_iterator_end()) {
1374 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1375 << id << ']' << endl;
1378 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1379 << " found." << endl;
1382 if (view()->theLockingInset())
1383 view()->unlockInset(view()->theLockingInset());
1384 if (par->inInset()) {
1385 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1386 par->inInset()->localDispatch(cmd);
1389 view()->getLyXText()->setCursor(par.pit(), 0);
1390 view()->switchKeyMap();
1391 owner->view_state_changed();
1394 // see BufferView_pimpl::center()
1395 view()->updateScrollbar();
1399 // --- insert characters ----------------------------------------
1401 // --- Mathed stuff. If we are here, there is no locked inset yet.
1402 case LFUN_MATH_EXTERN:
1403 case LFUN_MATH_NUMBER:
1404 case LFUN_MATH_NONUMBER:
1405 case LFUN_MATH_LIMITS:
1407 setErrorMessage(N_("This is only allowed in math mode!"));
1411 // passthrough hat and underscore outside mathed:
1412 case LFUN_SUBSCRIPT:
1413 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1415 case LFUN_SUPERSCRIPT:
1416 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1419 case LFUN_DIALOG_SHOW: {
1420 string const name = ev.getArg(0);
1421 string data = trim(ev.argument.substr(name.size()));
1423 if (name == "character") {
1424 data = freefont2string();
1426 owner->getDialogs().show("character", data);
1427 } else if (name == "document")
1428 owner->getDialogs().showDocument();
1429 else if (name == "findreplace")
1430 owner->getDialogs().showSearch();
1431 else if (name == "forks")
1432 owner->getDialogs().showForks();
1433 else if (name == "preamble")
1434 owner->getDialogs().showPreamble();
1435 else if (name == "preferences")
1436 owner->getDialogs().showPreferences();
1437 else if (name == "print")
1438 owner->getDialogs().showPrint();
1439 else if (name == "spellchecker")
1440 owner->getDialogs().showSpellchecker();
1442 owner->getDialogs().show(name, data);
1446 case LFUN_DIALOG_SHOW_NEW_INSET: {
1447 string const & name = argument;
1449 if (name == "bibitem" ||
1451 name == "include" ||
1456 InsetCommandParams p(name);
1457 data = InsetCommandMailer::params2string(name, p);
1458 } else if (name == "citation") {
1459 InsetCommandParams p("cite");
1460 data = InsetCommandMailer::params2string(name, p);
1462 owner->getDialogs().show(name, data, 0);
1466 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1470 case LFUN_DIALOG_UPDATE: {
1471 string const & name = argument;
1472 // Can only update a dialog connected to an existing inset
1473 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1475 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1477 inset->localDispatch(fr);
1478 } else if (name == "paragraph") {
1479 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1484 case LFUN_DIALOG_HIDE:
1485 Dialogs::hide(argument, 0);
1488 case LFUN_DIALOG_DISCONNECT_INSET:
1489 owner->getDialogs().disconnect(argument);
1492 case LFUN_CHILDOPEN:
1494 string const filename =
1495 MakeAbsPath(argument,
1496 owner->buffer()->filePath());
1497 setMessage(N_("Opening child document ") +
1498 MakeDisplayPath(filename) + "...");
1499 view()->savePosition(0);
1500 if (bufferlist.exists(filename))
1501 view()->buffer(bufferlist.getBuffer(filename));
1503 view()->loadLyXFile(filename);
1507 case LFUN_TOGGLECURSORFOLLOW:
1508 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1512 owner->getIntl().KeyMapOn(false);
1515 case LFUN_KMAP_PRIM:
1516 owner->getIntl().KeyMapPrim();
1520 owner->getIntl().KeyMapSec();
1523 case LFUN_KMAP_TOGGLE:
1524 owner->getIntl().ToggleKeyMap();
1529 // argument contains ';'-terminated commands
1530 while (!argument.empty()) {
1532 argument = split(argument, first, ';');
1538 case LFUN_SAVEPREFERENCES:
1540 Path p(user_lyxdir);
1541 lyxrc.write("preferences");
1545 case LFUN_SCREEN_FONT_UPDATE:
1547 // handle the screen font changes.
1548 lyxrc.set_font_norm_type();
1549 lyx_gui::update_fonts();
1550 // We also need to empty the textcache so that
1551 // the buffer will be formatted correctly after
1554 // Of course we should only do the resize and the textcache.clear
1555 // if values really changed...but not very important right now. (Lgb)
1556 // All visible buffers will need resize
1562 case LFUN_SET_COLOR:
1565 string const x11_name = split(argument, lyx_name, ' ');
1566 if (lyx_name.empty() || x11_name.empty()) {
1567 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1572 bool const graphicsbg_changed =
1573 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1574 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1576 if (!lcolor.setColor(lyx_name, x11_name)) {
1578 bformat(_("Set-color \"%1$s\" failed "
1579 "- color is undefined or "
1580 "may not be redefined"), lyx_name));
1584 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1586 if (graphicsbg_changed) {
1587 #ifdef WITH_WARNINGS
1588 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1591 lyx::graphics::GCache & gc =
1592 lyx::graphics::GCache::get();
1593 gc.changeDisplay(true);
1602 owner->message(argument);
1605 case LFUN_FORKS_KILL:
1607 if (!isStrInt(argument))
1610 pid_t const pid = strToInt(argument);
1611 ForkedcallsController & fcc = ForkedcallsController::get();
1616 case LFUN_TOOLTIPS_TOGGLE:
1617 owner->getDialogs().toggleTooltips();
1620 case LFUN_EXTERNAL_EDIT: {
1622 .localDispatch(FuncRequest(view(), action, argument));
1627 // Then if it was none of the above
1628 // Trying the BufferView::pimpl dispatch:
1629 if (!view()->dispatch(ev))
1630 lyxerr << "A truly unknown func ["
1631 << lyxaction.getActionName(ev.action) << "]!"
1638 view()->owner()->updateLayoutChoice();
1640 if (view()->available()) {
1641 view()->fitCursor();
1643 // If we executed a mutating lfun, mark the buffer as dirty
1644 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1645 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1646 view()->buffer()->markDirty();
1649 sendDispatchMessage(getMessage(), ev, verbose);
1653 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1655 owner->updateMenubar();
1656 owner->updateToolbar();
1658 if (ev.action == LFUN_SELFINSERT || !verbose) {
1659 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1661 owner->message(msg);
1665 string dispatch_msg = msg;
1666 if (!dispatch_msg.empty())
1667 dispatch_msg += ' ';
1669 string comname = lyxaction.getActionName(ev.action);
1671 int pseudoaction = ev.action;
1672 bool argsadded = false;
1674 if (!ev.argument.empty()) {
1675 // the pseudoaction is useful for the bindings
1676 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1678 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1679 pseudoaction = ev.action;
1681 comname += ' ' + ev.argument;
1686 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1688 if (!shortcuts.empty()) {
1689 comname += ": " + shortcuts;
1690 } else if (!argsadded && !ev.argument.empty()) {
1691 comname += ' ' + ev.argument;
1694 if (!comname.empty()) {
1695 comname = rtrim(comname);
1696 dispatch_msg += '(' + comname + ')';
1699 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1700 if (!dispatch_msg.empty())
1701 owner->message(dispatch_msg);
1705 void LyXFunc::setupLocalKeymap()
1707 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1708 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1712 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1714 string initpath = lyxrc.document_path;
1715 string filename(name);
1717 if (view()->available()) {
1718 string const trypath = owner->buffer()->filePath();
1719 // If directory is writeable, use this as default.
1720 if (IsDirWriteable(trypath))
1724 static int newfile_number;
1726 if (filename.empty()) {
1727 filename = AddName(lyxrc.document_path,
1728 "newfile" + tostr(++newfile_number) + ".lyx");
1729 FileInfo fi(filename);
1730 while (bufferlist.exists(filename) || fi.readable()) {
1732 filename = AddName(lyxrc.document_path,
1733 "newfile" + tostr(newfile_number) +
1735 fi.newFile(filename);
1739 // The template stuff
1742 FileDialog fileDlg(_("Select template file"),
1743 LFUN_SELECT_FILE_SYNC,
1744 make_pair(string(_("Documents|#o#O")),
1745 string(lyxrc.document_path)),
1746 make_pair(string(_("Templates|#T#t")),
1747 string(lyxrc.template_path)));
1749 FileDialog::Result result =
1750 fileDlg.open(lyxrc.template_path,
1751 _("*.lyx| LyX Documents (*.lyx)"));
1753 if (result.first == FileDialog::Later)
1756 string const fname = result.second;
1763 view()->newFile(filename, templname, !name.empty());
1767 void LyXFunc::open(string const & fname)
1769 string initpath = lyxrc.document_path;
1771 if (view()->available()) {
1772 string const trypath = owner->buffer()->filePath();
1773 // If directory is writeable, use this as default.
1774 if (IsDirWriteable(trypath))
1780 if (fname.empty()) {
1781 FileDialog fileDlg(_("Select document to open"),
1783 make_pair(string(_("Documents|#o#O")),
1784 string(lyxrc.document_path)),
1785 make_pair(string(_("Examples|#E#e")),
1786 string(AddPath(system_lyxdir, "examples"))));
1788 FileDialog::Result result =
1789 fileDlg.open(initpath,
1790 _("*.lyx| LyX Documents (*.lyx)"));
1792 if (result.first == FileDialog::Later)
1795 filename = result.second;
1797 // check selected filename
1798 if (filename.empty()) {
1799 owner->message(_("Canceled."));
1805 // get absolute path of file and add ".lyx" to the filename if
1807 string const fullpath = FileSearch(string(), filename, "lyx");
1808 if (!fullpath.empty()) {
1809 filename = fullpath;
1812 string const disp_fn(MakeDisplayPath(filename));
1814 // if the file doesn't exist, let the user create one
1815 FileInfo const f(filename, true);
1817 // the user specifically chose this name. Believe them.
1818 view()->newFile(filename, "", true);
1822 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1825 if (view()->loadLyXFile(filename)) {
1826 str2 = bformat(_("Document %1$s opened."), disp_fn);
1828 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1830 owner->message(str2);
1834 void LyXFunc::doImport(string const & argument)
1837 string filename = split(argument, format, ' ');
1839 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1840 << " file: " << filename << endl;
1842 // need user interaction
1843 if (filename.empty()) {
1844 string initpath = lyxrc.document_path;
1846 if (view()->available()) {
1847 string const trypath = owner->buffer()->filePath();
1848 // If directory is writeable, use this as default.
1849 if (IsDirWriteable(trypath))
1853 string const text = bformat(_("Select %1$s file to import"),
1854 formats.prettyName(format));
1856 FileDialog fileDlg(text,
1858 make_pair(string(_("Documents|#o#O")),
1859 string(lyxrc.document_path)),
1860 make_pair(string(_("Examples|#E#e")),
1861 string(AddPath(system_lyxdir, "examples"))));
1863 string const extension = "*." + formats.extension(format)
1864 + "| " + formats.prettyName(format)
1865 + " (*." + formats.extension(format) + ')';
1867 FileDialog::Result result = fileDlg.open(initpath,
1870 if (result.first == FileDialog::Later)
1873 filename = result.second;
1875 // check selected filename
1876 if (filename.empty())
1877 owner->message(_("Canceled."));
1880 if (filename.empty())
1883 // get absolute path of file
1884 filename = MakeAbsPath(filename);
1886 string const lyxfile = ChangeExtension(filename, ".lyx");
1888 // Check if the document already is open
1889 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1890 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1891 owner->message(_("Canceled."));
1896 // if the file exists already, and we didn't do
1897 // -i lyx thefile.lyx, warn
1898 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1899 string const file = MakeDisplayPath(lyxfile, 30);
1901 string text = bformat(_("The document %1$s already exists.\n\n"
1902 "Do you want to over-write that document?"), file);
1903 int const ret = Alert::prompt(_("Over-write document?"),
1904 text, 0, 1, _("&Over-write"), _("&Cancel"));
1907 owner->message(_("Canceled."));
1912 Importer::Import(owner, filename, format);
1916 void LyXFunc::closeBuffer()
1918 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1919 if (bufferlist.empty()) {
1920 // need this otherwise SEGV may occur while
1921 // trying to set variables that don't exist
1922 // since there's no current buffer
1923 owner->getDialogs().hideBufferDependent();
1925 view()->buffer(bufferlist.first());
1931 // Each "owner" should have it's own message method. lyxview and
1932 // the minibuffer would use the minibuffer, but lyxserver would
1933 // send an ERROR signal to its client. Alejandro 970603
1934 // This func is bit problematic when it comes to NLS, to make the
1935 // lyx servers client be language indepenent we must not translate
1936 // strings sent to this func.
1937 void LyXFunc::setErrorMessage(string const & m) const
1939 dispatch_buffer = m;
1944 void LyXFunc::setMessage(string const & m) const
1946 dispatch_buffer = m;
1950 void LyXFunc::setStatusMessage(string const & m) const
1956 string const LyXFunc::view_status_message()
1958 // When meta-fake key is pressed, show the key sequence so far + "M-".
1960 return keyseq.print() + "M-";
1963 // Else, when a non-complete key sequence is pressed,
1964 // show the available options.
1965 if (keyseq.length() > 0 && !keyseq.deleted()) {
1966 return keyseq.printOptions();
1969 if (!view()->available())
1970 return _("Welcome to LyX!");
1972 return currentState(view());
1976 BufferView * LyXFunc::view() const
1979 return owner->view().get();