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/path_defines.h"
72 #include "support/lyxfunctional.h"
82 using namespace lyx::support;
90 using std::back_inserter;
91 using namespace bv_funcs;
93 extern BufferList bufferlist;
94 extern LyXServer * lyxserver;
95 extern bool selection_possible;
97 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
100 extern tex_accent_struct get_accent(kb_action action);
102 extern void ShowLatexLog();
105 LyXFunc::LyXFunc(LyXView * o)
108 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
109 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
110 meta_fake_bit(key_modifier::none)
116 LyXText * LyXFunc::TEXT(bool flag = true) const
120 return view()->getLyXText();
125 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
127 if (selecting || TEXT(flag)->selection.mark()) {
128 TEXT(flag)->setSelection();
129 if (!TEXT(flag)->isInInset())
132 view()->update(TEXT(flag), BufferView::SELECT);
134 view()->switchKeyMap();
138 void LyXFunc::handleKeyFunc(kb_action action)
140 char c = encoded_last_key;
142 if (keyseq.length()) {
146 owner->getIntl().getTransManager()
147 .deadkey(c, get_accent(action).accent, TEXT(false));
148 // Need to clear, in case the minibuffer calls these
151 // copied verbatim from do_accent_char
152 view()->update(TEXT(false), BufferView::SELECT);
153 TEXT(false)->selection.cursor = TEXT(false)->cursor;
157 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
158 key_modifier::state state)
162 if (lyxerr.debugging(Debug::KEY)) {
163 lyxerr << "KeySym is "
164 << keysym->getSymbolName()
168 // Do nothing if we have nothing (JMarc)
169 if (!keysym->isOK()) {
170 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
175 if (keysym->isModifier()) {
176 lyxerr[Debug::KEY] << "isModifier true" << endl;
180 Encoding const * encoding = view()->getEncoding();
182 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
184 // Do a one-deep top-level lookup for
185 // cancel and meta-fake keys. RVDK_PATCH_5
186 cancel_meta_seq.reset();
188 int action = cancel_meta_seq.addkey(keysym, state);
189 lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
191 // When not cancel or meta-fake, do the normal lookup.
192 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
193 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
194 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
195 // remove Caps Lock and Mod2 as a modifiers
196 action = keyseq.addkey(keysym, (state | meta_fake_bit));
197 lyxerr[Debug::KEY] << "action now set to ["
198 << action << ']' << endl;
201 // Dont remove this unless you know what you are doing.
202 meta_fake_bit = key_modifier::none;
204 // can this happen now ?
205 if (action == LFUN_NOACTION) {
206 action = LFUN_PREFIX;
209 if (lyxerr.debugging(Debug::KEY)) {
210 lyxerr << "Key [action="
212 << keyseq.print() << ']'
216 // already here we know if it any point in going further
217 // why not return already here if action == -1 and
218 // num_bytes == 0? (Lgb)
220 if (keyseq.length() > 1) {
221 owner->message(keyseq.print());
225 // Maybe user can only reach the key via holding down shift.
226 // Let's see. But only if shift is the only modifier
227 if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
228 lyxerr[Debug::KEY] << "Trying without shift" << endl;
229 action = keyseq.addkey(keysym, key_modifier::none);
230 lyxerr[Debug::KEY] << "Action now " << action << endl;
233 if (action == LFUN_UNKNOWN_ACTION) {
234 // Hmm, we didn't match any of the keysequences. See
235 // if it's normal insertable text not already covered
237 if (keysym->isText() && keyseq.length() == 1) {
238 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
239 action = LFUN_SELFINSERT;
241 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
242 owner->message(_("Unknown function."));
247 if (action == LFUN_SELFINSERT) {
248 if (encoded_last_key != 0) {
250 arg += encoded_last_key;
252 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
254 lyxerr[Debug::KEY] << "SelfInsert arg[`"
255 << argument << "']" << endl;
263 FuncStatus LyXFunc::getStatus(int ac) const
265 return getStatus(lyxaction.retrieveActionArg(ac));
269 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
272 Buffer * buf = owner->buffer();
274 if (ev.action == LFUN_NOACTION) {
275 setStatusMessage(N_("Nothing to do"));
276 return flag.disabled(true);
280 case LFUN_UNKNOWN_ACTION:
281 #ifndef HAVE_LIBAIKSAURUS
282 case LFUN_THESAURUS_ENTRY:
287 flag |= lyx_gui::getStatus(ev);
290 if (flag.unknown()) {
291 setStatusMessage(N_("Unknown action"));
295 // the default error message if we disable the command
296 setStatusMessage(N_("Command disabled"));
298 // Check whether we need a buffer
299 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
300 // Yes we need a buffer, do we have one?
303 // Can we use a readonly buffer?
304 if (buf->isReadonly() &&
305 !lyxaction.funcHasFlag(ev.action,
306 LyXAction::ReadOnly)) {
308 setStatusMessage(N_("Document is read-only"));
313 setStatusMessage(N_("Command not allowed with"
314 "out any document open"));
315 return flag.disabled(true);
319 UpdatableInset * tli = view()->theLockingInset();
321 // I would really like to avoid having this switch and rather try to
322 // encode this in the function itself.
323 bool disable = false;
326 disable = ev.argument != "custom"
327 && !Exporter::IsExportable(buf, ev.argument);
330 disable = buf->undostack.empty();
333 disable = buf->redostack.empty();
338 UpdatableInset * in = tli;
339 if (in->lyxCode() != InsetOld::TABULAR_CODE) {
340 in = tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE);
342 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
347 disable = !mathcursor && !view()->getLyXText()->selection.set();
350 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
353 disable = !Exporter::IsExportable(buf, "program");
356 case LFUN_LAYOUT_TABULAR:
358 || (tli->lyxCode() != InsetOld::TABULAR_CODE
359 && !tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
363 disable = !changeDepth(view(), TEXT(false), DEC_DEPTH, true);
366 case LFUN_DEPTH_PLUS:
367 disable = !changeDepth(view(), TEXT(false), INC_DEPTH, true);
371 case LFUN_LAYOUT_PARAGRAPH: {
372 InsetOld * inset = TEXT(false)->cursor.par()->inInset();
373 disable = inset && inset->forceDefaultParagraphs(inset);
377 case LFUN_INSET_OPTARG:
378 disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
381 case LFUN_TABULAR_FEATURE:
384 // FIXME: check temporarily disabled
386 char align = mathcursor->valign();
391 if (ev.argument.empty()) {
395 if (!contains("tcb", ev.argument[0])) {
399 flag.setOnOff(ev.argument[0] == align);
403 char align = mathcursor->halign();
408 if (ev.argument.empty()) {
412 if (!contains("lcr", ev.argument[0])) {
416 flag.setOnOff(ev.argument[0] == align);
419 disable = !mathcursor->halign();
425 //ret.disabled(true);
426 if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
427 ret = static_cast<InsetTabular *>(tli)
428 ->getStatus(ev.argument);
431 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
432 ret = static_cast<InsetTabular *>
433 (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
434 ->getStatus(ev.argument);
441 static InsetTabular inset(*owner->buffer(), 1, 1);
445 ret = inset.getStatus(ev.argument);
446 if (ret.onoff(true) || ret.onoff(false))
447 flag.setOnOff(false);
451 case LFUN_VC_REGISTER:
452 disable = buf->lyxvc.inUse();
454 case LFUN_VC_CHECKIN:
455 disable = !buf->lyxvc.inUse() || buf->isReadonly();
457 case LFUN_VC_CHECKOUT:
458 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
462 disable = !buf->lyxvc.inUse();
464 case LFUN_MENURELOAD:
465 disable = buf->isUnnamed() || buf->isClean();
467 case LFUN_BOOKMARK_GOTO:
469 isSavedPosition(strToUnsignedInt(ev.argument));
471 case LFUN_MERGE_CHANGES:
472 case LFUN_ACCEPT_CHANGE:
473 case LFUN_REJECT_CHANGE:
474 case LFUN_ACCEPT_ALL_CHANGES:
475 case LFUN_REJECT_ALL_CHANGES:
476 disable = !buf->params.tracking_changes;
478 case LFUN_INSET_TOGGLE: {
479 LyXText * lt = view()->getLyXText();
480 disable = !(isEditableInset(lt->getInset())
482 && lt->inset_owner->owner()
483 && lt->inset_owner->owner()->isOpen()));
487 case LFUN_INSET_SETTINGS: {
489 UpdatableInset * inset = view()->theLockingInset();
494 // get the innermost inset
495 inset = inset->getLockingInset();
497 // jump back to owner if an InsetText, so
498 // we get back to the InsetTabular or whatever
499 if (inset->lyxCode() == InsetOld::TEXT_CODE)
500 inset = inset->owner();
502 InsetOld::Code code = inset->lyxCode();
504 case InsetOld::TABULAR_CODE:
505 disable = ev.argument != "tabular";
507 case InsetOld::ERT_CODE:
508 disable = ev.argument != "ert";
510 case InsetOld::FLOAT_CODE:
511 disable = ev.argument != "float";
513 case InsetOld::MINIPAGE_CODE:
514 disable = ev.argument != "minipage";
516 case InsetOld::WRAP_CODE:
517 disable = ev.argument != "wrap";
519 case InsetOld::NOTE_CODE:
520 disable = ev.argument != "note";
528 case LFUN_MATH_MUTATE:
530 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
531 flag.setOnOff(false);
536 // we just need to be in math mode to enable that
538 case LFUN_MATH_SPACE:
539 case LFUN_MATH_LIMITS:
540 case LFUN_MATH_NONUMBER:
541 case LFUN_MATH_NUMBER:
542 case LFUN_MATH_EXTERN:
543 disable = !mathcursor;
546 case LFUN_DIALOG_SHOW: {
547 string const name = ev.getArg(0);
549 disable = !(name == "aboutlyx" ||
552 name == "preferences" ||
557 if (name == "print") {
558 disable = !Exporter::IsExportable(buf, "dvi") ||
559 lyxrc.print_command == "none";
560 } else if (name == "character") {
561 UpdatableInset * tli = view()->theLockingInset();
562 disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
563 } else if (name == "vclog") {
564 disable = !buf->lyxvc.inUse();
565 } else if (name == "latexlog") {
566 disable = !IsFileReadable(buf->getLogName().second);
575 // the functions which insert insets
576 InsetOld::Code code = InsetOld::NO_CODE;
578 case LFUN_DIALOG_SHOW_NEW_INSET:
579 if (ev.argument == "bibitem")
580 code = InsetOld::BIBITEM_CODE;
581 else if (ev.argument == "bibtex")
582 code = InsetOld::BIBTEX_CODE;
583 else if (ev.argument == "citation")
584 code = InsetOld::CITE_CODE;
585 else if (ev.argument == "ert")
586 code = InsetOld::ERT_CODE;
587 else if (ev.argument == "external")
588 code = InsetOld::EXTERNAL_CODE;
589 else if (ev.argument == "float")
590 code = InsetOld::FLOAT_CODE;
591 else if (ev.argument == "graphics")
592 code = InsetOld::GRAPHICS_CODE;
593 else if (ev.argument == "include")
594 code = InsetOld::INCLUDE_CODE;
595 else if (ev.argument == "index")
596 code = InsetOld::INDEX_CODE;
597 else if (ev.argument == "label")
598 code = InsetOld::LABEL_CODE;
599 else if (ev.argument == "minipage")
600 code = InsetOld::MINIPAGE_CODE;
601 else if (ev.argument == "ref")
602 code = InsetOld::REF_CODE;
603 else if (ev.argument == "toc")
604 code = InsetOld::TOC_CODE;
605 else if (ev.argument == "url")
606 code = InsetOld::URL_CODE;
607 else if (ev.argument == "wrap")
608 code = InsetOld::WRAP_CODE;
612 code = InsetOld::ERT_CODE;
614 case LFUN_INSET_FOOTNOTE:
615 code = InsetOld::FOOT_CODE;
617 case LFUN_TABULAR_INSERT:
618 code = InsetOld::TABULAR_CODE;
620 case LFUN_INSET_MARGINAL:
621 code = InsetOld::MARGIN_CODE;
623 case LFUN_INSET_MINIPAGE:
624 code = InsetOld::MINIPAGE_CODE;
626 case LFUN_INSET_FLOAT:
627 case LFUN_INSET_WIDE_FLOAT:
628 code = InsetOld::FLOAT_CODE;
630 case LFUN_INSET_WRAP:
631 code = InsetOld::WRAP_CODE;
633 case LFUN_FLOAT_LIST:
634 code = InsetOld::FLOAT_LIST_CODE;
637 case LFUN_INSET_LIST:
638 code = InsetOld::LIST_CODE;
640 case LFUN_INSET_THEOREM:
641 code = InsetOld::THEOREM_CODE;
644 case LFUN_INSET_CAPTION:
645 code = InsetOld::CAPTION_CODE;
647 case LFUN_INSERT_NOTE:
648 code = InsetOld::NOTE_CODE;
650 case LFUN_INSERT_LABEL:
651 code = InsetOld::LABEL_CODE;
653 case LFUN_INSET_OPTARG:
654 code = InsetOld::OPTARG_CODE;
656 case LFUN_ENVIRONMENT_INSERT:
657 code = InsetOld::MINIPAGE_CODE;
659 case LFUN_INDEX_INSERT:
660 code = InsetOld::INDEX_CODE;
662 case LFUN_INDEX_PRINT:
663 code = InsetOld::INDEX_PRINT_CODE;
665 case LFUN_TOC_INSERT:
666 code = InsetOld::TOC_CODE;
670 code = InsetOld::URL_CODE;
673 // always allow this, since we will inset a raw quote
674 // if an inset is not allowed.
676 case LFUN_HYPHENATION:
677 case LFUN_LIGATURE_BREAK:
679 case LFUN_MENU_SEPARATOR:
681 case LFUN_END_OF_SENTENCE:
682 code = InsetOld::SPECIALCHAR_CODE;
684 case LFUN_SPACE_INSERT:
685 // slight hack: we know this is allowed in math mode
687 code = InsetOld::SPACE_CODE;
692 if (code != InsetOld::NO_CODE && tli && !tli->insetAllowed(code))
698 // A few general toggles
700 case LFUN_TOOLTIPS_TOGGLE:
701 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
704 case LFUN_READ_ONLY_TOGGLE:
705 flag.setOnOff(buf->isReadonly());
708 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
710 case LFUN_SWITCHBUFFER:
711 // toggle on the current buffer, but do not toggle off
712 // the other ones (is that a good idea?)
713 if (ev.argument == buf->fileName())
716 case LFUN_TRACK_CHANGES:
717 flag.setOnOff(buf->params.tracking_changes);
723 // the font related toggles
725 LyXFont const & font = TEXT(false)->real_current_font;
728 flag.setOnOff(font.emph() == LyXFont::ON);
731 flag.setOnOff(font.noun() == LyXFont::ON);
734 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
737 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
740 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
743 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
749 string tc = mathcursor->getLastCode();
752 flag.setOnOff(tc == "mathbf");
755 flag.setOnOff(tc == "mathsf");
758 flag.setOnOff(tc == "mathcal");
761 flag.setOnOff(tc == "mathrm");
764 flag.setOnOff(tc == "mathtt");
767 flag.setOnOff(tc == "mathbb");
770 flag.setOnOff(tc == "mathnormal");
777 // this one is difficult to get right. As a half-baked
778 // solution, we consider only the first action of the sequence
779 if (ev.action == LFUN_SEQUENCE) {
780 // argument contains ';'-terminated commands
781 flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
788 void LyXFunc::dispatch(string const & s, bool verbose)
790 int const action = lyxaction.LookupFunc(s);
792 if (action == LFUN_UNKNOWN_ACTION) {
793 owner->message(bformat(_("Unknown function (%1$s)"), s));
797 dispatch(action, verbose);
801 void LyXFunc::dispatch(int ac, bool verbose)
803 dispatch(lyxaction.retrieveActionArg(ac), verbose);
807 bool ensureBufferClean(BufferView * bv) {
809 Buffer & buf = *bv->buffer();
813 string const file = MakeDisplayPath(buf.fileName(), 30);
814 string text = bformat(_("The document %1$s has unsaved "
815 "changes.\n\nDo you want to save "
816 "the document?"), file);
817 int const ret = Alert::prompt(_("Save changed document?"),
818 text, 0, 1, _("&Save"),
822 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
824 return buf.isClean();
830 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
832 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
833 <<"] arg[" << ev.argument << ']' << endl;
835 // we have not done anything wrong yet.
837 dispatch_buffer.erase();
839 #ifdef NEW_DISPATCHER
840 // We try do call the most specific dispatcher first:
841 // 1. the lockinginset's dispatch
842 // 2. the bufferview's dispatch
843 // 3. the lyxview's dispatch
846 selection_possible = false;
848 string argument = ev.argument;
849 kb_action action = ev.action;
851 // We cannot use this function here
852 if (getStatus(ev).disabled()) {
853 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
854 << lyxaction.getActionName(action)
855 << " [" << action << "] is disabled at this location"
857 setErrorMessage(getStatusMessage());
858 goto exit_with_message;
861 if (view()->available())
862 view()->hideCursor();
864 if (view()->available() && view()->theLockingInset()) {
865 InsetOld::RESULT result;
866 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
867 (!keyseq.deleted())))
869 UpdatableInset * inset = view()->theLockingInset();
873 inset->getCursorPos(view(), inset_x, dummy_y);
875 if ((action == LFUN_UNKNOWN_ACTION)
876 && argument.empty()) {
877 argument = encoded_last_key;
880 // the insets can't try to handle this,
881 // a table cell in the dummy position will
882 // lock its insettext, the insettext will
883 // pass it the bufferview, and succeed,
884 // so it will stay not locked. Not good
885 // if we've just done LFUN_ESCAPE (which
886 // injects an LFUN_PARAGRAPH_UPDATE)
887 if (action == LFUN_PARAGRAPH_UPDATE) {
888 view()->dispatch(ev);
889 goto exit_with_message;
892 // Undo/Redo is a bit tricky for insets.
893 if (action == LFUN_UNDO) {
895 goto exit_with_message;
896 } else if (action == LFUN_REDO) {
898 goto exit_with_message;
899 } else if (((result=inset->
900 // Hand-over to inset's own dispatch:
901 localDispatch(FuncRequest(view(), action, argument))) ==
903 (result == DISPATCHED_NOUPDATE))
904 goto exit_with_message;
905 // If UNDISPATCHED, just soldier on
906 else if (result == FINISHED) {
907 owner->clearMessage();
908 goto exit_with_message;
909 // We do not need special RTL handling here:
910 // FINISHED means that the cursor should be
911 // one position after the inset.
912 } else if (result == FINISHED_RIGHT) {
913 TEXT()->cursorRight(view());
914 moveCursorUpdate(true, false);
915 owner->clearMessage();
916 goto exit_with_message;
917 } else if (result == FINISHED_UP) {
918 RowList::iterator const irow = TEXT()->cursorIRow();
919 if (irow != TEXT()->rows().begin()) {
921 TEXT()->setCursorFromCoordinates(
922 TEXT()->cursor.ix() + inset_x,
923 TEXT()->cursor.iy() -
924 irow->baseline() - 1);
925 TEXT()->cursor.x_fix(TEXT()->cursor.x());
927 TEXT()->cursorUp(view());
929 moveCursorUpdate(true, false);
931 view()->update(TEXT(), BufferView::SELECT);
933 owner->clearMessage();
934 goto exit_with_message;
935 } else if (result == FINISHED_DOWN) {
936 RowList::iterator const irow = TEXT()->cursorIRow();
937 if (boost::next(irow) != TEXT()->rows().end()) {
939 TEXT()->setCursorFromCoordinates(
940 TEXT()->cursor.ix() + inset_x,
941 TEXT()->cursor.iy() -
944 TEXT()->cursor.x_fix(TEXT()->cursor.x());
946 TEXT()->cursorDown(view());
949 TEXT()->cursorRight(view());
951 moveCursorUpdate(true, false);
952 owner->clearMessage();
953 goto exit_with_message;
955 #warning I am not sure this is still right, please have a look! (Jug 20020417)
956 else { // result == UNDISPATCHED
957 //setMessage(N_("Text mode"));
959 case LFUN_UNKNOWN_ACTION:
960 case LFUN_BREAKPARAGRAPH:
962 TEXT()->cursorRight(view());
963 view()->switchKeyMap();
964 owner->view_state_changed();
967 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
968 TEXT()->cursorRight(view());
969 moveCursorUpdate(true, false);
970 owner->view_state_changed();
972 goto exit_with_message;
974 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
975 TEXT()->cursorRight(view());
976 moveCursorUpdate(true, false);
977 owner->view_state_changed();
979 goto exit_with_message;
981 if (boost::next(TEXT()->cursorRow()) != TEXT()->rows().end())
982 TEXT()->cursorDown(view());
984 TEXT()->cursorRight(view());
985 moveCursorUpdate(true, false);
986 owner->view_state_changed();
987 goto exit_with_message;
999 if (!view()->available()) break;
1000 // this function should be used always [asierra060396]
1001 UpdatableInset * tli =
1002 view()->theLockingInset();
1004 UpdatableInset * lock = tli->getLockingInset();
1007 view()->unlockInset(tli);
1008 TEXT()->cursorRight(view());
1009 moveCursorUpdate(true, false);
1010 owner->view_state_changed();
1012 tli->unlockInsetInInset(view(),
1017 // Tell the paragraph dialog that we changed paragraph
1018 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1023 // --- Misc -------------------------------------------
1024 case LFUN_WORDFINDFORWARD :
1025 case LFUN_WORDFINDBACKWARD : {
1026 static string last_search;
1027 string searched_string;
1029 if (!argument.empty()) {
1030 last_search = argument;
1031 searched_string = argument;
1033 searched_string = last_search;
1035 bool fw = (action == LFUN_WORDFINDFORWARD);
1036 if (!searched_string.empty()) {
1037 lyx::find::find(view(), searched_string, fw);
1044 if (view()->available() && !view()->theLockingInset()) {
1045 view()->update(TEXT(), BufferView::SELECT);
1047 owner->message(keyseq.printOptions());
1051 // --- Misc -------------------------------------------
1052 case LFUN_EXEC_COMMAND:
1053 owner->focus_command_buffer();
1056 case LFUN_CANCEL: // RVDK_PATCH_5
1058 meta_fake_bit = key_modifier::none;
1059 if (view()->available())
1060 // cancel any selection
1061 dispatch(LFUN_MARK_OFF);
1062 setMessage(N_("Cancel"));
1065 case LFUN_META_FAKE: // RVDK_PATCH_5
1067 meta_fake_bit = key_modifier::alt;
1068 setMessage(keyseq.print());
1072 case LFUN_READ_ONLY_TOGGLE:
1073 if (owner->buffer()->lyxvc.inUse()) {
1074 owner->buffer()->lyxvc.toggleReadOnly();
1076 owner->buffer()->setReadonly(
1077 !owner->buffer()->isReadonly());
1081 case LFUN_CENTER: // this is center and redraw.
1085 // --- Menus -----------------------------------------------
1087 menuNew(argument, false);
1090 case LFUN_MENUNEWTMPLT:
1091 menuNew(argument, true);
1094 case LFUN_CLOSEBUFFER:
1098 case LFUN_MENUWRITE:
1099 if (!owner->buffer()->isUnnamed()) {
1100 string const str = bformat(_("Saving document %1$s..."),
1101 MakeDisplayPath(owner->buffer()->fileName()));
1102 owner->message(str);
1103 MenuWrite(owner->buffer());
1104 owner->message(str + _(" done."));
1106 WriteAs(owner->buffer());
1110 WriteAs(owner->buffer(), argument);
1113 case LFUN_MENURELOAD: {
1114 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1115 string text = bformat(_("Any changes will be lost. Are you sure "
1116 "you want to revert to the saved version of the document %1$s?"), file);
1117 int const ret = Alert::prompt(_("Revert to saved document?"),
1118 text, 0, 1, _("&Revert"), _("&Cancel"));
1126 Exporter::Export(owner->buffer(), argument, true);
1127 view()->showErrorList(BufferFormat(*owner->buffer()));
1131 Exporter::Preview(owner->buffer(), argument);
1132 view()->showErrorList(BufferFormat(*owner->buffer()));
1135 case LFUN_BUILDPROG:
1136 Exporter::Export(owner->buffer(), "program", true);
1137 view()->showErrorList(_("Build"));
1140 case LFUN_RUNCHKTEX:
1141 owner->buffer()->runChktex();
1142 view()->showErrorList(_("ChkTeX"));
1146 if (argument == "custom")
1147 owner->getDialogs().showSendto();
1149 Exporter::Export(owner->buffer(), argument, false);
1150 view()->showErrorList(BufferFormat(*owner->buffer()));
1164 InsetCommandParams p("tableofcontents");
1165 string const data = InsetCommandMailer::params2string("toc", p);
1166 owner->getDialogs().show("toc", data, 0);
1182 case LFUN_DEPTH_MIN:
1183 changeDepth(view(), TEXT(false), DEC_DEPTH, false);
1184 owner->view_state_changed();
1187 case LFUN_DEPTH_PLUS:
1188 changeDepth(view(), TEXT(false), INC_DEPTH, false);
1189 owner->view_state_changed();
1192 case LFUN_FREEFONT_APPLY:
1193 apply_freefont(view());
1196 case LFUN_FREEFONT_UPDATE:
1197 update_and_apply_freefont(view(), argument);
1200 case LFUN_RECONFIGURE:
1201 Reconfigure(view());
1205 case LFUN_FLOATSOPERATE:
1206 if (argument == "openfoot")
1207 view()->allFloats(1,0);
1208 else if (argument == "closefoot")
1209 view()->allFloats(0,0);
1210 else if (argument == "openfig")
1211 view()->allFloats(1,1);
1212 else if (argument == "closefig")
1213 view()->allFloats(0,1);
1216 #ifdef WITH_WARNINGS
1217 //#warning Find another implementation here (or another lyxfunc)!
1220 case LFUN_HELP_OPEN:
1222 string const arg = argument;
1224 setErrorMessage(N_("Missing argument"));
1227 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1228 if (fname.empty()) {
1229 lyxerr << "LyX: unable to find documentation file `"
1230 << arg << "'. Bad installation?" << endl;
1233 owner->message(bformat(_("Opening help file %1$s..."),
1234 MakeDisplayPath(fname)));
1235 view()->loadLyXFile(fname, false);
1239 // --- version control -------------------------------
1240 case LFUN_VC_REGISTER:
1242 if (!ensureBufferClean(view()))
1244 if (!owner->buffer()->lyxvc.inUse()) {
1245 owner->buffer()->lyxvc.registrer();
1251 case LFUN_VC_CHECKIN:
1253 if (!ensureBufferClean(view()))
1255 if (owner->buffer()->lyxvc.inUse()
1256 && !owner->buffer()->isReadonly()) {
1257 owner->buffer()->lyxvc.checkIn();
1263 case LFUN_VC_CHECKOUT:
1265 if (!ensureBufferClean(view()))
1267 if (owner->buffer()->lyxvc.inUse()
1268 && owner->buffer()->isReadonly()) {
1269 owner->buffer()->lyxvc.checkOut();
1275 case LFUN_VC_REVERT:
1277 owner->buffer()->lyxvc.revert();
1284 owner->buffer()->lyxvc.undoLast();
1289 // --- buffers ----------------------------------------
1291 case LFUN_SWITCHBUFFER:
1292 view()->buffer(bufferlist.getBuffer(argument));
1296 NewFile(view(), argument);
1299 case LFUN_FILE_OPEN:
1303 case LFUN_LAYOUT_TABULAR:
1304 if (view()->theLockingInset()) {
1305 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1306 InsetTabular * inset = static_cast<InsetTabular *>
1307 (view()->theLockingInset());
1308 inset->openLayoutDialog(view());
1309 } else if (view()->theLockingInset()->
1310 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1311 InsetTabular * inset = static_cast<InsetTabular *>(
1312 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1313 inset->openLayoutDialog(view());
1318 case LFUN_DROP_LAYOUTS_CHOICE:
1319 owner->getToolbar().openLayoutList();
1322 case LFUN_MENU_OPEN_BY_NAME:
1323 owner->getMenubar().openByName(argument);
1324 break; // RVDK_PATCH_5
1326 // --- lyxserver commands ----------------------------
1330 setMessage(owner->buffer()->fileName());
1331 lyxerr[Debug::INFO] << "FNAME["
1332 << owner->buffer()->fileName()
1338 dispatch_buffer = keyseq.print();
1339 lyxserver->notifyClient(dispatch_buffer);
1343 case LFUN_GOTOFILEROW:
1347 istringstream istr(argument.c_str());
1348 istr >> file_name >> row;
1349 // Must replace extension of the file to be .lyx and get full path
1350 string const s(ChangeExtension(file_name, ".lyx"));
1352 // Either change buffer or load the file
1353 if (bufferlist.exists(s)) {
1354 view()->buffer(bufferlist.getBuffer(s));
1356 view()->loadLyXFile(s);
1359 view()->setCursorFromRow(row);
1362 // see BufferView_pimpl::center()
1363 view()->updateScrollbar();
1367 case LFUN_GOTO_PARAGRAPH:
1369 istringstream istr(argument.c_str());
1373 ParIterator par = owner->buffer()->getParFromID(id);
1374 if (par == owner->buffer()->par_iterator_end()) {
1375 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1376 << id << ']' << endl;
1379 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1380 << " found." << endl;
1383 if (view()->theLockingInset())
1384 view()->unlockInset(view()->theLockingInset());
1385 if (par->inInset()) {
1386 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1387 par->inInset()->localDispatch(cmd);
1390 view()->getLyXText()->setCursor(par.pit(), 0);
1391 view()->switchKeyMap();
1392 owner->view_state_changed();
1395 // see BufferView_pimpl::center()
1396 view()->updateScrollbar();
1400 // --- insert characters ----------------------------------------
1402 // --- Mathed stuff. If we are here, there is no locked inset yet.
1403 case LFUN_MATH_EXTERN:
1404 case LFUN_MATH_NUMBER:
1405 case LFUN_MATH_NONUMBER:
1406 case LFUN_MATH_LIMITS:
1408 setErrorMessage(N_("This is only allowed in math mode!"));
1412 // passthrough hat and underscore outside mathed:
1413 case LFUN_SUBSCRIPT:
1414 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1416 case LFUN_SUPERSCRIPT:
1417 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1420 case LFUN_DIALOG_SHOW: {
1421 string const name = ev.getArg(0);
1422 string data = trim(ev.argument.substr(name.size()));
1424 if (name == "character") {
1425 data = freefont2string();
1427 owner->getDialogs().show("character", data);
1428 } else if (name == "document")
1429 owner->getDialogs().showDocument();
1430 else if (name == "findreplace")
1431 owner->getDialogs().showSearch();
1432 else if (name == "forks")
1433 owner->getDialogs().showForks();
1434 else if (name == "preamble")
1435 owner->getDialogs().showPreamble();
1436 else if (name == "preferences")
1437 owner->getDialogs().showPreferences();
1438 else if (name == "print")
1439 owner->getDialogs().showPrint();
1440 else if (name == "spellchecker")
1441 owner->getDialogs().showSpellchecker();
1443 owner->getDialogs().show(name, data);
1447 case LFUN_DIALOG_SHOW_NEW_INSET: {
1448 string const & name = argument;
1450 if (name == "bibitem" ||
1452 name == "include" ||
1457 InsetCommandParams p(name);
1458 data = InsetCommandMailer::params2string(name, p);
1459 } else if (name == "citation") {
1460 InsetCommandParams p("cite");
1461 data = InsetCommandMailer::params2string(name, p);
1463 owner->getDialogs().show(name, data, 0);
1467 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1471 case LFUN_DIALOG_UPDATE: {
1472 string const & name = argument;
1473 // Can only update a dialog connected to an existing inset
1474 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1476 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1478 inset->localDispatch(fr);
1479 } else if (name == "paragraph") {
1480 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1485 case LFUN_DIALOG_HIDE:
1486 Dialogs::hide(argument, 0);
1489 case LFUN_DIALOG_DISCONNECT_INSET:
1490 owner->getDialogs().disconnect(argument);
1493 case LFUN_CHILDOPEN:
1495 string const filename =
1496 MakeAbsPath(argument,
1497 owner->buffer()->filePath());
1498 setMessage(N_("Opening child document ") +
1499 MakeDisplayPath(filename) + "...");
1500 view()->savePosition(0);
1501 if (bufferlist.exists(filename))
1502 view()->buffer(bufferlist.getBuffer(filename));
1504 view()->loadLyXFile(filename);
1508 case LFUN_TOGGLECURSORFOLLOW:
1509 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1513 owner->getIntl().KeyMapOn(false);
1516 case LFUN_KMAP_PRIM:
1517 owner->getIntl().KeyMapPrim();
1521 owner->getIntl().KeyMapSec();
1524 case LFUN_KMAP_TOGGLE:
1525 owner->getIntl().ToggleKeyMap();
1530 // argument contains ';'-terminated commands
1531 while (!argument.empty()) {
1533 argument = split(argument, first, ';');
1539 case LFUN_SAVEPREFERENCES:
1541 Path p(user_lyxdir());
1542 lyxrc.write("preferences");
1546 case LFUN_SCREEN_FONT_UPDATE:
1548 // handle the screen font changes.
1549 lyxrc.set_font_norm_type();
1550 lyx_gui::update_fonts();
1551 // We also need to empty the textcache so that
1552 // the buffer will be formatted correctly after
1555 // Of course we should only do the resize and the textcache.clear
1556 // if values really changed...but not very important right now. (Lgb)
1557 // All visible buffers will need resize
1563 case LFUN_SET_COLOR:
1566 string const x11_name = split(argument, lyx_name, ' ');
1567 if (lyx_name.empty() || x11_name.empty()) {
1568 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1573 bool const graphicsbg_changed =
1574 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1575 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1577 if (!lcolor.setColor(lyx_name, x11_name)) {
1579 bformat(_("Set-color \"%1$s\" failed "
1580 "- color is undefined or "
1581 "may not be redefined"), lyx_name));
1585 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1587 if (graphicsbg_changed) {
1588 #ifdef WITH_WARNINGS
1589 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1592 lyx::graphics::GCache & gc =
1593 lyx::graphics::GCache::get();
1594 gc.changeDisplay(true);
1603 owner->message(argument);
1606 case LFUN_FORKS_KILL:
1608 if (!isStrInt(argument))
1611 pid_t const pid = strToInt(argument);
1612 ForkedcallsController & fcc = ForkedcallsController::get();
1617 case LFUN_TOOLTIPS_TOGGLE:
1618 owner->getDialogs().toggleTooltips();
1621 case LFUN_EXTERNAL_EDIT: {
1623 .localDispatch(FuncRequest(view(), action, argument));
1628 // Then if it was none of the above
1629 // Trying the BufferView::pimpl dispatch:
1630 if (!view()->dispatch(ev))
1631 lyxerr << "A truly unknown func ["
1632 << lyxaction.getActionName(ev.action) << "]!"
1639 view()->owner()->updateLayoutChoice();
1641 if (view()->available()) {
1642 view()->fitCursor();
1644 // If we executed a mutating lfun, mark the buffer as dirty
1645 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1646 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1647 view()->buffer()->markDirty();
1650 sendDispatchMessage(getMessage(), ev, verbose);
1654 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1656 owner->updateMenubar();
1657 owner->updateToolbar();
1659 if (ev.action == LFUN_SELFINSERT || !verbose) {
1660 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1662 owner->message(msg);
1666 string dispatch_msg = msg;
1667 if (!dispatch_msg.empty())
1668 dispatch_msg += ' ';
1670 string comname = lyxaction.getActionName(ev.action);
1672 int pseudoaction = ev.action;
1673 bool argsadded = false;
1675 if (!ev.argument.empty()) {
1676 // the pseudoaction is useful for the bindings
1677 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1679 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1680 pseudoaction = ev.action;
1682 comname += ' ' + ev.argument;
1687 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1689 if (!shortcuts.empty()) {
1690 comname += ": " + shortcuts;
1691 } else if (!argsadded && !ev.argument.empty()) {
1692 comname += ' ' + ev.argument;
1695 if (!comname.empty()) {
1696 comname = rtrim(comname);
1697 dispatch_msg += '(' + comname + ')';
1700 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1701 if (!dispatch_msg.empty())
1702 owner->message(dispatch_msg);
1706 void LyXFunc::setupLocalKeymap()
1708 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1709 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1713 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1715 string initpath = lyxrc.document_path;
1716 string filename(name);
1718 if (view()->available()) {
1719 string const trypath = owner->buffer()->filePath();
1720 // If directory is writeable, use this as default.
1721 if (IsDirWriteable(trypath))
1725 static int newfile_number;
1727 if (filename.empty()) {
1728 filename = AddName(lyxrc.document_path,
1729 "newfile" + tostr(++newfile_number) + ".lyx");
1730 FileInfo fi(filename);
1731 while (bufferlist.exists(filename) || fi.readable()) {
1733 filename = AddName(lyxrc.document_path,
1734 "newfile" + tostr(newfile_number) +
1736 fi.newFile(filename);
1740 // The template stuff
1743 FileDialog fileDlg(_("Select template file"),
1744 LFUN_SELECT_FILE_SYNC,
1745 make_pair(string(_("Documents|#o#O")),
1746 string(lyxrc.document_path)),
1747 make_pair(string(_("Templates|#T#t")),
1748 string(lyxrc.template_path)));
1750 FileDialog::Result result =
1751 fileDlg.open(lyxrc.template_path,
1752 _("*.lyx| LyX Documents (*.lyx)"));
1754 if (result.first == FileDialog::Later)
1757 string const fname = result.second;
1764 view()->newFile(filename, templname, !name.empty());
1768 void LyXFunc::open(string const & fname)
1770 string initpath = lyxrc.document_path;
1772 if (view()->available()) {
1773 string const trypath = owner->buffer()->filePath();
1774 // If directory is writeable, use this as default.
1775 if (IsDirWriteable(trypath))
1781 if (fname.empty()) {
1782 FileDialog fileDlg(_("Select document to open"),
1784 make_pair(string(_("Documents|#o#O")),
1785 string(lyxrc.document_path)),
1786 make_pair(string(_("Examples|#E#e")),
1787 string(AddPath(system_lyxdir(), "examples"))));
1789 FileDialog::Result result =
1790 fileDlg.open(initpath,
1791 _("*.lyx| LyX Documents (*.lyx)"));
1793 if (result.first == FileDialog::Later)
1796 filename = result.second;
1798 // check selected filename
1799 if (filename.empty()) {
1800 owner->message(_("Canceled."));
1806 // get absolute path of file and add ".lyx" to the filename if
1808 string const fullpath = FileSearch(string(), filename, "lyx");
1809 if (!fullpath.empty()) {
1810 filename = fullpath;
1813 string const disp_fn(MakeDisplayPath(filename));
1815 // if the file doesn't exist, let the user create one
1816 FileInfo const f(filename, true);
1818 // the user specifically chose this name. Believe them.
1819 view()->newFile(filename, "", true);
1823 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1826 if (view()->loadLyXFile(filename)) {
1827 str2 = bformat(_("Document %1$s opened."), disp_fn);
1829 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1831 owner->message(str2);
1835 void LyXFunc::doImport(string const & argument)
1838 string filename = split(argument, format, ' ');
1840 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1841 << " file: " << filename << endl;
1843 // need user interaction
1844 if (filename.empty()) {
1845 string initpath = lyxrc.document_path;
1847 if (view()->available()) {
1848 string const trypath = owner->buffer()->filePath();
1849 // If directory is writeable, use this as default.
1850 if (IsDirWriteable(trypath))
1854 string const text = bformat(_("Select %1$s file to import"),
1855 formats.prettyName(format));
1857 FileDialog fileDlg(text,
1859 make_pair(string(_("Documents|#o#O")),
1860 string(lyxrc.document_path)),
1861 make_pair(string(_("Examples|#E#e")),
1862 string(AddPath(system_lyxdir(), "examples"))));
1864 string const extension = "*." + formats.extension(format)
1865 + "| " + formats.prettyName(format)
1866 + " (*." + formats.extension(format) + ')';
1868 FileDialog::Result result = fileDlg.open(initpath,
1871 if (result.first == FileDialog::Later)
1874 filename = result.second;
1876 // check selected filename
1877 if (filename.empty())
1878 owner->message(_("Canceled."));
1881 if (filename.empty())
1884 // get absolute path of file
1885 filename = MakeAbsPath(filename);
1887 string const lyxfile = ChangeExtension(filename, ".lyx");
1889 // Check if the document already is open
1890 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1891 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1892 owner->message(_("Canceled."));
1897 // if the file exists already, and we didn't do
1898 // -i lyx thefile.lyx, warn
1899 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1900 string const file = MakeDisplayPath(lyxfile, 30);
1902 string text = bformat(_("The document %1$s already exists.\n\n"
1903 "Do you want to over-write that document?"), file);
1904 int const ret = Alert::prompt(_("Over-write document?"),
1905 text, 0, 1, _("&Over-write"), _("&Cancel"));
1908 owner->message(_("Canceled."));
1913 Importer::Import(owner, filename, format);
1917 void LyXFunc::closeBuffer()
1919 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1920 if (bufferlist.empty()) {
1921 // need this otherwise SEGV may occur while
1922 // trying to set variables that don't exist
1923 // since there's no current buffer
1924 owner->getDialogs().hideBufferDependent();
1926 view()->buffer(bufferlist.first());
1932 // Each "owner" should have it's own message method. lyxview and
1933 // the minibuffer would use the minibuffer, but lyxserver would
1934 // send an ERROR signal to its client. Alejandro 970603
1935 // This func is bit problematic when it comes to NLS, to make the
1936 // lyx servers client be language indepenent we must not translate
1937 // strings sent to this func.
1938 void LyXFunc::setErrorMessage(string const & m) const
1940 dispatch_buffer = m;
1945 void LyXFunc::setMessage(string const & m) const
1947 dispatch_buffer = m;
1951 void LyXFunc::setStatusMessage(string const & m) const
1957 string const LyXFunc::view_status_message()
1959 // When meta-fake key is pressed, show the key sequence so far + "M-".
1961 return keyseq.print() + "M-";
1964 // Else, when a non-complete key sequence is pressed,
1965 // show the available options.
1966 if (keyseq.length() > 0 && !keyseq.deleted()) {
1967 return keyseq.printOptions();
1970 if (!view()->available())
1971 return _("Welcome to LyX!");
1973 return currentState(view());
1977 BufferView * LyXFunc::view() const
1980 return owner->view().get();